mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-25 11:00:24 +00:00
scx_layered: Work around verification failure in antistall_set() on old kernels
In earlier kernels, the iterator variable wasn't trusted making the verifier choke on calling kfuncs on its dereferences. Work around by re-looking up the task by PID.
This commit is contained in:
parent
61f378c1cd
commit
dbcd233f17
@ -2497,7 +2497,7 @@ static bool layered_monitor(void)
|
||||
*/
|
||||
u64 antistall_set(u64 dsq_id, u64 jiffies_now)
|
||||
{
|
||||
struct task_struct *p;
|
||||
struct task_struct *__p, *p = NULL;
|
||||
struct task_ctx *tctx;
|
||||
s32 cpu;
|
||||
u64 *antistall_dsq, *delay, cur_delay;
|
||||
@ -2511,7 +2511,12 @@ u64 antistall_set(u64 dsq_id, u64 jiffies_now)
|
||||
|
||||
// verifier
|
||||
bpf_rcu_read_lock();
|
||||
bpf_for_each(scx_dsq, p, dsq_id, 0) {
|
||||
bpf_for_each(scx_dsq, __p, dsq_id, 0) {
|
||||
/* XXX verifier workaround: drop the following block later */
|
||||
if (p)
|
||||
bpf_task_release(p);
|
||||
if (!(p = bpf_task_from_pid(__p->pid)))
|
||||
continue;
|
||||
|
||||
if (!(tctx = lookup_task_ctx(p)))
|
||||
goto unlock;
|
||||
@ -2562,6 +2567,8 @@ look_for_cpu:
|
||||
}
|
||||
|
||||
unlock:
|
||||
if (p)
|
||||
bpf_task_release(p);
|
||||
bpf_rcu_read_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user