Skip to content

Commit 427a36b

Browse files
image-dragonAlexei Starovoitov
authored andcommitted
bpf: use rcu_read_lock_dont_migrate() for bpf_prog_run_array_cg()
Use rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate() in bpf_prog_run_array_cg to obtain better performance when PREEMPT_RCU is not enabled. Signed-off-by: Menglong Dong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent cf4303b commit 427a36b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/bpf/cgroup.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ bpf_prog_run_array_cg(const struct cgroup_bpf *cgrp,
7171
u32 func_ret;
7272

7373
run_ctx.retval = retval;
74-
migrate_disable();
75-
rcu_read_lock();
74+
rcu_read_lock_dont_migrate();
7675
array = rcu_dereference(cgrp->effective[atype]);
7776
item = &array->items[0];
7877
old_run_ctx = bpf_set_run_ctx(&run_ctx.run_ctx);
@@ -88,8 +87,7 @@ bpf_prog_run_array_cg(const struct cgroup_bpf *cgrp,
8887
item++;
8988
}
9089
bpf_reset_run_ctx(old_run_ctx);
91-
rcu_read_unlock();
92-
migrate_enable();
90+
rcu_read_unlock_migrate();
9391
return run_ctx.retval;
9492
}
9593

0 commit comments

Comments
 (0)