From patchwork Thu Feb 15 14:55:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201510 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp453433dyb; Thu, 15 Feb 2024 06:57:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmkfa5bXSMXhpufW3ZG8CVp8yCdeieYi6b2W0abAUGrj4c1BA1QCGPddXdh7P9FeQ57uBVuXJRTwjoDRwUhTpk77CYKA== X-Google-Smtp-Source: AGHT+IGm69413DA8U71k0nAgttkZAM6hTBOB5B0iCgVGXHp/RRjvnzaNhkE+xaXdrWOOpL24OEVq X-Received: by 2002:a05:6102:3b8a:b0:46d:2e4a:f114 with SMTP id z10-20020a0561023b8a00b0046d2e4af114mr1699287vsu.33.1708009036691; Thu, 15 Feb 2024 06:57:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009036; cv=pass; d=google.com; s=arc-20160816; b=d1PxaUHG6+cr2Mq7AUMOpBAXwjvtlc+nr5o8VDmp3Hrn6aDTq6Wm4O3cQ0aL5++Mdq Nz1iU1jKnQlD3OFDR7TQHVS8/rt+bLCQVZW6qIiCmsNhJzMzgYMW1IWXEY4G44VpCN4R fPxmkXae0TBfi8831c3e4Hh3cWtSU8BiWfp9x8KPAIKvfe/u0DQ0xolueWgqRs7fiS9R wFggcV245WCIfixEq1jU0Ef5ACHE1EpjWesa4a2bc2UoykjoUGr+ma/ATAv/BE6eGEs6 J8pRxqA/pNL9zIloT9q3TrPlrMpCHS5AnM9n7BPGLXqdcGU+YKNOLhinvkmrBKAI8T5R fb0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0oDI3MVOC+gdByL2sDhjkqrwTXc1Ta5YNXoQZrfiEOU=; fh=bHUjVG18l21m4hYQ7e2tE9phv0agwocDwV30aInFsCk=; b=BBZKUwXeea+TEbmxUoTILeGQnCAxgvfnhRyIxSgCA37lKOK5cHxYWA6LB+2GD+v7Ti d3fjrs2JpxjQPnkGl1IXTfpiFzOG9iLXwNPMWGFy2qmLmy5dEQ6ClSK1xb2GhZ2IK2Sa g/J8U/dFdMI0/CiIX8hSenXOvNwCyPvNzcQeUUKHMS7EvuQQlfVvMUs+hMVZOlemORve TDKGouH++c7Xfc60ZhfB7GbBactVUIMLuSilZb1SNVmx2g1XNThYB9QCBRTj5x/8hsf8 AP31MiU5M9odkyQjEL+arm4apgl+uOEYXb/W8u2+sf1wUDopCXkER/3JsSVx4ktuAeBG 29Hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=JqhowqsN; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67112-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67112-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c8-20020ac87dc8000000b0042dac5fe341si1680157qte.210.2024.02.15.06.57.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:57:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67112-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=JqhowqsN; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67112-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67112-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6B8BB1C22EB6 for ; Thu, 15 Feb 2024 14:57:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 525C1132499; Thu, 15 Feb 2024 14:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="JqhowqsN" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76DA2132486 for ; Thu, 15 Feb 2024 14:56:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008975; cv=none; b=nt2zFAWypr35Y+gW5rlEid9q/KdBEyZC5DkgkMEwAyDUGvHLH3np8qpoEGuv9bwr1wmcwLS0uaJ/uHlijwrP/MKUtLDPzNYsOvjhWWYNAd2mDG7Ra7kNWrxj0zB18HK99ng/EWD7kQEpxKmO8GufLvCo6Z+t3JmQyWMMsvbkRbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008975; c=relaxed/simple; bh=yo48K+OLdgpecXlpyx+V7fKNTco+Sad5NRmIDZmghJo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gB4LOoNzzA9IuXkRJALL3ZUl5lvCfDC2i8+dR5FBgN8v2abagzRfS6HSArae726UZ83pnyw6+IaQ6O+4MwRuYg63kBPJEhyqy1kAlLJA3EqDe2vy8FMBQPPJNxzUmqZPB61yWQ1y0hhdpWWS0u2epxOtmNT7wPPC0zT4Q3mKRso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=JqhowqsN; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a3d002bc6f7so92089966b.3 for ; Thu, 15 Feb 2024 06:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008971; x=1708613771; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0oDI3MVOC+gdByL2sDhjkqrwTXc1Ta5YNXoQZrfiEOU=; b=JqhowqsNVOMPhWp2Jab46RkI09nRxeHmIjKgges18CYFmU+GP7ilAkMWSC/5c+YhmC Dia20wsiaMyBX5u7x6E/PmP2W70JiDLxdpHzaGk+hpvvO8AF6BAG3Cgk+fsYfJRj3iVa RewcZedx5u21T4yUkehGo94nI8y1hM3JtdSinQdSCnRxhUQcpFFixlCCPZyzOw3z56Hg GWNxBTvruhcngIhY6IcWkx9z16TLSPS4CKBzlk4QBRE8lLIimce6ysbtvhS9dSL3b1VU HyG5EnChqX15Kkg88Joe6HgKbw4PIFf8F9q57VK7152bsGICDF44VntmUPLeCYfWgOK9 i7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008971; x=1708613771; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0oDI3MVOC+gdByL2sDhjkqrwTXc1Ta5YNXoQZrfiEOU=; b=cqamQw8alHyEu+UqKiRYc6aJNYO4VwTUJQezoQE1gJLiNiJQ+ALHfPZLe9kWqECqPF nCBsu+ZrO71/B8led++qmlefdEYLKAWaempHYQF53jvscu3mTrwhsIfTNRsaDcaYLYBT jmelQur4u4025tpTfhWmD9rR0GgYamcTn148f+fs2+YKlUkhTK9CmREE+FOa3LIvkcSu D72cc8TgmOboXyjgo9PYrZdFYEpjwqBFZnifVQ2O3GqeeOTgFjUJ3KyanA1i8Xe6xIt1 6aCA6sbIlCg4pkJv7S2Yy+2kHxc9pV5VxnWU4hMdbilhPbrZ9OkHIvebX6fGrkT1Pe+D Tyvg== X-Forwarded-Encrypted: i=1; AJvYcCUzJR8uxi0BCok3yqf37linFO8PbixbuW92Pglgd/8gbfpsKxrn5Trk7P667KGHZVWXVucp//gETbaAPdzqq5YOJMsAB+QMQwGnYqB7 X-Gm-Message-State: AOJu0YzY1pMePPXYP0A3men2ZnC+mh3Q/4M3k6vTE0Ey0WdFKo62jk6e 6xzWrq9U2SdAoYO2ZuZdaP6AbH3FZct9LxjCmZghGoLTEyuj6RfYag9PfjXxtkFCa8ntEvlkRu4 t X-Received: by 2002:a17:906:f343:b0:a3d:643f:1cd4 with SMTP id hg3-20020a170906f34300b00a3d643f1cd4mr1443557ejb.48.1708008970666; Thu, 15 Feb 2024 06:56:10 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:10 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 01/14] drivers: add missing includes on linux/mm.h (and others) Date: Thu, 15 Feb 2024 15:55:49 +0100 Message-Id: <20240215145602.1371274-2-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977283681757883 X-GMAIL-MSGID: 1790977283681757883 After developing the other patches in this series, I had lots of build failures because "#include " was missing. This patch fixes those build failures by adding the missing "#include" lines. To allow bisects, it is ordered before the others. Signed-off-by: Max Kellermann --- arch/arm/mm/iomap.c | 3 +++ drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c | 1 + drivers/dma/dma-axi-dmac.c | 1 + drivers/dma/sh/rcar-dmac.c | 1 + drivers/firmware/qcom/qcom_scm-legacy.c | 1 + drivers/firmware/qcom/qcom_scm-smc.c | 1 + drivers/firmware/raspberrypi.c | 1 + drivers/iio/buffer/industrialio-buffer-dma.c | 1 + drivers/iommu/iommufd/selftest.c | 1 + drivers/media/platform/mediatek/vpu/mtk_vpu.c | 1 + drivers/media/platform/ti/omap/omap_voutlib.c | 1 + drivers/misc/bcm-vk/bcm_vk_dev.c | 1 + drivers/misc/fastrpc.c | 1 + drivers/misc/genwqe/card_dev.c | 1 + drivers/misc/uacce/uacce.c | 1 + drivers/pci/p2pdma.c | 1 + drivers/pci/pci.c | 1 + drivers/remoteproc/remoteproc_core.c | 1 + drivers/soc/qcom/rmtfs_mem.c | 1 + drivers/spi/spi-bcm2835.c | 2 ++ drivers/spi/spi-intel.c | 1 + drivers/virtio/virtio_ring.c | 1 + include/linux/iommu.h | 1 + include/linux/nvme-keyring.h | 2 ++ kernel/dma/ops_helpers.c | 1 + kernel/dma/remap.c | 1 + mm/dmapool.c | 1 + 27 files changed, 31 insertions(+) diff --git a/arch/arm/mm/iomap.c b/arch/arm/mm/iomap.c index 415d0a454237..9873d8156908 100644 --- a/arch/arm/mm/iomap.c +++ b/arch/arm/mm/iomap.c @@ -29,6 +29,9 @@ EXPORT_SYMBOL(ioport_unmap); #endif #ifdef CONFIG_PCI + +#include // for VMALLOC_* + unsigned long pcibios_min_io = 0x1000; EXPORT_SYMBOL(pcibios_min_io); diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c b/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c index ee0b5079de3e..c9b2787baac7 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2023 Intel Corporation */ #include +#include // for simple_read_from_buffer() #include #include #include diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c index 4e339c04fc1e..0c98bf0e4b5d 100644 --- a/drivers/dma/dma-axi-dmac.c +++ b/drivers/dma/dma-axi-dmac.c @@ -15,6 +15,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 40482cb73d79..784da367665c 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -12,6 +12,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/firmware/qcom/qcom_scm-legacy.c b/drivers/firmware/qcom/qcom_scm-legacy.c index 029e6d117cb8..01e082c7163c 100644 --- a/drivers/firmware/qcom/qcom_scm-legacy.c +++ b/drivers/firmware/qcom/qcom_scm-legacy.c @@ -5,6 +5,7 @@ #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/qcom_scm-smc.c index 16cf88acfa8e..a5c74d8996fe 100644 --- a/drivers/firmware/qcom/qcom_scm-smc.c +++ b/drivers/firmware/qcom/qcom_scm-smc.c @@ -5,6 +5,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 322aada20f74..beef5c4afef2 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -9,6 +9,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c index 5610ba67925e..b3ce8c4b101a 100644 --- a/drivers/iio/buffer/industrialio-buffer-dma.c +++ b/drivers/iio/buffer/industrialio-buffer-dma.c @@ -6,6 +6,7 @@ #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index 8abf9747773e..710789a2add9 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -5,6 +5,7 @@ */ #include #include +#include // for GUP_PIN_COUNTING_BIAS #include #include #include diff --git a/drivers/media/platform/mediatek/vpu/mtk_vpu.c b/drivers/media/platform/mediatek/vpu/mtk_vpu.c index 7243604a82a5..885b873982e4 100644 --- a/drivers/media/platform/mediatek/vpu/mtk_vpu.c +++ b/drivers/media/platform/mediatek/vpu/mtk_vpu.c @@ -8,6 +8,7 @@ #include #include #include +#include // for totalram_pages() #include #include #include diff --git a/drivers/media/platform/ti/omap/omap_voutlib.c b/drivers/media/platform/ti/omap/omap_voutlib.c index 0ac46458e41c..3b653b49cc48 100644 --- a/drivers/media/platform/ti/omap/omap_voutlib.c +++ b/drivers/media/platform/ti/omap/omap_voutlib.c @@ -18,6 +18,7 @@ * */ +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/misc/bcm-vk/bcm_vk_dev.c b/drivers/misc/bcm-vk/bcm_vk_dev.c index d4a96137728d..c5a39a8189bf 100644 --- a/drivers/misc/bcm-vk/bcm_vk_dev.c +++ b/drivers/misc/bcm-vk/bcm_vk_dev.c @@ -11,6 +11,7 @@ #include #include #include +#include // for io_remap_pfn_range() #include #include #include diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 03319a1fa97f..43448a97e502 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -10,6 +10,7 @@ #include #include #include +#include // for find_vma() #include #include #include diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c index 4441aca2280a..ce3acb938ca6 100644 --- a/drivers/misc/genwqe/card_dev.c +++ b/drivers/misc/genwqe/card_dev.c @@ -17,6 +17,7 @@ #include #include +#include // for struct vm_operations_struct #include #include #include diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c index bdc2e6fda782..af815b8a718e 100644 --- a/drivers/misc/uacce/uacce.c +++ b/drivers/misc/uacce/uacce.c @@ -2,6 +2,7 @@ #include #include #include +#include // for struct vm_operations_struct #include #include #include diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 4f47a13cb500..ef37ea6c09fc 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -16,6 +16,7 @@ #include #include #include +#include // for VM_MAYSHARE #include #include #include diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index cfc5b84dc9c9..e2afd992caa7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -25,6 +25,7 @@ #include #include #include +#include // for pgprot_device() #include #include #include diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f276956f2c5c..938220fe29f5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -18,6 +18,7 @@ #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index df850d073102..15c2f6e5eaff 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c @@ -6,6 +6,7 @@ #include #include #include +#include // for remap_pfn_range() #include #include #include diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index e1b9b1235787..d8ed5575a9c6 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -33,6 +33,8 @@ #include #include +#include // for ZERO_PAGE() + /* SPI register offsets */ #define BCM2835_SPI_CS 0x00 #define BCM2835_SPI_FIFO 0x04 diff --git a/drivers/spi/spi-intel.c b/drivers/spi/spi-intel.c index 3e5dcf2b3c8a..cf8e4f1c4d93 100644 --- a/drivers/spi/spi-intel.c +++ b/drivers/spi/spi-intel.c @@ -8,6 +8,7 @@ #include #include +#include // for SZ_* #include #include diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 49299b1f9ec7..5c3ca44aef42 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -12,6 +12,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 8141a37556d5..25a3613a1f66 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -14,6 +14,7 @@ #include #include #include +#include // for copy_struct_from_user() #include #define IOMMU_READ (1 << 0) diff --git a/include/linux/nvme-keyring.h b/include/linux/nvme-keyring.h index e10333d78dbb..9e033850b967 100644 --- a/include/linux/nvme-keyring.h +++ b/include/linux/nvme-keyring.h @@ -6,6 +6,8 @@ #ifndef _NVME_KEYRING_H #define _NVME_KEYRING_H +#include + #if IS_ENABLED(CONFIG_NVME_KEYRING) key_serial_t nvme_tls_psk_default(struct key *keyring, diff --git a/kernel/dma/ops_helpers.c b/kernel/dma/ops_helpers.c index af4a6ef48ce0..641363b13bb9 100644 --- a/kernel/dma/ops_helpers.c +++ b/kernel/dma/ops_helpers.c @@ -4,6 +4,7 @@ * the allocated memory contains normal pages in the direct kernel mapping. */ #include +#include // for PAGE_ALIGN() static struct page *dma_common_vaddr_to_page(void *cpu_addr) { diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c index 27596f3b4aef..87b3c874d370 100644 --- a/kernel/dma/remap.c +++ b/kernel/dma/remap.c @@ -3,6 +3,7 @@ * Copyright (c) 2014 The Linux Foundation */ #include +#include // for vmap(), PAGE_ALIGN() #include #include diff --git a/mm/dmapool.c b/mm/dmapool.c index f0bfc6c490f4..b8e23fdc81d7 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -25,6 +25,7 @@ #include #include #include +#include // for want_init_on_alloc() #include #include #include From patchwork Thu Feb 15 14:55:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp453507dyb; Thu, 15 Feb 2024 06:57:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXjcCHs+cPSh+CpTS5GjZzPfaNULd88fto4oDry+ZD06GFAbrd8IyahtH+7f13YXUp16gQ6XjJdOAxBnaHFaR4gEj+OgQ== X-Google-Smtp-Source: AGHT+IFT7ZBxOqHuRAAvxrXAz3K2dM82IhKOxdPqToo5DG4TuPNEcyMdO3pUGLBp/wF3YFnl8H2x X-Received: by 2002:a2e:331a:0:b0:2d0:e2aa:24d4 with SMTP id d26-20020a2e331a000000b002d0e2aa24d4mr1424441ljc.9.1708009044819; Thu, 15 Feb 2024 06:57:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009044; cv=pass; d=google.com; s=arc-20160816; b=e5D4kc0qmo650pIp0cWmvos47wuyqzdCQC2D30EhUHwF/YLcLhEqcm3o2Fxc72nsDJ 417cIHBBQYMWyZ9bTA17rGePe4VVLghZ7DLcjq3TEp4bGjPqabSdPmJ/V8tFMUtypxev E8MTFFdlsCZLg1pkVvfB7c1GIO9/yaOaCPtHK+FggcHM+0QcWDVbWyyf0XpZ9imkL4g5 FWgwnKsGu5pLCrjuPhJJZmDBKFDRAalaMs0rOCY5RRNDErip3dGgbcx8VDlmD0S1QyrH SQarEOPed991ZhJfXS953t2n+YKVxvcbuVsCCWG9KC38/bIlA2C8g4H9EnQ7pVoZuoah FWWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BL1pmIo7s1MX4N9LU8kIbt0i/wU5mZK2rTJkOzRk4Zc=; fh=x1zi76kuYqMnbFEG9Dt6+9P2nliv5Mpr9h9ZBLD1pys=; b=GMosL+wqMJYYTZArvrsMffcQdmZVHNcJTCg0lwgYp1/WbtNPsz1f3nRxMOYrOH7bLg 5uTKEYzmNowZyH6I6+35XZfwxNyANs4YsWGZW0mZX7H6AR2PP3ghUs76WyRlRJE2XffZ Ut3HWtPGabcFnWgtBI3lm/ZIiifEqdmy8qPGBaiBTzSAcmnm2pu7wBS/33txIRYYNyfR C44x+XYpn2uS5lGRtyp+e5Nq2DFBrNCA9h7qUpqRMCDGBI4Ke8WE7Nt3oKnqGOmyTArC G2Y/XjEhHs6nbgn+dd/o75oRlK1w7BFHtW2+E1+EBERsWDSIpGoGkPorjXRS5h2h4QcW LcVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=Bhe1EYAG; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67113-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67113-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x20-20020aa7dad4000000b00560d6e9cd4esi701940eds.335.2024.02.15.06.57.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:57:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67113-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=Bhe1EYAG; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67113-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67113-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 728B11F24352 for ; Thu, 15 Feb 2024 14:57:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BF72133286; Thu, 15 Feb 2024 14:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="Bhe1EYAG" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E715F132481 for ; Thu, 15 Feb 2024 14:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008976; cv=none; b=VcDIuSWRaR+MM7GRLIfLE1haWKKAQZ7v1PaHYvgDE9bO/LPAAefjyWkmtLmNts3oMKURfaMyVPHOmna6O6jRejX8Q/B1GOeObTdp5ZlEOTIAfO+EobX915eywzeQtr31WZTRAJesoP0pVZi70Jpqc6es3NtGJgTrnEsZRykZSmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008976; c=relaxed/simple; bh=7E++P3NE3gX/uG8sJhez163L//hFb7dWE0h0h4Q6OTA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=kHLrdRnxI5nYr5duBlBlUTOy+eN+eFGhLX8ZtIauyI6utgqR23KTM9yQV+hPuLQZWaq+mlMs2oE6aA1SV9T9WxcGjpSujtzh8wbVKLfJ+i8qPN2VyBOIZ+3fVOht3V+xd71yfJnym+OIHh56HUc0y6Qv4AD+2Yb7Z3zsQFNuZE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=Bhe1EYAG; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a3d484a58f6so121797766b.3 for ; Thu, 15 Feb 2024 06:56:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008972; x=1708613772; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BL1pmIo7s1MX4N9LU8kIbt0i/wU5mZK2rTJkOzRk4Zc=; b=Bhe1EYAG/YFEC6l9e6eDHNaQIM4E6E6brL7hYkz/QoGItPANmWPY/F4bLqNik2O+Qf +amDM8s7+GgzU2OvQp1ftfuNw85DD1Hy+6HGCq78mdGCRmx8td4wtDpstteV54gBfFIX VcJuXjBE4vyAJsUh4lTMeOZpWTRb3t9i4ksmZH47d76wbgxEWwzu9UXZ0UMgOc4Fkvpe NGSpEIDW2tJpcDw7meTyrqWfEcQnalXfTECXIePGb++CT7hf1FKVrqlk7ovgm5aJWqQN 5x29ci9hY8LYuRUJA3ZwMAcfG9BNwGlU17UZIOpwru8gBd7GE6Z9AmKfkl0DUVvgqRO/ aD2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008972; x=1708613772; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BL1pmIo7s1MX4N9LU8kIbt0i/wU5mZK2rTJkOzRk4Zc=; b=i2wkKuxk/v7E81BuVK0QbP7qT7pomkqUbae1NlsXzySz4Ronobnu/6xz8eSimaV2Ec hx4fAX7Bxr8zTQO12i2u/RApb+XN/8Fb+QJNE1zEY3b+Bg3oQ1C3yOgTao27PceUgRy0 R3JICojrF8czUVecE7abLp+c7jn66ZQPptgpMpTC0naMPZbD7TGGFx+P/RZeO8l45jJ7 62Sadwa5N9w9H4gB38+vJmes67cElZKabS4UD5o8V89RjvAzvdMyAS/iBhQmBOJCbOjZ z0S0aYQO2MZ08CDiZOmuT6AZ+v6vaioDKagACYMlOzG88mur3J7okb/Rzw5LSY+wjHRo yedA== X-Forwarded-Encrypted: i=1; AJvYcCX0ukH9GWoJvPIN23ufdKtW4VwKCzSdOIwY2G+76fPW7LZ/fEJMxY6OkrdNsfBnk1veY556chQKX8XvZHfCN+/22oBOqXHUNLtE+VFz X-Gm-Message-State: AOJu0YytSviOHLezeIZc0qOBXvwOmq4CQ1D2Fth68ET5gYfncMkg7wxD QyRjtFDeblnkK4fJbSZn2QVGprqEGsylLg7cIaT5MSJP31p8iS0Vgi2reBTnFUQ= X-Received: by 2002:a17:906:4157:b0:a3d:7ca3:fbab with SMTP id l23-20020a170906415700b00a3d7ca3fbabmr1539833ejk.27.1708008972211; Thu, 15 Feb 2024 06:56:12 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:11 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 02/14] include/drm/drm_gem.h: add poll_table_struct forward declaration Date: Thu, 15 Feb 2024 15:55:50 +0100 Message-Id: <20240215145602.1371274-3-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977292300321873 X-GMAIL-MSGID: 1790977292300321873 After eliminating includes of linux/mm.h, the following build failure occurred: ./include/drm/drm_file.h:443:45: warning: ‘struct poll_table_struct’ declared inside parameter list will not be visible outside of this definition or declaration 443 | __poll_t drm_poll(struct file *filp, struct poll_table_struct *wait); | ^~~~~~~~~~~~~~~~~ In file included from drivers/gpu/drm/imagination/pvr_gem.h:12, from drivers/gpu/drm/imagination/pvr_fw.h:9: ./include/drm/drm_gem.h:447:27: error: initialization of ‘__poll_t (*)(struct file *, struct poll_table_struct *)’ {aka ‘unsigned int (*)(struct file *, struct poll_table_struct *)’} from incompatible pointer type ‘__poll_t (*)(struct file *, struct poll_table_struct *)’ {aka ‘unsigned int (*)(struct file *, struct poll_table_struct *)’} [-Werror=incompatible-pointer-types] 447 | .poll = drm_poll,\ | ^~~~~~~~ The compiler is confused, and that can be fixed easily by forward-declaring the struct expicitly. Signed-off-by: Max Kellermann --- include/drm/drm_file.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index ab230d3af138..f24ade9f766f 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -44,6 +44,7 @@ struct drm_device; struct drm_printer; struct device; struct file; +struct poll_table_struct; /* * FIXME: Not sure we want to have drm_minor here in the end, but to avoid From patchwork Thu Feb 15 14:55:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp453703dyb; Thu, 15 Feb 2024 06:57:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhGuMh0Jo2IVTkyFl6XtBH6htCFRvCgdsdUo/xANvUKwy0i9xJiuNJp11v/pNfzh6v3/xmMz9+iMJ1IU/6O3vkgqFmyA== X-Google-Smtp-Source: AGHT+IGHw1M1jKpxMzJ2VibZynC8j56IL26BJr1INDH2Yz3c76VqMjOOviAiT0xZUp7Lgeq1pC3M X-Received: by 2002:a17:906:f190:b0:a3c:ef50:e28 with SMTP id gs16-20020a170906f19000b00a3cef500e28mr1661964ejb.30.1708009065608; Thu, 15 Feb 2024 06:57:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009065; cv=pass; d=google.com; s=arc-20160816; b=Kv3ccotPoFrypimcqAuBCvT5TBVRZFDQqhlitAGNBDD83o+bTF2lDQpXs6a/B+Wmas wUlZk45TTMmeggkdO71V8HvCR2gpd7fgryWi9UAJ58qc02Ypvz2PERqYeK8LzkFAJbfz NgwnhtoT5015VU6Mn9aAi4l1/vqMUwTwoff3EolHInNT7J5Y88uAgdVsZGQyNsFrGBxw VxVmN9y3+y3+VdWukIWIZw/GVTRNTniqXPpI08GhCd1r8ZzDWWcPYu24BezRt9Tz0lHr oD877zsNYltsohrhsfwzVKzbqXXq171C66nGKp4KtIGAYrqOhrdoH9ug5RNEEotlJv2x 6q4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5yWhRxx5j9/Xhrml0aMKDxvuRZarY+DeLwc3tl7RleQ=; fh=F0tbqXbT1oZsBuj5afmnHOv0UzkYm+NanjP2Uf6n73k=; b=LEMgJx7bcgOm+/C2roUXoIoVysbUn90Usz5ADko6e6NJuOd8ur3TA7NlwB/SPk3zKh deG+uHxjwzLsQmUChhwlgwSMjB7A55u+ZSJSW0HrLumM/RiZ/Zd2vKJAMhs91kCe5ncn xfgIFlT749Hs13AOvZwcmOHXIlIitWSWwPklM8AWEf1bBfzRHOgNznQA9yAN5PpxoapV T8Gp4NZK31+CGuJjxXvLYwIoyzBePRS9pO88QA62dVskYmEjp4oAz6jxVBQ7Ysc9b/5A PictPBcHoyD2jfDMbKkZzq3lLfCEDuohD48BBUSQLPPFBv1sPk9taRlGO9FPulldsiex IUCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=aHu1Gnts; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67114-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67114-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r12-20020a170906364c00b00a3d18b8d397si718185ejb.643.2024.02.15.06.57.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:57:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67114-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=aHu1Gnts; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67114-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67114-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5F6541F21693 for ; Thu, 15 Feb 2024 14:57:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19E87133424; Thu, 15 Feb 2024 14:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="aHu1Gnts" Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70988132C1D for ; Thu, 15 Feb 2024 14:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008978; cv=none; b=VhyTCzc1kXZ03Ny9pJL0nWsvSSFAaW+vPy8jcbUWxkghELguQyVV4xkzCtyXoP/d4o18x16QErGrRpynepKybYniW+sCnUYTo/1RhR6E+vIt6bq6CvA8zigZEhddqJdH0laQwFsMDhXYpVgRPySTbA3CfS9JgOgJeIPgbmoJNYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008978; c=relaxed/simple; bh=gVIds65BiYL/PkB0EIOcX5QkFlfKbFVbwd5jl45KB+c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PHYo3Dca/cjWQhzdxViasQm97LfMz6r3bnD3WQuGIqx0rUruGZDHq3niFHl7MY4Yz97RwS/7Q0BxIyuPgAPflVM5FMDfaJ62gjS9lJXxKbDbhHjDJW9daL2VvjbTCEm/OCKL6O0Av/fhCPybzfdfXHfAKKE1cZ6Kvrwa4Fg/iUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=aHu1Gnts; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-55a8fd60af0so1428273a12.1 for ; Thu, 15 Feb 2024 06:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008975; x=1708613775; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5yWhRxx5j9/Xhrml0aMKDxvuRZarY+DeLwc3tl7RleQ=; b=aHu1Gnts7ESUimtXnVliJt87ieqUAZ58KDtFRje5csVltxLBJkrw0Wk1LhBx51OsMK pdEOsoLC/7AYtyvcojtYVpZaE0q+UdMV8HEMcdld0pjfmcB4FstAXCe5dNB95rMtkVSx rX/Dgyx23tuIMDhKIMul2B2Cuj0WXsGgLlkH8wzrziCpbXpdZa5Wnf12A4uvhoqRGPvO kdJnH5u+wN9pOw8D9I4clCGS3xvxE6PoUlInsqrchMaiSJ9NWR83u44j1RZeO+K1G6GI JBCyYeDk1919z/htK4cg+7kFv6LKNkBPgfLQDKqXUiiXr2CDFzWErZFAH5F3CtorH9oM nMkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008975; x=1708613775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5yWhRxx5j9/Xhrml0aMKDxvuRZarY+DeLwc3tl7RleQ=; b=M09p3sEN6mC4Kl8EUlrpvX84z2UOpDrpstxRUMfXSLugRlWIv14+Tx32k+DlsLHJeg qoBnayGbatXw3YbLO6wGNSyKhNw83K6LJNW0flhqCU1R/2aDPPA9AR2FBxzbg4rcRygI oxD14Yka0O7AViCNRqzzSQHZxYxmliDwXzPx8thDocj/hgi9ZjZ4kBCniaUqixUsvPdf I853CLEiox/PmrrOsdBkfxHeU7mXcJ9Xxvz1Gvxtjw6wiviRlVocHki7Qpo1Gmqfhi/w 33yMvLoPirMtovXTEFzHjq9Rj+/XxjfQg0A3b/KaBogrBWceFteFRivIg/E/VcKZ1hKZ yoTA== X-Forwarded-Encrypted: i=1; AJvYcCW/jmz3tsvStuSpDtv+Bvkq0qBEHUvt7NgLtMmgGF10O93d9iGaF/FSbidSQ9QTRwfmxn+toTHYF0aDnKclfkA81AUg1wtr4360zAzy X-Gm-Message-State: AOJu0Yx4UNNTBJ41Kt9nn4pyJLuOqV4VtFj0FkdWlG+Qdx0q2YkpUlIX 4SEyFrav4TTN45uk49HGFOOdG6650YZDvadbN13tC5LxKcu2tTt8I9vZQQnPM1Y= X-Received: by 2002:a17:906:1186:b0:a39:6c07:d31c with SMTP id n6-20020a170906118600b00a396c07d31cmr1552619eja.25.1708008972867; Thu, 15 Feb 2024 06:56:12 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:12 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 03/14] linux/mm.h: move page_kasan_tag() to mm/page_kasan_tag.h Date: Thu, 15 Feb 2024 15:55:51 +0100 Message-Id: <20240215145602.1371274-4-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977314371497177 X-GMAIL-MSGID: 1790977314371497177 Prepare to reduce dependencies in linux/mm.h. A side effect of this patch is that the include line is moved inside the "#ifdef CONFIG_KASAN..." block, i.e. it is not included at all if KASAN is disabled. Signed-off-by: Max Kellermann --- MAINTAINERS | 1 + include/linux/mm.h | 56 +------------------------- include/linux/mm/page_kasan_tag.h | 66 +++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 55 deletions(-) create mode 100644 include/linux/mm/page_kasan_tag.h diff --git a/MAINTAINERS b/MAINTAINERS index 897fbf1b0701..4fba8597b2c1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14227,6 +14227,7 @@ F: include/linux/mempolicy.h F: include/linux/mempool.h F: include/linux/memremap.h F: include/linux/mm.h +F: include/linux/mm/*.h F: include/linux/mm_*.h F: include/linux/mmzone.h F: include/linux/mmu_notifier.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 6095c86aa040..decc0cb8ed32 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H +#include #include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include #include #include @@ -1805,60 +1805,6 @@ static inline void vma_set_access_pid_bit(struct vm_area_struct *vma) } #endif /* CONFIG_NUMA_BALANCING */ -#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS) - -/* - * KASAN per-page tags are stored xor'ed with 0xff. This allows to avoid - * setting tags for all pages to native kernel tag value 0xff, as the default - * value 0x00 maps to 0xff. - */ - -static inline u8 page_kasan_tag(const struct page *page) -{ - u8 tag = KASAN_TAG_KERNEL; - - if (kasan_enabled()) { - tag = (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; - tag ^= 0xff; - } - - return tag; -} - -static inline void page_kasan_tag_set(struct page *page, u8 tag) -{ - unsigned long old_flags, flags; - - if (!kasan_enabled()) - return; - - tag ^= 0xff; - old_flags = READ_ONCE(page->flags); - do { - flags = old_flags; - flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); - flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; - } while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags))); -} - -static inline void page_kasan_tag_reset(struct page *page) -{ - if (kasan_enabled()) - page_kasan_tag_set(page, KASAN_TAG_KERNEL); -} - -#else /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ - -static inline u8 page_kasan_tag(const struct page *page) -{ - return 0xff; -} - -static inline void page_kasan_tag_set(struct page *page, u8 tag) { } -static inline void page_kasan_tag_reset(struct page *page) { } - -#endif /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ - static inline struct zone *page_zone(const struct page *page) { return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; diff --git a/include/linux/mm/page_kasan_tag.h b/include/linux/mm/page_kasan_tag.h new file mode 100644 index 000000000000..1210c62170a3 --- /dev/null +++ b/include/linux/mm/page_kasan_tag.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_KASAN_TAG_H +#define _LINUX_MM_PAGE_KASAN_TAG_H + +#include + +struct page; + +#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS) + +#include +#include // for struct page + +/* + * KASAN per-page tags are stored xor'ed with 0xff. This allows to avoid + * setting tags for all pages to native kernel tag value 0xff, as the default + * value 0x00 maps to 0xff. + */ + +static inline u8 page_kasan_tag(const struct page *page) +{ + u8 tag = KASAN_TAG_KERNEL; + + if (kasan_enabled()) { + tag = (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; + tag ^= 0xff; + } + + return tag; +} + +static inline void page_kasan_tag_set(struct page *page, u8 tag) +{ + unsigned long old_flags, flags; + + if (!kasan_enabled()) + return; + + tag ^= 0xff; + old_flags = READ_ONCE(page->flags); + do { + flags = old_flags; + flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); + flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; + } while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags))); +} + +static inline void page_kasan_tag_reset(struct page *page) +{ + if (kasan_enabled()) + page_kasan_tag_set(page, KASAN_TAG_KERNEL); +} + +#else /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ + +static inline u8 page_kasan_tag(const struct page *page) +{ + return 0xff; +} + +static inline void page_kasan_tag_set(struct page *page, u8 tag) { } +static inline void page_kasan_tag_reset(struct page *page) { } + +#endif /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ + +#endif /* _LINUX_MM_PAGE_KASAN_TAG_H */ From patchwork Thu Feb 15 14:55:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp453748dyb; Thu, 15 Feb 2024 06:57:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWBSZYn8eP4MqLMaVj+69J6NYroi4z5vEMD7JBAuA/LYqK9fdSNBQSP2HeoyPgs48gbLmRjXzXpTu66UTFP+CTmsb7g2Q== X-Google-Smtp-Source: AGHT+IEr/qcPWMh57u6S2EjtoSjsyqDwebineQkqJj6ZkYL44PUnopSu7hhDK7/KmcmeBkNCpnFa X-Received: by 2002:a05:6358:6484:b0:178:c4f4:4ae1 with SMTP id g4-20020a056358648400b00178c4f44ae1mr2728583rwh.13.1708009070036; Thu, 15 Feb 2024 06:57:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009069; cv=pass; d=google.com; s=arc-20160816; b=MPoCuoAULUYZGscV8FSXc9niN8ctG3WF/ge2nLucoyZGF8IeTjnftbEuJcDJSjK8ia qtCsN0qrNoTH4TtAVY1Z2tZzEQdZh9Huyb4PMzEXtifTwylOK1jBg/7SP9jBdAPkGOvV 6ZuUc6wwqMZt/mpLCMw4dKeTp8d87nj0rG/tj83ctQuJBVlAxswpCIeui8Pn/8Cfm9BE yERpEOcGwgtM7GxFH/RHNSHc26s9RoVdQcZadaRvkKhiuuULR5ILgjtAPd2LKptdjTcs fF9mHAS5bbcMCtG8/NaiFm+98PLgbsOtngv7VSYFh/NHNA7uu9uY69M8o2fOrWk6uu90 NYkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GOKW+J+Ft2qh+SDtx4ZJQpIK78L9+qr7BGcqORkx+gI=; fh=sZKcvTdI1y+3grkwgp1GLq4o20hUJv5aTOO0yN+n14g=; b=SG5H3ahfamfzziVMqBvqt0/dbL0+t1K16GvSRl5yKKmCNPvn5dkLuuWkR9vxQn8Tqu lgxsN8Ipe21aXt54noJvKYACZReQSaoJ5Ec9d/BqvGirVDY6mxUYaNt2RpLHZMBaToSi Fy6N20t92+S8mUCbBUn4JnF9nyooSQ9k5TtFWsfbZo13JK2xThEsU4gXfMoflpsfiRyy 37ry1WIF9C6qlMt06Om7SCgOx6d7regtmWBdeCOdEjEDp5O18rfjtbRmNgvEEE3x87iO 0K/4SuwneRf4W/PE99tOXg0K5O6tqIZiD3irTS08fBWzIUgoNH1BN61LSw4BH/ycrYhe 9FWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=bztQzl4Z; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67115-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67115-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b16-20020a631b10000000b005dc71c7b944si1275724pgb.144.2024.02.15.06.57.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:57:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67115-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=bztQzl4Z; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67115-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67115-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CCCD1289656 for ; Thu, 15 Feb 2024 14:57:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8EBCA133436; Thu, 15 Feb 2024 14:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="bztQzl4Z" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EFF0132C2F for ; Thu, 15 Feb 2024 14:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008979; cv=none; b=NT2NAl/qvlkuZh2ZbyBjQNSNlkOiF+JMjjD4GMRBI1ht043LhmKvu9FhkOl7rILvC+Q5LLOsP/2W9O/bx2vFVgLu2z8rAnGU9z81/dK78tUyNPE5ypPy994KfhtkqObXuCEfjjWM4WsfFwrDqg93MDIgUnRvtGDOjZyTgLJHLak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008979; c=relaxed/simple; bh=IpD67k2gO2M25PjFyFyPuo75aV97Zro4npvwo0DmQ38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bc7Tf3ENlFLg2KPEXMvAhcoUK5Kg6LlRWg9FY+8p6w4xWVvEsM1e+gfjH+YeX9O9f7L2yja25li5ekO7EkPKh12nvo+UexR8oKfnKhWZWaQD48y+tO2sg7uSjvw2lbPXzQzpRnEYpXN2fnYI+Lw1nFd2WpvNW6CMoKbgd6Qv4ko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=bztQzl4Z; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-55f279dca99so1643198a12.3 for ; Thu, 15 Feb 2024 06:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008975; x=1708613775; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GOKW+J+Ft2qh+SDtx4ZJQpIK78L9+qr7BGcqORkx+gI=; b=bztQzl4ZWifAlujdj5vU9b7rCWYZYBstWPTPITzvBWGyN1/pHG0qScI55r+q8KaAx3 KHzVRcW3GzPEg7ORfzTUY0LUM3nGBbzwRU/YQ1Z+5/SFj0VS+5G7+NvvMnFY7rrg1HYU 4gpwyIDo4L6VIKhsq1MEKP2NyPNcqHFO3yi5w2sdB8ODUwYIpPOegcMBTbf8YrC+Mkz+ RnZKMnkTYQGf4Zyz81ky/hzMIxtMYoiZLyt8bCXppFg0EFZLC66bukU5zTkc+azqGr1J nTv4YBvZPQGhgN+gMTg8TyLx4VnQguMv6nd896V5LXUS/kCp2QMDSBClfHNF+cWMok5F kI8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008975; x=1708613775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GOKW+J+Ft2qh+SDtx4ZJQpIK78L9+qr7BGcqORkx+gI=; b=vUrtpSxJPYIBFG3qktOguRsMsNlNRbVUKDwgYkgCgRjUyvi6J8ZCSi9DTAJFBBAFL5 LItniHAMG+5S4rO4N0nnd7InZUDzn0qlo+RW2E6VJe1T0t1N+MsK3BvMBlhVg0MQlqsL Qkn7DUkeVV5oc/vqLoLARYytlpQeBSVrgm3hkLRcls7L0AnifwbHM12WxIP4eA3Ct83G UfxgT23KrOqZz0gqKR9YO6akFYsRDyDY1C/2uYQw9nnIn0IIZC4fWjiz+9Ijk+yhXNVS XcnBPTLrKkKF9ipZCT0tHiZuiGSj3q5A1THcNYKLBBqteKReZ5fAIo/S/MYjc9aIAPys mD5w== X-Forwarded-Encrypted: i=1; AJvYcCUCcAncWQI1m38cwMH15xWw74HokclRJup0MPtVO1aFTj6d+03mlxXWuDyxUUHa/TNiHS1Twnf9FHmSj2rfY2T0RpJDVynCvj81p3U6 X-Gm-Message-State: AOJu0Yxd1fiimwArWZD1M2AfAH98hRfLepZmuZjzaLvBiwW+HemNHw8V 7WlgZ5UQOM9O8LaIiW0qrfWE3WpAf+hARTDt+uXdLI4koo+OhT03Jfh374mJoaw= X-Received: by 2002:a17:906:35c9:b0:a3b:b947:af77 with SMTP id p9-20020a17090635c900b00a3bb947af77mr1309692ejb.67.1708008975496; Thu, 15 Feb 2024 06:56:15 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:15 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 04/14] linux/mm.h: move section functions to mm/page_section.h Date: Thu, 15 Feb 2024 15:55:52 +0100 Message-Id: <20240215145602.1371274-5-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977318186181669 X-GMAIL-MSGID: 1790977318186181669 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 18 +----------------- include/linux/mm/page_section.h | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 include/linux/mm/page_section.h diff --git a/include/linux/mm.h b/include/linux/mm.h index decc0cb8ed32..84a49178b94a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3,6 +3,7 @@ #define _LINUX_MM_H #include +#include #include #include #include @@ -1622,10 +1623,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_t flags) } #endif -#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) -#define SECTION_IN_PAGE_FLAGS -#endif - /* * The identification function is mainly used by the buddy allocator for * determining if two pages could be buddies. We are not really identifying @@ -1825,19 +1822,6 @@ static inline pg_data_t *folio_pgdat(const struct folio *folio) return page_pgdat(&folio->page); } -#ifdef SECTION_IN_PAGE_FLAGS -static inline void set_page_section(struct page *page, unsigned long section) -{ - page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT); - page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT; -} - -static inline unsigned long page_to_section(const struct page *page) -{ - return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; -} -#endif - /** * folio_pfn - Return the Page Frame Number of a folio. * @folio: The folio. diff --git a/include/linux/mm/page_section.h b/include/linux/mm/page_section.h new file mode 100644 index 000000000000..e4558c2691b8 --- /dev/null +++ b/include/linux/mm/page_section.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_SECTION_H +#define _LINUX_MM_PAGE_SECTION_H + +#include // for struct page +#include // for SECTIONS_* + +#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) +#define SECTION_IN_PAGE_FLAGS + +static inline void set_page_section(struct page *page, unsigned long section) +{ + page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT); + page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT; +} + +static inline unsigned long page_to_section(const struct page *page) +{ + return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; +} +#endif + +#endif /* _LINUX_MM_PAGE_SECTION_H */ From patchwork Thu Feb 15 14:55:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454025dyb; Thu, 15 Feb 2024 06:58:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXc389CZpZRpKcAuw1NIM4AEcfqoIEnZvcL2Taru7ZG9VHnSn7mlxuqnbPZQmH7/7Dp62yK5/MdpNZ4aY5j7GA/dDx6VQ== X-Google-Smtp-Source: AGHT+IF/guxgLnFnc4VT7xdYPV/P2VKTiSbPF96LWi8NQD2fld6JzKULqMXKI6lgcs0zXRxEcCtO X-Received: by 2002:a17:906:ecea:b0:a36:fc15:c6d2 with SMTP id qt10-20020a170906ecea00b00a36fc15c6d2mr1495088ejb.5.1708009103617; Thu, 15 Feb 2024 06:58:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009103; cv=pass; d=google.com; s=arc-20160816; b=y2cXFDvb5HOfqgSnd6xFeNXT2Ab3gioSjhS79aZKeps2ddSw2InwWPuNsqIpTIwbtX 2+dE/3MErSm5tssTcN1DAkafK36pmUojr+Sowu5cf5iNoiG+L1fYrRY0t1Kbt0k3JWHl ZrMrjltUmZQrSPbLr7li3F/lzJ8ni+VVuuRXdU2py8i6SNn0yMHFmCP2ALF+W2j2vGku PMrCsrAGcz3Fhf3CvtX79zHvL3XjtaWOVryiD+uTCl9XyNlBnku0ev983T2lfzTU8M2B hHzXoYYDk24vl6fi9K6cdL3XXd91AgyMYAuICk4mr77OIuGaY2fsRckK4E94i7fXJ55S beeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=f2uzIED0RGgrcDO6EVVxl3NNU/jaMuJjJACfUgXp0rs=; fh=AfpZl/TKrvVCIWU3wgBeppF286cYG/5Cn/gWAUseLQA=; b=cHDf06k3Dm+UxZJC/B7e9nzvQXy0j7oB3IfDm67pzOpdZCvBNNaMTklah2Y64egMdW aYgYVdjd5KJ3/xdwWjpCiV1xBXMR421iCJbhvnHbIYcXzDG+E/O69MNuRGcst+ay9f3e 9EOjhXKwsYBtOyboRd9RD39ohFr9yDvs37m9ruunxQABCFf/Uaic1EmwrG3FObhcpa/+ aPmuI9exLXiuWoIc1g0MgAkKcv311xN6AcFh/xVeR0IlaIGxhDp7TGeD5q5zyAQPQVI5 TeE12szegTG0vuCfaWkbYDpWR0NV4HmSoI0Jj9YfB5JMYsylxdX1N4hZFp7OhmsCCeC/ Y7rQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=TTCNhKuU; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67116-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67116-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e18-20020a170906045200b00a3d9e6c2a03si512540eja.229.2024.02.15.06.58.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:58:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67116-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=TTCNhKuU; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67116-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67116-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 12FA21F213C7 for ; Thu, 15 Feb 2024 14:58:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8846B134720; Thu, 15 Feb 2024 14:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="TTCNhKuU" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B51B132C3E for ; Thu, 15 Feb 2024 14:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008980; cv=none; b=HLSYA9hKPzqyafh6sZ1QA2LMyHjYT93XdT/leNM4NOjxxT7Aa1fCNK90b7rXsBrBgqX7R519G4pSzYDmhQ5QzhfKMcTXqPhyztqCu36rcKRMlh70IIy8nUCkDdBEWqiQnKd3AzzLkZ/Fq4GmCSRzPaLufUoPpGfKrQv2wzm6GKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008980; c=relaxed/simple; bh=0uXYMYmV0wyNfz0Ocw3x17eNVG1QKmSQ8m1yDzP5ZNQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ILeGR8hihQ53olWtQsMh0QsE6DVIQW95h/hzI2G6VQgL/48qo7b2LCdiZMqx8Gby2Rll7MZSK85XYuyOxmnQJ35ksv/rD4jVEyO5YrtoIMcSYcBVzMWhy9ZIobeuWXYwrF8vbz5V3f48UcqzX3kzl/A+kSZ/q/IrMsmHjstZkFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=TTCNhKuU; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a36126ee41eso131434366b.2 for ; Thu, 15 Feb 2024 06:56:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008976; x=1708613776; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f2uzIED0RGgrcDO6EVVxl3NNU/jaMuJjJACfUgXp0rs=; b=TTCNhKuUQ1fkUvNebk7MVlAME5WV2aZhqGzzKw35BnzGGHDm30+w86cXjWCgiuiSXC Ovb12GN32NNjyYBMhRBsau6Vb87rcNtlWwtakKdjAp+DSLpl5XLb6BRME/wTiyUE9gAM r22axQD62xIqpFG0R1kTohREBL8xahLlO/clkUzh3aJamMq24P1Jyj+TtrNy6vLQ7b0M sIy2QZSwf1sxxNX93yvbH1burJUn0fDJEe9EES8nEuVemS3AthDZjq0kKi0xSgXHzy3H 9Lz9jpaD2AwbL2IpIYStLLiLQjj4e3alYQAxwWCCT8KJyKyzeMlu9OLwTP/mwKOv3olw Qz0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008976; x=1708613776; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f2uzIED0RGgrcDO6EVVxl3NNU/jaMuJjJACfUgXp0rs=; b=KORUGzH6CX3s5M2DS6E5ReDpbYBAPiX/sExpQEgqQtcq7OsU5ZtDTUaesdFwo8c/cI Kcfhy9zzv2wtBjIRKwV0vOUrdR9WuSq/jzOUjmrZQflSyWLsEenhFF2UiGfp3rWgT8lr buolQvZj3T4IIRQtuc4BktgqpMPrkD56l3F5pt7wJ4Bg4b4L3AUigBkgPDjlmYssYIf3 ICWDS5HietWimNxxF1NU/4gcudbxhMcQnKkPVYGQ9xSBCp0Cv+ihQRfdJxEVfZjoFFYf znzrgv3bynD5sIha5end9YCvNB71f3TqGIHRcIBQ7gAkp+3mrQ2CMjCqvLBThxTv3nfL nYYQ== X-Forwarded-Encrypted: i=1; AJvYcCUY96Rh8XhcEPlG+7bIkLRT2zk4dOREv00MrdW5DpnCLy7cOHu4XQegaa8+NLYOi/A4j58qocPuPl2HPvuuCteQMWt0U7qmRSkNnFJv X-Gm-Message-State: AOJu0YxdaQk/oUOh46WRQG3AiQEr/AQLN8gmx42OUiJkAssISaDJVwKL MgpDQ6xvU4a2i0lMTclq75rRC8quNj8lns1sUaZAAFDDvc7dGTQOiWzgy5pU3Xo= X-Received: by 2002:a17:906:4894:b0:a3d:bbea:da41 with SMTP id v20-20020a170906489400b00a3dbbeada41mr67225ejq.12.1708008976461; Thu, 15 Feb 2024 06:56:16 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:15 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 05/14] linux/mm.h: move page_address() and others to mm/page_address.h Date: Thu, 15 Feb 2024 15:55:53 +0100 Message-Id: <20240215145602.1371274-6-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977353921257095 X-GMAIL-MSGID: 1790977353921257095 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 56 +------------------------- include/linux/mm/page_address.h | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 55 deletions(-) create mode 100644 include/linux/mm/page_address.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 84a49178b94a..2cc39916cf04 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,7 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H -#include +#include #include #include #include @@ -103,10 +103,6 @@ extern int mmap_rnd_compat_bits __read_mostly; #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) #endif -#ifndef page_to_virt -#define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x))) -#endif - #ifndef lm_alias #define lm_alias(x) __va(__pa_symbol(x)) #endif @@ -210,14 +206,6 @@ int overcommit_kbytes_handler(struct ctl_table *, int, void *, size_t *, int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *, loff_t *); -#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) -#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) -#define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio)) -#else -#define nth_page(page,n) ((page) + (n)) -#define folio_page_idx(folio, p) ((p) - &(folio)->page) -#endif - /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) @@ -2117,44 +2105,6 @@ static inline int arch_make_folio_accessible(struct folio *folio) */ #include -static __always_inline void *lowmem_page_address(const struct page *page) -{ - return page_to_virt(page); -} - -#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL) -#define HASHED_PAGE_VIRTUAL -#endif - -#if defined(WANT_PAGE_VIRTUAL) -static inline void *page_address(const struct page *page) -{ - return page->virtual; -} -static inline void set_page_address(struct page *page, void *address) -{ - page->virtual = address; -} -#define page_address_init() do { } while(0) -#endif - -#if defined(HASHED_PAGE_VIRTUAL) -void *page_address(const struct page *page); -void set_page_address(struct page *page, void *virtual); -void page_address_init(void); -#endif - -#if !defined(HASHED_PAGE_VIRTUAL) && !defined(WANT_PAGE_VIRTUAL) -#define page_address(page) lowmem_page_address(page) -#define set_page_address(page, address) do { } while(0) -#define page_address_init() do { } while(0) -#endif - -static inline void *folio_address(const struct folio *folio) -{ - return page_address(&folio->page); -} - extern pgoff_t __page_file_index(struct page *page); /* @@ -2217,10 +2167,6 @@ static inline void clear_page_pfmemalloc(struct page *page) */ extern void pagefault_out_of_memory(void); -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) -#define offset_in_thp(page, p) ((unsigned long)(p) & (thp_size(page) - 1)) -#define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1)) - /* * Parameter block passed down to zap_pte_range in exceptional cases. */ diff --git a/include/linux/mm/page_address.h b/include/linux/mm/page_address.h new file mode 100644 index 000000000000..e1aaacc5003f --- /dev/null +++ b/include/linux/mm/page_address.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_ADDRESS_H +#define _LINUX_MM_PAGE_ADDRESS_H + +#include // for struct page +#include // needed by the page_to_virt() macro on some architectures (e.g. arm64) +#include // for PAGE_MASK, page_to_virt() + +#if defined(CONFIG_FLATMEM) +#include // for memmap (used by __pfn_to_page()) +#elif defined(CONFIG_SPARSEMEM_VMEMMAP) +#include // for vmemmap (used by __pfn_to_page()) +#elif defined(CONFIG_SPARSEMEM) +#include // for page_to_section() (used by __page_to_pfn()) +#endif + +#ifndef page_to_virt +#define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x))) +#endif + +#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) +#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) +#define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio)) +#else +#define nth_page(page,n) ((page) + (n)) +#define folio_page_idx(folio, p) ((p) - &(folio)->page) +#endif + +static __always_inline void *lowmem_page_address(const struct page *page) +{ + return page_to_virt(page); +} + +#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL) +#define HASHED_PAGE_VIRTUAL +#endif + +#if defined(WANT_PAGE_VIRTUAL) +static inline void *page_address(const struct page *page) +{ + return page->virtual; +} +static inline void set_page_address(struct page *page, void *address) +{ + page->virtual = address; +} +#define page_address_init() do { } while(0) +#endif + +#if defined(HASHED_PAGE_VIRTUAL) +void *page_address(const struct page *page); +void set_page_address(struct page *page, void *virtual); +void page_address_init(void); +#endif + +#if !defined(HASHED_PAGE_VIRTUAL) && !defined(WANT_PAGE_VIRTUAL) +#define page_address(page) lowmem_page_address(page) +#define set_page_address(page, address) do { } while(0) +#define page_address_init() do { } while(0) +#endif + +static inline void *folio_address(const struct folio *folio) +{ + return page_address(&folio->page); +} + +#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) +#define offset_in_thp(page, p) ((unsigned long)(p) & (thp_size(page) - 1)) +#define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1)) + +#endif /* _LINUX_MM_PAGE_ADDRESS_H */ From patchwork Thu Feb 15 14:55:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201516 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454160dyb; Thu, 15 Feb 2024 06:58:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWoGFk9xPGySZqmXBWvZiDnSSMIFD1VJFBoguiNpOM335qvc51MJr/XmWMek8HOD92h01JXsscjL+E9DJLqpbUXmf/BBQ== X-Google-Smtp-Source: AGHT+IE0dhuFG1LtoqA/5eWul8/eAzAyStxOZTQMRSnVuJGCshf+BuPS6o3vqAq1l+u3O2M3jZ9F X-Received: by 2002:a05:6a00:26e5:b0:6e1:7ba:9c6 with SMTP id p37-20020a056a0026e500b006e107ba09c6mr1755479pfw.29.1708009124849; Thu, 15 Feb 2024 06:58:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009124; cv=pass; d=google.com; s=arc-20160816; b=aJAfXmrn5LoBtmuwdVxgEIfIq4CyXCoy5MXH9ZnvmeNWNiQvueSkjlPIfmniQ/q3P2 xFWrnDXNjGGXSU8z4+9vvpAn0Mr5NxDKQlru6S6HLIkp7MmgFLiWZJpQbGshxugqMc7r 1pnxhwv4WcwgVVGe5Yi07fcerwmYG5I53ZjDtnpDrRsSTxWYlz6jKb4JZrsfmukqZyhp ogQt8Zk3KacITgd00QD5sVGfIPrrVlqDTyVOtEEBn8xlLTJNknMcB0Jcn7LJ0H6JCv/l 5QWEZwqwOX+NU2ZFtRSJ16gE3gf55CrpcZl9zwvWL1aDBlDv4eFMr9OHrFJc2/cGQfX+ BNzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eRdb10/lfp5UXJT3tHF43SuGZ47dFW6seynzctgmvuM=; fh=oY2DmZb+THPHHGJJxkNruVGFIw4kmtsiCT/V8IWI5XM=; b=U239gRgnjW7VLs1TW6TYOziqMOAQlz0+qd0QlLgAsT0mCHD9CCt2qJ5rmPna8RlNL4 ITsZojooSPEpqSOr8AnqqsICDQgJIIRCBZKBXYFfD6ayjoyoGYOE3ecto3NOuiq33dfG 5ZFiWLGz8z1Y48uVzk7vA1oaH1nnirjBSx6AdWY8tA2iT5UtxeVqzHJZUYxU9bUvlKhx /Tj9DJrGU0r8ft/zg+31JBWXa52xIk0Nt5QoTM/DbjivIajwGgn50yiz8QRfA+5TypiF k4b0ojQvFbP2tJtbVed3UI+/qUJ4sgMPcRPYuH/BWfMHG5r4Hvqx22yymbofeqhuLRWV vD5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=FfDMKMPy; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67117-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67117-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g16-20020a633750000000b005cf97c743c6si1202280pgn.749.2024.02.15.06.58.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:58:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67117-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=FfDMKMPy; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67117-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67117-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A2ACA288B9F for ; Thu, 15 Feb 2024 14:58:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E124D134751; Thu, 15 Feb 2024 14:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="FfDMKMPy" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3D5120B3D for ; Thu, 15 Feb 2024 14:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008981; cv=none; b=MSPlgtJk+BfOZkKCvRCjOLuGMW0p1v+q8GHEivHdLHFWlhj9ZaSCDv8MO+hYgbfHGXkE1HcVA8EGaEWNPNjg7G8krCo0/xLuiN3V2H/hC/eDoOC00x0eBIxqIc7zUPfuNoKiR6oHcgzmSA4PImasPR7L/eGF/8J+9fuONLwDWxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008981; c=relaxed/simple; bh=drH5FwH8zCNJpj9u2jazdf5C6xaBK3OAJ/0s4TdABBo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bU1TeTnDPYdMSXDOxLSaYrEnkjl/IWKbk4t9u6t9BLbL8dz98RqGvmmFLJKMnS7uclyHiVFSdxuplgdGceaL9l7omk+mM/q3sMIVSM/pN/z4fxWGi8PKteUwOs/Ljhx3g6wTr6afmUHv4UuRX4s2HfzIpNNaV9ZjQwgtZYx4koY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=FfDMKMPy; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a2d7e2e7fe0so184986566b.1 for ; Thu, 15 Feb 2024 06:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008977; x=1708613777; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eRdb10/lfp5UXJT3tHF43SuGZ47dFW6seynzctgmvuM=; b=FfDMKMPypEH6RDfAyzo+tvrRt4G9ESYzd8gvEiagPBP4ey5WE6UwBdEKElGBrznQvn jkx+9Xwp7/Nxgv+FxIIsD6oMBhIDUuIdhgXjzfeVtfoxAJo2yIUEcWKPF/Ac3CXU7+CD RhGZInkNhcnnXBTk3y7etyhK6VwreuL/i3IRr6TDLM99vgn7q4053OL0ruvRPPipbBVM hR9SRieAK0fL/k9x6Adk9FTfu+9NsEVV04HgZc0yjnUP7WUUn/0Yyh6YmT+o1gxJmOvu OCQI4XVoqsjw/Pi+lH5bOQ0tVFIe9CQwGSlyQcMdTxm7Y/Kfl9gYpkzFjHOaXDlAPqd8 vPqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008977; x=1708613777; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eRdb10/lfp5UXJT3tHF43SuGZ47dFW6seynzctgmvuM=; b=YVb44dmERN6sEUhARAln3SRXpGmVULmI+s2yU2axenO7Fu7bfkQQ6hyukngOjWJka8 3HgrRe0GEqqysCFz+j40Rm3mLyFVk7hfcAY4MvRttyfIglgXpA5a4mSKV9CG/UsK7+cA Iu63SEobyruUMXc8zDT0noA6KMlJ8klUKvfEyj49zlwL80t5hUA34hk4nFhU1tzuxvqS xP6RjfQIouNIRateCF1o/4MiNnQA5Q96jp9w9XUGj7h5KLps57Hg12fIM/X2g6D06piu 8zcG1I+J6AaXcOfNEDvZiZvwjD/FmNq6jX838fJIUYkcqi5Oi8hgcLvPa9mQvta1PKDj A4Dg== X-Forwarded-Encrypted: i=1; AJvYcCW1Em5ybGtsAquzcdwUUOBL85csBTGcFto8BSxG9K7Ur389zLe/QMRlSnP5kyycOeaHfPAVc+3PfT6sxMKIIWL0yUJYwRIbW18JJo/9 X-Gm-Message-State: AOJu0Yz1i9GOulzeyXT+FciOmDMY7kBf4xPbS4JVXYjQrKO0SRyIGMUm mG0AA4ZcZLrnsE0gS1LceCkmqmq2RHdGHucu6ysOAmNrc9c56VFWeoD5d8YGUnw= X-Received: by 2002:a17:906:22d8:b0:a38:4f6a:4e7e with SMTP id q24-20020a17090622d800b00a384f6a4e7emr1940730eja.32.1708008976994; Thu, 15 Feb 2024 06:56:16 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:16 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 06/14] linux/mm.h: move page_size() to mm/page_size.h Date: Thu, 15 Feb 2024 15:55:54 +0100 Message-Id: <20240215145602.1371274-7-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977375842874686 X-GMAIL-MSGID: 1790977375842874686 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 140 +------------------------------- include/linux/mm/page_size.h | 150 +++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 139 deletions(-) create mode 100644 include/linux/mm/page_size.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 2cc39916cf04..778f8aebb45c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -1049,38 +1050,6 @@ int vma_is_stack_for_current(struct vm_area_struct *vma); struct mmu_gather; struct inode; -/* - * compound_order() can be called without holding a reference, which means - * that niceties like page_folio() don't work. These callers should be - * prepared to handle wild return values. For example, PG_head may be - * set before the order is initialised, or this may be a tail page. - * See compaction.c for some good examples. - */ -static inline unsigned int compound_order(struct page *page) -{ - struct folio *folio = (struct folio *)page; - - if (!test_bit(PG_head, &folio->flags)) - return 0; - return folio->_flags_1 & 0xff; -} - -/** - * folio_order - The allocation order of a folio. - * @folio: The folio. - * - * A folio is composed of 2^order pages. See get_order() for the definition - * of order. - * - * Return: The order of the folio. - */ -static inline unsigned int folio_order(struct folio *folio) -{ - if (!folio_test_large(folio)) - return 0; - return folio->_flags_1 & 0xff; -} - #include /* @@ -1294,39 +1263,6 @@ unsigned long nr_free_buffer_pages(void); void destroy_large_folio(struct folio *folio); -/* Returns the number of bytes in this potentially compound page. */ -static inline unsigned long page_size(struct page *page) -{ - return PAGE_SIZE << compound_order(page); -} - -/* Returns the number of bits needed for the number of bytes in a page */ -static inline unsigned int page_shift(struct page *page) -{ - return PAGE_SHIFT + compound_order(page); -} - -/** - * thp_order - Order of a transparent huge page. - * @page: Head page of a transparent huge page. - */ -static inline unsigned int thp_order(struct page *page) -{ - VM_BUG_ON_PGFLAGS(PageTail(page), page); - return compound_order(page); -} - -/** - * thp_size - Size of a transparent huge page. - * @page: Head page of a transparent huge page. - * - * Return: Number of bytes in this page. - */ -static inline unsigned long thp_size(struct page *page) -{ - return PAGE_SIZE << thp_order(page); -} - #ifdef CONFIG_MMU /* * Do pte_mkwrite, but only if the vma says VM_WRITE. We do this when @@ -1966,50 +1902,6 @@ static inline void set_page_links(struct page *page, enum zone_type zone, #endif } -/** - * folio_nr_pages - The number of pages in the folio. - * @folio: The folio. - * - * Return: A positive power of two. - */ -static inline long folio_nr_pages(struct folio *folio) -{ - if (!folio_test_large(folio)) - return 1; -#ifdef CONFIG_64BIT - return folio->_folio_nr_pages; -#else - return 1L << (folio->_flags_1 & 0xff); -#endif -} - -/* - * compound_nr() returns the number of pages in this potentially compound - * page. compound_nr() can be called on a tail page, and is defined to - * return 1 in that case. - */ -static inline unsigned long compound_nr(struct page *page) -{ - struct folio *folio = (struct folio *)page; - - if (!test_bit(PG_head, &folio->flags)) - return 1; -#ifdef CONFIG_64BIT - return folio->_folio_nr_pages; -#else - return 1L << (folio->_flags_1 & 0xff); -#endif -} - -/** - * thp_nr_pages - The number of regular pages in this huge page. - * @page: The head page of a huge page. - */ -static inline int thp_nr_pages(struct page *page) -{ - return folio_nr_pages((struct folio *)page); -} - /** * folio_next - Move to the next physical folio. * @folio: The folio we're currently operating on. @@ -2029,36 +1921,6 @@ static inline struct folio *folio_next(struct folio *folio) return (struct folio *)folio_page(folio, folio_nr_pages(folio)); } -/** - * folio_shift - The size of the memory described by this folio. - * @folio: The folio. - * - * A folio represents a number of bytes which is a power-of-two in size. - * This function tells you which power-of-two the folio is. See also - * folio_size() and folio_order(). - * - * Context: The caller should have a reference on the folio to prevent - * it from being split. It is not necessary for the folio to be locked. - * Return: The base-2 logarithm of the size of this folio. - */ -static inline unsigned int folio_shift(struct folio *folio) -{ - return PAGE_SHIFT + folio_order(folio); -} - -/** - * folio_size - The number of bytes in a folio. - * @folio: The folio. - * - * Context: The caller should have a reference on the folio to prevent - * it from being split. It is not necessary for the folio to be locked. - * Return: The number of bytes in this folio. - */ -static inline size_t folio_size(struct folio *folio) -{ - return PAGE_SIZE << folio_order(folio); -} - /** * folio_estimated_sharers - Estimate the number of sharers of a folio. * @folio: The folio. diff --git a/include/linux/mm/page_size.h b/include/linux/mm/page_size.h new file mode 100644 index 000000000000..0f8ee3dab6d0 --- /dev/null +++ b/include/linux/mm/page_size.h @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_SIZE_H +#define _LINUX_MM_PAGE_SIZE_H + +#include // for test_bit() +#include // for VM_BUG_ON_PGFLAGS() +#include // for struct page +#include // for folio_test_large() +#include // for PAGE_SIZE, PAGE_SHIFT + +/* + * compound_order() can be called without holding a reference, which means + * that niceties like page_folio() don't work. These callers should be + * prepared to handle wild return values. For example, PG_head may be + * set before the order is initialised, or this may be a tail page. + * See compaction.c for some good examples. + */ +static inline unsigned int compound_order(struct page *page) +{ + struct folio *folio = (struct folio *)page; + + if (!test_bit(PG_head, &folio->flags)) + return 0; + return folio->_flags_1 & 0xff; +} + +/** + * folio_order - The allocation order of a folio. + * @folio: The folio. + * + * A folio is composed of 2^order pages. See get_order() for the definition + * of order. + * + * Return: The order of the folio. + */ +static inline unsigned int folio_order(struct folio *folio) +{ + if (!folio_test_large(folio)) + return 0; + return folio->_flags_1 & 0xff; +} + +/* Returns the number of bytes in this potentially compound page. */ +static inline unsigned long page_size(struct page *page) +{ + return PAGE_SIZE << compound_order(page); +} + +/* Returns the number of bits needed for the number of bytes in a page */ +static inline unsigned int page_shift(struct page *page) +{ + return PAGE_SHIFT + compound_order(page); +} + +/** + * thp_order - Order of a transparent huge page. + * @page: Head page of a transparent huge page. + */ +static inline unsigned int thp_order(struct page *page) +{ + VM_BUG_ON_PGFLAGS(PageTail(page), page); + return compound_order(page); +} + +/** + * thp_size - Size of a transparent huge page. + * @page: Head page of a transparent huge page. + * + * Return: Number of bytes in this page. + */ +static inline unsigned long thp_size(struct page *page) +{ + return PAGE_SIZE << thp_order(page); +} + +/** + * folio_nr_pages - The number of pages in the folio. + * @folio: The folio. + * + * Return: A positive power of two. + */ +static inline long folio_nr_pages(struct folio *folio) +{ + if (!folio_test_large(folio)) + return 1; +#ifdef CONFIG_64BIT + return folio->_folio_nr_pages; +#else + return 1L << (folio->_flags_1 & 0xff); +#endif +} + +/* + * compound_nr() returns the number of pages in this potentially compound + * page. compound_nr() can be called on a tail page, and is defined to + * return 1 in that case. + */ +static inline unsigned long compound_nr(struct page *page) +{ + struct folio *folio = (struct folio *)page; + + if (!test_bit(PG_head, &folio->flags)) + return 1; +#ifdef CONFIG_64BIT + return folio->_folio_nr_pages; +#else + return 1L << (folio->_flags_1 & 0xff); +#endif +} + +/** + * thp_nr_pages - The number of regular pages in this huge page. + * @page: The head page of a huge page. + */ +static inline int thp_nr_pages(struct page *page) +{ + return folio_nr_pages((struct folio *)page); +} + +/** + * folio_shift - The size of the memory described by this folio. + * @folio: The folio. + * + * A folio represents a number of bytes which is a power-of-two in size. + * This function tells you which power-of-two the folio is. See also + * folio_size() and folio_order(). + * + * Context: The caller should have a reference on the folio to prevent + * it from being split. It is not necessary for the folio to be locked. + * Return: The base-2 logarithm of the size of this folio. + */ +static inline unsigned int folio_shift(struct folio *folio) +{ + return PAGE_SHIFT + folio_order(folio); +} + +/** + * folio_size - The number of bytes in a folio. + * @folio: The folio. + * + * Context: The caller should have a reference on the folio to prevent + * it from being split. It is not necessary for the folio to be locked. + * Return: The number of bytes in this folio. + */ +static inline size_t folio_size(struct folio *folio) +{ + return PAGE_SIZE << folio_order(folio); +} + +#endif /* _LINUX_MM_PAGE_SIZE_H */ From patchwork Thu Feb 15 14:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201514 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454008dyb; Thu, 15 Feb 2024 06:58:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhSK5XJQmsYD+nfUu9rxA9uOWB1iHk6CltEtvAD3NhqWQm0JMJ9lc+gu++oA757vdpgRjb+p+Hh1rY//AlIUi0R/stmA== X-Google-Smtp-Source: AGHT+IHHY1Y8V/egV4UjX2W9x9vduL6FZFSLXbPLFcw1upxvfNDReyR1K74txJ6DsaBuo/Vr0jxo X-Received: by 2002:a05:6a20:1603:b0:19e:a524:a92c with SMTP id l3-20020a056a20160300b0019ea524a92cmr2459849pzj.23.1708009101843; Thu, 15 Feb 2024 06:58:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009101; cv=pass; d=google.com; s=arc-20160816; b=ejhG8TZO4DDqTB6zSayvsRila1CEh9wS3RoG2jQS1gOI1tS+NqsHcq/Sx6AMNiZTFU ArS7YQi2oxPwPQmhR2HRGPdZnrg6WXa0pmcLZrJmTSRXm40hYLCwj9IoAthB1G3EQCt9 006iiv0n2v7iw3E1Cyk23eamJ8NQx5szlHagLHOCBOgOtAVY/HUpgxL+78etasDymePJ MYqt7ER/wdrJV1x3LwQfkKKAdj/JvsD5htb0ZPj4mQWZgrjcrSAQWWy3sNwIdtLgUpcp HEphwPVbCtbeYDmO6C7jWYjoC3tKx3HeJSjPMrj0fTzhrK2ySx8XHZRBW0B3UEtkg4LC xuoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HWAZLa4eGWeLLFtGDVHZ7Dmnhq8s5ecyK6HpyTUArQY=; fh=EM87I6yxbyWiW+hwW1TRDZvD/aTptkTQsToHq3zH2MY=; b=gHMoBT/fACuu/BBTlYqNNJ2kxF61nQg4sEorNzjkV5qB0YzzX2jSJzIVp7m69SUME/ ePZcBNXxhouuR3waVu8F4dr37qAhAg9goSFMb/1RIO1OCClWTaPjQLSsz6VXaryqi0a6 9Pb+Ed397d/XVo5GPboDc5GoLiUvLZvrVpkqQw/LwidHuEI8FJdF40LnaMrYCxB8ULYw 1cNpkzTWpdrDtxbgXeTJt3dKTLSgNqMxNJm0yjkM4bkpvLlOZsOXAcmg5jQmH/Lh0Rqc va1F+4TjG1GecLo58QZefV3hFaHV0Xvma4CYcI1KGwuA7kHAXz0Pzw637HiMBk5qHupU Nyog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=emnPTkfc; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67118-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67118-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y21-20020a63b515000000b005dc189d320csi1219349pge.399.2024.02.15.06.58.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:58:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67118-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=emnPTkfc; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67118-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67118-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A3CCD28810A for ; Thu, 15 Feb 2024 14:58:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88C5B134723; Thu, 15 Feb 2024 14:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="emnPTkfc" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 445FC13329B for ; Thu, 15 Feb 2024 14:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008981; cv=none; b=B37s9g8przzcot4dFsIC1HGH9m7IQ59Y8rc1duelOCGzWjyLrFjtM9p2jqeYp1Yfsqxx0FXIbAPnJGBjfG4V4AZt9fTYWUd3ii8S0WRxr2H11nv4D49C63s2mHreyJ6kKAuMl3VicSYNBr1i4QSrlHRb0bF2ErFWPqm7xCMU59s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008981; c=relaxed/simple; bh=GSwFs2D/dYXSHD0S2NLeknpsO4i2Jaw9bBhm/AVsNpo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZNdbfCJBuZjwsonwo6O3krXSlt2cwfMawOUX7OpLUlcWPyDxJw7B13aHpZYaAH0CJphXd7r3zmfj9GYCSsStVYndFd+RIHag59P0rGBmlFQ4/8Gquu/cZ0ntZf8usJp/F3lGN8LVwIBcr3Ajg9Y0rZQbAKlrrB/6KCE3BCK0U1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=emnPTkfc; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-563b49a0f44so1069103a12.0 for ; Thu, 15 Feb 2024 06:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008977; x=1708613777; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HWAZLa4eGWeLLFtGDVHZ7Dmnhq8s5ecyK6HpyTUArQY=; b=emnPTkfc+C1ZoJcPulHRLRZKzufthxZWpJLiFAo2uQmzGTJ43PCJVWHSx8HiszXaRm Zqt7JN15y6BC+pZq2uQtYUtN3VVDhCmhn0Y0wkpp0rmsfEwR7Lyi8Qe9AIxJE9Luev/9 49NTeXES5ZIljsDItVfsWHjlMWdj1nx/sMhJWRH4d7fwlGNXiIeOdpCZPhSsXCCNBM6b esLUnI+J2pjyw5zAiKr0ZJ+Rs/wjtVgG7fJETffhu+6xYfmLvzRLIVoks0VQYqPWgXxy HMcPPXUwg3tA+Hip3j0PtCMO1yArYuxCiAdUf8+aesHviRxM3shkbMaOY4s5ZXw9XIhq DUfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008977; x=1708613777; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HWAZLa4eGWeLLFtGDVHZ7Dmnhq8s5ecyK6HpyTUArQY=; b=mZmvw0blZEG7kksQ7ukaWGeIsIRldzxFa90Vgegjo0qOvRVDUMF9DnAX17LRB0eFe7 jaAev+j81DxMlSjnV53UuZnYcClotnuiMHOykRzlSi6Sh4XxuFlaw7yUG897qEwaTjT8 N194oEl6edR7xtt/9xjXyEBb8cseaXEHTQXWR8UZUImBb/d9SkHc/GP9u0Un4nxVUhAf TXvXDkrbGhSTqYMIjNsAlkS3A0Pdhb8y1KePA33dG1erGqAqQfbpp3LK69iodSWzp96s 2qrHFR4DdCuRsddkl3miC+at74j8D/fGUOQNUhLqjvPSKFo8Orot0zh7CZd+y50X6vn0 gU1w== X-Forwarded-Encrypted: i=1; AJvYcCWQPZAvQ54j+YFaBnjIyyHhxdPRHJH19QJX2Af0FAuMFNMjTYRB2a3DlRy3B2AfNoov+X7d4vG/tqgc34yDlajzXHwGQFPm8w1+nkbh X-Gm-Message-State: AOJu0YyyQkbcB9YfeVX/bQ8HBna8pHs6bbC4qQLIh+lsZ7AW8mfIBLSQ SmjSb01HCHUjArSaF2m5CpRnelh5XLVIbioISZdYeu2Ij0CwV1zYy7xj0NrwmIBif5K2rbOf0h1 p X-Received: by 2002:a17:906:f8cd:b0:a3c:8e78:8b59 with SMTP id lh13-20020a170906f8cd00b00a3c8e788b59mr1737035ejb.15.1708008977452; Thu, 15 Feb 2024 06:56:17 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:17 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 07/14] linux/mm.h: move folio_next() to mm/folio_next.h Date: Thu, 15 Feb 2024 15:55:55 +0100 Message-Id: <20240215145602.1371274-8-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977352386770661 X-GMAIL-MSGID: 1790977352386770661 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 20 +------------------- include/linux/mm/folio_next.h | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 include/linux/mm/folio_next.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 778f8aebb45c..680329ec21ba 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H +#include #include #include #include @@ -1902,25 +1903,6 @@ static inline void set_page_links(struct page *page, enum zone_type zone, #endif } -/** - * folio_next - Move to the next physical folio. - * @folio: The folio we're currently operating on. - * - * If you have physically contiguous memory which may span more than - * one folio (eg a &struct bio_vec), use this function to move from one - * folio to the next. Do not use it if the memory is only virtually - * contiguous as the folios are almost certainly not adjacent to each - * other. This is the folio equivalent to writing ``page++``. - * - * Context: We assume that the folios are refcounted and/or locked at a - * higher level and do not adjust the reference counts. - * Return: The next struct folio. - */ -static inline struct folio *folio_next(struct folio *folio) -{ - return (struct folio *)folio_page(folio, folio_nr_pages(folio)); -} - /** * folio_estimated_sharers - Estimate the number of sharers of a folio. * @folio: The folio. diff --git a/include/linux/mm/folio_next.h b/include/linux/mm/folio_next.h new file mode 100644 index 000000000000..f92d649c42c6 --- /dev/null +++ b/include/linux/mm/folio_next.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_NEXT_H +#define _LINUX_MM_FOLIO_NEXT_H + +#include // for nth_page(), needed by folio_page() +#include // for folio_nr_pages() + +/** + * folio_next - Move to the next physical folio. + * @folio: The folio we're currently operating on. + * + * If you have physically contiguous memory which may span more than + * one folio (eg a &struct bio_vec), use this function to move from one + * folio to the next. Do not use it if the memory is only virtually + * contiguous as the folios are almost certainly not adjacent to each + * other. This is the folio equivalent to writing ``page++``. + * + * Context: We assume that the folios are refcounted and/or locked at a + * higher level and do not adjust the reference counts. + * Return: The next struct folio. + */ +static inline struct folio *folio_next(struct folio *folio) +{ + return (struct folio *)folio_page(folio, folio_nr_pages(folio)); +} + +#endif /* _LINUX_MM_FOLIO_NEXT_H */ From patchwork Thu Feb 15 14:55:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp479536dyb; Thu, 15 Feb 2024 07:32:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXf2Mh9qUZhbfm+m41auq1KRX0+FrCXznSY83LZFQmTtmFrwQCduWxAofyZj/gbtqFYwfvONibBA7WQDrzKAiEvocNU/g== X-Google-Smtp-Source: AGHT+IGE0qk4bQ9z/njdyGUsOqPddYa7sn46cajK/Myl5TfdCjzE2k1Ivop2nYP70v5qjAB8Op+m X-Received: by 2002:a05:6a21:3115:b0:19e:a1ae:7a95 with SMTP id yz21-20020a056a21311500b0019ea1ae7a95mr2168256pzb.47.1708011171561; Thu, 15 Feb 2024 07:32:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708011171; cv=pass; d=google.com; s=arc-20160816; b=Titld7d6+Gf0/jVwX5byNFXpUI2cpOlLmtfx+uuQU9F6TGRSTPQuPlTL/xffZRwS3H CKVotPqQJPTId6Xyino9E0weM4NQVVrWLIcro8ciTvRaCN13Bh1TXaG16rZA8GjHyfVb +mTx08AnVUnS3X2VUlsFiyndZOIONkST4N2YZC8LXN4FI8WX6XYuIWNrkJqOQKsds3Pv U1JohbaHNlv+qYTtruD8OueMwcu4jdFtqYnyHZ/KvN7vwydkLX3C0X72ChAHn2hVmLHQ GAd23FFNHre9mDdapobKqR5QydpZGgX41TacEYxZyHxjcv6PBPtIAT0lld0Y1j2KJIXR ol1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xRvSVsODNSSWpBrjcPj/MUDqCBoUjFcr6NI1MGfkDG8=; fh=qiSgx1pKpaEkhtfiJmXIIBwQMdRiw0W8IgdNDE4iuoQ=; b=anEz3Cv14YXT6OpnHXfb75yXFTD3Nl4m3/rxUDAHgIU5cFdUxaul765zpxgjcfhBkp /NgsvrYqC1HoJQ57v2qjXF42UJfWd/IqomxR/Q5pQCmE0mDNuP6EB07cTf7zS92tyKSU Uj6g57mWUbxx71TUBBqvu7j+qjVOQnQ9qbmBmzvyG7hQIL0IkXfVa3QZ2tDf/iXAr/TW /h381PQEJI+oNon1xs89l38vaPeBrm42nRlScqgwYO0qZHKbMc0LxEucvtjKdnWT06eu c8LHRPNjgzKS3qXmbdY9lcKoMqV6tH7v1gVYhMFzlMBD1lE2mGN1/8foBwgPXydCmVAY p/Hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KRjoka72; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67119-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67119-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c16-20020a6566d0000000b005cdfa6ec001si1299326pgw.380.2024.02.15.07.32.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:32:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67119-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KRjoka72; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67119-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67119-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E1389B26968 for ; Thu, 15 Feb 2024 14:58:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E108313474E; Thu, 15 Feb 2024 14:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="KRjoka72" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 620C91332AF for ; Thu, 15 Feb 2024 14:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008982; cv=none; b=GljQ9XDo9PrgaqIvlGoea9Kx7yvu65kycUP+0vhYOKvuSGCCNYQKdybI5QP/hWd0/ikjMD1Qtnq2oHoD6eOfBvSIcKdN240F6FdBcyFZei6ZOfzNKFa1gqByuVg6FTYao+jfEvsWPMC57RVmKhON1ALzbP+WBhuHNLgu4MGPq2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008982; c=relaxed/simple; bh=pgWmL1/kQ5EKgVkunmoc9kuE+c2QxgAXrDk6ncXpwtk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XEe4ZUKsViT2OQVtnjtyOSbeP6mgfZVWwbh6JJG12P6UnvwJ9sWCwEgXrd7V8WXt4zaFGtYmY8n+Utqk6+l1YCtcK79Wtc49H2wBORKSePO1uE+5f2YHkc1IOFDThbtCFTJWxUO0zZlt4HbktouV1RNWgNK2ULj1hZtT+tz+lWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=KRjoka72; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-563b7b48b9aso671047a12.2 for ; Thu, 15 Feb 2024 06:56:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008979; x=1708613779; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xRvSVsODNSSWpBrjcPj/MUDqCBoUjFcr6NI1MGfkDG8=; b=KRjoka72HcPUAjsYnRrAisjX86NnCNxsl3ZehjKlPeOT2rCIPoKZGY+WJUg9FiY3BT q3rAtlYOXYC6YUWrFDzocaxcZvYao8gkKymfy33hJBP6dmlUv81ke43cWGPsB8iWYCEH NMOZbc5fbIxMpv52whpGqgWRoLm62pgyH8DfoariqpKslCGdxAGKzDwENkYOtSkM4M+D E8mTouD8XZCvvlQufK5Y1cs7SsI1XeKkwKdrhqkDniuzrbCJ+mRkz1Tfm6+DdBxKclSj eg2+QQFZNcbq8iEHvO/4RG5u6gZ9hQS/7vaL0iZO2iB31NIFu6Dh37EbPt1lZbRkZj3i 9vqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008979; x=1708613779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xRvSVsODNSSWpBrjcPj/MUDqCBoUjFcr6NI1MGfkDG8=; b=LI8E+ljRb/rqrZeQu4/K6KACvleVMP7Hs6EP8IBFWgIEaFr46AiBLrdvaQhQj9L8JY HkXakn+3g1dgpTj3XihdeAPnLdCW7VllhXI9t53Km+DpO/vemTd3pDuNFBtZYdFu94Ir Cu8GYuxT0hUxTgGTMYneDV/CjqIBj7b12WZ9zO/ElOJ8s1ofQHZDTIpaLqk/0t3DjgZ4 mS6DdZLOIWpdoI+VzmyKW1rAszT9UaeO54JLQtQMe0CjyQur+sOvymsduhse0t1DeM/G E/rZUbmJPZ17PmNaSExx6pZOWyE++jiUaJJRRX62Esa1X87H4Dvn6tDqOtEU0BnV7n88 rzHg== X-Forwarded-Encrypted: i=1; AJvYcCWQRjzzVrVZxNNzmMb4RLWmkQzv16fpbct9kHnHnNdzaQycP1NosWSNUfu6MaaTl19s4SPsvyri075yRTcmS915ll6/bNMlGDI8cQk6 X-Gm-Message-State: AOJu0YyRJiGa7OX0eag10nhHXTsfWo56RiprcxSdD3RPnh+rCf2/AzGR 9zXE8L3hdjklKLbEQb6jzmOTj5iMFyBjmwdjD6hcC7qd8pwmlG047xYJeMmw6mpM9ekS+vkAibs O X-Received: by 2002:a17:906:bc5a:b0:a3c:875b:f378 with SMTP id s26-20020a170906bc5a00b00a3c875bf378mr1086457ejv.36.1708008978701; Thu, 15 Feb 2024 06:56:18 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:17 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 08/14] linux/mm.h: move devmap-related declarations to mm/devmap_managed.h Date: Thu, 15 Feb 2024 15:55:56 +0100 Message-Id: <20240215145602.1371274-9-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790979522158861113 X-GMAIL-MSGID: 1790979522158861113 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 24 -------------------- include/linux/mm/devmap_managed.h | 37 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 include/linux/mm/devmap_managed.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 680329ec21ba..cb2dd71e2940 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1345,30 +1345,6 @@ vm_fault_t finish_fault(struct vm_fault *vmf); * back into memory. */ -#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) -DECLARE_STATIC_KEY_FALSE(devmap_managed_key); - -bool __put_devmap_managed_page_refs(struct page *page, int refs); -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) -{ - if (!static_branch_unlikely(&devmap_managed_key)) - return false; - if (!is_zone_device_page(page)) - return false; - return __put_devmap_managed_page_refs(page, refs); -} -#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) -{ - return false; -} -#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ - -static inline bool put_devmap_managed_page(struct page *page) -{ - return put_devmap_managed_page_refs(page, 1); -} - /* 127: arbitrary random number, small enough to assemble well */ #define folio_ref_zero_or_close_to_overflow(folio) \ ((unsigned int) folio_ref_count(folio) + 127u <= 127u) diff --git a/include/linux/mm/devmap_managed.h b/include/linux/mm/devmap_managed.h new file mode 100644 index 000000000000..0773529d80b2 --- /dev/null +++ b/include/linux/mm/devmap_managed.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_DEVMAP_MANAGED_H +#define _LINUX_MM_DEVMAP_MANAGED_H + +#include // for bool + +struct page; + +#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) + +#include // for DECLARE_STATIC_KEY_FALSE(), static_branch_unlikely() +#include // is_zone_device_page() + +DECLARE_STATIC_KEY_FALSE(devmap_managed_key); + +bool __put_devmap_managed_page_refs(struct page *page, int refs); +static inline bool put_devmap_managed_page_refs(struct page *page, int refs) +{ + if (!static_branch_unlikely(&devmap_managed_key)) + return false; + if (!is_zone_device_page(page)) + return false; + return __put_devmap_managed_page_refs(page, refs); +} +#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ +static inline bool put_devmap_managed_page_refs(struct page *page, int refs) +{ + return false; +} +#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ + +static inline bool put_devmap_managed_page(struct page *page) +{ + return put_devmap_managed_page_refs(page, 1); +} + +#endif /* _LINUX_MM_DEVMAP_MANAGED_H */ From patchwork Thu Feb 15 14:55:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454554dyb; Thu, 15 Feb 2024 06:59:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUnVnxwHP3RPWlh/MgohFNRJrINZzY9V0yrB0xm6x+kd8A85K5r9exMo0bQpuDJA7IAj/+4qaodFo+dTZ4WY4oDUPdOkA== X-Google-Smtp-Source: AGHT+IHqFLf+32chyKzgO+w0wBvAVMZ0Lx/+TLFvz0txGjtMMa0Tdxtl2AtZEUAOJB+y5jpb6VIB X-Received: by 2002:a17:906:2517:b0:a3d:997c:32bd with SMTP id i23-20020a170906251700b00a3d997c32bdmr1532179ejb.12.1708009172685; Thu, 15 Feb 2024 06:59:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009172; cv=pass; d=google.com; s=arc-20160816; b=q/8KV4ajY/gybA9czYtMtjxELYt9i0GBAMDhjmE9c9PuaaUOkFD94f14Fk3nuZhsq+ 3BMdllwHDMEcf3oubL7PO57aUYC4qi8WmimRxYwaYq9B/7lovToJAroNUmvbZwguNE18 53tAFMV/jR9LorxlbgzRBjJRzWNw13y6nBwPeJZRDI7crjvnA1I/4TPvBfIckmGQ3RN6 JnK9zVN69GHe2l77YznzXkXVnI1+O4CeXjgCeVvbutohD+9ZVb7yaAUYxwyhd52iF/Oj Mk/FDm+0S6hhwrvjo1Ds6Q8T6edtcxHQA0JnITxXejGn8KWDaW3NvKek6yVUdvesTGPY SA8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=pAAfduKncyIlO7bGb0H7B4KC/vDoZlMcbrTq+YqBvns=; fh=vXcdVcASTcNY1HEjgvXI1ph1oDCLRfDvdnSFMC74Wt0=; b=m4qmq0Biv1u6kiqb7SzLdgSOzF+Wf7CN/S9JKDgxtzRV4vVOQmtVhNyiTKUbqx454R 0Hvl8o6HIQFAmdJgRbh6+8L9/N02XGUY7m40RGxSmxIL5c0qbcZw9davwUKvcS3mO/Ek YaqnueN60tNPPYdoYY2BRzBuMh2XciYnJwzAxcngOBcDZvAtiVhQJTOVmXSkGs+e3LJ6 oGrlAzp87qhSoOUs0LlqFJn+9ENti4CI3gAJQqzWFtE3tmm0CnAF54SsiOix9wltfvoa tc+k312I+E8uVlhSRgj2wDVrT0YNU612iPJFJIa1gvywZ3cFb4VGvwArf78Ly5Cu8JUY ssYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=bXdgcbXm; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67120-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67120-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i22-20020a170906265600b00a3cf61924a1si712880ejc.542.2024.02.15.06.59.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:59:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67120-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=bXdgcbXm; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67120-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67120-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 22CCE1F214FB for ; Thu, 15 Feb 2024 14:59:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E56AA1350C9; Thu, 15 Feb 2024 14:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="bXdgcbXm" Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08344132497 for ; Thu, 15 Feb 2024 14:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008983; cv=none; b=MLcjUsCFfsUg8dO5uRhmRX2kK5KIlPtfb7MwE2lXlmLBozXUdwVRwVwDmyRtlHxGtulaqWjQfVdpZojyccSDfT0hp8xsOXQAiLEBApnDRIoSzp3ryLlifpfv0GC3ZZGA5BE4W43FBpBYNHxRztaUpY2JhER1pYEYD3GNcmBqRAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008983; c=relaxed/simple; bh=N8bLCyldXfcu6rWJgUWRn6bFNyDC7DDiecstrCMhz7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V7MQ4bHvyJGro/umkoRPeBiBriv8AhDUu43zg7Kjmfp8d8xvWoeSeU91oDzX+NyRjwLuTvN7fAhr2pqQypFMnwLxiVQ3Bgiq5Qve53EF4Jp7ndqCtylba+iF+IsLd5O6yjs1soUB/jxQ9ieYdubhq5loE7/4QnplqQOVEeJfyL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=bXdgcbXm; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a3d5e77cfbeso177486566b.0 for ; Thu, 15 Feb 2024 06:56:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008979; x=1708613779; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pAAfduKncyIlO7bGb0H7B4KC/vDoZlMcbrTq+YqBvns=; b=bXdgcbXm2n3oX8TUttKWJmL5Dk9SPeNr5ntESwuuxJ3CGRdOckXD2uO4LEaEUQEPlC feMvXSSmoCip6mhmcCZYfB8sXK0ovph0USs7D+eaaXhTqe+apzzkCPV7eMhf03V/atSM VRa7249z5O/jC+FBX8olz4F/Icg5r+hYPLzDpKzoVMitdFo6gwEi9AAiP3tJVWCF4b1j 5E2sAc2rjJ8FCOSY5dxFQj62ll4qR/jVKSc3YcCYtrGTrBVRJQgyt27rjctLNJ7VVbLB WDXZocHToTir36EVmfmIrEP5fgq1X/iovpaKOIB3D/3aXS5H3P8eTAeGYV2FlPePTPWP UCIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008979; x=1708613779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pAAfduKncyIlO7bGb0H7B4KC/vDoZlMcbrTq+YqBvns=; b=sC+IdWjkom2ZkUxJiGpZKegq8iKWm0qG3NCMy4AVipS12FliZCZ4ZujC5xQ/okRRok ZhZ278hRBstWJESadJoJjKXhMQYuNUP7ydTte6JsDRgnKjN+ZZio2+GG5hWyRxKm38gd PnUoRNHtBmR2ORwabXqaKz9H3tWivjeFmXxTS7i/bG3tG32HatMRI4/z0YEzwjrImwNh 6UTHIqNS94RVasbbXocIPyw3DwYHc7scDdmg8ptmZ1471xwnuvAUh2+HRw2FZa7Xsclf e30V/FZAvGm5h2lz1Jk24o5r/DDa1p61/qWUgPPvA+6TgscnhjjoUFM7s6lrxjZydtXx qkDw== X-Forwarded-Encrypted: i=1; AJvYcCUKzzQmwcuKzsrKx3Ex9sZExYMib1TiRVXB5uVE/W0hgmy+xAfvM6DRAd2AXSBBiHhS5+oKQQNlSwCk+lHIHMjfnQDtEnkrWxvxFiiL X-Gm-Message-State: AOJu0Yxdr57A9j5KEYn41kACSIdHIsd4JOTvTXsT4PirDDfXvZuhs/lx +Xz3FHGCNjeMAqtC3PiDK/RIVlAjamUbJ/U8+Uut5I1QytlZSpZTUMg+D2CLK40= X-Received: by 2002:a17:906:3e11:b0:a3c:2c8e:9030 with SMTP id k17-20020a1709063e1100b00a3c2c8e9030mr4707897eji.6.1708008979244; Thu, 15 Feb 2024 06:56:19 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:19 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 09/14] linux/mm.h: move usage count functions to mm/page_usage.h Date: Thu, 15 Feb 2024 15:55:57 +0100 Message-Id: <20240215145602.1371274-10-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977426552037431 X-GMAIL-MSGID: 1790977426552037431 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 168 +------------------------------- include/linux/mm/page_usage.h | 177 ++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 167 deletions(-) create mode 100644 include/linux/mm/page_usage.h diff --git a/include/linux/mm.h b/include/linux/mm.h index cb2dd71e2940..26d506ed855f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1053,51 +1054,6 @@ struct inode; #include -/* - * Methods to modify the page usage count. - * - * What counts for a page usage: - * - cache mapping (page->mapping) - * - private data (page->private) - * - page mapped in a task's page tables, each mapping - * is counted separately - * - * Also, many kernel routines increase the page count before a critical - * routine so they can be sure the page doesn't go away from under them. - */ - -/* - * Drop a ref, return true if the refcount fell to zero (the page has no users) - */ -static inline int put_page_testzero(struct page *page) -{ - VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); - return page_ref_dec_and_test(page); -} - -static inline int folio_put_testzero(struct folio *folio) -{ - return put_page_testzero(&folio->page); -} - -/* - * Try to grab a ref unless the page has a refcount of zero, return false if - * that is the case. - * This can be called when MMU is off so it must not access - * any of the virtual mappings. - */ -static inline bool get_page_unless_zero(struct page *page) -{ - return page_ref_add_unless(page, 1, 0); -} - -static inline struct folio *folio_get_nontail_page(struct page *page) -{ - if (unlikely(!get_page_unless_zero(page))) - return NULL; - return (struct folio *)page; -} - extern int page_is_ram(unsigned long pfn); enum { @@ -1253,8 +1209,6 @@ static inline struct folio *virt_to_folio(const void *x) return page_folio(page); } -void __folio_put(struct folio *folio); - void put_pages_list(struct list_head *pages); void split_page(struct page *page, unsigned int order); @@ -1345,126 +1299,6 @@ vm_fault_t finish_fault(struct vm_fault *vmf); * back into memory. */ -/* 127: arbitrary random number, small enough to assemble well */ -#define folio_ref_zero_or_close_to_overflow(folio) \ - ((unsigned int) folio_ref_count(folio) + 127u <= 127u) - -/** - * folio_get - Increment the reference count on a folio. - * @folio: The folio. - * - * Context: May be called in any context, as long as you know that - * you have a refcount on the folio. If you do not already have one, - * folio_try_get() may be the right interface for you to use. - */ -static inline void folio_get(struct folio *folio) -{ - VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio); - folio_ref_inc(folio); -} - -static inline void get_page(struct page *page) -{ - folio_get(page_folio(page)); -} - -static inline __must_check bool try_get_page(struct page *page) -{ - page = compound_head(page); - if (WARN_ON_ONCE(page_ref_count(page) <= 0)) - return false; - page_ref_inc(page); - return true; -} - -/** - * folio_put - Decrement the reference count on a folio. - * @folio: The folio. - * - * If the folio's reference count reaches zero, the memory will be - * released back to the page allocator and may be used by another - * allocation immediately. Do not access the memory or the struct folio - * after calling folio_put() unless you can be sure that it wasn't the - * last reference. - * - * Context: May be called in process or interrupt context, but not in NMI - * context. May be called while holding a spinlock. - */ -static inline void folio_put(struct folio *folio) -{ - if (folio_put_testzero(folio)) - __folio_put(folio); -} - -/** - * folio_put_refs - Reduce the reference count on a folio. - * @folio: The folio. - * @refs: The amount to subtract from the folio's reference count. - * - * If the folio's reference count reaches zero, the memory will be - * released back to the page allocator and may be used by another - * allocation immediately. Do not access the memory or the struct folio - * after calling folio_put_refs() unless you can be sure that these weren't - * the last references. - * - * Context: May be called in process or interrupt context, but not in NMI - * context. May be called while holding a spinlock. - */ -static inline void folio_put_refs(struct folio *folio, int refs) -{ - if (folio_ref_sub_and_test(folio, refs)) - __folio_put(folio); -} - -/* - * union release_pages_arg - an array of pages or folios - * - * release_pages() releases a simple array of multiple pages, and - * accepts various different forms of said page array: either - * a regular old boring array of pages, an array of folios, or - * an array of encoded page pointers. - * - * The transparent union syntax for this kind of "any of these - * argument types" is all kinds of ugly, so look away. - */ -typedef union { - struct page **pages; - struct folio **folios; - struct encoded_page **encoded_pages; -} release_pages_arg __attribute__ ((__transparent_union__)); - -void release_pages(release_pages_arg, int nr); - -/** - * folios_put - Decrement the reference count on an array of folios. - * @folios: The folios. - * @nr: How many folios there are. - * - * Like folio_put(), but for an array of folios. This is more efficient - * than writing the loop yourself as it will optimise the locks which - * need to be taken if the folios are freed. - * - * Context: May be called in process or interrupt context, but not in NMI - * context. May be called while holding a spinlock. - */ -static inline void folios_put(struct folio **folios, unsigned int nr) -{ - release_pages(folios, nr); -} - -static inline void put_page(struct page *page) -{ - struct folio *folio = page_folio(page); - - /* - * For some devmap managed pages we need to catch refcount transition - * from 2 to 1: - */ - if (put_devmap_managed_page(&folio->page)) - return; - folio_put(folio); -} - /* * GUP_PIN_COUNTING_BIAS, and the associated functions that use it, overload * the page's refcount so that two separate items are tracked: the original page diff --git a/include/linux/mm/page_usage.h b/include/linux/mm/page_usage.h new file mode 100644 index 000000000000..53015e28b5df --- /dev/null +++ b/include/linux/mm/page_usage.h @@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_USAGE_H +#define _LINUX_MM_PAGE_USAGE_H + +#include // for put_devmap_managed_page() +#include // for VM_BUG_ON_PAGE() +#include // for struct folio +#include + +/* + * Methods to modify the page usage count. + * + * What counts for a page usage: + * - cache mapping (page->mapping) + * - private data (page->private) + * - page mapped in a task's page tables, each mapping + * is counted separately + * + * Also, many kernel routines increase the page count before a critical + * routine so they can be sure the page doesn't go away from under them. + */ + +/* + * Drop a ref, return true if the refcount fell to zero (the page has no users) + */ +static inline int put_page_testzero(struct page *page) +{ + VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); + return page_ref_dec_and_test(page); +} + +static inline int folio_put_testzero(struct folio *folio) +{ + return put_page_testzero(&folio->page); +} + +/* + * Try to grab a ref unless the page has a refcount of zero, return false if + * that is the case. + * This can be called when MMU is off so it must not access + * any of the virtual mappings. + */ +static inline bool get_page_unless_zero(struct page *page) +{ + return page_ref_add_unless(page, 1, 0); +} + +static inline struct folio *folio_get_nontail_page(struct page *page) +{ + if (unlikely(!get_page_unless_zero(page))) + return NULL; + return (struct folio *)page; +} + +void __folio_put(struct folio *folio); + +/* 127: arbitrary random number, small enough to assemble well */ +#define folio_ref_zero_or_close_to_overflow(folio) \ + ((unsigned int) folio_ref_count(folio) + 127u <= 127u) + +/** + * folio_get - Increment the reference count on a folio. + * @folio: The folio. + * + * Context: May be called in any context, as long as you know that + * you have a refcount on the folio. If you do not already have one, + * folio_try_get() may be the right interface for you to use. + */ +static inline void folio_get(struct folio *folio) +{ + VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio); + folio_ref_inc(folio); +} + +static inline void get_page(struct page *page) +{ + folio_get(page_folio(page)); +} + +static inline __must_check bool try_get_page(struct page *page) +{ + page = compound_head(page); + if (WARN_ON_ONCE(page_ref_count(page) <= 0)) + return false; + page_ref_inc(page); + return true; +} + +/** + * folio_put - Decrement the reference count on a folio. + * @folio: The folio. + * + * If the folio's reference count reaches zero, the memory will be + * released back to the page allocator and may be used by another + * allocation immediately. Do not access the memory or the struct folio + * after calling folio_put() unless you can be sure that it wasn't the + * last reference. + * + * Context: May be called in process or interrupt context, but not in NMI + * context. May be called while holding a spinlock. + */ +static inline void folio_put(struct folio *folio) +{ + if (folio_put_testzero(folio)) + __folio_put(folio); +} + +/** + * folio_put_refs - Reduce the reference count on a folio. + * @folio: The folio. + * @refs: The amount to subtract from the folio's reference count. + * + * If the folio's reference count reaches zero, the memory will be + * released back to the page allocator and may be used by another + * allocation immediately. Do not access the memory or the struct folio + * after calling folio_put_refs() unless you can be sure that these weren't + * the last references. + * + * Context: May be called in process or interrupt context, but not in NMI + * context. May be called while holding a spinlock. + */ +static inline void folio_put_refs(struct folio *folio, int refs) +{ + if (folio_ref_sub_and_test(folio, refs)) + __folio_put(folio); +} + +/* + * union release_pages_arg - an array of pages or folios + * + * release_pages() releases a simple array of multiple pages, and + * accepts various different forms of said page array: either + * a regular old boring array of pages, an array of folios, or + * an array of encoded page pointers. + * + * The transparent union syntax for this kind of "any of these + * argument types" is all kinds of ugly, so look away. + */ +typedef union { + struct page **pages; + struct folio **folios; + struct encoded_page **encoded_pages; +} release_pages_arg __attribute__ ((__transparent_union__)); + +void release_pages(release_pages_arg, int nr); + +/** + * folios_put - Decrement the reference count on an array of folios. + * @folios: The folios. + * @nr: How many folios there are. + * + * Like folio_put(), but for an array of folios. This is more efficient + * than writing the loop yourself as it will optimise the locks which + * need to be taken if the folios are freed. + * + * Context: May be called in process or interrupt context, but not in NMI + * context. May be called while holding a spinlock. + */ +static inline void folios_put(struct folio **folios, unsigned int nr) +{ + release_pages(folios, nr); +} + +static inline void put_page(struct page *page) +{ + struct folio *folio = page_folio(page); + + /* + * For some devmap managed pages we need to catch refcount transition + * from 2 to 1: + */ + if (put_devmap_managed_page(&folio->page)) + return; + folio_put(folio); +} + +#endif /* _LINUX_MM_PAGE_USAGE_H */ From patchwork Thu Feb 15 14:55:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454366dyb; Thu, 15 Feb 2024 06:59:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWK4hy8PprWugWXrDf5ABHNaYhD0qXt+pTF5rhi/PEpZ3bpb3m3L/WpTxHnpurLxGDZzl+2p+Pk2lsSgJoyUUMgRD4vOw== X-Google-Smtp-Source: AGHT+IEugqmvVMK5CXjZq3iiTGB5BWbOZQFT9VHUAB72gQVLMvHfy9Qlti/93xOAFQiuLOthQq79 X-Received: by 2002:a17:906:abcd:b0:a3d:9435:5884 with SMTP id kq13-20020a170906abcd00b00a3d94355884mr1469250ejb.44.1708009151090; Thu, 15 Feb 2024 06:59:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009151; cv=pass; d=google.com; s=arc-20160816; b=sDY6k7us4AQ/s9AhZykC2UyLJZzEKw+2wQT1Q9/6gfycKhAUszAFExBkWWizRFJQQi dPV3VPv+lpQp3T4ijUwg0SUCMxUmXTLpyfLEJExTXIfY5Sam/qEfk6EXSgnBXGB2cunw yhj89oYyl9Y9g4bzyFEvREIWakZE2SV8Nkfy/InL/ht5EqgNuqyfjPdDI2feIrteZ8BI VpS3HmvT+UXOyxM3ioo8eRppnhbgoXEDbzq4OQrCIFM94Lvf+oOd4fbkhlF/dqfOcTro wF2UCV8bKAa9Ih9HzmJxQSBQyUE9f9naob5IOyXNS0+Eina2GRvRxa6ZIYssVOSQfLOy hKFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; fh=sFdnkpTarNmRKLwa/ffPnIaj3pfCnWmhJo/HjV6uynY=; b=TXWpvev8m6BjIxhkjj/PHYFPlk81GWTaFbmLc3inHA561zCanU0Xv/sSWeTEg7E/hp UqXqwyuQ8jkWqDbPSSm0nyxOOsDTqOKT2CjDiMbV0Vwyj1XRv1iaBw8MJeGLNTH6aWF6 ImZADRBrQnO9MWH0oQesRJ3PePqjVQTcCe6GuybtVMqM9hrhUx8PHCFuP7SEZCJO5E9a KApGXzPS1C4a+ElXM7Cf6jnMs6mYcyx+GFr2PySdZrOAnmd+hJcd8QoaYaWa2TduGX5V HGpTfWX1VE3op2sGde3iVBHUaZ1GZ62JGfjMMf0ps8ns6bbKExO8sX1Qiick8LdqB7Kn 2CHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=fU2MgR2i; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67121-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67121-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i22-20020a170906265600b00a3cf61924a1si712880ejc.542.2024.02.15.06.59.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:59:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67121-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=fU2MgR2i; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67121-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67121-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 86C7F1F21497 for ; Thu, 15 Feb 2024 14:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90646134CE2; Thu, 15 Feb 2024 14:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="fU2MgR2i" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D98F813341F for ; Thu, 15 Feb 2024 14:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008983; cv=none; b=ngySZxBp1nkeVXJpgFl40lgOpwKHHnRAk+FEWFBp3UzVpZIJKyC0b63ZFNzbKJlA9I6wzHmEVsgScIskZlHMFHBG6XwefeYhQleSNALg8+8xEPI9N7e5GY9tCUURa25iTz9bhaXdbD3Q5FldhW8sGnKbG3jB2DaddNEunt1UY0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008983; c=relaxed/simple; bh=v8Wtk59h+JThQSBSnkbFVz52gm8jfgU5BR/RyxD7PT0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YZ71V8A2OcApXLlAiX/5ZDAE/rZBJOVw0z4RqcySi8zm5/8uGUeB3S3g1lkFWVuxHFewztJW98/vwR8fCaJlhZJB/yhEGPzV1mLAYbNZAD/Zja3GwFH5tB6psIgxIrMjsMc67VBewTBAYLPyQCc8Q7+HAfjBegf9ju/tHPLkJok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=fU2MgR2i; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-563c0f13cabso660027a12.3 for ; Thu, 15 Feb 2024 06:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008980; x=1708613780; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; b=fU2MgR2iUTgCRKCJ5Le+EVU7pJ5UiJwyG7Fvt+S6CpKty3ReCru/Wva6FH+JCQWLng CDLeaiAL1tAiAauNRropZcrjY0+xxU9jozK9tZqQbpUfhffHvvNfgyDcenEtgE8am050 2So+XOcyQ7hkGDGkN5FDYI3xI9w1p27dmEbGYSCcJ7rrWqLy3btJNG6F9oAGBjYUYhn2 tP3SfZD8n+iTGJWLZhsx3NQatM+dZY9ts2/Oo4vfT5rkK++NxFhYTPXpMR7pQiQ1j7ek qZAnn6g3lWGnKhms7czZ05dOU5+AI3WeO6l9C0EXR0pHHL3TBA8ZzZAbp5lmMUDPxhtK LO/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008980; x=1708613780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; b=aEVChNYlBNnys1RuKWpcebSHYYOIIr1cvaJRW1cTj8ddt36S83bbYIROPGKi9lZGlG uJCYGLgOuH0Vd5hTGYIYIZRQDRHCYfQOBbuMRRuPn6fUFtFOmMn9W+0JONmuXRuPgcbf thL1R6HxrsQET08Kzva/i47LmC8lYRNLVUNvS17vXIumujLoyPz2mEHbKe2SgP9soHgR ZxUfZp68hpWqNVJrpl4M5+1dSU8bPhvpPfzmTYW9jj2apOt3gnuUiNtHnxPponNXILP5 +tpXJVGYzdSJ6e4anCYBuGUhQ1i6381FfLZbAO9R3u2TPTmAm1iL0Eqqz3bm2q13E1Ex bTcA== X-Forwarded-Encrypted: i=1; AJvYcCWsdaX9mrosU3uevWJr9HK89KxhN0NF6ZH1qoPKQhiIUJ2oFIRKAGcCPjGeMuRHb2iixJUCk50l/0KuL/0HHlqA+xiwciVpHuwqPYFX X-Gm-Message-State: AOJu0Yxmr798HpfCdKNfi3PS4K4KqPKpVvpKGtNBrvSWfDQIuj0XT1MY phQYS/AmCCu2ZJ7/8ibmQEjzCmxU9hdi93PAp4EeC84+AbtI9x4viPjAbljQ1N4= X-Received: by 2002:a17:906:34cd:b0:a3d:b317:8ac9 with SMTP id h13-20020a17090634cd00b00a3db3178ac9mr499801ejb.33.1708008980212; Thu, 15 Feb 2024 06:56:20 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:19 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 10/14] linux/mm.h: move page_zone_id() and more to mm/page_zone.h Date: Thu, 15 Feb 2024 15:55:58 +0100 Message-Id: <20240215145602.1371274-11-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977403501148376 X-GMAIL-MSGID: 1790977403501148376 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 30 +--------------------------- include/linux/mm/page_zone.h | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 include/linux/mm/page_zone.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 26d506ed855f..aa24e6fed9b6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -1358,35 +1359,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_t flags) } #endif -/* - * The identification function is mainly used by the buddy allocator for - * determining if two pages could be buddies. We are not really identifying - * the zone since we could be using the section number id if we do not have - * node id available in page flags. - * We only guarantee that it will return the same value for two combinable - * pages in a zone. - */ -static inline int page_zone_id(struct page *page) -{ - return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; -} - -#ifdef NODE_NOT_IN_PAGE_FLAGS -extern int page_to_nid(const struct page *page); -#else -static inline int page_to_nid(const struct page *page) -{ - struct page *p = (struct page *)page; - - return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK; -} -#endif - -static inline int folio_nid(const struct folio *folio) -{ - return page_to_nid(&folio->page); -} - #ifdef CONFIG_NUMA_BALANCING /* page access time bits needs to hold at least 4 seconds */ #define PAGE_ACCESS_TIME_MIN_BITS 12 diff --git a/include/linux/mm/page_zone.h b/include/linux/mm/page_zone.h new file mode 100644 index 000000000000..6bbd46743aeb --- /dev/null +++ b/include/linux/mm/page_zone.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_ZONE_H +#define _LINUX_MM_PAGE_ZONE_H + +#include // for struct page, struct folio +#include // for ZONEID_*, NODES_* +#include // for PF_POISONED_CHECK() + +/* + * The identification function is mainly used by the buddy allocator for + * determining if two pages could be buddies. We are not really identifying + * the zone since we could be using the section number id if we do not have + * node id available in page flags. + * We only guarantee that it will return the same value for two combinable + * pages in a zone. + */ +static inline int page_zone_id(struct page *page) +{ + return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; +} + +#ifdef NODE_NOT_IN_PAGE_FLAGS +extern int page_to_nid(const struct page *page); +#else +static inline int page_to_nid(const struct page *page) +{ + struct page *p = (struct page *)page; + + return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK; +} +#endif + +static inline int folio_nid(const struct folio *folio) +{ + return page_to_nid(&folio->page); +} + +#endif /* _LINUX_MM_PAGE_ZONE_H */ From patchwork Thu Feb 15 14:55:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454613dyb; Thu, 15 Feb 2024 06:59:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpT9fZUGZWpA4DWIux3btBzzqYfz/CCStDjFJWywwzMyuU7wAX8a6PKSBP93Dw4WzRT+IyORiuJNpq46v+nqVnRq8m8A== X-Google-Smtp-Source: AGHT+IEWdfhbkaiTCC0lSEAaex2slIgv7gbom7cp/sY0R3w0UOzVQ835bc+K1RWy+5DGAzMFDuGO X-Received: by 2002:a17:907:1c21:b0:a38:4dc0:22f9 with SMTP id nc33-20020a1709071c2100b00a384dc022f9mr5636965ejc.4.1708009178854; Thu, 15 Feb 2024 06:59:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009178; cv=pass; d=google.com; s=arc-20160816; b=f+nAc824+UH/LB9J8kn7uC27a75Wm/Eoez3V7Jxhu1Gk9AKOL7seUYMv4iNiR54geE 7G4CzYXOEvo1k5IHYzhavDxDKEkU9dunLq507kHpsc/rUakC1WTLsaaaF3WUiPf5Xeao BFXv/9pvvlNg8YupXebuKfg+e4bd3RsJK5StIwWxhDouQMoAglGr95X0b6ckfcaZ6B3C Vk0NjzXmI5ngg6wyuoUcsKii5cFTISFhvh2rSdWO0bqRhW+fDm/Tjm+ojInH13i4K3Q4 FBK3Gm7Pnaj2xizVGTElPgaTk7EzHT6sPWwrV/mpfDE77oJjQ5qFxX3yOHpwceRxUihQ yYhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ui87eR1N8KdYrsRAWgwlBy5zGHV5S5KAP6ANHsd3+6c=; fh=tQLeZLykEiUpoEIiqtVPTkNozwozr9lLIThkvYKTfeg=; b=cvZl+VmuOaQEueoWF7rj6dUrCZu80ICDzvAb7iF40/xXyyjGEmCxIZejTJEovcoJuO 6MPWsZqEAjiFfDeYFJ4FbEA8cLp0bLAdgKsZPKY7jNO5Hn8A2/1p+VN7Bv416+T4zMDf oE1XbppB1E7GRe0p+EIBULEkNEHJqpvPtLNmVZr1W8sSmRJIYbJ+fW+6qQhjrz0gqJXW qNpykfBh6de7Wq8iF/CAlabsC+q4zrwyPuhN5+xE1amdUSEY2tGq5uiJ6kgP5b3kI4td 0QUMJfxbm14GYlbR2kW2y8so70Vai5LlV3R7l3utfrPs49MU8d48hIwhfCaXfPcnll3o 3J3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WSDNOxLA; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67122-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67122-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v19-20020a170906565300b00a3d38952605si720077ejr.746.2024.02.15.06.59.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67122-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WSDNOxLA; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67122-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67122-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4972A1F219D3 for ; Thu, 15 Feb 2024 14:59:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69FEF1350D7; Thu, 15 Feb 2024 14:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="WSDNOxLA" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8718132C02 for ; Thu, 15 Feb 2024 14:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008986; cv=none; b=NmIds+IlJcYx6Viipk3Jiw2pv+/qyn/U69jY0oQCtfmJ9Fh//T05jb4T7e472WxI/D51C7+gYZ7HnKjsrx+30+J9mSa6MFyTIcXsIlRo65vbbgz91HlYgN1zLHVp+JOXo3k390WGSv1LjIb3GB3+er7sFCOrmbkjk0dTSNw7pfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008986; c=relaxed/simple; bh=pxtwIOSGybK0E8+t3Yis8zIqDX8fSripsw1A41Tnjfc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KxOvNvh40MXN+C+K3oP6SGqIFxx3DoGuf1R1oBnAltzWyXE4JHC9Z/Vut6TbiFksOrGNZshk8SiAbb+bDLrFDnROf/+zPQLNWzc3WAI5lFXOkw8QHiRqsfGinvoezPygBGsqWBdBI3oH1oERq7oOrI/f5Fc1UeIXp+SWxwLWAi0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=WSDNOxLA; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-563cf32e130so346378a12.0 for ; Thu, 15 Feb 2024 06:56:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008982; x=1708613782; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ui87eR1N8KdYrsRAWgwlBy5zGHV5S5KAP6ANHsd3+6c=; b=WSDNOxLACrxXb9cY+bzWtYovcQSkpndkcyQ8ekdgm6s/SIfTelLjM7F+mA/1Tyfc+7 UBu1KNYuj4wijkv6YWlOkh+r1eKjXlf6naUCOqL1eLqnKKsHyBCOB9oEkyS2XuHYWmDJ XMFia/h9VVJoGB2mGVuVXyqv7WZHrnB6NRjt5wKQ52xRZEdtDym8fcfY8p2BysuTNez/ eitHa0tlW5Oxw1AvwQZjz3CYsz2uH3qj6+2Ukg54CEqMbO6gZ8I68zg9XyyVaZ+NMirZ Yhyq6OMw6OWJgp6ooFzYzkwy+g6A5fljFL1LE0ImRSkigtfIKwS3PQlOL7WSbK8BCyra UoUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008982; x=1708613782; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ui87eR1N8KdYrsRAWgwlBy5zGHV5S5KAP6ANHsd3+6c=; b=YvB/qA/XrqGgZMJxnrHRcD6d4e1wsOVgIBUAalFVaLkExOB+OkOUuVoSamQl+Sz++D GAtnotQq70xvJ8ll9Mug+HoMmnEW2bZcjwXHJg1YhViNyTLgtf4Vdc+3bEj8IL88iAxX +w8dsYoaauPx0i0Iu2OEz5N72XSFkN1Gn3NoMPipos6l/TP1VJv2SYsRkjSbx6ichc60 7s1umSkyUfD739/bxh06xxt6s4I/YQlgDLp5ijD++rWfVrF4caAa3DStsE2wQCvRwdrD N1pKMCgKnzfUVj+OgCIpdv64GJ6u1O8JEmMzuu2UD3gmpkRqp6TE/Xe5d7tSe6kZRXor /JMQ== X-Forwarded-Encrypted: i=1; AJvYcCUk8BGr1KVlSABs9/rfgvQjFJV7n+hpkusu6awUOToEbxJe3COQxoVwofonhv0y1XhyGCVzGcg6xb24iEutsdRwA5MFZT5diGJTMN1F X-Gm-Message-State: AOJu0Yx0SAAcoxxkxyZbbCP/WgxPb/5PMdED1rVLaH09DprpEwIrIuZe GfYkVM8OzuK5cj17yVKxtA7fWTtO7bOHuxJoHupoxs1/drp5cpC17/0us3sXzTU= X-Received: by 2002:a17:907:b0a:b0:a3c:ce90:bf4 with SMTP id h10-20020a1709070b0a00b00a3cce900bf4mr4128460ejl.14.1708008981990; Thu, 15 Feb 2024 06:56:21 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:20 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 11/14] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h Date: Thu, 15 Feb 2024 15:55:59 +0100 Message-Id: <20240215145602.1371274-12-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977432865857199 X-GMAIL-MSGID: 1790977432865857199 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 45 +----------------------------- include/linux/mm/pfmemalloc.h | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 include/linux/mm/pfmemalloc.h diff --git a/include/linux/mm.h b/include/linux/mm.h index aa24e6fed9b6..c7e53cd0cdd0 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1744,50 +1745,6 @@ static inline pgoff_t page_index(struct page *page) return page->index; } -/* - * Return true only if the page has been allocated with - * ALLOC_NO_WATERMARKS and the low watermark was not - * met implying that the system is under some pressure. - */ -static inline bool page_is_pfmemalloc(const struct page *page) -{ - /* - * lru.next has bit 1 set if the page is allocated from the - * pfmemalloc reserves. Callers may simply overwrite it if - * they do not need to preserve that information. - */ - return (uintptr_t)page->lru.next & BIT(1); -} - -/* - * Return true only if the folio has been allocated with - * ALLOC_NO_WATERMARKS and the low watermark was not - * met implying that the system is under some pressure. - */ -static inline bool folio_is_pfmemalloc(const struct folio *folio) -{ - /* - * lru.next has bit 1 set if the page is allocated from the - * pfmemalloc reserves. Callers may simply overwrite it if - * they do not need to preserve that information. - */ - return (uintptr_t)folio->lru.next & BIT(1); -} - -/* - * Only to be called by the page allocator on a freshly allocated - * page. - */ -static inline void set_page_pfmemalloc(struct page *page) -{ - page->lru.next = (void *)BIT(1); -} - -static inline void clear_page_pfmemalloc(struct page *page) -{ - page->lru.next = NULL; -} - /* * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. */ diff --git a/include/linux/mm/pfmemalloc.h b/include/linux/mm/pfmemalloc.h new file mode 100644 index 000000000000..345b215a3566 --- /dev/null +++ b/include/linux/mm/pfmemalloc.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PFMEMALLOC_H +#define _LINUX_MM_PFMEMALLOC_H + +#include // for BIT() +#include // for struct page + +/* + * Return true only if the page has been allocated with + * ALLOC_NO_WATERMARKS and the low watermark was not + * met implying that the system is under some pressure. + */ +static inline bool page_is_pfmemalloc(const struct page *page) +{ + /* + * lru.next has bit 1 set if the page is allocated from the + * pfmemalloc reserves. Callers may simply overwrite it if + * they do not need to preserve that information. + */ + return (uintptr_t)page->lru.next & BIT(1); +} + +/* + * Return true only if the folio has been allocated with + * ALLOC_NO_WATERMARKS and the low watermark was not + * met implying that the system is under some pressure. + */ +static inline bool folio_is_pfmemalloc(const struct folio *folio) +{ + /* + * lru.next has bit 1 set if the page is allocated from the + * pfmemalloc reserves. Callers may simply overwrite it if + * they do not need to preserve that information. + */ + return (uintptr_t)folio->lru.next & BIT(1); +} + +/* + * Only to be called by the page allocator on a freshly allocated + * page. + */ +static inline void set_page_pfmemalloc(struct page *page) +{ + page->lru.next = (void *)BIT(1); +} + +static inline void clear_page_pfmemalloc(struct page *page) +{ + page->lru.next = NULL; +} + +#endif /* _LINUX_MM_PFMEMALLOC_H */ From patchwork Thu Feb 15 14:56:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201522 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp456452dyb; Thu, 15 Feb 2024 07:01:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLcMQVPtRjB899OzD6sqnR+80UYGA59qOutvYHczFzO1APihmVZc1gkZsFo+SIzDushSUDKAE3D/SpO6ckB+a63gPo9g== X-Google-Smtp-Source: AGHT+IF70GhRSqbfiVKwAxWknofpoth+JJuHDQFMg4IZEVfwuCtu6y8O8628bEYcswHduzb6Ahmt X-Received: by 2002:a05:6a21:1519:b0:1a0:828a:50d8 with SMTP id nq25-20020a056a21151900b001a0828a50d8mr575109pzb.22.1708009309068; Thu, 15 Feb 2024 07:01:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009309; cv=pass; d=google.com; s=arc-20160816; b=Yo3d1q/Tp7vx74K1ddJC80IfngnDr4wZhM/fG1rOPkHItwIouvdf4k1VFV2MUY01PI ZHaCgPczF5QuqfdZAknCOXJSKDujCY2ZjPH228PbRi0ZQSgCcoq2EwcVCL7W9alRfyLu o2lc2zEQY6BJMM6WhrWihxAFvJei4GuI5qLMNAKCTvGiJDM74vAD+LfW7yKDwy4ikt9C 9tbV2yHoV+bbaVvCe9Kbe6Puv/VeCkJ0/Ah2qf/XprB06MSKHWOUE1KNIPAZUizB8uGf bbT+qHL8aiyVMhSz6FTshHVz/SLLFP8D10o5UW34bBenbBTwO4BWKtkaV2fO1d1mDbXc YYoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hDi3zk+Z/SLj4QVGPle17xDH/MSBW8emaxfc34uAZG8=; fh=S5cvOgQaQ4GwWcOAJsYk0YpoRIWoJXal2AFEd1Nqfc8=; b=apiput//GZDe7UpOJ/KbtOIpYck2rEUh9V7X8dKELVyVweusb2MFMcNXVMBBpPvhGe 4VapipTDIru8yf2k7roDKyz/3LTEz8ZeNXm0fPrNcSD3qM7a8H4TaYHwHI/RYYrtSPZt KDXve+2l3OHOwWmg66GprBZJg3IU3cXZfPck26tqMQuCAC0HgxgXUf9MpnMylw+MK++X 9fJN5GEwGEmj/JNoa1dqzddhQk7xD1btd0g3QyMf9SdnHAYoGLrjyDawTjsI2Q5BOb0V lyJRF8Man/8ZR3uzPqtU1pAFQS8w6rry5yKKCyMdmCgb0yABmX3lJCoWf+Ynyznp2Lgy eQug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="Rm/Nobin"; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67123-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67123-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p21-20020a637f55000000b005dc76f56a18si1195452pgn.559.2024.02.15.07.01.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:01:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67123-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="Rm/Nobin"; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67123-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67123-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D675A28551A for ; Thu, 15 Feb 2024 14:59:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBD801350E4; Thu, 15 Feb 2024 14:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="Rm/Nobin" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87E181339BE for ; Thu, 15 Feb 2024 14:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008986; cv=none; b=H1oQKQpPNkqbpri3vTUPts6TqLD6/BOHUZbDdnuDkA++n6Qme/pTNyF7yUWiREJohQBeuZo7BDjhs8LtNAwMhtvTUbmzfosfP9TLOuY6shG8R9hLf+2pXfqB7YFFUdWgWkwaGPmIITZ6frVeJ8t27srXyq3iaKOgC+MFfe11/6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008986; c=relaxed/simple; bh=v9cPlxD645ETqqwrU2mneRRT1GLcfGc/VwKe6UrwJKg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ltvev8WHJz1MwmRVH0vqpvz0DTIqxD/mN777MzKuYKBIaT3Z7s5MXjWxh3TJUIxc1XB29ZrobMvEDjZWQ5ekcYJgjq0KBUIWxfwneA5PU5c+xCOFXEzXZzC+v0DLZT0wbNpF4F5nQ3U6Hs1e+GXBHRyf+f1gFxJ+e0/vvsP20Kc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=Rm/Nobin; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a3832ef7726so123247466b.0 for ; Thu, 15 Feb 2024 06:56:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008982; x=1708613782; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hDi3zk+Z/SLj4QVGPle17xDH/MSBW8emaxfc34uAZG8=; b=Rm/Nobinc4rClo55Tp8XMgLCiLCZADV/QiPhWLiFYDZY5w3zhWuEPklPLGsZ73CbMS /36YfFuh0oq1dFg7k+bsAOe4wQtAVXfjYoZaGCCJhOCfE0SA2ejw4PcIuaxubql9MIDt qGP/U6I6qhtl0UQM8Hha2hpzX/WmwjSrxbvDW0Y8H0LMtwjbbyr/367PQ6k4HftV4Yp/ GxUUTgwMdYjyM9xjuCjYg2bH9V3QIH2x7dNe6T5JhAr8KBvWPg31Vb9rNofdzA3gZaMu O3axoPCGxj14F3S8z3RxfKDyVhq7tRinfCTsr5Ee1X+dxzdoj1KLAMl+ck5F+oyoxcmr Wrow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008982; x=1708613782; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hDi3zk+Z/SLj4QVGPle17xDH/MSBW8emaxfc34uAZG8=; b=BqktQWosVnA1tBAWhzHP9mU5WFOeGg9RR4T+Lypfunfa5TBvxetroAL3yFmPZbrujS IWAPhw/12gYaDRSH8t1bPLB6d01CR1APdlMZID7rc0t+IP3J/U1FcuK+YyCUdhU/YEdZ CKWUTt+PtBP4TfbSbwJqS3GcBD8dvXf3bxNEpFtItQfOzC3Mc592sNKa8lGKQ51kkbTu 5pNIGT5V3AvszQb8JWGfHfX4QyBzJUGbOTIzeY83TvPFxsS+HKzp+bCZzBNT2rm+1pub BXzJKoF1MPp3dEza4x74mRk0QejRw6qvWhDTmTqAiVngb8VbDh91wl4jSF7m9Ndjjet9 Jl7Q== X-Forwarded-Encrypted: i=1; AJvYcCViZxQZuYjXyBLazkXZc+onHB8nxG1zRMwaZ+V4qnJglokyuyVVbJDJDq6fsQgI6blacPsMlPZ2Jq8yNJL/Rb0XQxLfStGwRoXKzI15 X-Gm-Message-State: AOJu0YwB3cG+1Vk7bJRLpa1ujgywPjLPm3Ez67N9IX1N6IyGz6JiKo0r l/O7Sa8urVp7RBVp/XzuLbvUnOtwHpPweQaRCZ/SM2gB71686swwkNOGdddG/SI= X-Received: by 2002:a17:906:5fc5:b0:a38:7171:e832 with SMTP id k5-20020a1709065fc500b00a387171e832mr1267787ejv.32.1708008982697; Thu, 15 Feb 2024 06:56:22 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:22 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 12/14] linux/mm.h: move is_vmalloc_addr() to mm/vmalloc_addr.h Date: Thu, 15 Feb 2024 15:56:00 +0100 Message-Id: <20240215145602.1371274-13-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977569204342143 X-GMAIL-MSGID: 1790977569204342143 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 25 +------------------------ include/linux/mm/vmalloc_addr.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 include/linux/mm/vmalloc_addr.h diff --git a/include/linux/mm.h b/include/linux/mm.h index c7e53cd0cdd0..d4624940923f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1067,30 +1068,6 @@ enum { int region_intersects(resource_size_t offset, size_t size, unsigned long flags, unsigned long desc); -/* Support for virtually mapped pages */ -struct page *vmalloc_to_page(const void *addr); -unsigned long vmalloc_to_pfn(const void *addr); - -/* - * Determine if an address is within the vmalloc range - * - * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there - * is no special casing required. - */ -#ifdef CONFIG_MMU -extern bool is_vmalloc_addr(const void *x); -extern int is_vmalloc_or_module_addr(const void *x); -#else -static inline bool is_vmalloc_addr(const void *x) -{ - return false; -} -static inline int is_vmalloc_or_module_addr(const void *x) -{ - return 0; -} -#endif - /* * How many times the entire folio is mapped as a single unit (eg by a * PMD or PUD entry). This is probably not what you want, except for diff --git a/include/linux/mm/vmalloc_addr.h b/include/linux/mm/vmalloc_addr.h new file mode 100644 index 000000000000..86ad2dc94960 --- /dev/null +++ b/include/linux/mm/vmalloc_addr.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_VMALLOC_ADDR_H +#define _LINUX_MM_VMALLOC_ADDR_H + +#include // for bool + +struct page; + +/* Support for virtually mapped pages */ +struct page *vmalloc_to_page(const void *addr); +unsigned long vmalloc_to_pfn(const void *addr); + +/* + * Determine if an address is within the vmalloc range + * + * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there + * is no special casing required. + */ +#ifdef CONFIG_MMU +extern bool is_vmalloc_addr(const void *x); +extern int is_vmalloc_or_module_addr(const void *x); +#else +static inline bool is_vmalloc_addr(const void *x) +{ + return false; +} +static inline int is_vmalloc_or_module_addr(const void *x) +{ + return 0; +} +#endif + +#endif /* _LINUX_MM_VMALLOC_ADDR_H */ From patchwork Thu Feb 15 14:56:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp455000dyb; Thu, 15 Feb 2024 07:00:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTidxPannX0ijuQWxLe9a9GjQeNHZKx7nYjAmotVaUWiaIjEN9G06gJZeELfvm6YlBZKXfApBovN1St/iaftvA9/ssTQ== X-Google-Smtp-Source: AGHT+IGz9Jy5uQqPLVrThG6cy/1+C9/XjwwT7HJGaqyTpWETKBNZZku+Vqy3FZhQmXsKiiitfA+1 X-Received: by 2002:a05:6512:138c:b0:511:5411:1144 with SMTP id fc12-20020a056512138c00b0051154111144mr1943998lfb.14.1708009212552; Thu, 15 Feb 2024 07:00:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009212; cv=pass; d=google.com; s=arc-20160816; b=JE/5VFGuwCImitbxcLe19ZDDaaNC1jxf8GHXEm+1C2z6XAnkZOZVuIXgF9BUTV+ck4 vCSLogcLuLkSHhwMCVu0r7SiHx0lRgG/zhibkB6OQAIVHf6V82LNbX6DinEhvMtW7Lv7 CNYnOvn96wRV7ypfIuT0XbbzM4Ry1IbvQ0Y3niENHXjKMOfOb+LJG1axFdwBcnuX27yC NNzMtry9e5FQ+db0cveHchy7u8dGm0KxzXEBypeNoYD+bMIIYJRnSLmXoF7JPBqOGtuJ GxTPVYKu0C5IaWiLMAJOnd3DRzvrSePnG6onlwU8HrXApr6mxEGV+e1RopIraAauZVme ZMkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UMOhGrGj8ZKb8QpbixTkN6L6ZFBU6wOv0Z5Y6TlRvLQ=; fh=sD35p224mE51LPy6t7x+1HVX2Ywd14J6BRhJfcxttmk=; b=p0vXhk0ielX+k3mozrx1h+D1+t8nFMhsPsr8VCUtM19ST+WhPonnS4OiNZ4HbH8m9D 1043JI4+F1G4W8I/LLAx3exZHrnM5Cm9jHTgRQa8n1x0sGWycoqnkAcsy3GCrTv2DGUj wOqoLfDU0CMuEQsXdbJASlY/ORkQ4ZqchVErhYdMbIY8n07DfNavWAyVd10VL95qzy+o Gj/5uHms4jyu/Kx8cSnUDbkhPvV8zq05TMIt4iyhIrEc06rOBDZUWQOEEBn11n+60qPT oMs1wKtjdmc8NTetw6MJAsiIcjJyaK1Cl2kclwtqPP5KKDrTk+sp0OOrvGu40K6HckAC DCCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KLj+s59V; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67124-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67124-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lj11-20020a170906f9cb00b00a3db5f70c8csi144433ejb.510.2024.02.15.07.00.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:00:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67124-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KLj+s59V; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67124-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67124-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F37661F212C4 for ; Thu, 15 Feb 2024 15:00:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D10931353EC; Thu, 15 Feb 2024 14:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="KLj+s59V" Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6491713473F for ; Thu, 15 Feb 2024 14:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008987; cv=none; b=LwG1j05Ntk/p4WsB0wOrtpN7qpSJTATfwceRdyq6Wyu+gSTd+9Hmcq+KmP1ascFSN0GNIUW1nTf743CwDVyU2wirLnXQMs01WgPPydq+lKM+xzEPULLqf1mGNWPf7AXCzeERZ8mgDUGoei7jvmAskq0emSR5xqphTHp2z7ikhsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008987; c=relaxed/simple; bh=qL4DR4wz2fFAx8PAq9Sk1DQylS4SyIzfyxgi/LjNHjo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NVYZR8Gx/g/NCGomGg9Jgg2MT8yUmm6DMPsstnunPZ45GYrhn3alq8CiUByWDurxE7ge7sKXnMR/Y/iDbnCw2ok+XlDBLXTh74u0RbRqMZPyS+K7GAF1NucsYepvwX5mjZFXWjzWey/odpmteBS17w1MO4zxNZWDRyEqeRGaVZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=KLj+s59V; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d208d0b282so9304281fa.0 for ; Thu, 15 Feb 2024 06:56:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008983; x=1708613783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UMOhGrGj8ZKb8QpbixTkN6L6ZFBU6wOv0Z5Y6TlRvLQ=; b=KLj+s59VYTi3pWx2M4pfO9dpOROkz6jIls83+fNZsVrE1WteEQNv7EX3lKI4587paD ug5t5wQzyZurrUpQ05CORjLEeG4iSWZrj5Qy2fcRHzdDMeRm7gLFeyYYW6jceaTQzcra hFrjVVqjB/IXvXyycHzg7IMKpik1W8/MZaX/DBftiodzHn+33Z0qlVob8JHt7XblKc41 nnbrObIJOpkzGZGwrsvxWXBkiJgadsnEBqW7G5nY1IrKS5XiITEGL6Ll/7yMv8KWxEvh BEWi4h8EnKTAdJcLf6qppE6dZ4qYAcij6xOSq7ZQhTxzgzpYayk4Byz+8+xEj7HHQIQD HTvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008983; x=1708613783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UMOhGrGj8ZKb8QpbixTkN6L6ZFBU6wOv0Z5Y6TlRvLQ=; b=GiV8hqu5mWwv7o3hIaPDkbTLo+n6XH8M6xl50HhtsJMRqwhQQzzqX84Shg0kivQPKI yxwRrK0qVL8gTa0LtGOW0zSVCM90v0i1zTmoc+nL7edhmQ1qO9kn6U80Bio9yNLGUN/0 GiyFKiRpsvfCQCgsf76BQRte2oBnfXvY6SJnwV0TqQjneuP+gzvrZjKuLFtXTLqkOZF/ N6XVFy053HCKh2lkvAz+G7MxhZC/NM7rJzNbseqTDWcraNsg5krqP4Ow7WVqdWc4ASjj u9Y7nO16PI3Fygc+9MvNKuawqBZlNAKJ3fvZpt8JFKxIp7g6Bu85HDIJcQRBlF5hc6Dy ZFaA== X-Forwarded-Encrypted: i=1; AJvYcCV6oB9M4t/7Akcfmo34ROU+ly5klWXMf1zxksgYHrpx7ALTEuTugeZ41EH6jgM7ZwGQHAbce003wSlp+7olFOxb51OtxXbARyAWbkRj X-Gm-Message-State: AOJu0YxKuYq89qRAgC9/W8eUHfEYfZ8cdVinMeWNmf+mstt/GS8dYIHQ eZOK1HUIzGP9/qAQhRxJ0QwXq73zxINtuk0zmSM1gMJ3qvaMleMpUaHM9RE1ymy5KJ2iTQeZyzl N X-Received: by 2002:a19:5e12:0:b0:511:7746:5687 with SMTP id s18-20020a195e12000000b0051177465687mr1519101lfb.24.1708008983414; Thu, 15 Feb 2024 06:56:23 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:23 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 13/14] linux/mm.h: move high_memory to mm/high_memory.h Date: Thu, 15 Feb 2024 15:56:01 +0100 Message-Id: <20240215145602.1371274-14-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977468316739722 X-GMAIL-MSGID: 1790977468316739722 This variable is used by lots of arch/*/include/asm/ headers, but these do not (and should not) include the huge linux/mm.h header. Let's move this "extern" variable to a separate header and include this one in arch/. Signed-off-by: Max Kellermann --- arch/arm/include/asm/memory.h | 4 ++++ arch/arm/include/asm/pgtable.h | 2 ++ arch/csky/include/asm/page.h | 1 + arch/hexagon/include/asm/mem-layout.h | 4 ++++ arch/m68k/include/asm/page_mm.h | 1 + arch/m68k/include/asm/pgtable_mm.h | 1 + arch/parisc/include/asm/floppy.h | 1 + arch/powerpc/include/asm/book3s/32/pgtable.h | 4 ++++ arch/powerpc/include/asm/nohash/32/pgtable.h | 1 + arch/powerpc/include/asm/page.h | 1 + arch/x86/include/asm/floppy.h | 1 + arch/x86/include/asm/pgtable_32_areas.h | 4 ++++ include/linux/mm.h | 2 +- include/linux/mm/high_memory.h | 7 +++++++ 14 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 include/linux/mm/high_memory.h diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index ef2aa79ece5a..a67afb213e2e 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -387,6 +387,10 @@ static inline unsigned long __virt_to_idmap(unsigned long x) */ #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET +#ifndef __ASSEMBLY__ +#include +#endif + #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) #define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \ && pfn_valid(virt_to_pfn(kaddr))) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index be91e376df79..eb80f6a65619 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -11,6 +11,8 @@ #include #ifndef __ASSEMBLY__ +#include + /* * ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h index 4a0502e324a6..016f722fbe43 100644 --- a/arch/csky/include/asm/page.h +++ b/arch/csky/include/asm/page.h @@ -32,6 +32,7 @@ #ifndef __ASSEMBLY__ +#include #include #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && \ diff --git a/arch/hexagon/include/asm/mem-layout.h b/arch/hexagon/include/asm/mem-layout.h index e2f99413fe56..a09116c50043 100644 --- a/arch/hexagon/include/asm/mem-layout.h +++ b/arch/hexagon/include/asm/mem-layout.h @@ -10,6 +10,10 @@ #include +#ifndef __ASSEMBLY__ +#include +#endif + /* * Have to do this for ginormous numbers, else they get printed as * negative numbers, which the linker no likey when you try to diff --git a/arch/m68k/include/asm/page_mm.h b/arch/m68k/include/asm/page_mm.h index e0ae4d5fc985..f958655d1931 100644 --- a/arch/m68k/include/asm/page_mm.h +++ b/arch/m68k/include/asm/page_mm.h @@ -5,6 +5,7 @@ #ifndef __ASSEMBLY__ #include +#include #include /* diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h index dbdf1c2b2f66..ec593656bdc5 100644 --- a/arch/m68k/include/asm/pgtable_mm.h +++ b/arch/m68k/include/asm/pgtable_mm.h @@ -13,6 +13,7 @@ #ifndef __ASSEMBLY__ #include +#include #include #include diff --git a/arch/parisc/include/asm/floppy.h b/arch/parisc/include/asm/floppy.h index b318a7df52f6..98ed37c5dc59 100644 --- a/arch/parisc/include/asm/floppy.h +++ b/arch/parisc/include/asm/floppy.h @@ -8,6 +8,7 @@ #ifndef __ASM_PARISC_FLOPPY_H #define __ASM_PARISC_FLOPPY_H +#include #include diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h index 52971ee30717..03e0a32e1c2c 100644 --- a/arch/powerpc/include/asm/book3s/32/pgtable.h +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -4,6 +4,10 @@ #include +#ifndef __ASSEMBLY__ +#include +#endif + /* * The "classic" 32-bit implementation of the PowerPC MMU uses a hash * table containing PTEs, together with a set of 16 segment registers, diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h index 9164a9e41b02..8a9f5b546e4a 100644 --- a/arch/powerpc/include/asm/nohash/32/pgtable.h +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -5,6 +5,7 @@ #include #ifndef __ASSEMBLY__ +#include #include #include #include /* For sub-arch specific PPC_PIN_SIZE */ diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index e5fcc79b5bfb..c541e71d3d5c 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -7,6 +7,7 @@ */ #ifndef __ASSEMBLY__ +#include #include #include #include diff --git a/arch/x86/include/asm/floppy.h b/arch/x86/include/asm/floppy.h index 6ec3fc969ad5..7756e984f146 100644 --- a/arch/x86/include/asm/floppy.h +++ b/arch/x86/include/asm/floppy.h @@ -10,6 +10,7 @@ #ifndef _ASM_X86_FLOPPY_H #define _ASM_X86_FLOPPY_H +#include #include /* diff --git a/arch/x86/include/asm/pgtable_32_areas.h b/arch/x86/include/asm/pgtable_32_areas.h index b6355416a15a..b339137b4f4e 100644 --- a/arch/x86/include/asm/pgtable_32_areas.h +++ b/arch/x86/include/asm/pgtable_32_areas.h @@ -3,6 +3,10 @@ #include +#ifndef __ASSEMBLY__ +#include +#endif + /* * Just any arbitrary offset to the start of the vmalloc VM area: the * current 8MB value just means that there will be a 8MB "hole" after the diff --git a/include/linux/mm.h b/include/linux/mm.h index d4624940923f..75ab0144656c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3,6 +3,7 @@ #define _LINUX_MM_H #include +#include #include #include #include @@ -81,7 +82,6 @@ static inline void totalram_pages_add(long count) atomic_long_add(count, &_totalram_pages); } -extern void * high_memory; extern int page_cluster; extern const int page_cluster_max; diff --git a/include/linux/mm/high_memory.h b/include/linux/mm/high_memory.h new file mode 100644 index 000000000000..e504aafd0d48 --- /dev/null +++ b/include/linux/mm/high_memory.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_HIGH_MEMORY_H +#define _LINUX_MM_HIGH_MEMORY_H + +extern void * high_memory; + +#endif /* _LINUX_MM_HIGH_MEMORY_H */ From patchwork Thu Feb 15 14:56:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454979dyb; Thu, 15 Feb 2024 07:00:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVh35w8ZPrs6HJnqVXxRBAh2BiK46ibKSa91OJ59tS40sr8gyfmyrnz22knDbjmusVdUyqP5Dg66XGGdn+5mRRsp9J6aA== X-Google-Smtp-Source: AGHT+IGLWoOnZ+meVDlxCt2A5kQtEyjdByJBRrBrkMixSRH3NIOuIVw3aUjZ6yWyBf4Vnd1zNjCy X-Received: by 2002:aa7:c645:0:b0:563:8b25:1658 with SMTP id z5-20020aa7c645000000b005638b251658mr1750880edr.19.1708009210894; Thu, 15 Feb 2024 07:00:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009210; cv=pass; d=google.com; s=arc-20160816; b=GYwPbmaAidvQ746S1bVTYvbRZwTnymSxf9QTWw1k7kt0hVTduPn7nXSCDE9yos6wIh 7xPMwyCcpsur5gCbqnX7/XbcaDs5rFzI+LyhNFAyeCEZFDT/ld3KjBrj9AT8ilQpK3E2 oQJZ9tpmj1JUX0OLAG+F1saIUU8CMRGY/zzm60duRpF7sRB1V0ZIEwZqrxwXDQCpzmPQ 54lseyVLYXDpAdj4OSfKfrZZpqRCH6EU8NwQoQTSKhjVWTqS+HtK+e9vy7qpRRwUcI2j m+SaVPJxi0QB920YHxKOPCChJ7SB/4lsp0QxEVUwn75Pz2ngYuTbWssBUIEsQ69CxRDE Fz9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=k5bNFuP+26n2WAnHi+toNNvLtJ00uY1JoGlCS6SUUmE=; fh=4JIr2CRSGoFo7UcN+zSYPAERMMyhb401V/t63VsrK1U=; b=wntzQOkdnfr0mzZmFHc/cwgQRMIO3zEa6v7aQm3mbNNmIMP5aBIDzRfeN2ElXr6JJF x5Rhvr7HfZupszAj79mEa7HXzFh73mwaVb/GqL6fvrkZOytZ8Kds5AAxfV37nGbHHXOg y1MOZKq0RhAWeZozKfnL0ImhMOf/URgD3U+GiM2wnvOsf89SXO4Vsojd6rhk4gRKJPzm 39oGHaQR17gggf9of56DyaL8Gu//GSaEbHkG8D+ZKn0odbXp9LChO/L1fvbc60flOCXb T9/hu1jyT6MBKfJbc+CmwUB/l/cjs8qa2LSQNHNXy5hn9LUvqiSPZ9UL6iVtUiSH0/UU 1CkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=ZUNiT+mB; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67125-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67125-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i6-20020aa7c706000000b00560d6e97583si695485edq.226.2024.02.15.07.00.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:00:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67125-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=ZUNiT+mB; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67125-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67125-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4EEFB1F2174B for ; Thu, 15 Feb 2024 15:00:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B10301353E9; Thu, 15 Feb 2024 14:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="ZUNiT+mB" Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37EAE13398A for ; Thu, 15 Feb 2024 14:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008988; cv=none; b=tr/mTwvY1gokxhcDEPO/htm0JSGmI3HfIXchc2dKBrbwPBqk7ARV92+L/pu2ZGfG1GPM7u8NfzyUL8EtoJIGHVpO+abxPLUwBsaRnWy/AtEQ8GKzejdQ8SPpfVKzYLqyzOoMMDlrrt4B6PIwORGASFRdK/ULSjoQDLfKUM5px9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008988; c=relaxed/simple; bh=99abj94cdBtHWVGTVg4oNZ+VC7s2b8Dvb4V+r0FrVoY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gC4AGqwYMtqzUxUoBJ1SWCGjhiVsEIXaEePfCwkT7oK7XWGHob0Sr6slHnqhhaNi5MW69ML/4FUp2aoaKbtVoQy+TvOJU+5wIXaJM6NjtzyWc1LTo4ZNryww1F+SzjmIvniysDGYUP+Kd18aBtDhBE5momts3orJAQ+LClOC6GQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=ZUNiT+mB; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5116ec49081so1125243e87.2 for ; Thu, 15 Feb 2024 06:56:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008984; x=1708613784; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k5bNFuP+26n2WAnHi+toNNvLtJ00uY1JoGlCS6SUUmE=; b=ZUNiT+mBSOWniI42pndDtvF09ox6f75QaOJD40J8jpHr4ipe8HrfmKrGrsymVKZjF1 nN0IdTbrAlksw74gDKDlznGuK7M5N0WPZuksSj3qkD24FLY9R4nWg7d7w4GCPFdTdaKQ XmI916qGi+TSRF8yebdVBcPfIhoSHsxBEVvoR5hA8VIacFxIGUsLr/XO5SAHwfSPjMjo 8chq/cLNd1IQ6pzassYtl6NKf7CMGcDpnu0Hu5F+H31Gv3UcxM/Sg3anWou0F7qU4kaw 5EfnwC0eovGJBjVuxjlMVDXlvp2f5l4LMfMk98u/JIcdmj/hHMFJRTunl0jsvTBG8Odn igQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008984; x=1708613784; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k5bNFuP+26n2WAnHi+toNNvLtJ00uY1JoGlCS6SUUmE=; b=eSfpWAaK8JJxsFaTKlkrrMwb6yjwq1qQI7KxtIzrwxvBOiLsxMzdV+Apb1aJ/Smkts KrGelEdMAelgUwuCPDQCzByI4wd6dGKFNqnngvjxb5D6JTBtVraqiwWB8lpcLGxkRO42 g7c3xN/9TaOfCvGvrVG2MX5VnmoEjW+1i8qxHtRJsmN3iaV5VXpjlv9QM7jRYrFJxDe5 UNvyDvwS+ds5p9KT45S59EYqpUIZaqtAQcKBD0o3ZHEc8sCpkUQWogBOr7lnosk37Oce k6hzjzFkGd6yFwRslgZxzY3TNmdgL0gvxQtLbSFURH52ZuoBrGjP0z3g4Fw/OS4GKRs4 BTGQ== X-Forwarded-Encrypted: i=1; AJvYcCXvFWjE6vnFTqyl4dzkoF1GXko5DDIIZH5gNjE7nIF75q2uZAxIQYXWE3luR9jIpXDsGWYfMX1sqsTDuaYdmNI0PRWoUhUvNhehuq7c X-Gm-Message-State: AOJu0YyYWtqaud2095wB0ccdpxrU6Z7KsliHrq6BWmwaATr5W/T20yQm kC+aGnhKn7vwYqLICd+mS1dxwdXTcnhBQLgQ2LbzB+LrSCsF/b90UL93WLfOxCpJJ5t8wj7+CdV P X-Received: by 2002:ac2:58f3:0:b0:511:986e:671e with SMTP id v19-20020ac258f3000000b00511986e671emr1726945lfo.10.1708008984131; Thu, 15 Feb 2024 06:56:24 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:23 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 14/14] include: reduce dependencies on linux/mm.h Date: Thu, 15 Feb 2024 15:56:02 +0100 Message-Id: <20240215145602.1371274-15-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790977466425994953 X-GMAIL-MSGID: 1790977466425994953 Replace with the smaller pieces that were just splitted out. This affects a few headers that are included by many, e.g. bio.h and highmem.h, which now no longer depend on the fat header. For this, several missing includes need to be added because they are no longer indirectly included, e.g. . Signed-off-by: Max Kellermann --- include/linux/bio.h | 2 ++ include/linux/dma-mapping.h | 1 + include/linux/highmem-internal.h | 2 ++ include/linux/highmem.h | 4 +++- include/linux/scatterlist.h | 2 +- include/linux/skbuff.h | 4 ++++ 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 875d792bffff..e2f24d7235d3 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -5,7 +5,9 @@ #ifndef __LINUX_BIO_H #define __LINUX_BIO_H +#include // for struct kiocb, IOCB_NOWAIT #include +#include /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */ #include #include diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 4a658de44ee9..37d5591039c7 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -11,6 +11,7 @@ #include #include #include +#include /** * List of possible attributes associated with a DMA mapping. The semantics diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h index a3028e400a9c..a479e6b7c54c 100644 --- a/include/linux/highmem-internal.h +++ b/include/linux/highmem-internal.h @@ -2,6 +2,8 @@ #ifndef _LINUX_HIGHMEM_INTERNAL_H #define _LINUX_HIGHMEM_INTERNAL_H +#include + /* * Outside of CONFIG_HIGHMEM to support X86 32bit iomap_atomic() cruft. */ diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 00341b56d291..b9dd5dd915c3 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -7,7 +7,9 @@ #include #include #include -#include +#include +#include +#include // for folio_put() #include #include diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 77df3d7b18a6..d55cfcde1b09 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include struct scatterlist { diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 696e7680656f..5bd89f0f7e7e 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -16,6 +16,10 @@ #include #include #include +#include // for alloc_pages_node() +#include // for get_page(), put_page() +#include // for page_to_nid() +#include // for page_is_pfmemalloc() #include #include #include