Re: [PATCH v2 1/2] cgroup: add BPF kfuncs to read a cpu cgroup's stats

Ziyang Men <[email protected]>
Newsgroups org.kernel.vger.cgroups,org.kernel.vger.bpf,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest
Message-ID <[email protected]>
Hi Tejun,

On Tue, Aug 18, 2026 at 12:47:11PM -1000, Tejun Heo wrote:
>On Tue, Aug 18, 2026 at 03:44:36PM -0700, Ziyang Men wrote:
>> > > +BTF_KFUNCS_START(bpf_rstat_common_kfunc_ids)
>> > > +BTF_ID_FLAGS(func, bpf_css_flush_rstat, KF_SLEEPABLE)
>> > > +BTF_ID_FLAGS(func, bpf_cgroup_base_stat, KF_SLEEPABLE)
>> >
>> > Why are these SLEEPABLE?
>> >
>>
>> The css_rstat_flush() calls might_sleep() and cond_resched().
>
>I see.
>
>> The bpf_cgroup_base_stat() takes an rstat spinlock_t, which can sleep on
>> PREEMPT_RT.
>
>Is this actually required? This doesn't really make sense to me. Shouldn't
>what SLEEPABLE mean change on RT kernels instead?

Oh sorry, I didn't notice that.

I might be wrong: this function calls the cputime_adjust(), which in turn
acquires raw_spin_lock_irqsave(), so there would be NMI deadlock in the
perf_event program. The __css_rstat_lock() take the spin_lock_irq() as well. So
maybe a SLEEPABLE tag is still necessary?

Please let me know your concerns. Thanks!

Best,
Ziyang

>
>Thanks.
>
>-- 
>tejun
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.