Commit fedd3b4
committed
scx_p2dq: Add DHQ support and fix migration-disabled task errors
Integrate Double Helix Queue (DHQ) as an alternative to ATQ for LLC-aware
task migration, and fix critical race condition causing migration-disabled
task errors.
DHQ Integration:
- Add --dhq-enabled flag to enable DHQ mode for LLC migration
- Add --dhq-max-imbalance parameter (default: 3) to control strand balance
- Create one DHQ per pair of LLCs in same NUMA node
- Map each LLC to a specific strand (A or B) for cache affinity
- Each CPU inherits strand from its LLC for proper load distribution
- DHQ provides cache-aware migration with controlled cross-LLC movement
Strand-Specific DHQ Operations:
Use scx_dhq_peek_strand() and scx_dhq_pop_strand() instead of generic
operations to ensure CPUs only consume from their designated strand.
This preserves cache locality and prevents load imbalance.
Data Structure Changes:
- Add mig_dhq and dhq_strand to cpu_ctx and llc_ctx
- Add llc_pair_dhqs[] for shared DHQs between LLC pairs
- Add llcs_per_node[] to track LLCs per NUMA node
- Add P2DQ_ENQUEUE_PROMISE_DHQ_VTIME enqueue promise type
- Add enqueue_promise_dhq struct for DHQ-specific metadata
Configuration:
- p2dq_config.dhq_enabled: Enable DHQ mode
- p2dq_config.dhq_max_imbalance: Control strand pairing (0 = unlimited)
- Priority mode: lowest vtime wins across strands
Build System:
- Add lib/dhq.bpf.c to scx_p2dq and scx_chaos builds
scx_chaos Compatibility:
- Update enqueue promise handling to recognize DHQ type
- Error message updated to mention both ATQs and DHQs not supported
Benefits:
- Cache affinity: Tasks stay on origin LLC (strand)
- Controlled migration: max_imbalance prevents migration storms
- Race-free: Atomic affinity handling eliminates migration-disabled errors
- Work conservation: Cross-strand stealing when priority demands
- Scalable: Lock contention distributed across DHQ strands
Signed-off-by: Daniel Hodges <[email protected]>1 parent f11fd26 commit fedd3b4
File tree
7 files changed
+367
-59
lines changed- lib
- scheds/rust
- scx_chaos
- src/bpf
- scx_p2dq
- src
- bpf
7 files changed
+367
-59
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
| 508 | + | |
| 509 | + | |
509 | 510 | | |
510 | 511 | | |
511 | 512 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
0 commit comments