From nobody Thu Dec 18 07:20:54 2025 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 B14E31428F5 for ; Tue, 4 Jun 2024 09:09:08 +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=1717492151; cv=none; b=AlJ24HZr0mkvd+bekZLtsuOh6Ki8uGB/i8dXhbatCIKfZD6puQr/XSu/PVWi/gFPKmz5ZLRI6Q2/HS2PBnNB/REeKMOnPYg0C36PTlS0FPzNaPMjzmS1SagkK2u8cEz1Rs3BzAcI5PjjDf8fovjsnkeEF+7DZiLEd1Lr/ANcQQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492151; c=relaxed/simple; bh=PIMgUHILZaBD4zfg7wh7KkdwJbP30hYsk8LsiTVX2d0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NDJTvXJvcsdH0kUEQ9ZIOyw+ymsWNkXNypsmwIA1sHoADaljyK4EmE1TWbIZT7ECSq+6rc95HyW25J7+Q5eSnAAjjnMg065GKk+MIzmqGbdbbKkj5od23mBbOs9r2NpoyVy5+RiNEDewXTYHPjJ+T9EQX6Kk8S5W52DAPZB8d0s= 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=ZL1iY0nv; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="ZL1iY0nv" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a63359aaaa6so681762266b.2 for ; Tue, 04 Jun 2024 02:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492147; x=1718096947; 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=F9nIWEpeq+x9zjwKZn660Hrmucb48woIRSOtfjCvxw0=; b=ZL1iY0nvd5/Xnilv+jiiagJ2DGeTGLFnvlWZUr8ko699UFgZiWcriIvA4fyhFVzq+/ WRqkAucXEGUUvu+3rELHzzCuaaKMMOKNTw3XKC7wDWe6rk+cdM2UrzCY9drW2i07bvN6 cPtpbPoQW/UHxPInAbUGWLGyjvNNrasO3ah01XUjTKXi3jMNfTVkobYzRhxPKSr/jKtG HfCdSFxinQ8JXJED/xYlAAvKtt7TdgVmUovLedpfg1NvBNOqkaCEP4n3BPFeQiYTmUcI WhEbzNjFRNa/m39JOuIiudIdEjU6IcvF1iVNVHroX1h40WDUxj38fIwIvlrhcaXcwS3R 2Ejw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492147; x=1718096947; 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=F9nIWEpeq+x9zjwKZn660Hrmucb48woIRSOtfjCvxw0=; b=tybe5hqXSE7B6jhSakaQGH0md5n3ZV9XKY8+x7SmDzSG0TIKQ+8G3QKOSuV4ajeVO1 S2bkQwYN30rjf4F+3TWpjS64jw8H+7ozJBGryyBeB7B09QIIvoZ8bhVUToJkxuKkRvr+ cmdYAt+shVUBNVh6AgIhM4PdXdZrO9desKhfoYywsN7u3XuAHXThU210cRFnx9dc5t/U 0iEAXGTNNuBevLYbwUfLTnHK6gKAUrzuZ9IO4/4XzwXtq/ydsPfQomuUfYIpnJoH1T78 T1s7CcsBXwNuEp5tVVdC2R5hgEoIGTblMphGnQKCCGNZf4fE4oh/6PZ+NxKR1Sj1cq4N 3lIg== X-Forwarded-Encrypted: i=1; AJvYcCUVjxjVftHZwfgk0lNvklhgw2QXAlFpXWty5kXxhnbMhkz4Vu8clRMNX2vsXUvbJpg1xAtamHissF5SFIzuPYKUIz1uMkzV8ikA1nux X-Gm-Message-State: AOJu0Yw6sBjOha217Q3k1iOnUUGYf9tzxlOX6lYC/FtZpn9pyCVmgDyU ixgtzyKy06V3D3uWS/iSHL65rqGffFB7E+xaH/S45cRTyRkiB8DZLgSwxW9o8nY= X-Google-Smtp-Source: AGHT+IH/QWdZZ4hxij414qaSi16QQPTkgw/+VI8cd7eUev+6bYbrIXWUDGZs5ah4lxOjZno8KDMAsg== X-Received: by 2002:a17:906:31c7:b0:a59:b61f:b96d with SMTP id a640c23a62f3a-a681fe4d0c3mr753625466b.5.1717492146689; Tue, 04 Jun 2024 02:09:06 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:06 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 01/15] drivers: add missing includes on linux/mm.h (and others) Date: Tue, 4 Jun 2024 11:08:31 +0200 Message-Id: <20240604090845.2182265-2-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/comedi/comedi_buf.c | 1 + drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c | 1 + drivers/dma/bcm2835-dma.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/ioas.c | 2 ++ 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/mtd/spi-nor/core.h | 2 ++ drivers/pci/p2pdma.c | 1 + drivers/pci/pci.c | 1 + drivers/remoteproc/mtk_scp.c | 1 + drivers/remoteproc/remoteproc_core.c | 1 + drivers/soc/qcom/rmtfs_mem.c | 1 + drivers/spi/spi-aspeed-smc.c | 1 + drivers/spi/spi-bcm2835.c | 2 ++ drivers/spi/spi-intel.c | 1 + drivers/virtio/virtio_ring.c | 1 + include/linux/huge_mm.h | 2 ++ include/linux/iommu.h | 1 + include/linux/nvme-keyring.h | 2 ++ include/linux/page-flags.h | 3 +++ include/linux/scatterlist.h | 6 ++++++ include/linux/vmstat.h | 1 + include/scsi/scsicam.h | 3 +++ kernel/dma/ops_helpers.c | 1 + kernel/dma/remap.c | 1 + kernel/rcu/rcutorture.c | 1 + mm/dmapool.c | 1 + 39 files changed, 55 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 =20 #ifdef CONFIG_PCI + +#include // for VMALLOC_* + unsigned long pcibios_min_io =3D 0x1000; EXPORT_SYMBOL(pcibios_min_io); =20 diff --git a/drivers/comedi/comedi_buf.c b/drivers/comedi/comedi_buf.c index 393966c09740..23b07ebc97ca 100644 --- a/drivers/comedi/comedi_buf.c +++ b/drivers/comedi/comedi_buf.c @@ -10,6 +10,7 @@ #include #include #include +#include // for PAGE_KERNEL* #include "comedi_internal.h" =20 #ifdef PAGE_KERNEL_NOCACHE diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c b/dr= ivers/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/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 9d74fe97452e..1d971999fd39 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -31,6 +31,7 @@ #include #include #include +#include // for ZERO_PAGE() =20 #include "virt-dma.h" =20 diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c index bdb752f11869..7538459f1d8a 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/qco= m/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 @@ =20 #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/q= com_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 ac34876a97f8..b7858014a59c 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -10,6 +10,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buf= fer/industrialio-buffer-dma.c index 13b1a858969e..d3e82d25df70 100644 --- a/drivers/iio/buffer/industrialio-buffer-dma.c +++ b/drivers/iio/buffer/industrialio-buffer-dma.c @@ -6,6 +6,7 @@ =20 #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/iommu/iommufd/ioas.c b/drivers/iommu/iommufd/ioas.c index 742248276548..40c4942406cd 100644 --- a/drivers/iommu/iommufd/ioas.c +++ b/drivers/iommu/iommufd/ioas.c @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include =20 #include "io_pagetable.h" diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selft= est.c index 7a2199470f31..bcecf44681fe 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 724ae7c2ab3b..f248e4194b49 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 @@ * */ =20 +#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 694fc083b1bd..1e7421995f6b 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 @@ =20 #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/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 1516b6d0dc37..6b48bb57b638 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -9,6 +9,8 @@ =20 #include "sfdp.h" =20 +#include // for SZ_* + #define SPI_NOR_MAX_ID_LEN 6 /* * 256 bytes is a sane default for most older flashes. Newer flashes will 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 aac5daad3188..780d6b4f923b 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/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index b885a9a041e4..4f4f1e51d160 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #include "mtk_common.h" #include "remoteproc_internal.h" diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remo= teproc_core.c index f276956f2c5c..938220fe29f5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -18,6 +18,7 @@ =20 #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-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c index bbd417c55e7f..e45f64761e5e 100644 --- a/drivers/spi/spi-aspeed-smc.c +++ b/drivers/spi/spi-aspeed-smc.c @@ -11,6 +11,7 @@ #include #include #include +#include // for SZ_* #include #include =20 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 =20 +#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 @@ =20 #include #include +#include // for SZ_* =20 #include #include diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 2a972752ff1b..12ad62415312 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 =20 diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 020e2344eb86..c48fdb486bb3 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -7,6 +7,8 @@ =20 #include /* only for vma_is_dax() */ =20 +#include // for pmd_t + vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf); int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr, diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 7bc8dff7cf6d..d56e17a0fdf6 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -14,6 +14,7 @@ #include #include #include +#include // for copy_struct_from_user() =20 #define IOMMU_READ (1 << 0) #define IOMMU_WRITE (1 << 1) 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 =20 +#include + #if IS_ENABLED(CONFIG_NVME_KEYRING) =20 key_serial_t nvme_tls_psk_default(struct key *keyring, diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index f04fea86324d..4d7265bbd93e 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -12,6 +12,9 @@ #ifndef __GENERATING_BOUNDS_H #include #include +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP +#include // for DECLARE_STATIC_KEY_FALSE +#endif #endif /* !__GENERATING_BOUNDS_H */ =20 /* diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 77df3d7b18a6..0516e64dc03e 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -8,6 +8,12 @@ #include #include =20 +#ifdef CONFIG_UML +#include // for virt_to_page(), page_to_phys() +#else +#include // for virt_to_page(), page_to_phys() +#endif + struct scatterlist { unsigned long page_link; unsigned int offset; diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 131966a4af78..67c2505d3b78 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -4,6 +4,7 @@ =20 #include #include +#include // for folio_zone(), folio_nr_pages() #include #include #include diff --git a/include/scsi/scsicam.h b/include/scsi/scsicam.h index 08edd603e521..6eb9fb7a57d0 100644 --- a/include/scsi/scsicam.h +++ b/include/scsi/scsicam.h @@ -13,6 +13,9 @@ =20 #ifndef SCSICAM_H #define SCSICAM_H + +#include // for sector_t + int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *= ip); bool scsi_partsize(struct block_device *bdev, sector_t capacity, int geom[= 3]); unsigned char *scsi_bios_ptable(struct block_device *bdev); 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() =20 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 =20 diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 08bf7c669dd3..a1527f855f2a 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -47,6 +47,7 @@ #include #include #include +#include // for mem_dump_obj() #include =20 #include "rcu.h" 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 --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 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 A681D143724 for ; Tue, 4 Jun 2024 09:09:09 +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=1717492152; cv=none; b=s5Z162+dj5DK1M7m0fJ7+oKzMSV9nN9DcTuW0Kf/1jPkEOa0M0z1EnTA/izyKGo89NOruFoUWXJuDYWOKwwYmTHhe+GotX42Dpci0AplfxhQI7oug0fwb+qx9j98LQNlHptyuJnwMs6bice5p6Y03yC0Tc2A9DTioeN0sR7tuvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492152; 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=rytDAaJ7gS1y0U0fHnJJmLfiGR1pk+feFUVJQOXaI+EBNtBuzUB4ye7NSp/IhyQSMPcrYHOqQ3zDETZe50CiKy0FjzM1DWugUPxMVjsHOko5FVc3wfSsVN2G+YqP2gc6eCXW+yadDYMathaoIf3VE+THNVQpAMdgLvpl7RQwaPE= 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=NJU6pIZR; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="NJU6pIZR" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a68cd75b97dso270895166b.3 for ; Tue, 04 Jun 2024 02:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492148; x=1718096948; 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=NJU6pIZRF37ypQ1IrVoAhz61ggKsiNb2nDA6S6awqiRYpxWywZ+lvsSoFOmETsAqxW MQJ7nHp+4lyg/c97ehJlmrfmUt04lMIzHW55KYR77jv0BwHyjnvvKSnVvBGbjSVmWNmn 8gLeYbuMZxLEhjVkaLaO4/VncxfSO6DeQqy5vyKTIjYvhtoIku1VnAoc5+tLbbvy+Lc/ /FPNMKSUKLGbvM7AWLe8nZSJczgHaNJpwzHrTKgzbzy1tsDzzmF9Y06J0kpYXNvgDmV+ Ojgpw/Jiyx35fllkHZaiRdC2SspsQFtZUqNDFU1Lq8qiZE4LaU5tS13ucPkQXe1+lmsT uS5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492148; x=1718096948; 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=jTh6BE3Zf8yNeYjtYJL44+4BMRju7xCt4m4r6RlGSuNBBvHTo5RFe/E1Eannr3udpi V87/iBSHUwv26YFauDRNfx7N6NBZRE0/iffp9dr4qKs/Q86QMEj3TnLuPXW8aM7w2uDF mUqJLqya7gGhRihtH1PSxwnO8F0HtUv9w1Mhf9nXzRUJcoVCBjIp49IMQt1somMXzcv8 oeR8x8XCfvGNW+l1vpI8ZamUhiDbcwR/I0oUI2LbGNLAlOcnN+DDVrxBIp3FVt5ivyj3 WhN3PANRrehncASgyHAQf8f1ZLanfIXbiS5V0TALrzzlVsnKKrrNaHBH9MOaLMsqVvLb 9iSg== X-Forwarded-Encrypted: i=1; AJvYcCVawPSkUC5BiHoDP+NU2F7xehtgvSK4mEPOBVdOm1ddWClbGyGC6dm3+me+MLj+70d6oTJMYa1tUgB/vfegON0MoT3otO/MndCYozuw X-Gm-Message-State: AOJu0YwVeJP5/3woZW+ORH7QEqhRG7Vcir9zFxSc04JgTeqAS4QIssSZ srFAYCy9GFocBXMM7SDCHRMw5aRYadV8KnEt2emHyAEjOwBTQBL8ctt5o/5sfeo= X-Google-Smtp-Source: AGHT+IFF9eijKFo0jcGZn+um4NEghvBvIsaStj/BEJsY3lBQq9sQLzDiRHTklTVApw9KdQGhS/rGUw== X-Received: by 2002:a17:906:3b47:b0:a68:e429:1d96 with SMTP id a640c23a62f3a-a68e4291f3dmr482446466b.75.1717492148072; Tue, 04 Jun 2024 02:09:08 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:07 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 02/15] include/drm/drm_gem.h: add poll_table_struct forward declaration Date: Tue, 4 Jun 2024 11:08:32 +0200 Message-Id: <20240604090845.2182265-3-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable After eliminating includes of linux/mm.h, the following build failure occurred: ./include/drm/drm_file.h:443:45: warning: =E2=80=98struct poll_table_struc= t=E2=80=99 declared inside parameter list will not be visible outside of th= is definition or declaration 443 | __poll_t drm_poll(struct file *filp, struct poll_table_struct *wai= t); | ^~~~~~~~~~~~~~~~~ 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 =E2=80=98__poll_t= (*)(struct file *, struct poll_table_struct *)=E2=80=99 {aka =E2=80=98unsi= gned int (*)(struct file *, struct poll_table_struct *)=E2=80=99} from inco= mpatible pointer type =E2=80=98__poll_t (*)(struct file *, struct poll_tabl= e_struct *)=E2=80=99 {aka =E2=80=98unsigned int (*)(struct file *, struct p= oll_table_struct *)=E2=80=99} [-Werror=3Dincompatible-pointer-types] 447 | .poll =3D 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; =20 /* * FIXME: Not sure we want to have drm_minor here in the end, but to avoid --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 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 D6FF714372F for ; Tue, 4 Jun 2024 09:09:10 +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=1717492152; cv=none; b=FuVy71c1F9wnUi+cb6XypfcCFdlKm5n/McAXls03q41lZuNtwXX6FaZBQjIEKknAg+/kL+r4llT25m5gnRNzb/ZBBbfypjK0y3zNfIt5t2DS5dSv/oJsb4Yvku9oLAdrteOtCV6C+606VARIOm7UeUxWPc7fSCPwcsuu2iyzdtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492152; c=relaxed/simple; bh=DWv4Ts4UPDewpPAZDKo61Q6cBJ8156Q/JPUenZNlwS8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EYCk7aRLbDR6qo2KY7EnbQgGvPa5rtwcZYtgX4RYgWW/PSFOiL8CJd6nuMinFP5PG636vfaPjWxasclP4USUrd28ugoJ7IWi4YGpdpHN22zE/24CN8Dmf63KC7NKvZtrEPo2mUYFDl+1V1Ji9knUb/sqaiiBDaxkko5inAoeQ6s= 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=K8amYOfo; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="K8amYOfo" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-57a50ac2ca1so3261344a12.0 for ; Tue, 04 Jun 2024 02:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492149; x=1718096949; 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=TwZhGhfqKNwGAAazIH0NZHq5xaKIh/aom8Ka+wD6k0o=; b=K8amYOfowrokWNPT6gXG/PlWCasoziDhTFdXG4oNVQo9BuMRz2hYJdmxDFpi+5IvVG VBBe8Zy2FqHRStnxZQHW+R/bYoQxrpjMQ/w/+FZzJVBOIIZXNqMinqC9HISAGkkHJIkZ JTNQy8xvjWLpGdYvMSHczW5PO/T5nZY9AYT9NYg+bgrk5BLloheUbvi+clLD81SqvZAe hcsXE24eNMZJI+v1zN96ihqUdRKX6XMnucp9yUD3jGECZSc/Zz4cH3xmHu2W7BL2W2fP qkN+Y2hiAb5LHch1N/rLvMoUymHHAx9A7dl/Sot0bzDW19ecYWv/MLZvtqIXlPy0nZmy 9wng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492149; x=1718096949; 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=TwZhGhfqKNwGAAazIH0NZHq5xaKIh/aom8Ka+wD6k0o=; b=nAcjh4unktlITGaqRmX6tW3EJo8m1d/MHuWd8fRlgaOQD7sNqWQ4ap3ecub+nToRUU T5J43VY7GKEqNBUrOyaA1Jnjw5RGzaLcX97vakGWFIi+AjSAJiLqqL3qxkdD2SmiT5IQ tp+f4alLTASa6VSZqeuNIAJ0lJzaU+b3TxbeMH6fAEAf8PvrzltWGqMVagv/d1+EOqN+ +cT22RD5wnmudYKjKORB9U7bUgDiqH29ii3LIoIj9cljgMt9hlcoHgoVIep19RaIk7od AtU0Io+kLuOo8gfB3+D0vtAQPA1uCRghvt/5iA4B06mEt75/s7M/r5k1iylj9iXc2k3w 8LXw== X-Forwarded-Encrypted: i=1; AJvYcCWfhuR08zetxjtTjds3BeNeeNRw+OGyqC1DHtnBbgdNDJ912oFY9K3VguhAhMsEZlPyHhGS2Ir8+4efYUacJikLUIKpHnqzbWs40E+o X-Gm-Message-State: AOJu0YwvYvf8/Z2HFt2JLaXjFS5a5dGwfLY4zS+3FvivdaymBsrbdw28 kklzHTzq9Br4frnWjnOpNm3eE43UNxHkZyxfHwD4zDyMw61pOm+9oUG/ClTAml8= X-Google-Smtp-Source: AGHT+IHidc0HMkZpoHuW0F0Uuz8Q2jiGIktaIZ3mnWU/29ySDASkCqqcBJVcUe29ebu6h5fIJXGpJA== X-Received: by 2002:a17:906:4bd3:b0:a65:ab25:24da with SMTP id a640c23a62f3a-a681ff4540amr819129466b.22.1717492149299; Tue, 04 Jun 2024 02:09:09 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:08 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 03/15] include/scsi/scsicam.h: forward-declare struct block_device Date: Tue, 4 Jun 2024 11:08:33 +0200 Message-Id: <20240604090845.2182265-4-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After eliminating includes of linux/mm.h, the following build failure occurred: In file included from drivers/scsi/fdomain.c:87: ./include/scsi/scsicam.h:16:31: error: 'struct block_device' declared insi= de parameter list will not be visible outside of this definition or declara= tion [-Werror] 16 | int scsicam_bios_param(struct block_device *bdev, sector_t capacit= y, int *ip); | ^~~~~~~~~~~~ ./include/scsi/scsicam.h:17:27: error: 'struct block_device' declared insi= de parameter list will not be visible outside of this definition or declara= tion [-Werror] 17 | bool scsi_partsize(struct block_device *bdev, sector_t capacity, i= nt geom[3]); | ^~~~~~~~~~~~ ./include/scsi/scsicam.h:18:40: error: 'struct block_device' declared insi= de parameter list will not be visible outside of this definition or declara= tion [-Werror] 18 | unsigned char *scsi_bios_ptable(struct block_device *bdev); | ^~~~~~~~~~~~ drivers/scsi/fdomain.c: In function 'fdomain_biosparam': drivers/scsi/fdomain.c:475:45: error: passing argument 1 of 'scsi_bios_pta= ble' from incompatible pointer type [-Werror=3Dincompatible-pointer-types] 475 | unsigned char *p =3D scsi_bios_ptable(bdev); | ^~~~ | | | struct block_device * ./include/scsi/scsicam.h:18:54: note: expected 'struct block_device *' but= argument is of type 'struct block_device *' 18 | unsigned char *scsi_bios_ptable(struct block_device *bdev); | ~~~~~~~~~~~~~~~~~~~~~^~~~ Signed-off-by: Max Kellermann --- include/scsi/scsicam.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/scsi/scsicam.h b/include/scsi/scsicam.h index 6eb9fb7a57d0..c0de038b76b5 100644 --- a/include/scsi/scsicam.h +++ b/include/scsi/scsicam.h @@ -16,6 +16,8 @@ =20 #include // for sector_t =20 +struct block_device; + int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *= ip); bool scsi_partsize(struct block_device *bdev, sector_t capacity, int geom[= 3]); unsigned char *scsi_bios_ptable(struct block_device *bdev); --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 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 DBA57143879 for ; Tue, 4 Jun 2024 09:09:12 +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=1717492155; cv=none; b=cLYmDOi3HgQIZP6MvUeW0eGAnySNwO3aGgiAu7P2T9GiRMYfhe8KWaNBnFA0dwaXFkWV6FeQ67Aw8a22m3T6CYYoA08+g8f0avV8W32V615TELraCY+gdxxd2KXfaNDFzX8bD/Y4GoSMEHc9jlM3sdKOEG7B1Luk1RocHVlD4Hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492155; c=relaxed/simple; bh=UdxRgzWjFQ8nvwfCq2iecsJsp5rik97H65lidWIfejs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vE9OwoZwqiVrOvK/yQly4d+PVYDhfHhh6sLA5XgI6GduyMosGS67N0R2Yw0jE0dNyxBBbKn5/OfWCcAQthGS9RswcBMjbOZaL3vVTSKfDOMKFZMeTiWyvgnQVuA/xPV+OoPnq+DQu4X7/G5uDeYPrdHUxfSHSnrQ8uuYP+Z/7xw= 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=M0kAdpmy; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="M0kAdpmy" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a626919d19dso943648866b.0 for ; Tue, 04 Jun 2024 02:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492151; x=1718096951; 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=Lu9yS7pQCrsoRi7ZUhn1+G2Y6nFzVt+avQdoI72cAe0=; b=M0kAdpmysxYo5hqM46ymYTojdJC21cmzRtlYqOczx8sa1AdEFmqLvxYB9T5ApP1KOu KoaVcCTDqqKGzXry0NHtkC7lub32MHyB63YyGZntsPb8kRMZqbv7H0XAFmP10/x2qjHj 0B7zKpZPdnROjrROLHix0aU9ZfzbFLuhOUVjS4qCcM5jkMuRLnQ8KaxAcWVK4jbXPYBH I7b70SdADkYB+lEWlBt1ZEhhwn0EGqhbSo5F8ziPuhaCLAtbfc6P6RY9vx0OoZMAICo4 OP9uuVINUSuvI9wTiKW+1E+tv3UDO6bRcMnW+UkRXTtUTPm/0qyIT+yTH1GR+8t91UZE e9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492151; x=1718096951; 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=Lu9yS7pQCrsoRi7ZUhn1+G2Y6nFzVt+avQdoI72cAe0=; b=meehdl5x4ZhJ0SXuvpPJxx2PSYTKHttWGP5cTOSVkO0f3HPgcOGn9tKiEQa+LC+U14 KnoSLBAeVTZtRTdQjtBoPyENlRIHngf7mq6MGrFgpYXJ3oQO1xHUX+nu0raLGGMAasww U0K54Islh6z5kG6Dqw6YU3zImI0wxEPuOGbTMSRvlfNWy80hBrKj62Z4jlGqcVIYIVSD q8aLyqsYZfPW548B/8Bqa/sYcT4Ey5NZkPfYmYqaQdDCFDT9B0ULXZLdo7Q8XkX6JLdp 19n7Gs83VxV5ULZGMpqjdd168JYM8oG6DIZfigHPPJQtbaapjhN5A47ISBSGW3+SCgNf U7cA== X-Forwarded-Encrypted: i=1; AJvYcCWTi1/3FQbvcJOVd6LTAc0OsFegj5jDdjw9T17lcAdqg+WE4OmGJvMgYRz0mDb5/B0R/4c3T7OFGkoS7gkuzQXqMoNWMN7nASpwSE20 X-Gm-Message-State: AOJu0Yxm0f2ytMUyqVp1D6+CuA9Ow9u3p5gy6QF9o6UBXR9qe0mU6M3d Z9ShtcrEXIEFYNYNrjKaOBZ2XYSLDE4EkIoji0ajIu1X/esMus8/BkzjIJrCbw8= X-Google-Smtp-Source: AGHT+IFXHmTUY2LAO0CrBslhuc7TrTKlPItnXfEjmCqfLbltfo+OCfR+cziyr/TPphDgOmpCJJexuA== X-Received: by 2002:a17:906:471a:b0:a59:dba0:1544 with SMTP id a640c23a62f3a-a69544242b4mr149880166b.31.1717492151196; Tue, 04 Jun 2024 02:09:11 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:09 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 04/15] linux/mm.h: move page_kasan_tag() to mm/page_kasan_tag.h Date: Tue, 4 Jun 2024 11:08:34 +0200 Message-Id: <20240604090845.2182265-5-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare to reduce dependencies on linux/mm.h. page_kasan_tag() is used by the page_to_virt() macro in ARM64 (but asm/memory.h does not include linux/mm.h). Thus, in order to be able to use anything that calls page_to_virt(), linux/mm.h needs to be included. This would prevent us from moving page_address() to a separate header, because it calls lowmem_page_address() which in turn calls page_to_virt(). To prepare for this move, we move page_kasan_tag() out of linux/mm.h into a separate lean header. 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 bb9f8077b37d..a9459947a3b3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14475,6 +14475,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 c41c82bcbec2..3ff239992d4c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H =20 +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include =20 @@ -1812,60 +1812,6 @@ static inline void vma_set_access_pid_bit(struct vm_= area_struct *vma) } #endif /* CONFIG_NUMA_BALANCING */ =20 -#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 defa= ult - * value 0x00 maps to 0xff. - */ - -static inline u8 page_kasan_tag(const struct page *page) -{ - u8 tag =3D KASAN_TAG_KERNEL; - - if (kasan_enabled()) { - tag =3D (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; - tag ^=3D 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 ^=3D 0xff; - old_flags =3D READ_ONCE(page->flags); - do { - flags =3D old_flags; - flags &=3D ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); - flags |=3D (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_kasa= n_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 defa= ult + * value 0x00 maps to 0xff. + */ + +static inline u8 page_kasan_tag(const struct page *page) +{ + u8 tag =3D KASAN_TAG_KERNEL; + + if (kasan_enabled()) { + tag =3D (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; + tag ^=3D 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 ^=3D 0xff; + old_flags =3D READ_ONCE(page->flags); + do { + flags =3D old_flags; + flags &=3D ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); + flags |=3D (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 */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 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 88B78143C62 for ; Tue, 4 Jun 2024 09:09:14 +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=1717492156; cv=none; b=E6+h3tQbAoClqbIA0BnAie1UU/SqufMToIph8Sa6rthT9Wr0DDNgMu6cp/W0ZV/RSTBI7zGwlAei4yjKqgPoFJwSl9b0iS3eK8z4ReeJv6Aad4YH0HY5O7yIWcDRpSEuBRWJNyMd6YB5SnHE7+a1+AnsI3dG59CSunL/+ucu2QM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492156; c=relaxed/simple; bh=E3A3l3B6ecN/6qv87Qca2szysFuXPHOomJqMT+mzlXY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Go1D3TWIB6o86PKq3hJlKIKmo+RiDqQLL2I7MFlSKZ+DJxIaAxbBrYhZ74oseEpHOxIKr1GkU3TPRiwSwtD+ZsN4qi92ReNQ64xgOeV1QlzJH4cKNVjPxINSt1b86LTTRnlIYoO0VVg7b0ynS5gIgoqHWUkT7B32oSrqbCdQmcw= 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=Uhwp6MO0; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="Uhwp6MO0" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57a20ccafc6so4695246a12.2 for ; Tue, 04 Jun 2024 02:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492153; x=1718096953; 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=5ugwYiQRh7gsSZKM5f9fZEfiERzaZSJH9xrcJo+enM8=; b=Uhwp6MO0YYJlz6FHPU9FAtNqKkFq46/XkEh+8teWHfkJTDDtuzsHzmMzGEeZ8I+ZtR nFkOUH7SsBhmCJANAfIQGbyFSMcU6LHkgfMzVFpsHXyAiLRWYh3zoGqALt7O0QVkCSoF d/6xUVd/Zg0U7x5dLrZgo7G8FFxmSecLSCXtjBTfUkoi3mick5nlnd5HZR/yPEIYWLjL SzLQ/DshFuGxajsOcLYqccKd4JaoC6R4PrZfV/p8fpLt8PdXu+uZsibVvZoBW5U5uGbz ElK4hWmtrj9VNNSCZo37qKuw13eb6TAxVYtvJ7tYIdWvnSKXYNz00a8V3BKwaoBK84Qw 5HZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492153; x=1718096953; 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=5ugwYiQRh7gsSZKM5f9fZEfiERzaZSJH9xrcJo+enM8=; b=N5pLxwBm3Vahbm9mr/BfRRo3TU7UNizQNaG3JzZqOECWstxK7XFi1ikt/oK59iH9/s D7hb0e57XMG626KVo1aZH57sWLQbMZarOOxgfwbpS3xe+2QQUb8rIFv0g5Wrc28KrnwC cor7BqjCMuTR9RCv5gNA9ZWX289DH2Ps/s4v3RRpWfHlbxKJtJJgh/T6oIfF0G5NmmCG k+OFdRswr+NdMou3WWdmhYB/4o4Yi0Atx5NNvTntn4+ZvfOfcPWySb3JC0w1W/37jMZE fO4qUlSeRU2gFrPG01/MZsJFbCJ3tumXxTB5eKKB/gdgHCnn6Qvb2OQwT8CP5u+CAO+l 8eaw== X-Forwarded-Encrypted: i=1; AJvYcCUDTXRxvNPT6YHF15HUtn/DTG4v1djM/znWs/x5jUG7vqFbQA94Q/O1ZhQ33DPmxvB8/X9Ero8YIA4YIY/C3XHGyAZPRzEqehpBZFHi X-Gm-Message-State: AOJu0Yzj2f/tduevFeOeBq8MWKss2SzcVi9lRBWNqSCqQiSp7bqRII4u M/rYBILxt2cA1BxMEtaHrCNBNXg44tSXWOkjJ8Ul3whdW5b+bw/K6xx243fkC/c= X-Google-Smtp-Source: AGHT+IHuYP1ufnXMMmWaJJ03GHA9WgouemhQpCjHhbIXLQh1XyAq6YAVOglv63VcXHv+oaxWEjtZQA== X-Received: by 2002:a17:907:9725:b0:a68:fafc:659 with SMTP id a640c23a62f3a-a68fafc0807mr430280566b.29.1717492152699; Tue, 04 Jun 2024 02:09:12 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:11 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 05/15] linux/mm.h: move section functions to mm/page_section.h Date: Tue, 4 Jun 2024 11:08:35 +0200 Message-Id: <20240604090845.2182265-6-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare to reduce dependencies on linux/mm.h. page_to_section() is used by __page_to_pfn() (but asm-generic/memory_model.h does not include linux/mm.h). Thus, in order to be able to use anything that calls page_to_pfn(), linux/mm.h needs to be included. This would prevent us from moving page_address() to a separate header, because it calls lowmem_page_address() which in turn calls page_to_virt() and then page_to_pfn(). To prepare for this move, we move page_to_section() out of linux/mm.h into a separate lean header. 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 3ff239992d4c..c9a3f1c0ae07 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3,6 +3,7 @@ #define _LINUX_MM_H =20 #include +#include #include #include #include @@ -1631,10 +1632,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_= t flags) } #endif =20 -#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 @@ -1832,19 +1829,6 @@ static inline pg_data_t *folio_pgdat(const struct fo= lio *folio) return page_pgdat(&folio->page); } =20 -#ifdef SECTION_IN_PAGE_FLAGS -static inline void set_page_section(struct page *page, unsigned long secti= on) -{ - page->flags &=3D ~(SECTIONS_MASK << SECTIONS_PGSHIFT); - page->flags |=3D (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_sectio= n.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 secti= on) +{ + page->flags &=3D ~(SECTIONS_MASK << SECTIONS_PGSHIFT); + page->flags |=3D (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 */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 97B561442EF for ; Tue, 4 Jun 2024 09:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492157; cv=none; b=oBb1b6FC6Sl1xJPJrVGZY8Nc7zeLO43zIxgfLwP3B5rfWbGBdK2BXCEhubSELbRCPqxMxs4IlSMzkScTJWB670qnCM8ImuCv2LQvHkkj6mEZKsUFjr0W2yCMm85JJgFDz798fZJL9uEzvlaQWmZNHXiO2LByakmX4CtTOjPbDco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492157; c=relaxed/simple; bh=rkUGvj+ij6RicIA5EFzODwQ7Ora3dIw64eYqggjnLq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qq6xNuCRzSbAXiLikj8A53iIMD7OVJ4HcOBrU0CMxxgzVwu++7TDmu20uI3zITaGTuIGWqMVNADgNUa25NzbraU+bs8zT/o8YsIgFfiY/rkvYdr0EMP2zyMjwHbHZrSu6Dd94k5jvQ7/XqNWT0zHo5T0ncgNRQnHLHSKaIr7xqM= 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=blYZpVz4; arc=none smtp.client-ip=209.85.218.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="blYZpVz4" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a68f10171bdso264743566b.0 for ; Tue, 04 Jun 2024 02:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492154; x=1718096954; 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=oVxAKKIuGzczdMzzJCnaqt6bk9QQZalHnDhl7auSlGA=; b=blYZpVz49Qr7+sw4ovvi/0Dh9nCrkFMyfR9XE4+H+tihCd96m/5cQZ0PId8Y8K7Whb krClDfagcHsDARdCAcIKVWgwN5i9q1YgDWVmt/iVxcfD78rQcxv3HGmeyUhqi1W2s65q br66KT4Q8ggMpBIV2BSEe2qf0frehvMm8SBdwhCHg3/vBe92PqNJKt3aIQvUa9qombQ/ tST3NkQSbiMjG/CO1VWTjrUiAf2TNUogeoHHpmJ7D0rHtlyDPYbjcDQNiZHYZxHuIWC7 J2vzTaK0920z1nBCrZSyANIXfTo2i5wWwkgviyyDzQjp7cgBuvLb3Zi6USasYPCzZ8Um Qs/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492154; x=1718096954; 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=oVxAKKIuGzczdMzzJCnaqt6bk9QQZalHnDhl7auSlGA=; b=D2jxoMGYaQuiWZ2m4F2QCKkn2jvG8r83u41qc3kd/4srE0I2k6EznqAfTlz6ztJqgt jzymUgMQBeM+0lH3GiXL940c+J4TZHDTj1THiWSBeOd1+Pm2SzL7gx7lsqAFj8bKu0o4 WGc30kozAwYA0iVgC5lezLlHjw6dkViFI5dT1hsi+iczltX9pA92OJJGiPs/gSXlx1D7 N9RqqPoxElIlSYV0lNAj3ClggkqcyVYumwJYeMOuc+Pa4aXUQDpQ4aSKlhTv5hZ0OC7u CqSVhtp9iszwRsVRoomrV+K5aZnBUZuNLlUBsPa9NlI5F2Sdv7gJ2O37XapiZwSniZYn pt3g== X-Forwarded-Encrypted: i=1; AJvYcCWlpk8W88qoeezSu1W1jwz3ZO79yq3d0Mj8m0ajcl47Gw+l9P3eRroSCmUXgJoGyepgLEGq3YbDiCmuLCh+V7IlbcWjMoNvnnuFWLSc X-Gm-Message-State: AOJu0YzQDqAzrrCCey1ie0Qw0fCujnCi3JG8KVNKV+2t3poWX+JztmLr VQL7VhT07NYY3sTDTI2iA3V4eFqLiq3f1XoJ+yTknS8wdkD4wAcEHuK8CBSZR7I= X-Google-Smtp-Source: AGHT+IGOgen2Jx0g/YQ6+0A61e2VmACILINzoPWZHBtfeJO66xBbBL4F3Gr+Gh7gEwW1i0zrX6OeUg== X-Received: by 2002:a17:906:c94d:b0:a67:aa2b:1028 with SMTP id a640c23a62f3a-a681fc5cbccmr901709666b.8.1717492153798; Tue, 04 Jun 2024 02:09:13 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:13 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 06/15] linux/mm.h: move page_address() and others to mm/page_address.h Date: Tue, 4 Jun 2024 11:08:36 +0200 Message-Id: <20240604090845.2182265-7-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare to reduce dependencies on linux/mm.h. page_address() is used by the following popular headers: - linux/bio.h - linux/bvec.h - linux/highmem.h - linux/scatterlist.h - linux/skbuff.h Moving it to a separate lean header will allow us to avoid the dependency on 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 c9a3f1c0ae07..014db2b39c16 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,7 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H =20 -#include +#include #include #include #include @@ -105,10 +105,6 @@ extern int mmap_rnd_compat_bits __read_mostly; #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) #endif =20 -#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 @@ -212,14 +208,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 *); =20 -#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) =20 @@ -2174,44 +2162,6 @@ static inline int arch_make_folio_accessible(struct = folio *folio) */ #include =20 -#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 =3D 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 - -static __always_inline void *lowmem_page_address(const struct page *page) -{ - return page_to_virt(page); -} - -#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); -} - /* * Return true only if the page has been allocated with * ALLOC_NO_WATERMARKS and the low watermark was not @@ -2261,10 +2211,6 @@ static inline void clear_page_pfmemalloc(struct page= *page) */ extern void pagefault_out_of_memory(void); =20 -#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_addres= s.h new file mode 100644 index 000000000000..630fc4e2be95 --- /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 __pag= e_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 + +#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 =3D 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 + +static __always_inline void *lowmem_page_address(const struct page *page) +{ + return page_to_virt(page); +} + +#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 */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 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 DA782144317 for ; Tue, 4 Jun 2024 09:09:16 +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=1717492159; cv=none; b=RN7rj/Umu3rHP/l9zkuauqESfUmbcDM6Y/LtdYTx/zGJxZUnFUXUZZxWH4I1VUPzlFPVj6bgJ596V0xrGj5nBtX3YFlnMbZpFhAjSzaupRrbcjEzE4L6TJEEiF4vb+qUbNhPfW12zizb5b6XW8c+wTu4Oe2A7C2nNn9TAuCUtvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492159; c=relaxed/simple; bh=7KHwc80u0MdxH3ly7D3UFHG1v4F0rKQH8Y4sOrdUBRw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZVxLDAcZuKmSNWKdE8Q4L74mRN2ZcSKu9DEeQjJ+A8shmj5Ndpts0mUj0CssidwPOTKwe1N+NGkZzGmIM9uWHF5d+LuzF87AwRMMEuEx8d5XKXGuBDDIto0zAApvIOcZ30szGiQgiYZITOErxJJkQQj+oEaJ3RZrHaxAD2aS+uc= 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=g2P48wKc; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="g2P48wKc" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a689ad8d1f6so406899966b.2 for ; Tue, 04 Jun 2024 02:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492155; x=1718096955; 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=LGA97Ct+cPd+7V/cTW+dx47R1ZSFkzyCh6qF0w1u/vk=; b=g2P48wKcC2NlTaNih8WWD+KAegFvx7fibw4lBId7ZzBvHTvTg835iLH3OfSrI+v1A7 F7JIeKXXd9GBdnalGEh1dcHKtGpAMrnbnRgOTv2ceLkmAIwfJE5tBvblI6OZSejc1uCX J5V+2M7GIPij3VoYnKZeMyE6Fw5FMV1kXpf+jtW8rzhMVg9maKc05wbAFramKxdnkNK1 4D5YAIlOa2p7IRIHG13S/3hhwpHB5vQmxgi7tMYM5P2HgLZjdLp9pFqfzmOMSS8tTOob kK+jF+vrSTAF4GUWz7VM5hfhBFQJMRzv4eP7F8szzuwFfC/RHE7NMIkB7Hw3kePs6yIk c60Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492155; x=1718096955; 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=LGA97Ct+cPd+7V/cTW+dx47R1ZSFkzyCh6qF0w1u/vk=; b=P9Dm+HvhcP0PTqsMGuA6E9U5XSncF/NPR5eZSfdBIGNA7ooz789MTJbdollorceRDk 6j2tmhx34km1+vbP1Osl2NDmeZDWsuLFE1JIM+EeetJzuno+I4gx9TWBPcqKwfvmGJoo rOC0nRGHMJeTE6cO1oUAlevpLDIdo7n1B/0KAFENU7uH0VvJxlpZ5r9q74FsWtc0qxzT Ynuyz2nl9MWX65c0ydzsDqKnJKlyOT8Hed4J4ejteLKFuPFs6udz/dhL95y6g7Kl2NdQ +z+TGRGXRcXbgJJT4FMbY8G+Euq4qtiNOYmuVj3GByE2kJzoDvx0Ua5AQLMXAL0PK9Si O11A== X-Forwarded-Encrypted: i=1; AJvYcCXKxZZtaJ1SuQBTELmjzQGfyogss71KZCvev9aYjriBR8dffvfq0qRx/IWJaPGg+KYnBjEotrnPYALrcXyNj+8Zjzt8LbQ8P7fP6/Es X-Gm-Message-State: AOJu0YykzhEbSbKgIOiUrYXydOYANfQpkCQA/Ba3P1MF/wkKC6BV2WlW lbl7u3+G6Ry4Zgrt7nzfbQq/EO7NNYCl2KPJ51J5QXAmJxa4Fn9XFemIoWvmAAc= X-Google-Smtp-Source: AGHT+IEsb+sDgUGZexqUFY3hraRHpEBznY4zG62l35w3uux2zbvBuWOtU9Ps2+jctDU3Yl2qZVDwFQ== X-Received: by 2002:a17:907:516:b0:a59:b88c:2b2a with SMTP id a640c23a62f3a-a6821b71cdemr586561966b.50.1717492155201; Tue, 04 Jun 2024 02:09:15 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:14 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 07/15] linux/mm.h: move folio_size(), ... to mm/folio_size.h Date: Tue, 4 Jun 2024 11:08:37 +0200 Message-Id: <20240604090845.2182265-8-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare to reduce dependencies on linux/mm.h. folio_size()/page_size() are used by the following popular headers: - linux/highmem.h - linux/iov_iter.h - linux/pagemap.h Moving them to a separate lean header will allow us to avoid the dependency on linux/mm.h. Additionally, it allows us to move folio_next() to a separate header, because it needs folio_nr_pages() which is also moved to folio_size.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 140 +------------------------------ include/linux/mm/folio_size.h | 150 ++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 139 deletions(-) create mode 100644 include/linux/mm/folio_size.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 014db2b39c16..b11bbbdd2754 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H =20 +#include #include #include #include @@ -1069,38 +1070,6 @@ int vma_is_stack_for_current(struct vm_area_struct *= vma); struct mmu_gather; struct inode; =20 -/* - * 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 =3D (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 definiti= on - * 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 =20 /* @@ -1303,39 +1272,6 @@ void folio_copy(struct folio *dst, struct folio *src= ); =20 unsigned long nr_free_buffer_pages(void); =20 -/* 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 @@ -1973,23 +1909,6 @@ static inline void set_page_links(struct page *page,= enum zone_type zone, #endif } =20 -/** - * 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(const 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 -} - /* Only hugetlbfs can allocate folios larger than MAX_ORDER */ #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE #define MAX_FOLIO_NR_PAGES (1UL << PUD_ORDER) @@ -1997,33 +1916,6 @@ static inline long folio_nr_pages(const struct folio= *folio) #define MAX_FOLIO_NR_PAGES MAX_ORDER_NR_PAGES #endif =20 -/* - * 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 =3D (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. @@ -2043,36 +1935,6 @@ static inline struct folio *folio_next(struct folio = *folio) return (struct folio *)folio_page(folio, folio_nr_pages(folio)); } =20 -/** - * 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_likely_mapped_shared - Estimate if the folio is mapped into the p= age * tables of more than one MM diff --git a/include/linux/mm/folio_size.h b/include/linux/mm/folio_size.h new file mode 100644 index 000000000000..e7cd567cf069 --- /dev/null +++ b/include/linux/mm/folio_size.h @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_SIZE_H +#define _LINUX_MM_FOLIO_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 =3D (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 definiti= on + * 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(const 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 =3D (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_FOLIO_SIZE_H_H */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 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 3B6AC1448DC for ; Tue, 4 Jun 2024 09:09:18 +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=1717492160; cv=none; b=G2rU3TjX4ht9gk8tkUKxat40s+18FB6vL9r61hxZ4tEzJfOebU1uJMnKJCXHkkOu5SudxPJNcKe9J8V75e+8xbxLIbDOZ8IKSiG89WpqHiD+KbmJ+sabaJw9qF/KaHQnk4g96W+KHAmTXcujChl/KmNUyrGi/aEkdt4SWRC840U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492160; c=relaxed/simple; bh=6CsVTNav/2xxEWRFZ4+7NyJK7QkNGv4emu58fxOVnhM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rYvNY9mXCWxH8qpjkwTg46jYEmjO9Rb9AB+twQqy9U0B87kKJqQBhPp8XT1zypJtmS/qyPBXY8TCatWDwuFncVaFu5pfdFQYkciQQk8+io3CsJE2TifXSYw0znlwAeTdNTe4deb/IkQxLWuB5hJQC3fPktj2DlSI0uN0giiTemk= 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=NLyYdngd; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="NLyYdngd" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57a50ac2ca1so3261522a12.0 for ; Tue, 04 Jun 2024 02:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492156; x=1718096956; 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=qOL4vXuZ0a4PoiG22TiWEmdORRFE9U+5xK6xKS6y2zU=; b=NLyYdngdQ635dsixX/j4uc9LIreyNhPsO8CsfZywJEcY4baMgxLJuwCBxkl27HgLp5 w5SivYR/qXYomWcOYmpmp+AC7xhJdzVuPYSUHz7GjALhar2xRfDtF5odBSuB9bLpkWws 5L5lKz8PJz3xJh/qAGEHZEO25LjUPmkezahbIenkyt8AW047ZlwdQG3OZIKPazuRN9o5 c8L+8ipkGOkKcRC28UNc378y+SMtuS51CBmQJCqfZ77BNfx7acu/o1bl21c56/BXF2HQ bFu37KhqKVAOyPh6qDoSzw9vJky70HRml7rCF+w169p9rN0f1doY4O+WUolSnCsPy48J 710w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492156; x=1718096956; 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=qOL4vXuZ0a4PoiG22TiWEmdORRFE9U+5xK6xKS6y2zU=; b=e3rqRiaxiCpiQAYskisn1kxlABgUuC6P1JnieJwzm3CHDHJ9ySg8pOB5ZOCgZx7KE6 r6jocj8g7E3xwJb3zrVSoETbCOLhHRFjmRRTkI05ZTjs/vsEn+xnf3hTlCV9ZrS/JTXq hdeyMDiXn20g3EgcGab0yFlAbvGOqj/Xo8RWt/1POUvbiOIMCFwyD8QSpNYj87KlYOk2 Y2M6K5MZQguhkY0RPiSjrtOcVNKi9tqfhpQyXLFQzZ8YpYT9I8+muxLBakJPZsFr2Fdl h7gdQZbeFC0TChuZAOkA5SOZxs+VgN722xEcPSXcp5a7AIdUa6Z8OX5Ot7RUTxonLHhJ 1dUw== X-Forwarded-Encrypted: i=1; AJvYcCW3cYp5ejN2apw9HS/0gyIWpItwjba6xKkWxdDPoOlHB0AvOldLmjKgPjdR5y9wMqBHzrMjNNiDT7tClBcNMtS+c2XV7Qj74L6tZRRj X-Gm-Message-State: AOJu0YwrdqFSL6S9T1jcCZlgaHr8OvRe3IFhWeVXZ8YbK3h9axw5x8bV AjvDxX2sIO3wlfWJnVrFBl7x6qcSpMBAXctv7pR6xTe8BaBDm2xrPQi8DKi8JTjU+B48zRiM6iu 4mrc= X-Google-Smtp-Source: AGHT+IHt9F2oYYdhVTvxemPiWIf8QKaB1WXTbOFaVE7w6l+bxeSDT0tJO0j/hkCZ7p0XgmZYIYi9Bw== X-Received: by 2002:a17:906:6bc4:b0:a68:d2c:2a23 with SMTP id a640c23a62f3a-a6822049940mr757127166b.76.1717492156465; Tue, 04 Jun 2024 02:09:16 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:15 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 08/15] linux/mm.h: move folio_next() to mm/folio_next.h Date: Tue, 4 Jun 2024 11:08:38 +0200 Message-Id: <20240604090845.2182265-9-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare to reduce dependencies on linux/mm.h. folio_next() is used by linux/bio.h. Moving it to a separate lean header will allow us to avoid the dependency on linux/mm.h. Having a one-function header may seem excessive, but there is hardly another way if we want to distangle linux/mm.h from linux/bio.h. If one day, say, folio_prev() gets added, we can still rename the header to something like folio_iterator.h, but until that happens, this folio_next.h header seems like the best trade-off to reduce dependencies. 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 b11bbbdd2754..7be75960e7e1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H =20 +#include #include #include #include @@ -1916,25 +1917,6 @@ static inline void set_page_links(struct page *page,= enum zone_type zone, #define MAX_FOLIO_NR_PAGES MAX_ORDER_NR_PAGES #endif =20 -/** - * 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_likely_mapped_shared - Estimate if the folio is mapped into the p= age * tables of more than one MM diff --git a/include/linux/mm/folio_next.h b/include/linux/mm/folio_next.h new file mode 100644 index 000000000000..7016e303439c --- /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 folio_nr_pages() +#include // for nth_page(), needed by folio_page= () + +/** + * 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 */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 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 485351448FA for ; Tue, 4 Jun 2024 09:09:19 +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=1717492161; cv=none; b=YK5CVSpUMN8puR6ee4fkFX5DhhiQgLemKRhV1IOly3E1osjX1Lt1xyzHyB+bLF1SyxBDHstCb2d0XCQn1DwvGm6CZymIMLJ6szk7xqy+r6uoiD8IABU28igQD8lkabJtUZaa5it84++cUZtQFLNhj3StQRgHNgVeTTuqaZ0p0uI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492161; c=relaxed/simple; bh=Cd4N3ppnIKo96UjuDYKqNAWCqoo7sSNwgSH8lYyi25w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f+f+zvXaeny9aQHjTcAV+3iDhe3vyCXpW6nrr8NvCVowdZEaoafIkpEFD2vVVQnzdM6ufz039ecHzR7cyFX9iaG62G1d88jtoPD1kzBrdHTXZ9EMZ7A78IfX8OwDR7wW7mf/Gt31LIXOu/SpvPOz40iosS6XjeArFU2ehvlvvZA= 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=G9yMqb+5; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="G9yMqb+5" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a6265d3ba8fso75046666b.0 for ; Tue, 04 Jun 2024 02:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492157; x=1718096957; 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=HwBsgjYa0IXOImdBe/4+bRIQcCY8SgWsOwsbDkpj0Qk=; b=G9yMqb+5y+fskP0M+Dp9D2JAnx5D8aYx6BCHwZ11OJr63fw0LbLiW79W8MpJHI1EeS /1Sj3Qg/sginyzX/kOyj8Pzszf7n3BZpDu/M8OnKRvlsD96QxTACULYN4rybY5zayT6o EPYXI4dZREftrLIz6fzv6jvSsG55lCpOcBRWKinTSpmKDLL7GdF0SO9u2VeCB0YCyR63 L0q3NNaz2y1K9xR4lCXg/mtylQHeIxMt6UmlHJG0rD6GnSIvJTe4M9UDeKOm017tWpiU VO1gHdwbTJyrU59cGsbT2KiWrVzDlLmki+0zqBipRA5lCHKI/oG9jGAY3vsnNRTKAnGh ptow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492157; x=1718096957; 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=HwBsgjYa0IXOImdBe/4+bRIQcCY8SgWsOwsbDkpj0Qk=; b=I/8ca5HqSmI8ZrvaA0g0So9IVudomKv619mOXAdVimx7jgQ4vrL90gjSjpcgjltsnd PZ+mnR5G0jzKR39cjF6WyCuKL8NJs9Vl1mSmYK/4YpxVQZIFI4NptQtRKrrNg7k2Hr5J UVfheR5niZPfGH4JflaFJPbc2zmGYfjIRDUvQ+WdbFXr3ZFXUwGIhxkJ9E8w0Z0tEoWB WBpOFkWatFHl4JmTjMe7g6vLuvmmJmBLK0DuygPG3CRU+Y8f9Gxte5uKG2ds1zYOPKNT 6Bo4FfZ9NZkycKYQuNHzZgJxvyL5MGXdAitSQzwi07P0FXSFivW7rnu3wU9LRbUZ/Pyf d14Q== X-Forwarded-Encrypted: i=1; AJvYcCUkXEDPqSNvAVs1hi+Tgjmhr7VdA/d+wew0ErHZ+irEnHkcH9cOfyX/hbIL71uYZhHofBFmZtVlZrETUgV6Eo8gTNu782a6jGx7C73h X-Gm-Message-State: AOJu0YyalvCPU5UP1LCm3x2ywC4h8QPnjji7or51JRhn4GOR84zJFUA9 vsTeHopnlxRLTjsEgjpgwEdRGzlxH5TUaRjE4Lc1kxkUvXH3DwT484qrRocrWG0= X-Google-Smtp-Source: AGHT+IHIJT2BE+IHPYnFS/7wmnu2XAw4mULYk5HJdR9W0oN6DhpUIE6zi6XQ1spmCyvvSqUKhBaXJg== X-Received: by 2002:a17:906:4f0d:b0:a68:c6e5:3574 with SMTP id a640c23a62f3a-a68c6e5360bmr467546066b.75.1717492157591; Tue, 04 Jun 2024 02:09:17 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:17 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 09/15] linux/mm.h: move devmap-related declarations to mm/devmap_managed.h Date: Tue, 4 Jun 2024 11:08:39 +0200 Message-Id: <20240604090845.2182265-10-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare to reduce dependencies on linux/mm.h. put_devmap_managed_page() is called by put_page(). Moving it to a separate header allows us to move put_page() to a separate lean header as well. Signed-off-by: Max Kellermann --- include/linux/mm.h | 20 +------------------ include/linux/mm/devmap_managed.h | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 include/linux/mm/devmap_managed.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 7be75960e7e1..6ae6961e83bf 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H =20 +#include #include #include #include @@ -1354,25 +1355,6 @@ vm_fault_t finish_fault(struct vm_fault *vmf); * back into memory. */ =20 -#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) -DECLARE_STATIC_KEY_FALSE(devmap_managed_key); - -bool __put_devmap_managed_folio_refs(struct folio *folio, int refs); -static inline bool put_devmap_managed_folio_refs(struct folio *folio, int = refs) -{ - if (!static_branch_unlikely(&devmap_managed_key)) - return false; - if (!folio_is_zone_device(folio)) - return false; - return __put_devmap_managed_folio_refs(folio, refs); -} -#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ -static inline bool put_devmap_managed_folio_refs(struct folio *folio, int = refs) -{ - return false; -} -#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ - /* 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 <=3D 127u) diff --git a/include/linux/mm/devmap_managed.h b/include/linux/mm/devmap_ma= naged.h new file mode 100644 index 000000000000..50357b304d68 --- /dev/null +++ b/include/linux/mm/devmap_managed.h @@ -0,0 +1,32 @@ +/* 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_br= anch_unlikely() +#include // folio_is_zone_device() + +DECLARE_STATIC_KEY_FALSE(devmap_managed_key); + +bool __put_devmap_managed_folio_refs(struct folio *folio, int refs); +static inline bool put_devmap_managed_folio_refs(struct folio *folio, int = refs) +{ + if (!static_branch_unlikely(&devmap_managed_key)) + return false; + if (!folio_is_zone_device(folio)) + return false; + return __put_devmap_managed_folio_refs(folio, refs); +} +#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ +static inline bool put_devmap_managed_folio_refs(struct folio *folio, int = refs) +{ + return false; +} +#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ + +#endif /* _LINUX_MM_DEVMAP_MANAGED_H */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 CF4A5144D1A for ; Tue, 4 Jun 2024 09:09:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492163; cv=none; b=TgTR/ZRZlBMdnT2PagTddPJnfdADJEGSdnyzzp56OUgN5TdO+W+FEKMUTE+ZXfEiWmIt6EIhAbqPVes4DSqoCen+mPK2UhQ/NpGIhBjsuwg+1WhboW2WNBQ928n+Kv0K3RXwjUfm6j0htx2Zk0bL2NkAMt3FpBSyJT9sD0rTnOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492163; c=relaxed/simple; bh=Z4hvY1uctw58NTWdM7rNyP6R2/EAy7sNCXs18rZQTUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ftup4t/fQHCKfk792yhhi54JdbZFNY9NtTZKl/h6hCAKL9X50N9s3oLw0m+6YGvVEeBUCagQ06y6M1Y61TWnFhBiPYiY8czH/tv5s5i9t33nrW/da5rDyRfT2efQagUXa5SOb5Jcb3no2AaJpdBhC+yNIO96Fs1ZZFq4ev9kqkg= 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=i9dRalzo; arc=none smtp.client-ip=209.85.218.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="i9dRalzo" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a68b5f18fc5so323430466b.1 for ; Tue, 04 Jun 2024 02:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492159; x=1718096959; 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=ib6uKSj7xS/ycwqLjicn1v63gCXQSDvpTlGGC5UinQY=; b=i9dRalzoK8JENqCI7ft/x7NbeNX4IoewPCz/f+ESqfgGvBsGHHlCNiC7TP612ygp+5 t30JG+IWeO4L0dcftKKNgxH3xQLh9ItYzrzPwEQxtSyKbzyAo6gUYdMjVagoH0Y6CbzH +kpBAROW1vhpGp7IkBya1duW/oCPHUrQZziCz6KN03l/v2A+Je13IhatTAb1p97W8Tbx p0okHLcMppl/GaKPz2gigM+edD0vI2FBbVhRMiskO+Oa4Ef/GUAAp9SvoONPZNIkpGX0 j9tUu8CrtNa8A8ysjoakbqdxR9u5gQwFNp1u1HUyST06H0aho69KtBDpwp4YBi6kr0+J wjAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492159; x=1718096959; 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=ib6uKSj7xS/ycwqLjicn1v63gCXQSDvpTlGGC5UinQY=; b=frmu0IkT1/haCrekXiiCgbQHJZ0HZtZX0RXXygqfVn0aP+FYOpyCPpnPLPiNWtqJtz 6sFXKmcyfzG66igoocdPsVOJ0bopcFEDzMdpRWyZSWscBHPB9PZ8HaRROMgkPc6/2FjZ yE3pC8B9hZkYkJpMrXt7tRtAvQv8DgzOWReUH9Q1VR/zfepZCtl1LsxVxx6af+qcwfLf gI98ndmDyMY3T01TTG+rr7i6wyw7a5wirrQKLmIEyvuzxLXm8XuO/ZZldeR4RYetCd8o S2aJeckOAC+ef4v+TpPD66RNmKVwPvu6obDlcTcwSy5q/Vsh+Fj8eP+sExb4dAlEpxrc OOvw== X-Forwarded-Encrypted: i=1; AJvYcCVzmiShDjpv/syD8hVuVDah75j1q+SAY9BVV8rN0AWIG8685zPKs6ttYiYJI+jHeVRTs1Y+V0st5B4XvvuivqY0zMoYJQolkhKn4hGI X-Gm-Message-State: AOJu0YwOO1wBchk/b6QKtl1haddI0B7wADDI+2Id0x9RYH0EYoqFW2f/ HLiUtNVgT/vcWwhcq/YNxtkPwOMeOs4k6U7LS6aFBW+d17ZzA+YmPvQo4oX36GA= X-Google-Smtp-Source: AGHT+IErVk8d/9y/kb0Ga83nzzJPAptWAOoI16J5Z6NNnpL0um0Mhe5dQgJ/cpp18A88n2GMuIzlBA== X-Received: by 2002:a17:906:a10b:b0:a5a:34ae:10ea with SMTP id a640c23a62f3a-a682272f34amr756980666b.76.1717492159079; Tue, 04 Jun 2024 02:09:19 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:18 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 10/15] linux/mm.h: move usage count functions to mm/folio_usage.h Date: Tue, 4 Jun 2024 11:08:40 +0200 Message-Id: <20240604090845.2182265-11-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare to reduce dependencies on linux/mm.h. This new header contains wrappers for the low-level functions from page_ref.h. By having those higher-level functions in a separate header, we can avoid their additional dependencies in the page_ref.h. Having these in a separate header will allow eliminating the dependency on linux/mm.h from these headers: - linux/skbuff.h - linux/swap.h Signed-off-by: Max Kellermann --- include/linux/mm.h | 172 +------------------------------ include/linux/mm/folio_usage.h | 182 +++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 171 deletions(-) create mode 100644 include/linux/mm/folio_usage.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 6ae6961e83bf..a32d284813f4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,9 +2,9 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H =20 -#include #include #include +#include #include #include #include @@ -1074,51 +1074,6 @@ struct inode; =20 #include =20 -/* - * 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 u= sers) - */ -static inline int put_page_testzero(struct page *page) -{ - VM_BUG_ON_PAGE(page_ref_count(page) =3D=3D 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); =20 enum { @@ -1265,8 +1220,6 @@ static inline struct folio *virt_to_folio(const void = *x) return page_folio(page); } =20 -void __folio_put(struct folio *folio); - void put_pages_list(struct list_head *pages); =20 void split_page(struct page *page, unsigned int order); @@ -1355,129 +1308,6 @@ vm_fault_t finish_fault(struct vm_fault *vmf); * back into memory. */ =20 -/* 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 <=3D 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 =3D compound_head(page); - if (WARN_ON_ONCE(page_ref_count(page) <=3D 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); -} - -void folios_put_refs(struct folio_batch *folios, unsigned int *refs); - -/* - * 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. - * - * Like folio_put(), but for a batch 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. The folios batch is returned - * empty and ready to be reused for another batch; there is no need to - * reinitialise it. - * - * 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_batch *folios) -{ - folios_put_refs(folios, NULL); -} - -static inline void put_page(struct page *page) -{ - struct folio *folio =3D page_folio(page); - - /* - * For some devmap managed pages we need to catch refcount transition - * from 2 to 1: - */ - if (put_devmap_managed_folio_refs(folio, 1)) - return; - folio_put(folio); -} - /* * GUP_PIN_COUNTING_BIAS, and the associated functions that use it, overlo= ad * the page's refcount so that two separate items are tracked: the origina= l page diff --git a/include/linux/mm/folio_usage.h b/include/linux/mm/folio_usage.h new file mode 100644 index 000000000000..1cf11ca1f5ab --- /dev/null +++ b/include/linux/mm/folio_usage.h @@ -0,0 +1,182 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_USAGE_H +#define _LINUX_MM_FOLIO_USAGE_H + +#include // for put_devmap_managed_page() +#include // for VM_BUG_ON_PAGE() +#include // for struct folio +#include + +struct folio_batch; + +/* + * 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 u= sers) + */ +static inline int put_page_testzero(struct page *page) +{ + VM_BUG_ON_PAGE(page_ref_count(page) =3D=3D 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 <=3D 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 =3D compound_head(page); + if (WARN_ON_ONCE(page_ref_count(page) <=3D 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); +} + +void folios_put_refs(struct folio_batch *folios, unsigned int *refs); + +/* + * 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. + * + * Like folio_put(), but for a batch 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. The folios batch is returned + * empty and ready to be reused for another batch; there is no need to + * reinitialise it. + * + * 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_batch *folios) +{ + folios_put_refs(folios, NULL); +} + +static inline void put_page(struct page *page) +{ + struct folio *folio =3D page_folio(page); + + /* + * For some devmap managed pages we need to catch refcount transition + * from 2 to 1: + */ + if (put_devmap_managed_folio_refs(folio, 1)) + return; + folio_put(folio); +} + +#endif /* _LINUX_MM_FOLIO_USAGE_H */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 EE95B144D38 for ; Tue, 4 Jun 2024 09:09:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492163; cv=none; b=NqPLfFa2ZnQs+fj3vqoBPFX2Fok0uVaSAuh70RNKJtiTnn4QhYb+TPHKx915KyenWv1rongXzuxHry1XgBeg79jlvytjHPDQjwZqlBbxi3ywNwzsAsUELKhp9PUQjiqJeFwr6k0612PEY0qMXnFlXTIb/cwxBWmPeaBVSLZHk3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492163; c=relaxed/simple; bh=3Sz+Aj3CJQm/oV0JwgpIRYXzlurt8LpdkUahvJGjCqg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mRz4TaHGkpBBBJgKTA44qzJkneJJ2aw8e1PvzaT/sHHsKFnEC08PfTlwFNVNXu67Itgl8SGCy0KUvulLb0v9+qFpfoUHbp7DcUV0M5adHMmfQhe5AAhd83R/1/xylpWVySIf5DjqL9aIam6z2KHIn+vZQSK67UWU5XitkRqYPWo= 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=XxhLpnXo; arc=none smtp.client-ip=209.85.208.172 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="XxhLpnXo" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2eaad2c673fso31778691fa.3 for ; Tue, 04 Jun 2024 02:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492160; x=1718096960; 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=7a14+jXYXTjmg6E3qRGIvRJfYcGA2t0M1Ozzz17Ypyc=; b=XxhLpnXoPrNLG8bYixdzk8iipsGpkr2ELIViKvAuPJS8ouhGl2fZKKdB0eKvL6JTA1 hEBYOEg3+Bk6tL4gNsatTF5C2mymf5eMUbmlrcQBz6dPZeeUuvsWIK9E4TeaGFECNZUQ Ez/+NJklKMr7NhGTatmOxrN1jtKd2pgYOnjkBLu9l2DqfcNxu8BePTVEhJi/JxXH+e8M l8JkpH8PW5q0diCb/ROqwvN3zkQJiUYHU/BFZ6UX5qBLbpyVB4dsU3XdW6aQ7R7l5IE/ 7Dor0/w++oZJEhV5ABBU/Yb7TwTwFNV9J51L2iOAeCzu8L1V4CSulmpRZXAnDU3ps69m GjIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492160; x=1718096960; 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=7a14+jXYXTjmg6E3qRGIvRJfYcGA2t0M1Ozzz17Ypyc=; b=WSQL/9W7CMtAkps74K8ohBOrxb7rWQTNSlOnlt9KJI/TUnKR66oKwRwjoBP3XCPHAB GjJRkwW3rRcgSgkbsZu8tC6K3d0Ga0Ta5eiMKCjmt9OtEooBZP7s3gZE9Oo6y5JoP70m Wi5+jQ7O0cpdbCBN9/6QIac92+lDwwoIMHuJEkQXd0Smw+KEeIPz/lJ2KXzQL3s6isoM /wdeTHfsNL/rNN/u2dOwR7vXuXd+hgmiHppuk60e0vbyl4YtZik7jhCUWNWNt0Jo++r6 uT6+THHo4Z7yZthV5AiTzjeXZRflwk1EzSbx51Ufl765anmiHsRY+AVbh95E4mpc8jUR bT+w== X-Forwarded-Encrypted: i=1; AJvYcCWLTZZoPGSJ50MBG/CPgLeasCjMuJa6uWxVF7V8L92NB0bFLcZHdTdI2S2TBGcjHALS9QNm0KWsGWbhWS+73W0budBgRlSrf1R5B+An X-Gm-Message-State: AOJu0YzWAwOecX2mVVkvrUQMI9ADBGbMaApj+Ic+Iimgzogs5WMntFv2 YyNuPfCJ/bDr7dYs0/+YnoQ8BZtJoMVmAqfjIcdZ/MYQa18wrsJ9t4ua5JBVVZg= X-Google-Smtp-Source: AGHT+IHsJf4f3OBFK5S9RQgJe4xLIo0Z7mZgH0CJQAgenYk9ZH6OP2KgkT94QdNs7YGr5ClMSzJPQA== X-Received: by 2002:a2e:9d88:0:b0:2e1:9c57:195a with SMTP id 38308e7fff4ca-2ea951de27fmr93794341fa.32.1717492160177; Tue, 04 Jun 2024 02:09:20 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:19 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 11/15] linux/mm.h: move page_zone_id() and more to mm/folio_zone.h Date: Tue, 4 Jun 2024 11:08:41 +0200 Message-Id: <20240604090845.2182265-12-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is needed to eliminate linux/skbuff.h's dependency on linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 48 +----------------------------- include/linux/mm/folio_zone.h | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 47 deletions(-) create mode 100644 include/linux/mm/folio_zone.h diff --git a/include/linux/mm.h b/include/linux/mm.h index a32d284813f4..c026e58e3725 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -1369,33 +1370,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_= t flags) } #endif =20 -/* - * 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 -int page_to_nid(const struct page *page); -#else -static inline int page_to_nid(const struct page *page) -{ - return (PF_POISONED_CHECK(page)->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 @@ -1546,26 +1520,6 @@ static inline void vma_set_access_pid_bit(struct vm_= area_struct *vma) } #endif /* CONFIG_NUMA_BALANCING */ =20 -static inline struct zone *page_zone(const struct page *page) -{ - return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; -} - -static inline pg_data_t *page_pgdat(const struct page *page) -{ - return NODE_DATA(page_to_nid(page)); -} - -static inline struct zone *folio_zone(const struct folio *folio) -{ - return page_zone(&folio->page); -} - -static inline pg_data_t *folio_pgdat(const struct folio *folio) -{ - return page_pgdat(&folio->page); -} - /** * folio_pfn - Return the Page Frame Number of a folio. * @folio: The folio. diff --git a/include/linux/mm/folio_zone.h b/include/linux/mm/folio_zone.h new file mode 100644 index 000000000000..3f3e4284b911 --- /dev/null +++ b/include/linux/mm/folio_zone.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_ZONE_H +#define _LINUX_MM_FOLIO_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 +int page_to_nid(const struct page *page); +#else +static inline int page_to_nid(const struct page *page) +{ + return (PF_POISONED_CHECK(page)->flags >> NODES_PGSHIFT) & NODES_MASK; +} +#endif + +static inline int folio_nid(const struct folio *folio) +{ + return page_to_nid(&folio->page); +} + +static inline struct zone *page_zone(const struct page *page) +{ + return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; +} + +static inline pg_data_t *page_pgdat(const struct page *page) +{ + return NODE_DATA(page_to_nid(page)); +} + +static inline struct zone *folio_zone(const struct folio *folio) +{ + return page_zone(&folio->page); +} + +static inline pg_data_t *folio_pgdat(const struct folio *folio) +{ + return page_pgdat(&folio->page); +} + +#endif /* _LINUX_MM_FOLIO_ZONE_H */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 E5B0B143870 for ; Tue, 4 Jun 2024 09:09:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492165; cv=none; b=ekX84zIwZ9DXQreUqXTohkA7yZGrmHBKegEcd9jJ+BvxFbUmnPo1ODoco1YaN/HqNQbxZq6lCF03lhNexfW9XS0f8tBbVMNLfFFWTkihA1lkOYae6YFiEC7nz4G50WmtkxgQda/p/P8w9Edr3Zv6CVnmjzDBs6bp9z1HUqw7hjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492165; c=relaxed/simple; bh=E7omIAd4oioz178wbahLxCf/I00afQCoybuhoNDREsg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UiRkNrpO2KDYVX/grYJOMpkQfy8mo1QCb+79rkiJ5rrW/MSEALApuiBKyJBy8TPLtmmRoPE6I9B37Xg8FGvvwahBL/RuSDqx/LE5Le8ERTpgQFoSKaaBVwGDcJiQxwJELzjxGwE7/Tovak1JhsJrMGv/HornGZIUCqRClkb+VYY= 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=iizB5ryk; arc=none smtp.client-ip=209.85.208.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="iizB5ryk" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-57a1fe6392eso6069898a12.0 for ; Tue, 04 Jun 2024 02:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492161; x=1718096961; 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=66hU7JCzDxZkm1iV/ENOXsQE3QPWNxsFJw0nhpOp8E8=; b=iizB5ryk4QWnKCluE/rRqllcKR4DA6W90mXewvxC5i1XnoEgg6uOPKE/YRN4BOiNGm jz1DGQvo49Kdr0Ec4LaIzHbDrE9zh1DyPuhxN2Dud380bt4Zr+1kC2djlZsD3QUoE2Gf umLOMSfeRN3ASTsv2LPRL7tHeegNXwhlC/y534l1PNyyXhBiOuJh+fxaRg+N7QSikgai lK5vnvVjVsyXHLBKbidoeWnFsCQkN/UMDDh2v11mKKvYZD5298Mp9rELhvBFsRFh5vXK lGw9dHKFla0RuFfgk22FCOqTNclqwb888vJV8kW8eEE+7TxVPAqKVxSVkQOeyKhTLf53 4Nrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492161; x=1718096961; 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=66hU7JCzDxZkm1iV/ENOXsQE3QPWNxsFJw0nhpOp8E8=; b=u9zA0QnKsJzvRrcjK2c9YTiXHCA8SHUIeltTZYrw2rRnA/u2lMgeOWVBOlIAvxZxVW vHGE481/miVqNxLYP1fjEI/kxFBZn6RIY78WgwDPeLXSt5rBZG8XO6CEI+TmNugxq1qd WHREj/fUDIfO1F/rtkxI9fhUuUh2tthvXrHyOs8apLGQgiIzarFM3AQ6olGX8EAerkcb RXciLn5aJ6iBKx2z06xE2hZE+TGR3rTRudBTptSZSEs94QZLLLqVzeK9kzq8tqVb3vq+ rb5rXQLJb0afaaXzq/nn6DyPNbeIyQEOV9mOt0mr47JRg+ONFblegeqTzgfGyNgBrrSI sIvg== X-Forwarded-Encrypted: i=1; AJvYcCUlJlbOVDNyy0Mnzx31Yur7EbKgdsSO77fYfSI4+An8/O4FQyekPPmVliJb4YSTuE8noLM/VbdZEnG9lKQUDamskyh9jajPK8fdHtz5 X-Gm-Message-State: AOJu0Yww1CJ4NchR2nzsDL6y1GhkoDXZUJIRGzI4vBU+Z5obeLNz3C7/ PNzrAemAqKXcCDbn1OLXrSjHxlw14HiVCl/tQWSjyCNjqGyFCNN1Z+Yeru86YumxAxZwHa4VEh3 Mw/w= X-Google-Smtp-Source: AGHT+IFjlRq5i4sRiIz9ii8DICuiWwLZihtIRXZ77Dt4nvy+Gy+GZJvOZGsJ7ckHFkBdl+70Wt0aaw== X-Received: by 2002:a17:906:f585:b0:a68:f0ce:9f2e with SMTP id a640c23a62f3a-a68f0cea079mr465457066b.44.1717492161256; Tue, 04 Jun 2024 02:09:21 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:20 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 12/15] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h Date: Tue, 4 Jun 2024 11:08:42 +0200 Message-Id: <20240604090845.2182265-13-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is needed to eliminate linux/skbuff.h's dependency on 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 c026e58e3725..e178bda2525d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1772,50 +1773,6 @@ static inline int arch_make_folio_accessible(struct = folio *folio) */ #include =20 -/* - * 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 =3D (void *)BIT(1); -} - -static inline void clear_page_pfmemalloc(struct page *page) -{ - page->lru.next =3D 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 =3D (void *)BIT(1); +} + +static inline void clear_page_pfmemalloc(struct page *page) +{ + page->lru.next =3D NULL; +} + +#endif /* _LINUX_MM_PFMEMALLOC_H */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 B645F145348 for ; Tue, 4 Jun 2024 09:09:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492165; cv=none; b=ggh4jiE8EI2IAcN//0l88G4+IvKIm6hCufmemQoGYcYFoKMqLxfOJLoIfyBvsVbOwcCJz2VyK8FthFpQnIa7aps1uBSSN8Tp0VWeCWjtTq2hanSMuF/lBEHEGLqpnWBZCDvGuy/UsrPCOoSYsp2a5/gHC8mBTRbZQNft6XLgixE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492165; c=relaxed/simple; bh=dlTQMSRsIpZjRzOd2Rm/WzLiyJ/xHYiubGPGAJZf/Cs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QaLNFgLdbrHcCuenbhZB/Nm6omWPfdT1WOP40oNhuKXXU5LA8l4VoyvC7DPM5tEV7PUxT0C3UvZeun3iclAWtJ8dThB71IyGLjTlsqrMX/RDVpeNbKvztGXHW2uazJ/OdNOxVpGyrxsXp9CtOzf/7gZdccEWf7wGVCB+Btrx7xQ= 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=DFpQ9JUh; arc=none smtp.client-ip=209.85.218.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="DFpQ9JUh" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a6267778b3aso466698166b.3 for ; Tue, 04 Jun 2024 02:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492162; x=1718096962; 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=1o8h4WW2rkKyKPUI+a/gz6b5mzKTaMa0Q8zXDVfDCoM=; b=DFpQ9JUhBl0RMW0QGCUXj4K+RHRw1bbbX/B4wJiik5W1sFw4RQwnGk/Iw+tr6v5iue Qo3Fju+QTrvlEA4RsLCzuJ4T8XZ905S4sCGdRO4S3lW8iYbWvKhftBtm+voEDRhKjsmh UKY4QOWVqmx3dFmJlVTNHKnl/QVIy72QktpmgVj6nadHPQYlR81vj2q1iaWhm9CTFF8u 8XCwljG/dgtNquOPWVImWybnlyLJlDBpYOoxC2yeh0bEoUOK+wuS+4ONN5uWp2YmVm9y pfGZu/gn2DiFVZB6+U+5K46TfqXmIqqY/i6hNe3/843S0Pn+avShLZWu4Rvnzv3EuyTu vnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492162; x=1718096962; 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=1o8h4WW2rkKyKPUI+a/gz6b5mzKTaMa0Q8zXDVfDCoM=; b=VO0aX166hLEQjOHYqvgUfyBhAdy2867kFPZiIybjU77wOi9mcBN2L8GPJNGABs4jde JES7/o/pPa5nFkjvXBzcUVjv3Oh6rqFcFoIzNuosDOGEw+fQ7sN3HcEqhg2PChsyWIaF Lo/XxGFbj7RFTyKTNq2DwDqpahZQgI6lmSkKahrEInBljsjZXoNZ6zjrp8zIyUb+wS3G tMapSJF0+04192irUkoTs7tIrDeBWAHX1iIpcdPUQADEctzOv7kjEq7pXqscNa/xTg6o v8WpSNWKa07Ug4iDC8A07oplRGFwcWqjSUqqAsHMskKpZmT6SIw0DOYLj22+BKjwtqVZ fqDQ== X-Forwarded-Encrypted: i=1; AJvYcCVnoNEpKkdf98lqhB/xv8vThztvIzJnjic8PfsQmbd9ddtXnMYs8J+HCcsuSgAJi7l1iqnAHpCG+cdsKg5AvhaWYf+aPm2YD6RQSfJM X-Gm-Message-State: AOJu0YwE0pPTWpv8Ekon8IdfH6wF5yFBWi3UUEEgnH1ktOngHouw95Wx pZ851KclKAcZyRQP6/tQt3oxsrdWf2aNhNuFtvt3umebHOQcIgz2VYZI4Sj5+G0= X-Google-Smtp-Source: AGHT+IHcBCOnI/AP+4Gs+A9GVqIIvYfhFKwdpV9/+hIkLKh+cjnNIZ7LwpLVGv8+f7nFEA7iDEBeHg== X-Received: by 2002:a17:906:40d8:b0:a68:379d:d623 with SMTP id a640c23a62f3a-a68379dd799mr735700466b.36.1717492162204; Tue, 04 Jun 2024 02:09:22 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:21 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 13/15] linux/mm.h: move is_vmalloc_addr() to mm/vmalloc_addr.h Date: Tue, 4 Jun 2024 11:08:43 +0200 Message-Id: <20240604090845.2182265-14-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is needed to eliminate linux/dma-mapping.h's dependency on 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 e178bda2525d..6c9089adbb4e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1087,30 +1088,6 @@ enum { int region_intersects(resource_size_t offset, size_t size, unsigned long f= lags, unsigned long desc); =20 -/* 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_add= r.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 */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 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 93DB414533C for ; Tue, 4 Jun 2024 09:09:25 +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=1717492168; cv=none; b=mpYUG9yUNJYX1sQmQ7iOokmtu85haNuD6RggVjoxaYc0elAidxl8dgpwH4xCcr39r3w+tkSHLQB23CuwazsTfZmCsPFft4nfIKbjSWYw5Q/7GVYjtQ+L0c8VWTKOuRCsmRXPjVsL/g6ihQFaUuvb3lJLMs0Kihg9N3K2mLZMQXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492168; c=relaxed/simple; bh=qzo424Vk5rNxGD6BzmCZaZ2WBrZluiV/F8P4RMNJ0qI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CDRFM+dULP99/h6KkvCULuZ+5O/KV4EwfUx5gnNlpGKqFxDcZ3wtVFO0C3mgG2RiJ/AiGOojQ6U768OzF/7xMcvRAj/tlWl9YUp3UznOviby//JLtv+6o67YsqK/HQu4GKukfZ/4RTyOGGmcmtgArAfNGB/1UrPlQOPZHV4zggQ= 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=hlnEUBcy; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="hlnEUBcy" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a68f1017170so77482766b.0 for ; Tue, 04 Jun 2024 02:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492164; x=1718096964; 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=n3U0KL7w5U75JMn9WGwTfgeaFpYbfkGLETLiHeR3bJI=; b=hlnEUBcy+KP/tnIcd+B1HRDEX3CdAr5lMWPxpb/1I5fzfYCTKvaTKKgKV5xAFh0tnt A+vmIWNDVTSr17kHKxpgWsR52txSD1kCFQ/NAsc+Z3zhmkcvc3AmSKliGCSwClp6SVf8 fFeMGvlLBrgL3AHTTmayijVYQaR153Sbqeer84nQLoo/kXMVqJB6mDGcY1uU5rD8OpPy 53j7Y0WkZDgIoqS4ka3AC8sANe5HJU19ViHId82j1tuNtrZ/Ff57SrwJRGipbXl23GQ0 L9vLHZwXmENS6qAYd+nO87qpCRc1xzookqTWVKKrOFemZCj1jqurdtjFd6BqsdHST+Te Q8pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492164; x=1718096964; 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=n3U0KL7w5U75JMn9WGwTfgeaFpYbfkGLETLiHeR3bJI=; b=kaZUjAOAJBJs1boJMjX0pyFaku/nHFp1TnGluipz9YwP3VrhmyESRpKuQH874qqjGm Miq88w3t0gVBBHVOyDe1/A9wcUDOwf1u1BDS43S5zoptEMTfu/2ksB7pphTQo6ah89bR f7wpJ6+TSCqoUEaZ2Z8YDJNVgzXwm6e+ZP47SaPdTjqH1rWMOCLLEBPuVlV5jrIQ/Ws7 cY+aXPx1JJj0sEluFfrUveXag/32ZylE4CsinSYsjkV0B6V6q+Zct0rIBBm10clLYqIm McwvaBptVqq/WeCsK6npfkgL5UjpY4B/yXQaAUZJV63iJCyBYF7NYH76dTfZaEsBz5XQ sFiA== X-Forwarded-Encrypted: i=1; AJvYcCXmdQYflw5u3XK+LupLPL71/4wl1TrMnlKrjnw7QwlXc4LzCqjTS/qTkzBvZWXygO/ldQz6Fb/eEsJVIM3cXEGxoBtfpWT+yAyQxXtc X-Gm-Message-State: AOJu0Ywj5YcUnjB2kONqpqqTsbn2r+6m1QeUXmtw6MxlhBGRYYgrQMw0 GwfQfSMvqaIhpVb5Uu+DVMRPjnkUgw1DatlXCb5xOvRn68CemrG4QPDcqQDw+CA= X-Google-Smtp-Source: AGHT+IEufjYupL5V5fjGHiqCyxBU1VmyGKHrnjXAzODktOVBv2dBJp+P8PCQHm8Bv1pzw0q+GjsDJg== X-Received: by 2002:a17:906:c4ca:b0:a68:3bf0:79eb with SMTP id a640c23a62f3a-a683c10d453mr547303066b.47.1717492164227; Tue, 04 Jun 2024 02:09:24 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:22 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 14/15] linux/mm.h: move high_memory to mm/high_memory.h Date: Tue, 4 Jun 2024 11:08:44 +0200 Message-Id: <20240604090845.2182265-15-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 ++++ drivers/mtd/nand/onenand/onenand_samsung.c | 1 + include/linux/mm.h | 2 +- include/linux/mm/high_memory.h | 7 +++++++ 15 files changed, 34 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 l= ong x) */ #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET =20 +#ifndef __ASSEMBLY__ +#include +#endif + #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) #define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >=3D 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 =20 #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 0ca6c408c07f..17ccc91c3cd6 100644 --- a/arch/csky/include/asm/page.h +++ b/arch/csky/include/asm/page.h @@ -32,6 +32,7 @@ =20 #ifndef __ASSEMBLY__ =20 +#include #include =20 #define virt_addr_valid(kaddr) ((void *)(kaddr) >=3D (void *)PAGE_OFFSET = && \ diff --git a/arch/hexagon/include/asm/mem-layout.h b/arch/hexagon/include/a= sm/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 @@ =20 #include =20 +#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_m= m.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__ =20 #include +#include #include =20 /* diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgt= able_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 @@ =20 #ifndef __ASSEMBLY__ #include +#include #include #include =20 diff --git a/arch/parisc/include/asm/floppy.h b/arch/parisc/include/asm/flo= ppy.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 =20 +#include #include =20 =20 diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/in= clude/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 @@ =20 #include =20 +#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/in= clude/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 =20 #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/pag= e.h index e411e5a70ea3..9ae87fc2c648 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -7,6 +7,7 @@ */ =20 #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 =20 +#include #include =20 /* 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 @@ =20 #include =20 +#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/drivers/mtd/nand/onenand/onenand_samsung.c b/drivers/mtd/nand/= onenand/onenand_samsung.c index fd6890a03d55..7c3cc270386d 100644 --- a/drivers/mtd/nand/onenand/onenand_samsung.c +++ b/drivers/mtd/nand/onenand/onenand_samsung.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/include/linux/mm.h b/include/linux/mm.h index 6c9089adbb4e..83613e9297b5 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -83,7 +84,6 @@ static inline void totalram_pages_add(long count) atomic_long_add(count, &_totalram_pages); } =20 -extern void * high_memory; extern int page_cluster; extern const int page_cluster_max; =20 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 */ --=20 2.39.2 From nobody Thu Dec 18 07:20:54 2025 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 F02BD145A14 for ; Tue, 4 Jun 2024 09:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492169; cv=none; b=kK4p++bSl/BCD/iHhTkQASVq9giBIHdMjwd6MJW7nX6lCn/VFe6X8LMObbIhx9zsVrAd3unbhv+2Del8iEfKVmscFFpmffdVLwENypaqmit122COlV+63wWrZdiD4Byyq6b8VMJKz8Pp/IFv8YVW9n1//VEcKDH1wLFy0fMW08U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717492169; c=relaxed/simple; bh=HD/XTIQjEizEu0O4MOPQDcGyqhajbjK+uDvPpK4p2jo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SsqlqXQrfN9GE9iyIn8BcRc77N9tnLCJ+2+5OVi4YvtEMv6bH7qjYRna3TnW07noO37T6n4YJL0yWpddUsJb8CH0D8bBGxVR1lzyWG/90c94USwh6XSDv/aPlxbPjsacyjKHHloMT8PzKIFZ/SkjXX3KKsDEKJeq8swsHk82rPM= 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=dmwAWrFv; arc=none smtp.client-ip=209.85.208.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="dmwAWrFv" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-57a7dc13aabso850991a12.0 for ; Tue, 04 Jun 2024 02:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492165; x=1718096965; 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=i89wEAwGLV+FFt8LVEfujtav/wRlt8aIRY/CjDWyxYI=; b=dmwAWrFvkCM29wyBVVBcY6ITOhiCvnXkhdkN8fMYSQoSPlik7Sai9Vd8rrxy/FrnHV m3VrLVGlqFzGRj8PTJggPT7QDSurjqMXgla0/Fq4JJZrzT+V6TK8s0ze7PsAaopsqzwI GXLG0/rYizSaOZ4lsefcNpg7mXtY5LigBC/XJTvl2nM5qNgV08yOOzTdb01fEIMjV6Hj hQLE6SnzMdk87WMpazTU1b7RxOzN9kL7QIrFHA35HPDDfwa8dLe2N7BzqONtlEWC5VhU 8p/QWK366aGz36tYgONqgYvpIm5XEgtN+VwKfC0dXMyZiWXyMj8C/RFeYDdBHohQyb+i WtGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492165; x=1718096965; 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=i89wEAwGLV+FFt8LVEfujtav/wRlt8aIRY/CjDWyxYI=; b=X7R7zvMQ1ov+/48uldsMAxpN9ZqGCwoH8VlcV9d0ASxQ1H93ipUwOqfNI1THMGEZuA vJUAOlCDzANRv2JpSBVmhq+5+HFdKKTqrThiJnBN3iEbR300mSZvlmYY+8KT447AHcJo Ix/HhmeT42s6d70SjRCj5XHPLMWMjAD5qNkroWw1kvO2PDYUKUy4RBA+9vzaBmEm7KS+ SRs2eWmeow4ssk0s32hK9X98rNxeyIit9WjRHyBbOqq3Sc5ho8eP1snv/mF5FX4uPguT fc6kyXaVbUQLLx2oWU66Sp5Fi2iyZtPaGSIuVZrNHKvFZNVRPg8I+Fbizse1hg/wacuM CnAA== X-Forwarded-Encrypted: i=1; AJvYcCWmpSfjoSWSr7OOkOY1p4KfpS9ljcjz3z+fm/hpkozmUZXItSE0cIcH1x6tY4W2mK9sO6bVOhvTzI1XA0SuCLLhWTAAaanhFRTL1jSi X-Gm-Message-State: AOJu0YzmOkpxWgb2Oxi7wGro7TgP2XCZbcdHKqY+OK+69C1CDzewNuod z1vhwPGD3D2V8oIfXL9aUgzeJeCScEDB0ZPN016pdGeLcQiNlHu3739xoO0mr/s= X-Google-Smtp-Source: AGHT+IEEQrB10Ia4g3WkoPKh5/jpdFJJpYBOp5KDOiMCUB9VjtT3LFxj+J1ilVV1yreFVtWqt8rEuw== X-Received: by 2002:a17:907:970e:b0:a69:228:8a6e with SMTP id a640c23a62f3a-a690228939dmr414530066b.44.1717492165278; Tue, 04 Jun 2024 02:09:25 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:24 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 15/15] include: reduce dependencies on linux/mm.h Date: Tue, 4 Jun 2024 11:08:45 +0200 Message-Id: <20240604090845.2182265-16-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/bpfptr.h | 1 - include/linux/dma-mapping.h | 1 + include/linux/highmem-internal.h | 2 ++ include/linux/highmem.h | 4 +++- include/linux/net.h | 2 +- include/linux/oom.h | 2 +- include/linux/pagemap.h | 2 +- include/linux/scatterlist.h | 2 +- include/linux/skbuff.h | 4 ++++ include/linux/vmstat.h | 3 ++- lib/scatterlist.c | 1 + 12 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index d5379548d684..ddb0c831557b 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -5,7 +5,9 @@ #ifndef __LINUX_BIO_H #define __LINUX_BIO_H =20 +#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/bpfptr.h b/include/linux/bpfptr.h index 1af241525a17..19967a0e510c 100644 --- a/include/linux/bpfptr.h +++ b/include/linux/bpfptr.h @@ -3,7 +3,6 @@ #ifndef _LINUX_BPFPTR_H #define _LINUX_BPFPTR_H =20 -#include #include =20 typedef sockptr_t bpfptr_t; diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index f693aafe221f..5a66ade2ddf8 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -11,6 +11,7 @@ #include #include #include +#include =20 /** * List of possible attributes associated with a DMA mapping. The semantics diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-inter= nal.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 =20 +#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..10a165a913ad 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -7,7 +7,9 @@ #include #include #include -#include +#include // for page_size() +#include // for folio_put() +#include #include #include =20 diff --git a/include/linux/net.h b/include/linux/net.h index 688320b79fcc..481fd7e831af 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include // for page_count() #include =20 #include diff --git a/include/linux/oom.h b/include/linux/oom.h index 7d0c9c48a0c5..518426e092d0 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h @@ -8,7 +8,7 @@ #include #include #include /* MMF_* */ -#include /* VM_FAULT* */ +#include /* VM_FAULT* */ =20 struct zonelist; struct notifier_block; diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 8f09ed4a4451..43e233c998d2 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -5,7 +5,7 @@ /* * Copyright 1995 Linus Torvalds */ -#include +#include #include #include #include diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 0516e64dc03e..9221bba82b23 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include =20 #ifdef CONFIG_UML diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index fe7d8dbef77e..09d020d5a6f4 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 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 67c2505d3b78..b9ad7fa932e0 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -4,7 +4,8 @@ =20 #include #include -#include // for folio_zone(), folio_nr_pages() +#include // for folio_nr_pages() +#include // for folio_zone() #include #include #include diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 7bc2220fea80..775bad99fcd9 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include =20 --=20 2.39.2