The AUFS code introduces a new mm/prfile.c which is used to hook in a shadow structure plus some __FUNC__ and __LINE__ tracing via hijacking some fs/file and mm/vma calls (see aufs5-standalone/aufs5-mmap.patch).
As these tiny stubs live in a separate source module, we are always going to be bouncing through them, even with AUFS completely disabled. We also see AUFS adding some content to existing structs even with AUFS disabled. We can fix the 1st by getting rid of prfile.c in the disabled case; we replace it with macros that collapse to the original unpatched code. We can fix the latter by using IS_ENABLED(CONFIG_AUFS_FS) around the extra content AUFS adds/changes so they aren't present when disabled. This covers both the CONFIG_AUFS_FS=m and CONFIG_AUFS_FS=y cases. Finally, there is the deprecated remap_file_pages() syscall - and while it has been deprecated since 2014 - it does add unused code and possibly exposure to regressions/CVE etc. - and so I also used the very same IS_ENABLED() there so we have the original code in the disabled case. The size difference for the disabled case is easy to detect/display. Functions found in prfile.c show up as "-" below since it isn't built: linux-yocto$ size ../aufs*/vmlinux text data bss dec hex filename 20176019 8124604 2019564 30320187 1cea63b ../aufs-debloat/vmlinux 20176259 8124604 2019564 30320427 1cea72b ../aufs-default/vmlinux linux-yocto$./scripts/bloat-o-meter ../aufs-default/vmlinux ../aufs-debloat/vmlinux add/remove: 0/4 grow/shrink: 0/14 up/down: 0/-871 (-871) Function old new delta filemap_page_mkwrite 252 247 -5 gate_vma 200 192 -8 mmap_region 1528 1517 -11 __vma_adjust 2357 2345 -12 remove_vma 104 91 -13 dup_mm.isra 1403 1387 -16 map_files_get_link 429 408 -21 copy_vma 597 576 -21 __split_vma 420 394 -26 show_numa_map 944 917 -27 vma_do_pr_or_file 29 - -29 vma_do_get_file 35 - -35 show_map_vma 350 310 -40 vma_do_fput 47 - -47 vma_do_file_update_time 47 - -47 __func__ 17583 17424 -159 __ia32_sys_remap_file_pages 786 623 -163 __x64_sys_remap_file_pages 817 626 -191 Total: Before=17285664, After=17284793, chg -0.01% linux-yocto$ Performance should be restored to the original non-AUFS baseline given the above reduction in code and removal of out-of-line stubs. Signed-off-by: Paul Gortmaker <paul.gortma...@windriver.com> --- include/linux/mm.h | 15 +++++++++++++++ include/linux/mm_types.h | 4 ++++ mm/Makefile | 3 ++- mm/mmap.c | 12 +++++++++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 31afd5410740..04c46c1ff2bf 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1813,6 +1813,7 @@ static inline void unmap_shared_mapping_range(struct address_space *mapping, unmap_mapping_range(mapping, holebegin, holelen, 0); } +#if IS_ENABLED(CONFIG_AUFS_FS) extern void vma_do_file_update_time(struct vm_area_struct *, const char[], int); extern struct file *vma_do_pr_or_file(struct vm_area_struct *, const char[], int); @@ -1835,6 +1836,20 @@ extern void vmr_do_fput(struct vm_region *, const char[], int); #define vmr_fput(region) vmr_do_fput(region, __func__, __LINE__) #endif /* !CONFIG_MMU */ +#else /* !CONFIG_AUFS_FS */ + +#define vma_file_update_time(vma) file_update_time((vma)->vm_file) +#define vma_pr_or_file(vma) (vma)->vm_file +#define vma_get_file(vma) get_file((vma)->vm_file) +#define vma_fput(vma) fput((vma)->vm_file) + +#ifndef CONFIG_MMU +#define vmr_pr_or_file(region) (region)->vm_file +#define vmr_fput(region) fput((region)->vm_file) +#endif /* !CONFIG_MMU */ + +#endif /* !CONFIG_AUFS_FS */ + extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, unsigned int gup_flags); extern int access_remote_vm(struct mm_struct *mm, unsigned long addr, diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 3a9a798a4ae1..8fea872e08f7 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -294,7 +294,9 @@ struct vm_region { unsigned long vm_top; /* region allocated to here */ unsigned long vm_pgoff; /* the offset in vm_file corresponding to vm_start */ struct file *vm_file; /* the backing file or NULL */ +#if IS_ENABLED(CONFIG_AUFS_FS) struct file *vm_prfile; /* the virtual backing file or NULL */ +#endif int vm_usage; /* region usage count (access under nommu_region_sem) */ bool vm_icache_flushed : 1; /* true if the icache has been flushed for @@ -374,7 +376,9 @@ struct vm_area_struct { unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE units */ struct file * vm_file; /* File we map to (can be NULL). */ +#if IS_ENABLED(CONFIG_AUFS_FS) struct file *vm_prfile; /* shadow of vm_file */ +#endif void * vm_private_data; /* was vm_pte (shared mem) */ #ifdef CONFIG_SWAP diff --git a/mm/Makefile b/mm/Makefile index c715b0138237..d45773672730 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -52,7 +52,7 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \ mm_init.o percpu.o slab_common.o \ compaction.o vmacache.o \ interval_tree.o list_lru.o workingset.o \ - prfile.o debug.o gup.o mmap_lock.o $(mmu-y) + debug.o gup.o mmap_lock.o $(mmu-y) # Give 'page_alloc' its own module-parameter namespace page-alloc-y := page_alloc.o @@ -130,3 +130,4 @@ obj-$(CONFIG_PAGE_REPORTING) += page_reporting.o obj-$(CONFIG_IO_MAPPING) += io-mapping.o obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o +obj-$(CONFIG_AUFS_FS:m=y) += prfile.o diff --git a/mm/mmap.c b/mm/mmap.c index 6c276614ca96..c0a6652e3809 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2945,7 +2945,10 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, struct vm_area_struct *vma; unsigned long populate = 0; unsigned long ret = -EINVAL; - struct file *file, *prfile; + struct file *file; +#if IS_ENABLED(CONFIG_AUFS_FS) + struct file *prfile; +#endif pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. See Documentation/vm/remap_file_pages.rst.\n", current->comm, current->pid); @@ -3001,6 +3004,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, if (vma->vm_flags & VM_LOCKED) flags |= MAP_LOCKED; +#if IS_ENABLED(CONFIG_AUFS_FS) vma_get_file(vma); file = vma->vm_file; prfile = vma->vm_prfile; @@ -3022,6 +3026,12 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, fput(file); if (prfile) fput(prfile); +#else + file = get_file(vma->vm_file); + ret = do_mmap(vma->vm_file, start, size, + prot, flags, pgoff, &populate, NULL); + fput(file); +#endif out: mmap_write_unlock(mm); if (populate) -- 2.17.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#11085): https://lists.yoctoproject.org/g/linux-yocto/message/11085 Mute This Topic: https://lists.yoctoproject.org/mt/90039130/21656 Group Owner: linux-yocto+ow...@lists.yoctoproject.org Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-