Centos-kernel-stream-9/fs/ramfs
Štěpán Horáček 7a2fdfdaad mm: switch mm->get_unmapped_area() to a flag
JIRA: https://issues.redhat.com/browse/RHEL-15599

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Conflicts: Minor context differences

commit 529ce23a764f25d172198b4c6ba90f1e2ad17f93
Author: Rick Edgecombe <rick.p.edgecombe@intel.com>
Date:   Mon Mar 25 19:16:44 2024 -0700

    mm: switch mm->get_unmapped_area() to a flag

    The mm_struct contains a function pointer *get_unmapped_area(), which is
    set to either arch_get_unmapped_area() or arch_get_unmapped_area_topdown()
    during the initialization of the mm.

    Since the function pointer only ever points to two functions that are
    named the same across all arch's, a function pointer is not really
    required.  In addition future changes will want to add versions of the
    functions that take additional arguments.  So to save a pointers worth of
    bytes in mm_struct, and prevent adding additional function pointers to
    mm_struct in future changes, remove it and keep the information about
    which get_unmapped_area() to use in a flag.

    Add the new flag to MMF_INIT_MASK so it doesn't get clobbered on fork by
    mmf_init_flags().  Most MM flags get clobbered on fork.  In the
    pre-existing behavior mm->get_unmapped_area() would get copied to the new
    mm in dup_mm(), so not clobbering the flag preserves the existing behavior
    around inheriting the topdown-ness.

    Introduce a helper, mm_get_unmapped_area(), to easily convert code that
    refers to the old function pointer to instead select and call either
    arch_get_unmapped_area() or arch_get_unmapped_area_topdown() based on the
    flag.  Then drop the mm->get_unmapped_area() function pointer.  Leave the
    get_unmapped_area() pointer in struct file_operations alone.  The main
    purpose of this change is to reorganize in preparation for future changes,
    but it also converts the calls of mm->get_unmapped_area() from indirect
    branches into a direct ones.

    The stress-ng bigheap benchmark calls realloc a lot, which calls through
    get_unmapped_area() in the kernel.  On x86, the change yielded a ~1%
    improvement there on a retpoline config.

    In testing a few x86 configs, removing the pointer unfortunately didn't
    result in any actual size reductions in the compiled layout of mm_struct.
    But depending on compiler or arch alignment requirements, the change could
    shrink the size of mm_struct.

    Link: https://lkml.kernel.org/r/20240326021656.202649-3-rick.p.edgecombe@intel.com
    Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
    Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
    Acked-by: Liam R. Howlett <Liam.Howlett@oracle.com>
    Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Acked-by: Alexei Starovoitov <ast@kernel.org>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
    Cc: Borislav Petkov (AMD) <bp@alien8.de>
    Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
    Cc: Deepak Gupta <debug@rivosinc.com>
    Cc: Guo Ren <guoren@kernel.org>
    Cc: Helge Deller <deller@gmx.de>
    Cc: H. Peter Anvin (Intel) <hpa@zytor.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Mark Brown <broonie@kernel.org>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
2025-03-18 17:09:47 +01:00
..
Makefile
file-mmu.c mm: switch mm->get_unmapped_area() to a flag 2025-03-18 17:09:47 +01:00
file-nommu.c mm, treewide: rename MAX_ORDER to MAX_PAGE_ORDER 2024-12-09 12:24:17 -05:00
inode.c fs: port inode_init_owner() to mnt_idmap 2024-10-16 10:45:26 +08:00
internal.h