Skip to contentSkip to conversation

status of BPF in conjunction with PREEMPT_RT for the 6.6 kernel?

DISCUSSION Chris Friesen 3 participants 3 messages Jan 9, 2025 – Jan 11, 2025 1 message not in the archive BPF

lore
Share & tools
lore
#0 lore raw

Hi,

Back in 2019 there were some concerns raised (https://lwn.net/ml/bpf/[email protected]/#t) around using BPF in conjunction with PREEMPT_RT.

In the context of the 6.6 kernel and the corresponding PREEMPT_RT patchset, are those concerns still valid or have they been sorted out?

Please CC me on replies, I'm not subscribed to the list.

Thanks,
Chris Friesen

#1 lore raw

Hi,

Quoted 10 lines · Chris Friesen

Hi,

Back in 2019 there were some concerns raised
(https://lwn.net/ml/bpf/[email protected]/#t)
around using BPF in conjunction with PREEMPT_RT.

In the context of the 6.6 kernel and the corresponding PREEMPT_RT patchset, are those concerns still valid or have they been sorted out?

Please CC me on replies, I'm not subscribed to the list.

Do you have any use case for BPF + PREEMPT_RT ?  I am not a RT expert, however, In my understanding, BPF + PREEMPT_RT in the vanilla kernel basically can work togerther basically. The memory allocation concern is partially resolved and there is still undergoing effort trying to resolve it [1]. The up_read_non_owner problem has been avoided explicitly and the non-preemptible context for bpf prog has also been fixed. Although the running of test_maps and test_progs under PREEMPT_RT report some problems, I think these problem could be fixed. As for v6.6, I think it may be OK for BPF + PREEMPT_RT case.

[1]:
https://lore.kernel.org/bpf/[email protected]/

Quoted 5 lines

Thanks,
Chris Friesen

.

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

#3 lore raw

Hi,

Quoted 10 lines · Chris Friesen

Thanks for the info.

Our system is mostly used for DPDK applications, which are basically latency-sensitive busy-looping CPU hogs that rarely make syscalls, so they want to run on the RT kernel to minimize interruptions.   There are various BPF-based tools and optimizations that I have been hearing about, and I was just wondering if they could now be used on RT kernels and if so whether there are any potential problems.

I see.

Quoted 9 lines

I did have one additional question...some time back (on the 5.10 kernel with RT patches) we noted that when net.core.bpf_jit_enable was enabled, merely restarting some systemd services would be enough to cause function call inter-processor interrupts on all CPUs, even isolated ones.  (Thus interrupting the RT tasks.)   Is that still the case?

I think the IPI may be due to kernel TLB flush. When bpf jit is enabled, the memory allocated for the bpf program will be marked as executable, and during the free of bpf program, the exec permission needs to be cleared. The clearing of permission bit involves the update of kernel page table, therefore, TLB flush is needed. I think the TLB flush will still be there, however, the introduction of pack allocator in v5.18 in bpf may alleviate it.

Quoted 39 lines

Thanks,

Chris

Quoted 30 lines · Hou Tao

Hi,

Quoted 10 lines · Chris Friesen

Hi,

Back in 2019 there were some concerns raised
(https://lwn.net/ml/bpf/[email protected]/#t)
around using BPF in conjunction with PREEMPT_RT.

In the context of the 6.6 kernel and the corresponding PREEMPT_RT patchset, are those concerns still valid or have they been sorted out?

Please CC me on replies, I'm not subscribed to the list.

Do you have any use case for BPF + PREEMPT_RT ? I am not a RT expert, however, In my understanding, BPF + PREEMPT_RT in the vanilla kernel basically can work togerther basically. The memory allocation concern is partially resolved and there is still undergoing effort trying to resolve it [1]. The up_read_non_owner problem has been avoided explicitly and the non-preemptible context for bpf prog has also been fixed. Although the running of test_maps and test_progs under PREEMPT_RT report some problems, I think these problem could be fixed. As for v6.6, I think it may be OK for BPF + PREEMPT_RT case.

[1]:
https://lore.kernel.org/bpf/[email protected]/

Quoted 5 lines

Thanks,
Chris Friesen

.