Skip to content

Commit 02ad059

Browse files
davem330Alexei Starovoitov
authored andcommitted
bpf: Use migrate_disable/enabe() in trampoline code.
Instead of preemption disable/enable to reflect the purpose. This allows PREEMPT_RT to substitute it with an actual migration disable implementation. On non RT kernels this is still mapped to preempt_disable/enable(). Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200224145643.891428873@linutronix.de
1 parent 6eac779 commit 02ad059

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kernel/bpf/trampoline.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,9 @@ void bpf_trampoline_put(struct bpf_trampoline *tr)
367367
mutex_unlock(&trampoline_mutex);
368368
}
369369

370-
/* The logic is similar to BPF_PROG_RUN, but with explicit rcu and preempt that
371-
* are needed for trampoline. The macro is split into
370+
/* The logic is similar to BPF_PROG_RUN, but with an explicit
371+
* rcu_read_lock() and migrate_disable() which are required
372+
* for the trampoline. The macro is split into
372373
* call _bpf_prog_enter
373374
* call prog->bpf_func
374375
* call __bpf_prog_exit
@@ -378,7 +379,7 @@ u64 notrace __bpf_prog_enter(void)
378379
u64 start = 0;
379380

380381
rcu_read_lock();
381-
preempt_disable();
382+
migrate_disable();
382383
if (static_branch_unlikely(&bpf_stats_enabled_key))
383384
start = sched_clock();
384385
return start;
@@ -401,7 +402,7 @@ void notrace __bpf_prog_exit(struct bpf_prog *prog, u64 start)
401402
stats->nsecs += sched_clock() - start;
402403
u64_stats_update_end(&stats->syncp);
403404
}
404-
preempt_enable();
405+
migrate_enable();
405406
rcu_read_unlock();
406407
}
407408

0 commit comments

Comments
 (0)