Skip to contentSkip to conversation

bpf: Add sleepable support for classic tracepoint programs

PATCH [email protected] 2 participants 3 messages Mar 23 – Mar 24 1 message not in the archive BPF

lore
Share & tools
lore
#0 lore raw
Quoted 1 line · Mykyta Yatsenko

Agree, the same point was raised by sashiko review.

Hi,

I have a follow-up question on the recursion handling.

Even with migrate_disable(), this still runs in a preemptible and sleepable context. So if a task sleeps after incrementing bpf_prog_active, another task could run on the same CPU and also modify the per-CPU counter.

Would this interleaving affect recursion tracking correctness here, or is this accounted for?

Thanks,
Oskar Gerlicz Kowalczuk

#1 lore raw
Quoted 1 line

+ if (unlikely(this_cpu_inc_return(bpf_prog_active) != 1)) {

Hi,

A question regarding the recursion handling.

Even with migrate_disable(), this still runs in a preemptible and sleepable context. So if a task increments bpf_prog_active and then sleeps, another task could run on the same CPU and also modify the same per-CPU counter.

Would this interleaving affect recursion tracking correctness, or is this accounted for?

Oskar Gerlicz Kowalczuk

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 17 lines · Mykyta Yatsenko
Quoted 11 lines · On 3/23/26 9:26 PM, [email protected] wrote:
Quoted 1 line

+       if (unlikely(this_cpu_inc_return(bpf_prog_active) != 1)) {

Hi,

A question regarding the recursion handling.

Even with migrate_disable(), this still runs in a preemptible and sleepable context. So if a task increments bpf_prog_active and then sleeps, another task could run on the same CPU and also modify the same per-CPU counter.

Quoted 5 lines

Would this interleaving affect recursion tracking correctness, or is this accounted for?

Oskar Gerlicz Kowalczuk

Quoted 8 lines

We discussed this with Kumar in the sibling thread, the initial thinking behind this was that second task incrementing this counter won't see 1, so it's going to

this_cpu_dec(bpf_prog_active);
return 0;

I'm reworking this for the next version.

The initial thinking behind this was that the second task incrementing this counter won't see 1, so it's going to

this_cpu_dec(bpf_prog_active);
return 0;

I'm reworking this for the next version, as discussed in the sibling thread with Kumar.