Commit 60c27fb
committed
sched_ext: Implement sched_ext_ops.cpu_online/offline()
Add ops.cpu_online/offline() which are invoked when CPUs come online and
offline respectively. As the enqueue path already automatically bypasses
tasks to the local dsq on a deactivated CPU, BPF schedulers are guaranteed
to see tasks only on CPUs which are between online() and offline().
If the BPF scheduler doesn't implement ops.cpu_online/offline(), the
scheduler is automatically exited with SCX_ECODE_RESTART |
SCX_ECODE_RSN_HOTPLUG. Userspace can implement CPU hotpplug support
trivially by simply reinitializing and reloading the scheduler.
scx_qmap is updated to print out online CPUs on hotplug events. Other
schedulers are updated to restart based on ecode.
v3: - The previous implementation added @Reason to
sched_class.rq_on/offline() to distinguish between CPU hotplug events
and topology updates. This was buggy and fragile as the methods are
skipped if the current state equals the target state. Instead, add
scx_rq_[de]activate() which are directly called from
sched_cpu_de/activate(). This also allows ops.cpu_on/offline() to
sleep which can be useful.
- ops.dispatch() could be called on a CPU that the BPF scheduler was
told to be offline. The dispatch patch is updated to bypass in such
cases.
v2: - To accommodate lock ordering change between scx_cgroup_rwsem and
cpus_read_lock(), CPU hotplug operations are put into its own SCX_OPI
block and enabled eariler during scx_ope_enable() so that
cpus_read_lock() can be dropped before acquiring scx_cgroup_rwsem.
- Auto exit with ECODE added.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: David Vernet <dvernet@meta.com>
Acked-by: Josh Don <joshdon@google.com>
Acked-by: Hao Luo <haoluo@google.com>
Acked-by: Barret Rhoden <brho@google.com>1 parent 245254f commit 60c27fb
File tree
10 files changed
+290
-12
lines changed- kernel/sched
- tools/sched_ext
- include/scx
10 files changed
+290
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7984 | 7984 | | |
7985 | 7985 | | |
7986 | 7986 | | |
| 7987 | + | |
| 7988 | + | |
7987 | 7989 | | |
7988 | 7990 | | |
7989 | 7991 | | |
| |||
8044 | 8046 | | |
8045 | 8047 | | |
8046 | 8048 | | |
| 8049 | + | |
| 8050 | + | |
8047 | 8051 | | |
8048 | 8052 | | |
8049 | 8053 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
33 | 56 | | |
34 | 57 | | |
35 | 58 | | |
| |||
457 | 480 | | |
458 | 481 | | |
459 | 482 | | |
460 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
461 | 506 | | |
462 | 507 | | |
463 | 508 | | |
| |||
496 | 541 | | |
497 | 542 | | |
498 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
499 | 553 | | |
500 | 554 | | |
501 | 555 | | |
| |||
509 | 563 | | |
510 | 564 | | |
511 | 565 | | |
512 | | - | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
513 | 569 | | |
514 | 570 | | |
515 | 571 | | |
| |||
694 | 750 | | |
695 | 751 | | |
696 | 752 | | |
| 753 | + | |
697 | 754 | | |
698 | 755 | | |
699 | 756 | | |
| |||
1419 | 1476 | | |
1420 | 1477 | | |
1421 | 1478 | | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
| 1479 | + | |
1427 | 1480 | | |
1428 | 1481 | | |
1429 | 1482 | | |
| |||
1438 | 1491 | | |
1439 | 1492 | | |
1440 | 1493 | | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
1441 | 1499 | | |
1442 | 1500 | | |
1443 | 1501 | | |
| |||
2673 | 2731 | | |
2674 | 2732 | | |
2675 | 2733 | | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
2676 | 2770 | | |
2677 | 2771 | | |
2678 | 2772 | | |
| |||
3104 | 3198 | | |
3105 | 3199 | | |
3106 | 3200 | | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
3107 | 3204 | | |
3108 | 3205 | | |
3109 | 3206 | | |
| |||
3235 | 3332 | | |
3236 | 3333 | | |
3237 | 3334 | | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
3238 | 3342 | | |
3239 | 3343 | | |
3240 | 3344 | | |
3241 | 3345 | | |
| 3346 | + | |
3242 | 3347 | | |
3243 | 3348 | | |
3244 | 3349 | | |
| |||
3941 | 4046 | | |
3942 | 4047 | | |
3943 | 4048 | | |
| 4049 | + | |
| 4050 | + | |
| 4051 | + | |
| 4052 | + | |
| 4053 | + | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
| 4060 | + | |
| 4061 | + | |
| 4062 | + | |
| 4063 | + | |
| 4064 | + | |
| 4065 | + | |
| 4066 | + | |
| 4067 | + | |
3944 | 4068 | | |
3945 | 4069 | | |
3946 | 4070 | | |
| |||
4023 | 4147 | | |
4024 | 4148 | | |
4025 | 4149 | | |
| 4150 | + | |
| 4151 | + | |
| 4152 | + | |
| 4153 | + | |
4026 | 4154 | | |
4027 | 4155 | | |
4028 | 4156 | | |
| |||
4064 | 4192 | | |
4065 | 4193 | | |
4066 | 4194 | | |
| 4195 | + | |
| 4196 | + | |
4067 | 4197 | | |
4068 | 4198 | | |
4069 | 4199 | | |
| |||
4374 | 4504 | | |
4375 | 4505 | | |
4376 | 4506 | | |
| 4507 | + | |
| 4508 | + | |
| 4509 | + | |
4377 | 4510 | | |
4378 | 4511 | | |
4379 | 4512 | | |
| |||
4387 | 4520 | | |
4388 | 4521 | | |
4389 | 4522 | | |
| 4523 | + | |
| 4524 | + | |
4390 | 4525 | | |
4391 | 4526 | | |
4392 | 4527 | | |
| |||
4457 | 4592 | | |
4458 | 4593 | | |
4459 | 4594 | | |
| 4595 | + | |
| 4596 | + | |
4460 | 4597 | | |
4461 | 4598 | | |
4462 | 4599 | | |
| |||
4479 | 4616 | | |
4480 | 4617 | | |
4481 | 4618 | | |
| 4619 | + | |
| 4620 | + | |
4482 | 4621 | | |
4483 | 4622 | | |
4484 | 4623 | | |
| |||
4719 | 4858 | | |
4720 | 4859 | | |
4721 | 4860 | | |
| 4861 | + | |
| 4862 | + | |
| 4863 | + | |
4722 | 4864 | | |
4723 | 4865 | | |
4724 | 4866 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
| 86 | + | |
| 87 | + | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
726 | 726 | | |
727 | 727 | | |
728 | 728 | | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
729 | 735 | | |
730 | 736 | | |
731 | 737 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
109 | 134 | | |
110 | 135 | | |
111 | 136 | | |
| |||
123 | 148 | | |
124 | 149 | | |
125 | 150 | | |
| 151 | + | |
126 | 152 | | |
127 | 153 | | |
128 | 154 | | |
| |||
0 commit comments