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 per layer weights #735

Merged
merged 17 commits into from
Oct 4, 2024
Merged

Conversation

hodgesds
Copy link
Contributor

@hodgesds hodgesds commented Oct 4, 2024

This is a rather large PR and I can break it into smaller chunks if needed. There are a few new features added:

  • layer dsq iteration algos: There's now an implementation that allows for different layer DSQ iteration algorithms. Currently, the algorithm is a round robin style iteration algorithm but it has caused some performance regressions as noted by @samuelnair. This should provide more configuration to the scheduler.

  • layer weights: The BPF side of layer weighting is not done and will be added in future PRs as this PR is already too large. The weights of a layer are used during layer growth in user-space side as well weighted utilization/load metrics via stats.

  • layer growth/preemption disabling based on load: These features are additional configuration that allow to disable preemption/layer growth on layers that are utilizing beyond the configured threshold.

stats output:

###### Fri, 4 Oct 2024 07:38:07 -0700 ######
tot=  32346 local=78.16 open_idle= 0.21 affn_viol= 0.00 proc=5ms nodes=2
busy= 46.5 util= 3171.4 load=  15270.2 fallback_cpu= 20
excl_coll=0.00 excl_preempt=0.00 excl_idle=0.28 excl_wakeup=0.07
  hodgesd  : util/dcycle/frac/ 38.0/  1.2/    1.2 load/load_adj/frac=   115.00/0.62/  0.8 tasks=   906
             tot=   7553 local=14.55 wake/exp/reenq=85.28/ 0.17/ 0.00
             xlayer_wake= 5.84 xlayer_rewake= 0.73
             keep/max/busy= 3.87/ 0.00/ 0.00 kick= 0.08 yield/ign= 0.66/    2 
             open_idle= 0.00 mig=55.40 xnuma_mig=18.10 xllc_mig=18.10 affn_viol= 0.00
             preempt/first/xllc/xnuma/idle/fail= 2.61/ 2.03/ 0.00/ 0.00/75.41/14.70 min_exec= 0.00/   0.00ms, slice=0.8ms
             cpus=  2 [  2,  4] 00000001 00000100 00000000
  normal   : util/dcycle/frac/133.7/  4.2/    4.2 load/load_adj/frac= 12155.23/0.88/ 79.6 tasks=  2760
             tot=  24745 local=97.73 wake/exp/reenq= 1.96/ 0.31/ 0.00
             xlayer_wake= 6.17 xlayer_rewake= 1.09
             keep/max/busy= 2.93/ 0.00/ 0.00 kick= 0.31 yield/ign= 0.07/  485 
             open_idle= 0.28 mig= 9.11 xnuma_mig= 0.53 xllc_mig= 0.53 affn_viol= 0.00
             preempt/first/xllc/xnuma/idle/fail= 0.00/ 0.00/ 0.00/ 0.00/ 0.00/ 0.00 min_exec= 0.00/   0.00ms, slice=0.8ms
             cpus= 40 [ 38, 40] fff00000 f00000ff 0000ffff
             excl_coll= 0.00 excl_preempt= 0.00
  random   : util/dcycle/frac/  0.0/  0.0/    0.0 load/load_adj/frac=     0.00/0.00/  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/xllc/xnuma/idle/fail= 0.00/ 0.00/ 0.00/ 0.00/ 0.00/ 0.00 min_exec= 0.00/   0.00ms, slice=0.5ms
             cpus=  0 [  0,  0] 00000000 00000000 00000000
  stress-ng: util/dcycle/frac/2999.7/ 94.6/   94.6 load/load_adj/frac=  3000.01/98.50/ 19.6 tasks=    31
             tot=     48 local= 0.00 wake/exp/reenq= 0.00/100.0/ 0.00
             xlayer_wake= 0.00 xlayer_rewake= 0.00
             keep/max/busy=62112.5/118.8/ 0.00 kick=100.0 yield/ign= 0.00/    0 
             open_idle= 0.00 mig=91.67 xnuma_mig=41.67 xllc_mig=41.67 affn_viol= 0.00
             preempt/first/xllc/xnuma/idle/fail= 0.00/ 0.00/ 0.00/ 0.00/ 0.00/ 0.00 min_exec= 0.00/   0.00ms, slice=0.8ms
             cpus= 38 [ 38, 38] 000ffffe 0ffffe00 00000000
             excl_coll= 0.00 excl_preempt= 0.00

if (disable_topology) {
if (MEMBER_VPTR(layers, [layer_idx].preempt) && scx_bpf_consume(layer_idx))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @samuelnair this is reverting back to the previous logic of disabled topology.

Copy link
Contributor

@JakeHillion JakeHillion left a comment

Choose a reason for hiding this comment

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

Some comments, a few rust nits, but LGTM.

scheds/rust/scx_layered/src/bpf/intf.h Outdated Show resolved Hide resolved
scheds/rust/scx_layered/src/bpf/main.bpf.c Show resolved Hide resolved
scheds/rust/scx_layered/src/main.rs Outdated Show resolved Hide resolved
scheds/rust/scx_layered/src/main.rs Outdated Show resolved Hide resolved
scheds/rust/scx_layered/src/main.rs Outdated Show resolved Hide resolved
scheds/rust/scx_layered/src/main.rs Outdated Show resolved Hide resolved
Add weights to layers and use the infeasible weights crate to properly
apply weights during contention to prevent starvation.

Signed-off-by: Daniel Hodges <[email protected]>
Add stats for infeasible weights adjusted layer stats.

Signed-off-by: Daniel Hodges <[email protected]>
Add weights to userspace layer config.

Signed-off-by: Daniel Hodges <[email protected]>
Add two new flags `layer_preempt_weight_disable` and
`layer_growth_weight_disable` to disabled preemption and layer growth
when weighted layer load exceeds the configured threshold.

Signed-off-by: Daniel Hodges <[email protected]>
Add a flag to control DSQ iteration across layers by layer weight. This
helps prevent starvation by iterating over layers with the lowest weight
first.

Signed-off-by: Daniel Hodges <[email protected]>
Signed-off-by: Daniel Hodges <[email protected]>
Fix a bug to use duty cycle for infeasible weights calculations.

Signed-off-by: Daniel Hodges <[email protected]>
Add DSQ iteration algorithms.

Signed-off-by: Daniel Hodges <[email protected]>
Cleanup from code review.

Signed-off-by: Daniel Hodges <[email protected]>
Cleanup the calculation of the infeasible weight to not use an
unneccesary collect.

Signed-off-by: Daniel Hodges <[email protected]>
@hodgesds
Copy link
Contributor Author

hodgesds commented Oct 4, 2024

Testing different iteration orders:

$ /scx_layered --stats 1 f:/home/hodgesd/user2.json  --dsq-iter-algo round_robin -vvv
...
     scx_layered-3213102 [027] ....1 3645195.774364: bpf_trace_printk: ITER algo: 0
     scx_layered-3213102 [027] ....1 3645195.774365: bpf_trace_printk: ITER order i: 0 0
     scx_layered-3213102 [027] ....1 3645195.774365: bpf_trace_printk: ITER order i: 1 1
     scx_layered-3213102 [027] ....1 3645195.774365: bpf_trace_printk: ITER order i: 2 2
     scx_layered-3213102 [027] ....1 3645195.774366: bpf_trace_printk: ITER order i: 3 3
     scx_layered-3214054 [018] ....1 3645205.864882: bpf_trace_printk: ITER algo: 1
     scx_layered-3214054 [018] ....1 3645205.864883: bpf_trace_printk: ITER order i: 0 0
     scx_layered-3214054 [018] ....1 3645205.864883: bpf_trace_printk: ITER order i: 1 1
     scx_layered-3214054 [018] ....1 3645205.864884: bpf_trace_printk: ITER order i: 2 2
     scx_layered-3214054 [018] ....1 3645205.864884: bpf_trace_printk: ITER order i: 3 3
     scx_layered-3214431 [033] ....1 3645212.502821: bpf_trace_printk: ITER algo: 2
     scx_layered-3214431 [033] ....1 3645212.502822: bpf_trace_printk: ITER order i: 0 3
     scx_layered-3214431 [033] ....1 3645212.502823: bpf_trace_printk: ITER order i: 1 0
     scx_layered-3214431 [033] ....1 3645212.502823: bpf_trace_printk: ITER order i: 2 1
     scx_layered-3214431 [033] ....1 3645212.502824: bpf_trace_printk: ITER order i: 3 2

@hodgesds hodgesds added this pull request to the merge queue Oct 4, 2024
Merged via the queue into sched-ext:main with commit fdc5640 Oct 4, 2024
19 checks passed
@hodgesds hodgesds deleted the layered-weights branch October 4, 2024 19:48
@hodgesds
Copy link
Contributor Author

hodgesds commented Oct 4, 2024

This partially implements #646

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.

2 participants