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

scx_layered: Add waker stats per layer #671

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

hodgesds
Copy link
Contributor

Update the task context to keep a mask of wakers and add stats for wakes across layers.

Example output of layer stats:

###### Sun, 22 Sep 2024 02:52:17 -0400 ######
tot=   6030 local=43.55 open_idle= 0.32 affn_viol=18.71 proc=17ms
busy=  1.8 util=   32.0 load=      5.3 fallback_cpu=  4
excl_coll=0.00 excl_preempt=0.00 excl_idle=0.00 excl_wakeup=0.00
  chrome: util/frac=    4.5/ 14.0 load/frac=      1.3/ 24.7 tasks=    52
          tot=    409 local=89.98 wake/exp/reenq=10.02/ 0.00/ 0.00
          keep/max/busy= 0.00/ 0.00/ 0.00 kick= 0.00 yield/ign= 0.73/    0
          open_idle= 3.18 mig= 6.11 xnuma_mig= 0.00 xllc_mig= 2.20 affn_viol= 0.00 xlayer_wake= 2.20 xlayer_rewake= 0.49
          preempt/first/idle/fail= 0.73/ 0.00/ 9.29/ 0.00 min_exec=97.31/ 154.45ms
          cpus=  2 [  2,  2] 00000003
  daemon: util/frac=   25.9/ 80.8 load/frac=      3.7/ 69.4 tasks=    71
          tot=   4995 local=32.73 wake/exp/reenq=64.66/ 2.58/ 0.02
          keep/max/busy= 0.12/ 0.00/ 0.26 kick= 1.58 yield/ign= 3.30/    0
          open_idle= 0.00 mig=26.07 xnuma_mig= 0.00 xllc_mig= 7.07 affn_viol=22.58 xlayer_wake=20.72 xlayer_rewake=20.02
          preempt/first/idle/fail= 0.00/ 0.00/ 0.00/ 0.00 min_exec= 0.00/   0.00ms
          cpus=  2 [  2,  4] 0000000c
  normal: util/frac=    0.0/  0.0 load/frac=      0.0/  0.0 tasks=     0
          tot=      0 local= 0.00 wake/exp/reenq= 0.00/ 0.00/ 0.00
          keep/max/busy= 0.00/ 0.00/ 0.00 kick= 0.00 yield/ign= 0.00/    0
          open_idle= 0.00 mig= 0.00 xnuma_mig= 0.00 xllc_mig= 0.00 affn_viol= 0.00 xlayer_wake= 0.00 xlayer_rewake= 0.00
          preempt/first/idle/fail= 0.00/ 0.00/ 0.00/ 0.00 min_exec= 0.00/   0.00ms
          cpus=  0 [  0,  0] 00000000
  user  : util/frac=    1.7/  5.2 load/frac=      0.3/  6.0 tasks=    10
          tot=    626 local=99.52 wake/exp/reenq= 0.48/ 0.00/ 0.00
          keep/max/busy= 0.00/ 0.00/ 0.00 kick= 0.00 yield/ign= 0.00/    0
          open_idle= 0.96 mig= 2.88 xnuma_mig= 0.00 xllc_mig= 2.56 affn_viol= 0.00 xlayer_wake= 1.76 xlayer_rewake= 0.80
          preempt/first/idle/fail= 0.00/ 0.00/ 0.48/ 0.00 min_exec=79.55/  25.25ms
          cpus=  2 [  2,  2] 00000300

@hodgesds hodgesds requested a review from htejun September 22, 2024 06:52
!(waker_tctx = lookup_task_ctx_may_fail(waker)))
return;

if (tctx->layer == waker_tctx->layer)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

At some point we'll probably want to add some logic around here for interactivity boosting similar to scx_lavd.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Update the task context to keep a mask of wakers and add stats for wakes
across layers.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
@hodgesds hodgesds changed the title scx_layered: Add waker stats per layered scx_layered: Add waker stats per layer Sep 22, 2024
if (tctx->layer == waker_tctx->layer)
return;

if ((pid_t)(tctx->waker_mask & waker->pid) == waker->pid)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether this is a bit too fuzzy. Maybe just remember the last waker pid instead of keeping or'ing them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's probably good enough.

@@ -241,13 +247,15 @@ impl LayerStats {

writeln!(
w,
" {:<width$} open_idle={} mig={} xnuma_mig={} xllc_mig={} affn_viol={}",
" {:<width$} open_idle={} mig={} xnuma_mig={} xllc_mig={} affn_viol={} xlayer_wake={} xlayer_rewake={}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's break the line so that they end up more or less with similar column width.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
@hodgesds
Copy link
Contributor Author

Refactored to use only last waker and the stats still seem reasonable:

###### Sun, 22 Sep 2024 18:05:35 -0400 ######
tot=    438 local=16.21 open_idle= 0.23 affn_viol=26.94 proc=3ms
busy=  0.4 util=   15.6 load=     16.5 fallback_cpu=  6
excl_coll=0.23 excl_preempt=0.23 excl_idle=0.13 excl_wakeup=0.26
  chrome: util/frac=    5.8/ 37.5 load/frac=      4.4/ 27.0 tasks=    75
          tot=     75 local= 1.33 wake/exp/reenq=97.33/ 0.00/ 1.33
          xlayer_wake= 4.00 xlayer_rewake= 1.33
          keep/max/busy= 0.00/ 0.00/ 0.00 kick= 1.33 yield/ign= 2.67/    0
          open_idle= 0.00 mig= 6.67 xnuma_mig= 0.00 xllc_mig= 0.00 affn_viol= 0.00
          preempt/first/idle/fail= 1.33/ 1.33/96.00/ 0.00 min_exec=97.33/  43.43ms
          cpus=  2 [  2,  2] 00000003
          excl_coll= 0.00 excl_preempt= 0.00
  daemon: util/frac=    1.4/  9.0 load/frac=      7.5/ 45.4 tasks=    56
          tot=    253 local=22.53 wake/exp/reenq=69.17/ 7.51/ 0.79
          xlayer_wake=49.80 xlayer_rewake=26.48
          keep/max/busy= 1.19/ 0.00/ 0.40 kick= 4.35 yield/ign= 9.88/    0
          open_idle= 0.00 mig= 7.91 xnuma_mig= 0.00 xllc_mig= 0.00 affn_viol=46.64
          preempt/first/idle/fail= 0.00/ 0.00/ 0.00/ 0.00 min_exec= 0.00/   0.00ms
          cpus=  2 [  2,  2] 0000000c
  normal: util/frac=    0.0/  0.0 load/frac=      0.0/  0.0 tasks=     0
          tot=      0 local= 0.00 wake/exp/reenq= 0.00/ 0.00/ 0.00
          xlayer_wake= 0.00 xlayer_rewake= 0.00
          keep/max/busy= 0.00/ 0.00/ 0.00 kick= 0.00 yield/ign= 0.00/    0
          open_idle= 0.00 mig= 0.00 xnuma_mig= 0.00 xllc_mig= 0.00 affn_viol= 0.00
          preempt/first/idle/fail= 0.00/ 0.00/ 0.00/ 0.00 min_exec= 0.00/   0.00ms
          cpus=  0 [  0,  0] 00000000
  user  : util/frac=    8.3/ 53.5 load/frac=      4.5/ 27.6 tasks=    24
          tot=    110 local=11.82 wake/exp/reenq=87.27/ 0.00/ 0.91
          xlayer_wake=10.00 xlayer_rewake= 4.55
          keep/max/busy= 0.91/ 0.00/ 0.00 kick= 1.82 yield/ign= 1.82/    0
          open_idle= 0.91 mig=26.36 xnuma_mig= 0.00 xllc_mig= 1.82 affn_viol= 0.00
          preempt/first/idle/fail= 2.73/ 2.73/83.64/ 0.00 min_exec=98.18/  66.62ms
          cpus=  2 [  2,  2] 00000030
          excl_coll= 0.91 excl_preempt= 0.91

@hodgesds hodgesds merged commit 8b14e48 into sched-ext:main Sep 23, 2024
1 of 2 checks passed
@hodgesds hodgesds deleted the layered-last-waker branch September 23, 2024 14:58
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.

None yet

2 participants