Re: [PATCH 2/2] sched/ext: Add BPF functions for uclamp inc and dec

From: Hongyan Xia
Date: Wed Jul 03 2024 - 15:50:03 EST


On 03/07/2024 19:15, Tejun Heo wrote:
Hello.

On Wed, Jul 03, 2024 at 11:07:48AM +0100, Hongyan Xia wrote:
+__bpf_kfunc void scx_bpf_uclamp_rq_inc(s32 cpu, struct task_struct *p)
+{
+ uclamp_rq_inc(cpu_rq(cpu), p);
+}
+
+__bpf_kfunc void scx_bpf_uclamp_rq_dec(s32 cpu, struct task_struct *p)
+{
+ uclamp_rq_dec(cpu_rq(cpu), p);
+}

So, I don't think we can expose these functions directly to the BPF
scheduler. The BPF schedulers shouldn't be able to break system integrity no
matter what they do and with the above it'd be trivial to get the bucket
counters unbalanced, right?

You are right.

Actually, avoiding double enqueue or dequeue is easy and might be just a one-line change. The real concern is when the BPF scheduler somehow still has tasks on uclamp buckets when it's unloaded. Then, unloading the scheduler needs to do uclamp_dec().

I'll see what I can do.