Skip to contentSkip to conversation

mm: split out anon_vma declarations to separate header

PATCH In review Arnd Bergmann 3 participants 3 messages Dec 4, 2021

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: split out anon_vma declarations to separate header

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 to a separate header that is only included where necessary to avoid bloating linux/mm_types.h further.

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/anon_vma.h | 55 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mm_types.h | 48 -----------------------------------
 kernel/fork.c            |  1 +
 mm/madvise.c             |  1 +
 mm/mempolicy.c           |  1 +
 mm/mlock.c               |  1 +
 mm/mmap.c                |  1 +
 mm/mprotect.c            |  1 +
 10 files changed, 63 insertions(+), 48 deletions(-)
 create mode 100644 include/linux/anon_vma.h
fs/proc/task_mmu.c +1 -0
index e6998652fd67..5b0106afa870 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/pagewalk.h>
 #include <linux/vmacache.h>
+#include <linux/anon_vma.h>
 #include <linux/hugetlb.h>
 #include <linux/huge_mm.h>
 #include <linux/mount.h>
fs/userfaultfd.c +1 -0
index 5b2af7b82776..f1d9265e8581 100644
@@ -15,6 +15,7 @@
 #include <linux/sched/signal.h>
 #include <linux/sched/mm.h>
 #include <linux/mm.h>
+#include <linux/anon_vma.h>
 #include <linux/mmu_notifier.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
include/linux/anon_vma.h new file +55 -0

55 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..8964e1559722 100644
@@ -42,6 +42,7 @@
 #include <linux/mmu_notifier.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
+#include <linux/anon_vma.h>
 #include <linux/vmacache.h>
 #include <linux/nsproxy.h>
 #include <linux/capability.h>
mm/madvise.c +1 -0
index c63aacbbfa78..4d0ab22b31c0 100644
@@ -18,6 +18,7 @@
 #include <linux/fadvise.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
+#include <linux/anon_vma.h>
 #include <linux/string.h>
 #include <linux/uio.h>
 #include <linux/ksm.h>
mm/mempolicy.c +1 -0
index e0066ca91d9a..58fbd8ec527f 100644
@@ -99,6 +99,7 @@
 #include <linux/syscalls.h>
 #include <linux/ctype.h>
 #include <linux/mm_inline.h>
+#include <linux/anon_vma.h>
 #include <linux/mmu_notifier.h>
 #include <linux/printk.h>
 #include <linux/swapops.h>
mm/mlock.c +1 -0
index 8f584eddd305..f3179d8169e4 100644
@@ -9,6 +9,7 @@
 #include <linux/capability.h>
 #include <linux/mman.h>
 #include <linux/mm.h>
+#include <linux/anon_vma.h>
 #include <linux/sched/user.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
mm/mmap.c +1 -0
index 6ea9e6775fa3..289a40d1d4f3 100644
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/backing-dev.h>
 #include <linux/mm.h>
+#include <linux/anon_vma.h>
 #include <linux/vmacache.h>
 #include <linux/shm.h>
 #include <linux/mman.h>
mm/mprotect.c +1 -0
index 0138dfcdb1d8..96d57b1b41cd 100644
@@ -28,6 +28,7 @@
 #include <linux/ksm.h>
 #include <linux/uaccess.h>
 #include <linux/mm_inline.h>
+#include <linux/anon_vma.h>
 #include <linux/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/mmu_context.h>
Signature · 1 line
2.29.2
#1 lore raw
Quoted 9 lines · Arnd Bergmann

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 to a separate header that is only included where necessary to avoid bloating linux/mm_types.h further.

We already have an mm_inline.h. Why do we need a new header file?

#2 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Quoted 8 lines · On Sat, 4 Dec 2021 18:42:17 +0100 Arnd Bergmann <[email protected]> wrote:
include/linux/anon_vma.h new file +0 -0
new file mode 100644
index 000000000000..5ce8b5be31ae

include/linux/anon_vma.h line 6

Quoted 6 lines
include/linux/anon_vma.h new file +6 -0
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_ANON_VMA_H
+#define _LINUX_ANON_VMA_H
+
+#include <linux/mm_types.h>
+

Shouldn't this also include string.h to fix the original problem?

Signature · 2 lines
Cheers,
Stephen Rothwell