提交 c82a344b 编写于 作者: A Alexei Starovoitov 提交者: Zheng Zengkai

bpf: Run sleepable programs with migration disabled

mainline inclusion
from mainline-5.12-rc1
commit 031d6e02
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=031d6e02ddbb8dea747c1abb697d556901f07dd4

-------------------------------------------------

In older non-RT kernels migrate_disable() was the same as preempt_disable().
Since commit 74d862b6 ("sched: Make migrate_disable/enable() independent of RT")
migrate_disable() is real and doesn't prevent sleeping.

Running sleepable programs with migration disabled allows to add support for
program stats and per-cpu maps later.
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Acked-by: NKP Singh <kpsingh@kernel.org>
Link: https://lore.kernel.org/bpf/20210210033634.62081-3-alexei.starovoitov@gmail.com
(cherry picked from commit 031d6e02)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 1e2df962
......@@ -534,11 +534,13 @@ void notrace __bpf_prog_exit(struct bpf_prog *prog, u64 start)
void notrace __bpf_prog_enter_sleepable(void)
{
rcu_read_lock_trace();
migrate_disable();
might_fault();
}
void notrace __bpf_prog_exit_sleepable(void)
{
migrate_enable();
rcu_read_unlock_trace();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册