Skip to content

Commit 4223bf8

Browse files
Tao Chenanakryiko
authored andcommitted
bpf: Remove preempt_disable in bpf_try_get_buffers
Now BPF program will run with migration disabled, so it is safe to access this_cpu_inc_return(bpf_bprintf_nest_level). Fixes: d9c9e4d ("bpf: Factorize bpf_trace_printk and bpf_seq_printf") Signed-off-by: Tao Chen <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent d47cc4d commit 4223bf8

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

kernel/bpf/helpers.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,11 +774,9 @@ int bpf_try_get_buffers(struct bpf_bprintf_buffers **bufs)
774774
{
775775
int nest_level;
776776

777-
preempt_disable();
778777
nest_level = this_cpu_inc_return(bpf_bprintf_nest_level);
779778
if (WARN_ON_ONCE(nest_level > MAX_BPRINTF_NEST_LEVEL)) {
780779
this_cpu_dec(bpf_bprintf_nest_level);
781-
preempt_enable();
782780
return -EBUSY;
783781
}
784782
*bufs = this_cpu_ptr(&bpf_bprintf_bufs[nest_level - 1]);
@@ -791,7 +789,6 @@ void bpf_put_buffers(void)
791789
if (WARN_ON_ONCE(this_cpu_read(bpf_bprintf_nest_level) == 0))
792790
return;
793791
this_cpu_dec(bpf_bprintf_nest_level);
794-
preempt_enable();
795792
}
796793

797794
void bpf_bprintf_cleanup(struct bpf_bprintf_data *data)

0 commit comments

Comments
 (0)