2024-02-15 15:30:37

by Max Kellermann

[permalink] [raw]
Subject: [PATCH v1 00/14] Fast kernel headers: split linux/mm.h

This patch set aims to clean up the linux/mm.h header and reduce
dependencies on it by moving parts out.

The goal was to eliminate dependencies on linux/mm.h from other
popular headers such as highmem.h and dma-mapping.h, and I started by
checking which symbols were really used and moved those declarations
to separate slim headers.

Max Kellermann (14):
drivers: add missing includes on linux/mm.h (and others)
include/drm/drm_gem.h: add poll_table_struct forward declaration
linux/mm.h: move page_kasan_tag() to mm/page_kasan_tag.h
linux/mm.h: move section functions to mm/page_section.h
linux/mm.h: move page_address() and others to mm/page_address.h
linux/mm.h: move page_size() to mm/page_size.h
linux/mm.h: move folio_next() to mm/folio_next.h
linux/mm.h: move devmap-related declarations to mm/devmap_managed.h
linux/mm.h: move usage count functions to mm/page_usage.h
linux/mm.h: move page_zone_id() and more to mm/page_zone.h
linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h
linux/mm.h: move is_vmalloc_addr() to mm/vmalloc_addr.h
linux/mm.h: move high_memory to mm/high_memory.h
include: reduce dependencies on linux/mm.h

MAINTAINERS | 1 +
arch/arm/include/asm/memory.h | 4 +
arch/arm/include/asm/pgtable.h | 2 +
arch/arm/mm/iomap.c | 3 +
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 +
.../qat/qat_common/adf_gen4_pm_debugfs.c | 1 +
drivers/dma/dma-axi-dmac.c | 1 +
drivers/dma/sh/rcar-dmac.c | 1 +
drivers/firmware/qcom/qcom_scm-legacy.c | 1 +
drivers/firmware/qcom/qcom_scm-smc.c | 1 +
drivers/firmware/raspberrypi.c | 1 +
drivers/iio/buffer/industrialio-buffer-dma.c | 1 +
drivers/iommu/iommufd/selftest.c | 1 +
drivers/media/platform/mediatek/vpu/mtk_vpu.c | 1 +
drivers/media/platform/ti/omap/omap_voutlib.c | 1 +
drivers/misc/bcm-vk/bcm_vk_dev.c | 1 +
drivers/misc/fastrpc.c | 1 +
drivers/misc/genwqe/card_dev.c | 1 +
drivers/misc/uacce/uacce.c | 1 +
drivers/pci/p2pdma.c | 1 +
drivers/pci/pci.c | 1 +
drivers/remoteproc/remoteproc_core.c | 1 +
drivers/soc/qcom/rmtfs_mem.c | 1 +
drivers/spi/spi-bcm2835.c | 2 +
drivers/spi/spi-intel.c | 1 +
drivers/virtio/virtio_ring.c | 1 +
include/drm/drm_file.h | 1 +
include/linux/bio.h | 2 +
include/linux/dma-mapping.h | 1 +
include/linux/highmem-internal.h | 2 +
include/linux/highmem.h | 4 +-
include/linux/iommu.h | 1 +
include/linux/mm.h | 582 +-----------------
include/linux/mm/devmap_managed.h | 37 ++
include/linux/mm/folio_next.h | 27 +
include/linux/mm/high_memory.h | 7 +
include/linux/mm/page_address.h | 71 +++
include/linux/mm/page_kasan_tag.h | 66 ++
include/linux/mm/page_section.h | 23 +
include/linux/mm/page_size.h | 150 +++++
include/linux/mm/page_usage.h | 177 ++++++
include/linux/mm/page_zone.h | 38 ++
include/linux/mm/pfmemalloc.h | 52 ++
include/linux/mm/vmalloc_addr.h | 33 +
include/linux/nvme-keyring.h | 2 +
include/linux/scatterlist.h | 2 +-
include/linux/skbuff.h | 4 +
kernel/dma/ops_helpers.c | 1 +
kernel/dma/remap.c | 1 +
mm/dmapool.c | 1 +
59 files changed, 761 insertions(+), 575 deletions(-)
create mode 100644 include/linux/mm/devmap_managed.h
create mode 100644 include/linux/mm/folio_next.h
create mode 100644 include/linux/mm/high_memory.h
create mode 100644 include/linux/mm/page_address.h
create mode 100644 include/linux/mm/page_kasan_tag.h
create mode 100644 include/linux/mm/page_section.h
create mode 100644 include/linux/mm/page_size.h
create mode 100644 include/linux/mm/page_usage.h
create mode 100644 include/linux/mm/page_zone.h
create mode 100644 include/linux/mm/pfmemalloc.h
create mode 100644 include/linux/mm/vmalloc_addr.h

--
2.39.2



2024-02-15 15:32:59

by Max Kellermann

[permalink] [raw]
Subject: [PATCH v1 12/14] linux/mm.h: move is_vmalloc_addr() to mm/vmalloc_addr.h

Prepare to reduce dependencies in linux/mm.h.

Signed-off-by: Max Kellermann <[email protected]>
---
include/linux/mm.h | 25 +------------------------
include/linux/mm/vmalloc_addr.h | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 24 deletions(-)
create mode 100644 include/linux/mm/vmalloc_addr.h

diff --git a/include/linux/mm.h b/include/linux/mm.h
index c7e53cd0cdd0..d4624940923f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -9,6 +9,7 @@
#include <linux/mm/page_usage.h>
#include <linux/mm/page_zone.h>
#include <linux/mm/pfmemalloc.h>
+#include <linux/mm/vmalloc_addr.h>
#include <linux/errno.h>
#include <linux/mmdebug.h>
#include <linux/gfp.h>
@@ -1067,30 +1068,6 @@ enum {
int region_intersects(resource_size_t offset, size_t size, unsigned long flags,
unsigned long desc);

-/* Support for virtually mapped pages */
-struct page *vmalloc_to_page(const void *addr);
-unsigned long vmalloc_to_pfn(const void *addr);
-
-/*
- * Determine if an address is within the vmalloc range
- *
- * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there
- * is no special casing required.
- */
-#ifdef CONFIG_MMU
-extern bool is_vmalloc_addr(const void *x);
-extern int is_vmalloc_or_module_addr(const void *x);
-#else
-static inline bool is_vmalloc_addr(const void *x)
-{
- return false;
-}
-static inline int is_vmalloc_or_module_addr(const void *x)
-{
- return 0;
-}
-#endif
-
/*
* How many times the entire folio is mapped as a single unit (eg by a
* PMD or PUD entry). This is probably not what you want, except for
diff --git a/include/linux/mm/vmalloc_addr.h b/include/linux/mm/vmalloc_addr.h
new file mode 100644
index 000000000000..86ad2dc94960
--- /dev/null
+++ b/include/linux/mm/vmalloc_addr.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_MM_VMALLOC_ADDR_H
+#define _LINUX_MM_VMALLOC_ADDR_H
+
+#include <linux/types.h> // 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 */
--
2.39.2