Skip to content

Commit

Permalink
bpf: Run sleepable programs with migration disabled
Browse files Browse the repository at this point in the history
In older non-RT kernels migrate_disable() was the same as preempt_disable().
Since commit 74d862b ("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: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: KP Singh <kpsingh@kernel.org>
Link: https://lore.kernel.org/bpf/20210210033634.62081-3-alexei.starovoitov@gmail.com
  • Loading branch information
Alexei Starovoitov authored and Daniel Borkmann committed Feb 11, 2021
1 parent 700d479 commit 031d6e0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/bpf/trampoline.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,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();
}

Expand Down

0 comments on commit 031d6e0

Please sign in to comment.