Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sched/c/scx_nest: task priority is not respected properly #419

Open
honxia02 opened this issue Jul 12, 2024 · 1 comment
Open

sched/c/scx_nest: task priority is not respected properly #419

honxia02 opened this issue Jul 12, 2024 · 1 comment

Comments

@honxia02
Copy link

Code in scx_next obviously tries to take p->scx.weight into account and priorities (or nice values) should work.

However, scheduling two tasks on the same rq with +5 and -5 nice values results in roughly 50%-50% run time, while such values should give you roughly 10% and 90% in CFS.

Some initial investigations lead me to this code block in nest_enqueue()

        /*
         * Limit the amount of budget that an idling task can accumulate
         * to one slice.
         */ 
        if (vtime_before(vtime, vtime_now - slice_ns))
                vtime = vtime_now - slice_ns;

The line right below it

        scx_bpf_dispatch_vtime(p, FALLBACK_DSQ_ID, slice_ns, vtime,
                               enq_flags);

will then bring the nice(-5) task's vtime to roughly the same as that of the nice(5) task, therefore ruining the previous slow accumulation of vtime and ruining how priorities work.

Removing the vtime fix here and just use the normal version scx_bpf_dispatch() without passing vtime gives the correct task run time distribution of 10% and 90%.

@honxia02 honxia02 reopened this Jul 12, 2024
@honxia02
Copy link
Author

honxia02 commented Jul 12, 2024

After more experiments, the bug exists but my comments around scx_bpf_dispatch(vtime) were wrong, so please disregard them. But I left the issue open because the bug still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant