[PATCH v1 14/14] include: reduce dependencies on linux/mm.h

From: Max Kellermann
Date: Thu Feb 15 2024 - 10:00:01 EST


Replace <linux/mm.h> 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 <linux/mm.h>
header.

For this, several missing includes need to be added because they are
no longer indirectly included, e.g. <linux/fs.h>.

Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
---
include/linux/bio.h | 2 ++
include/linux/dma-mapping.h | 1 +
include/linux/highmem-internal.h | 2 ++
include/linux/highmem.h | 4 +++-
include/linux/scatterlist.h | 2 +-
include/linux/skbuff.h | 4 ++++
6 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/linux/bio.h b/include/linux/bio.h
index 875d792bffff..e2f24d7235d3 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -5,7 +5,9 @@
#ifndef __LINUX_BIO_H
#define __LINUX_BIO_H

+#include <linux/fs.h> // for struct kiocb, IOCB_NOWAIT
#include <linux/mempool.h>
+#include <linux/mm/folio_next.h>
/* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
#include <linux/blk_types.h>
#include <linux/uio.h>
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 4a658de44ee9..37d5591039c7 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -11,6 +11,7 @@
#include <linux/scatterlist.h>
#include <linux/bug.h>
#include <linux/mem_encrypt.h>
+#include <linux/mm/vmalloc_addr.h>

/**
* List of possible attributes associated with a DMA mapping. The semantics
diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
index a3028e400a9c..a479e6b7c54c 100644
--- a/include/linux/highmem-internal.h
+++ b/include/linux/highmem-internal.h
@@ -2,6 +2,8 @@
#ifndef _LINUX_HIGHMEM_INTERNAL_H
#define _LINUX_HIGHMEM_INTERNAL_H

+#include <linux/mm/page_address.h>
+
/*
* Outside of CONFIG_HIGHMEM to support X86 32bit iomap_atomic() cruft.
*/
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 00341b56d291..b9dd5dd915c3 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -7,7 +7,9 @@
#include <linux/bug.h>
#include <linux/cacheflush.h>
#include <linux/kmsan.h>
-#include <linux/mm.h>
+#include <linux/mm/page_address.h>
+#include <linux/mm/page_size.h>
+#include <linux/mm/page_usage.h> // for folio_put()
#include <linux/uaccess.h>
#include <linux/hardirq.h>

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 77df3d7b18a6..d55cfcde1b09 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -5,7 +5,7 @@
#include <linux/string.h>
#include <linux/types.h>
#include <linux/bug.h>
-#include <linux/mm.h>
+#include <linux/mm/page_address.h>
#include <asm/io.h>

struct scatterlist {
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 696e7680656f..5bd89f0f7e7e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -16,6 +16,10 @@
#include <linux/bug.h>
#include <linux/bvec.h>
#include <linux/cache.h>
+#include <linux/gfp.h> // for alloc_pages_node()
+#include <linux/mm/page_usage.h> // for get_page(), put_page()
+#include <linux/mm/page_zone.h> // for page_to_nid()
+#include <linux/mm/pfmemalloc.h> // for page_is_pfmemalloc()
#include <linux/rbtree.h>
#include <linux/socket.h>
#include <linux/refcount.h>
--
2.39.2