Centos-kernel-stream-9/kernel/bpf
Š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
..
preload
Kconfig
Makefile bpf: Remove custom build rule 2025-01-21 11:27:02 +01:00
arena.c mm: switch mm->get_unmapped_area() to a flag 2025-03-18 17:09:47 +01:00
arraymap.c bpf: Check percpu map value size first 2025-01-21 11:27:05 +01:00
bloom_filter.c
bpf_cgrp_storage.c
bpf_inode_storage.c
bpf_iter.c
bpf_local_storage.c bpf: fix order of args in call to bpf_map_kvcalloc 2024-11-19 07:40:50 +01:00
bpf_lru_list.c
bpf_lru_list.h
bpf_lsm.c bpf, lsm: Add disabled BPF LSM hook list 2025-01-13 17:36:13 +01:00
bpf_struct_ops.c bpf: Check unsupported ops from the bpf_struct_ops's cfi_stubs 2025-01-13 17:36:13 +01:00
bpf_task_storage.c
btf.c bpf: Fix memory leak in bpf_core_apply 2025-01-21 11:27:07 +01:00
btf_iter.c bpf: Remove custom build rule 2025-01-21 11:27:02 +01:00
btf_relocate.c bpf: Remove custom build rule 2025-01-21 11:27:02 +01:00
cgroup.c cgroup/bpf: use a dedicated workqueue for cgroup bpf destruction 2025-01-21 11:27:07 +01:00
cgroup_iter.c
core.c riscv, bpf: inline bpf_get_smp_processor_id() 2025-01-13 17:36:14 +01:00
cpumap.c net: skbuff: drop the word head from skb cache 2024-11-28 16:03:44 -05:00
cpumask.c
devmap.c bpf: fix OOB devmap writes when deleting elements 2025-01-09 17:43:24 +01:00
disasm.c
disasm.h
dispatcher.c
hashtab.c bpf: Check percpu map value size first 2025-01-21 11:27:05 +01:00
helpers.c bpf: Add MEM_WRITE attribute 2025-01-21 11:27:08 +01:00
inode.c bpf: Preserve param->string when parsing mount options 2025-01-21 11:27:08 +01:00
link_iter.c
local_storage.c bpf: Replace 8 seq_puts() calls by seq_putc() calls 2025-01-13 17:36:12 +01:00
log.c bpf: Fix print_reg_state's constant scalar dump 2024-11-26 15:55:21 +01:00
lpm_trie.c Merge: BPF 6.10 rebase 2024-11-22 09:24:52 +00:00
map_in_map.c
map_in_map.h
map_iter.c
memalloc.c bpf: Fix percpu address space issues 2025-01-21 11:24:25 +01:00
mmap_unlock_work.h
mprog.c
net_namespace.c
offload.c
percpu_freelist.c
percpu_freelist.h
prog_iter.c
queue_stack_maps.c
relo_core.c bpf: Remove custom build rule 2025-01-21 11:27:02 +01:00
reuseport_array.c bpf: Use sockfd_put() helper 2025-01-21 11:27:02 +01:00
ringbuf.c bpf: Add MEM_WRITE attribute 2025-01-21 11:27:08 +01:00
stackmap.c bpf: wire up sleepable bpf_get_stack() and bpf_get_task_stack() helpers 2025-01-21 11:27:05 +01:00
syscall.c mm: switch mm->get_unmapped_area() to a flag 2025-03-18 17:09:47 +01:00
sysfs_btf.c
task_iter.c bpf: Fix iter/task tid filtering 2025-01-21 11:27:08 +01:00
tcx.c
tnum.c
token.c
trampoline.c
verifier.c bpf: disallow 40-bytes extra stack for bpf_fastcall patterns 2025-01-21 12:39:29 +01:00