Hi, The header of patch #0 is broken for the patch set. However, it seems BPF CI still can handle it and the content of patch #0 is still intact, so I will not resend the patch set and instead I will respin it after receiving some comments. Sorry for the inconvenience. On 1/6/2025 4:18 PM, Hou Tao wrote: > Hi, > > The use of migrate_{disable|enable} pair in BPF is mainly due to the > introduction of bpf memory allocator and the use of per-CPU data struct > in its internal implementation. The caller needs to disable migration > before invoking the alloc or free APIs of bpf memory allocator, and > enable migration after the invocation. > > The main users of bpf memory allocator are various kind of bpf maps in > which the map values or the special fields in the map values are > allocated by using bpf memory allocator. > > At present, the running context for bpf program has already disabled > migration explictly or implictly, therefore, when these maps are > manipulated in bpf program, it is OK to not invoke migrate_disable() > and migrate_enable() pair. Howevers, it is not always the case when > these maps are manipulated through bpf syscall, therefore many > migrate_{disable|enable} pairs are added when the map can either be > manipulated by BPF program or BPF syscall. > > The initial idea of reducing the use of migrate_{disable|enable} comes > from Alexei [1]. I turned it into a patch set that archives the goals > through the following three methods: > > 1. remove unnecessary migrate_{disable|enable} pair > when the BPF syscall path also disables migration, it is OK to remove > the pair. Patch #1~#3 fall into this category, while patch #4~#5 are > partially included. > > 2. move the migrate_{disable|enable} pair from inner callee to outer > caller > Instead of invoking migrate_disable() in the inner callee, invoking > migrate_disable() in the outer caller to simplify reasoning about when > migrate_disable() is needed. Patch #4~#5 and patch #6~#19 belongs to > this category. > > 3. add cant_migrate() check in the inner callee > Add cant_migrate() check in the inner callee to ensure the guarantee > that migration is disabled is not broken. Patch #1~#5, #13, #16~#19 also > belong to this category. > > Considering the bpf-next CI is broken, the patch set is verified by > using bpf tree. Please check the individual patches for more details. > Comments are always welcome. > > [1]: https://lore.kernel.org/bpf/CAADnVQKZ3=F0L7_R_pYqu7ePzpXRwQEN8tCzmFoxjdJHamMOUQ@xxxxxxxxxxxxxx > > Hou Tao (19): > bpf: Remove migrate_{disable|enable} from LPM trie > bpf: Remove migrate_{disable|enable} in ->map_for_each_callback > bpf: Remove migrate_{disable|enable} in htab_elem_free > bpf: Remove migrate_{disable|enable} from bpf_cgrp_storage_lock > helpers > bpf: Remove migrate_{disable|enable} from bpf_task_storage_lock > helpers > bpf: Disable migration when destroying inode storage > bpf: Disable migration when destroying sock storage > bpf: Disable migration when cloning sock storage > bpf: Disable migration in bpf_selem_free_rcu > bpf: Disable migration in array_map_free() > bpf: Disable migration in htab_map_free() > bpf: Disable migration for bpf_selem_unlink in > bpf_local_storage_map_free() > bpf: Remove migrate_{disable|enable} in bpf_obj_free_fields() > bpf: Remove migrate_{disable,enable} in bpf_cpumask_release() > bpf: Disable migration before calling ops->map_free() > bpf: Remove migrate_{disable|enable} from bpf_selem_alloc() > bpf: Remove migrate_{disable|enable} from bpf_local_storage_alloc() > bpf: Remove migrate_{disable|enable} from bpf_local_storage_free() > bpf: Remove migrate_{disable|enable} from bpf_selem_free() > > kernel/bpf/arraymap.c | 6 ++---- > kernel/bpf/bpf_cgrp_storage.c | 15 +++++++------- > kernel/bpf/bpf_inode_storage.c | 9 ++++---- > kernel/bpf/bpf_local_storage.c | 38 +++++++++++++++------------------- > kernel/bpf/bpf_task_storage.c | 15 +++++++------- > kernel/bpf/cpumask.c | 2 -- > kernel/bpf/hashtab.c | 21 ++++++++----------- > kernel/bpf/helpers.c | 4 ---- > kernel/bpf/lpm_trie.c | 24 +++++++-------------- > kernel/bpf/range_tree.c | 2 -- > kernel/bpf/syscall.c | 12 ++++++++--- > net/core/bpf_sk_storage.c | 11 ++++++---- > 12 files changed, 71 insertions(+), 88 deletions(-) >