Merge branch 'bpf-avoid-rcu-context-warning-when-unpinning-htab-with-internal-structs'

KaFai Wan says:

====================
bpf: Avoid RCU context warning when unpinning htab with internal structs

This small patchset is about avoid RCU context warning when unpinning
htab with internal structs (timer, workqueue, or task_work).

v3:
- fix nit (Yonghong Song)
- add Acked-by: Yonghong Song <yonghong.song@linux.dev>

v2:
- rename bpf_free_inode() to bpf_destroy_inode() (Andrii)
https://lore.kernel.org/all/20251007012235.755853-1-kafai.wan@linux.dev/

v1:
https://lore.kernel.org/all/20251003084528.502518-1-kafai.wan@linux.dev/
---
====================

Link: https://patch.msgid.link/20251008102628.808045-1-kafai.wan@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+63 -2
+2 -2
kernel/bpf/inode.c
··· 775 775 return 0; 776 776 } 777 777 778 - static void bpf_free_inode(struct inode *inode) 778 + static void bpf_destroy_inode(struct inode *inode) 779 779 { 780 780 enum bpf_type type; 781 781 ··· 790 790 .statfs = simple_statfs, 791 791 .drop_inode = inode_just_drop, 792 792 .show_options = bpf_show_options, 793 - .free_inode = bpf_free_inode, 793 + .destroy_inode = bpf_destroy_inode, 794 794 }; 795 795 796 796 enum {
+36
tools/testing/selftests/bpf/prog_tests/pinning_htab.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <test_progs.h> 4 + #include "test_pinning_htab.skel.h" 5 + 6 + static void unpin_map(const char *map_name, const char *pin_path) 7 + { 8 + struct test_pinning_htab *skel; 9 + struct bpf_map *map; 10 + int err; 11 + 12 + skel = test_pinning_htab__open_and_load(); 13 + if (!ASSERT_OK_PTR(skel, "skel open_and_load")) 14 + return; 15 + 16 + map = bpf_object__find_map_by_name(skel->obj, map_name); 17 + if (!ASSERT_OK_PTR(map, "bpf_object__find_map_by_name")) 18 + goto out; 19 + 20 + err = bpf_map__pin(map, pin_path); 21 + if (!ASSERT_OK(err, "bpf_map__pin")) 22 + goto out; 23 + 24 + err = bpf_map__unpin(map, pin_path); 25 + ASSERT_OK(err, "bpf_map__unpin"); 26 + out: 27 + test_pinning_htab__destroy(skel); 28 + } 29 + 30 + void test_pinning_htab(void) 31 + { 32 + if (test__start_subtest("timer_prealloc")) 33 + unpin_map("timer_prealloc", "/sys/fs/bpf/timer_prealloc"); 34 + if (test__start_subtest("timer_no_prealloc")) 35 + unpin_map("timer_no_prealloc", "/sys/fs/bpf/timer_no_prealloc"); 36 + }
+25
tools/testing/selftests/bpf/progs/test_pinning_htab.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include "vmlinux.h" 4 + #include <bpf/bpf_helpers.h> 5 + 6 + char _license[] SEC("license") = "GPL"; 7 + 8 + struct timer_val { 9 + struct bpf_timer timer; 10 + }; 11 + 12 + struct { 13 + __uint(type, BPF_MAP_TYPE_HASH); 14 + __type(key, __u32); 15 + __type(value, struct timer_val); 16 + __uint(max_entries, 1); 17 + } timer_prealloc SEC(".maps"); 18 + 19 + struct { 20 + __uint(type, BPF_MAP_TYPE_HASH); 21 + __type(key, __u32); 22 + __type(value, struct timer_val); 23 + __uint(max_entries, 1); 24 + __uint(map_flags, BPF_F_NO_PREALLOC); 25 + } timer_no_prealloc SEC(".maps");