summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Stoakes <ljs@kernel.org>2026-07-10 21:17:11 +0100
committerAndrew Morton <akpm@linux-foundation.org>2026-08-04 19:19:04 -0700
commitdd7d7d00c073b742922ae1a82c7bd2f3a27b4140 (patch)
tree85c0ee00291cc03dc7d71391478820f6c1184e09
parent613562c29fa69840f9a6239f1c3e0c24270a795d (diff)
downloadlinux-dd7d7d00c073b742922ae1a82c7bd2f3a27b4140.tar.gz
linux-dd7d7d00c073b742922ae1a82c7bd2f3a27b4140.zip
mm/vma: correct incorrect vma.h inclusion
The only files which should be including vma.h are the implementation files for the core VMA logic - vma.c, vma_init.c, and vma_exec.c. This is in order to allow for userland testing of core VMA logic. In this cases, vma_internal.h and vma.h are included, providing both the dependencies upon which the core VMA logic requires and its declarations. Userland testable VMA logic is achieved by having separate vma_internal.h implementations for userland and kernel. Callers other than the core VMA implementation should include internal.h instead. This header does not need to include vma_internal.h as it only contains the vma.h declarations, for which the includes already present suffice. Update code to reflect this, update comments to reflect the fact there are 3 VMA implementation files and document things more clearly. While we're here, slightly improve the language of the comment describing vma_exec.c. No functional change intended. Link: https://lore.kernel.org/20260710-b4-pre-scalable-cow-v2-30-2a5aa403d977@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Reviewed-by: Gregory Price <gourry@gourry.net> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Ackerley Tng <ackerleytng@google.com> Cc: David Hildenbrand (Arm) <david@kernel.org> Cc: Kai Huang <kai.huang@intel.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: SJ Park <sj@kernel.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Liam R. Howlett (Oracle) <liam@infradead.org> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--mm/mmu_notifier.c2
-rw-r--r--mm/nommu.c1
-rw-r--r--mm/vma.c4
-rw-r--r--mm/vma.h9
-rw-r--r--mm/vma_exec.c8
-rw-r--r--mm/vma_init.c4
-rw-r--r--mm/vma_internal.h4
7 files changed, 25 insertions, 7 deletions
diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
index 245b74f39f91..df69ba6e797f 100644
--- a/mm/mmu_notifier.c
+++ b/mm/mmu_notifier.c
@@ -19,7 +19,7 @@
#include <linux/sched/mm.h>
#include <linux/slab.h>
-#include "vma.h"
+#include "internal.h"
/* global SRCU for all MMs */
DEFINE_STATIC_SRCU(srcu);
diff --git a/mm/nommu.c b/mm/nommu.c
index 82556301b356..a7da5ec21f42 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -41,7 +41,6 @@
#include <asm/tlbflush.h>
#include <asm/mmu_context.h>
#include "internal.h"
-#include "vma.h"
unsigned long highest_memmap_pfn;
int heap_stack_gap = 0;
diff --git a/mm/vma.c b/mm/vma.c
index c253c5498359..d74a8ae16bfa 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -4,6 +4,10 @@
* VMA-specific functions.
*/
+/*
+ * To allow for userland testing we place internal dependencies in
+ * vma_internal.h and external VMA API declarations in vma.h.
+ */
#include "vma_internal.h"
#include "vma.h"
diff --git a/mm/vma.h b/mm/vma.h
index 58f48609ce22..adb7a0ba1192 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -2,7 +2,14 @@
/*
* vma.h
*
- * Core VMA manipulation API implemented in vma.c.
+ * Core VMA manipulation API implemented in vma.c, vma_init.c and vma_exec.c.
+ *
+ * Note that, in order for VMA logic to be userland testable, this header
+ * intentionally includes no dependencies.
+ *
+ * This is specifically scoped to mm-only. Users of this functionality (other
+ * than the core VMA implementation itself) should not include this header
+ * directly, but rather include internal.h.
*/
#ifndef __MM_VMA_H
#define __MM_VMA_H
diff --git a/mm/vma_exec.c b/mm/vma_exec.c
index 13a05e041195..ef1fa2b161f3 100644
--- a/mm/vma_exec.c
+++ b/mm/vma_exec.c
@@ -1,10 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * Functions explicitly implemented for exec functionality which however are
- * explicitly VMA-only logic.
+ * Functions provided for exec functionality which however are
+ * specifically VMA-only logic.
*/
+/*
+ * To allow for userland testing we place internal dependencies in
+ * vma_internal.h and external VMA API declarations in vma.h.
+ */
#include "vma_internal.h"
#include "vma.h"
diff --git a/mm/vma_init.c b/mm/vma_init.c
index a459669a1654..715feee283f0 100644
--- a/mm/vma_init.c
+++ b/mm/vma_init.c
@@ -5,6 +5,10 @@
* between CONFIG_MMU and non-CONFIG_MMU kernel configurations.
*/
+/*
+ * To allow for userland testing we place internal dependencies in
+ * vma_internal.h and external VMA API declarations in vma.h.
+ */
#include "vma_internal.h"
#include "vma.h"
diff --git a/mm/vma_internal.h b/mm/vma_internal.h
index 2da6d224c1a8..4d300e7bbaf4 100644
--- a/mm/vma_internal.h
+++ b/mm/vma_internal.h
@@ -2,8 +2,8 @@
/*
* vma_internal.h
*
- * Headers required by vma.c, which can be substituted accordingly when testing
- * VMA functionality.
+ * Headers required by vma.c, vma_init.c and vma_exec.c, which can be
+ * substituted accordingly when testing VMA functionality.
*/
#ifndef __MM_VMA_INTERNAL_H