Skip to contentSkip to conversation

mm: move anon_vma declarations to linux/mm_inline.h

PATCH New Arnd Bergmann 1 participant 2 messages Dec 7, 2021

Subsystems (14)
Memory management x86 VFS MM core +10 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 mm: move anon_vma declarations to linux/mm_inline.h

From: Arnd Bergmann <[email protected]>

The patch to add anonymous vma names causes a build failure in some configurations:

include/linux/mm_types.h: In function 'is_same_vma_anon_name':
include/linux/mm_types.h:924:37: error: implicit declaration of function 'strcmp' [-Werror=implicit-function-declaration]
924 | return name && vma_name && !strcmp(name, vma_name);
| ^~~~~~
include/linux/mm_types.h:22:1: note: 'strcmp' is defined in header '<string.h>'; did you forget to '#include <string.h>'?

This should not really be part of linux/mm_types.h in the first place, as that header is meant to only contain structure defintions and need a minimum set of indirect includes itself. While the header clearly includes more than it should at this point, let's not make it worse by including string.h as well, which would pull in the expensive (compile-speed wise) fortify-string logic.

Move the new functions into a separate header that only needs to be included in a couple of locations.

Fixes 52f545eb6dd7 ("mm: add a field to store names for private anonymous memory")
---
 fs/proc/task_mmu.c        |  1 +
 fs/userfaultfd.c          |  1 +
 include/linux/mm_inline.h | 50 +++++++++++++++++++++++++++++++++++++++
 include/linux/mm_types.h  | 48 -------------------------------------
 kernel/fork.c             |  1 +
 mm/madvise.c              |  1 +
 mm/mmap.c                 |  1 +
 7 files changed, 55 insertions(+), 48 deletions(-)
fs/proc/task_mmu.c +1 -0
index e6998652fd67..18f8c3acbb85 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/pagewalk.h>
 #include <linux/vmacache.h>
+#include <linux/mm_inline.h>
 #include <linux/hugetlb.h>
 #include <linux/huge_mm.h>
 #include <linux/mount.h>
fs/userfaultfd.c +1 -0
index 5b2af7b82776..e26b10132d47 100644
@@ -15,6 +15,7 @@
 #include <linux/sched/signal.h>
 #include <linux/sched/mm.h>
 #include <linux/mm.h>
+#include <linux/mm_inline.h>
 #include <linux/mmu_notifier.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
include/linux/mm_inline.h +50 -0

60 lines not on this page · raw message

include/linux/mm_types.h +0 -48

52 lines not on this page · raw message

kernel/fork.c +1 -0
index 7c06be0ca31b..1c989cc4208a 100644
@@ -42,6 +42,7 @@
 #include <linux/mmu_notifier.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
+#include <linux/mm_inline.h>
 #include <linux/vmacache.h>
 #include <linux/nsproxy.h>
 #include <linux/capability.h>
mm/madvise.c +1 -0
index c63aacbbfa78..5604064df464 100644
@@ -18,6 +18,7 @@
 #include <linux/fadvise.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
+#include <linux/mm_inline.h>
 #include <linux/string.h>
 #include <linux/uio.h>
 #include <linux/ksm.h>
mm/mmap.c +1 -0
index 6ea9e6775fa3..3f48d0928e6b 100644
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/backing-dev.h>
 #include <linux/mm.h>
+#include <linux/mm_inline.h>
 #include <linux/vmacache.h>
 #include <linux/shm.h>
 #include <linux/mman.h>
Signature · 1 line
2.29.2
#1 lore raw

PATCH 2/2 mm: move tlb_flush_pending inline helpers to mm_inline.h

From: Arnd Bergmann <[email protected]>

linux/mm_types.h should only define structure definitions, to make it cheap to include elsewhere. The atomic_t helper function definitions are particularly large, so it's better to move the helpers using those into the existing linux/mm_inline.h and only include that where needed.

As a follow-up, we may want to go through all the indirect includes in mm_types.h and reduce them as much as possible.

---
Bonus patch: unlike the previous one, this does not fix an urgent bug, but rather cleans up the code along the same lines, preparing for possible follow-up patches

---
 arch/x86/include/asm/pgtable.h |   2 +-
 include/linux/mm.h             |  45 ------------
 include/linux/mm_inline.h      |  86 ++++++++++++++++++++++
 include/linux/mm_types.h       | 129 ++++++++++++---------------------
 mm/ksm.c                       |   1 +
 mm/mapping_dirty_helpers.c     |   1 +
 mm/memory.c                    |   1 +
 mm/mmu_gather.c                |   1 +
 mm/pgtable-generic.c           |   1 +
 9 files changed, 137 insertions(+), 130 deletions(-)
arch/x86/include/asm/pgtable.h +1 -1
index ae34614b7e8d..d7d287ac1018 100644
@@ -753,7 +753,7 @@ static inline bool pte_accessible(struct mm_struct *mm, pte_t a)
 		return true;
 
 	if ((pte_flags(a) & _PAGE_PROTNONE) &&
-			mm_tlb_flush_pending(mm))
+			atomic_read(&mm->tlb_flush_pending))
 		return true;
 
 	return false;
include/linux/mm.h +0 -45

51 lines not on this page · raw message

include/linux/mm_inline.h +86 -0

96 lines not on this page · raw message

include/linux/mm_types.h +45 -84

139 lines not on this page · raw message

mm/ksm.c +1 -0
index 4ce462dd31a4..c20bd4d9a0d9 100644
@@ -15,6 +15,7 @@
 
 #include <linux/errno.h>
 #include <linux/mm.h>
+#include <linux/mm_inline.h>
 #include <linux/fs.h>
 #include <linux/mman.h>
 #include <linux/sched.h>
mm/mapping_dirty_helpers.c +1 -0
index ea734f248fce..1b0ab8fcfd8b 100644
@@ -3,6 +3,7 @@
 #include <linux/hugetlb.h>
 #include <linux/bitops.h>
 #include <linux/mmu_notifier.h>
+#include <linux/mm_inline.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
mm/memory.c +1 -0
index ced3274c3deb..674b3751965f 100644
@@ -41,6 +41,7 @@
 
 #include <linux/kernel_stat.h>
 #include <linux/mm.h>
+#include <linux/mm_inline.h>
 #include <linux/sched/mm.h>
 #include <linux/sched/coredump.h>
 #include <linux/sched/numa_balancing.h>
mm/mmu_gather.c +1 -0
index 1b9837419bf9..afb7185ffdc4 100644
@@ -3,6 +3,7 @@
 #include <linux/kernel.h>
 #include <linux/mmdebug.h>
 #include <linux/mm_types.h>
+#include <linux/mm_inline.h>
 #include <linux/pagemap.h>
 #include <linux/rcupdate.h>
 #include <linux/smp.h>
mm/pgtable-generic.c +1 -0
index 4e640baf9794..6523fda274e5 100644
@@ -10,6 +10,7 @@
 #include <linux/pagemap.h>
 #include <linux/hugetlb.h>
 #include <linux/pgtable.h>
+#include <linux/mm_inline.h>
 #include <asm/tlb.h>
 
 /*
Signature · 1 line
2.29.2