Commit ffce84bc authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

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: default avatarYonghong 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: default avatarAlexei Starovoitov <ast@kernel.org>
parents 07ca98f9 accb9a7e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -775,7 +775,7 @@ static int bpf_show_options(struct seq_file *m, struct dentry *root)
	return 0;
}

static void bpf_free_inode(struct inode *inode)
static void bpf_destroy_inode(struct inode *inode)
{
	enum bpf_type type;

@@ -790,7 +790,7 @@ const struct super_operations bpf_super_ops = {
	.statfs		= simple_statfs,
	.drop_inode	= inode_just_drop,
	.show_options	= bpf_show_options,
	.free_inode	= bpf_free_inode,
	.destroy_inode	= bpf_destroy_inode,
};

enum {
+36 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

#include <test_progs.h>
#include "test_pinning_htab.skel.h"

static void unpin_map(const char *map_name, const char *pin_path)
{
	struct test_pinning_htab *skel;
	struct bpf_map *map;
	int err;

	skel = test_pinning_htab__open_and_load();
	if (!ASSERT_OK_PTR(skel, "skel open_and_load"))
		return;

	map = bpf_object__find_map_by_name(skel->obj, map_name);
	if (!ASSERT_OK_PTR(map, "bpf_object__find_map_by_name"))
		goto out;

	err = bpf_map__pin(map, pin_path);
	if (!ASSERT_OK(err, "bpf_map__pin"))
		goto out;

	err = bpf_map__unpin(map, pin_path);
	ASSERT_OK(err, "bpf_map__unpin");
out:
	test_pinning_htab__destroy(skel);
}

void test_pinning_htab(void)
{
	if (test__start_subtest("timer_prealloc"))
		unpin_map("timer_prealloc", "/sys/fs/bpf/timer_prealloc");
	if (test__start_subtest("timer_no_prealloc"))
		unpin_map("timer_no_prealloc", "/sys/fs/bpf/timer_no_prealloc");
}
+25 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>

char _license[] SEC("license") = "GPL";

struct timer_val {
	struct bpf_timer timer;
};

struct {
	__uint(type, BPF_MAP_TYPE_HASH);
	__type(key, __u32);
	__type(value, struct timer_val);
	__uint(max_entries, 1);
} timer_prealloc SEC(".maps");

struct {
	__uint(type, BPF_MAP_TYPE_HASH);
	__type(key, __u32);
	__type(value, struct timer_val);
	__uint(max_entries, 1);
	__uint(map_flags, BPF_F_NO_PREALLOC);
} timer_no_prealloc SEC(".maps");