mm: split out anon_vma declarations to separate header
Subsystems (9)
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.
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Quoted 9 lines · Arnd Bergmann
This should not really be part of
linux/mm_types.hin 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 includingstring.has 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.hfurther.
We already have an mm_inline.h. Why do we need a new header file?
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
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