Skip to content

Conversation

hodgesds
Copy link
Contributor

@hodgesds hodgesds commented May 9, 2025

Add accounting for non scx usage for LLC utilization. This should make load balancing decisions more accurate.

@hodgesds hodgesds changed the title scx_p1dq: Acccount for non scx usage scx_p2dq: Acccount for non scx usage May 9, 2025
@hodgesds hodgesds force-pushed the p2dq-non-scx-accounting branch from 87a73f8 to bf60129 Compare May 9, 2025 18:39
@etsal
Copy link
Contributor

etsal commented May 9, 2025

This assumes the CPU was running full throttle when not in scx, but IIUC that includes time spent in the idle scheduling class, so isn't this going to skew accounting?

@hodgesds
Copy link
Contributor Author

hodgesds commented May 9, 2025

This assumes the CPU was running full throttle when not in scx, but IIUC that includes time spent in the idle scheduling class, so isn't this going to skew accounting?

Hmmm good observation... let me think about this some more may be able to test if TASK_IDLE for that case.

@hodgesds hodgesds force-pushed the p2dq-non-scx-accounting branch 2 times, most recently from 45a0279 to c98beb6 Compare May 9, 2025 19:18
Copy link
Contributor

@etsal etsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming PF_IDLE covers it, looks good.


UEI_DEFINE(uei);


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Stray line?

if (!(cpuc = lookup_cpu_ctx(cpu)))
return;

if (is_idle_task(args->task)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... I don't think ops.cpu_release() is called if we're switching to a scheduling class below SCHED_EXT. See: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/sched/ext.c#n3171

So this condition should be always false, unless I'm missing something...

if (!(cpuc = lookup_cpu_ctx(cpu)))
return;

if (is_idle_task(args->task)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better approach would be to use ops.update_idle() to track the idle transition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely missed that, let me try that!

Add accounting for non scx usage for LLC utilization. This should make
load balancing decisions more accurate.

Signed-off-by: Daniel Hodges <hodgesd@meta.com>
@hodgesds hodgesds force-pushed the p2dq-non-scx-accounting branch from c98beb6 to 039760e Compare May 29, 2025 12:50
@EricccTaiwan
Copy link
Collaborator

scx_p2dq: Acccount for non scx usage

Nit: s/Acccount/Account

@hodgesds hodgesds marked this pull request as draft June 2, 2025 19:39
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

Successfully merging this pull request may close these issues.

5 participants