Skip to content

Commit 8ba6ffd

Browse files
authored
Merge pull request raspberrypi#51 from sched-ext/set_slice_central
2 parents b448bbd + f4fd473 commit 8ba6ffd

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

tools/sched_ext/scx_central.bpf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ enum {
5858
const volatile bool switch_partial;
5959
const volatile s32 central_cpu;
6060
const volatile u32 nr_cpu_ids = 1; /* !0 for veristat, set during init */
61+
const volatile u64 slice_ns = SCX_SLICE_DFL;
6162

6263
u64 nr_total, nr_locals, nr_queued, nr_lost_pids;
6364
u64 nr_timers, nr_dispatches, nr_mismatches, nr_retries;
@@ -263,7 +264,7 @@ static int central_timerfn(void *map, int *key, struct bpf_timer *timer)
263264
/* kick iff the current one exhausted its slice */
264265
started_at = ARRAY_ELEM_PTR(cpu_started_at, cpu, nr_cpu_ids);
265266
if (started_at && *started_at &&
266-
vtime_before(now, *started_at + SCX_SLICE_DFL))
267+
vtime_before(now, *started_at + slice_ns))
267268
continue;
268269

269270
/* and there's something pending */

tools/sched_ext/scx_central.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ const char help_fmt[] =
1818
"\n"
1919
"See the top-level comment in .bpf.c for more details.\n"
2020
"\n"
21-
"Usage: %s [-c CPU] [-p]\n"
21+
"Usage: %s [-s SLICE_US] [-c CPU] [-p]\n"
2222
"\n"
23+
" -s SLICE_US Override slice duration\n"
2324
" -c CPU Override the central CPU (default: 0)\n"
2425
" -p Switch only tasks on SCHED_EXT policy intead of all\n"
2526
" -h Display this help and exit\n";
@@ -49,8 +50,11 @@ int main(int argc, char **argv)
4950
skel->rodata->central_cpu = 0;
5051
skel->rodata->nr_cpu_ids = libbpf_num_possible_cpus();
5152

52-
while ((opt = getopt(argc, argv, "c:ph")) != -1) {
53+
while ((opt = getopt(argc, argv, "s:c:ph")) != -1) {
5354
switch (opt) {
55+
case 's':
56+
skel->rodata->slice_ns = strtoull(optarg, NULL, 0) * 1000;
57+
break;
5458
case 'c':
5559
skel->rodata->central_cpu = strtoul(optarg, NULL, 0);
5660
break;

0 commit comments

Comments
 (0)