Skip to content

Commit 5b30fbb

Browse files
committed
scx_layered: Make cpumask debug dump prettier
Layer cpumasks were dumped in a format which is really verbose and different from how cpumasks are dumped in general. Make it follow the usual convention.
1 parent 1e5fa72 commit 5b30fbb

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

scheds/rust/scx_layered/src/bpf/main.bpf.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,26 +2809,32 @@ static s64 dsq_first_runnable_at_ms(u64 dsq_id, u64 now)
28092809
return 0;
28102810
}
28112811

2812+
__hidden void dump_cpumask_word(s32 word, struct cpumask *cpumask)
2813+
{
2814+
u32 u, v = 0;
2815+
2816+
bpf_for(u, 0, 32) {
2817+
s32 cpu = 32 * word + u;
2818+
if (cpu < nr_cpu_ids &&
2819+
bpf_cpumask_test_cpu(cpu, cpumask))
2820+
v |= 1 << u;
2821+
}
2822+
scx_bpf_dump("%08x", v);
2823+
}
2824+
28122825
static void dump_layer_cpumask(int id)
28132826
{
28142827
struct cpumask *layer_cpumask;
2815-
s32 cpu;
2816-
char buf[128] = "", *p;
2828+
u32 word, nr_words = (nr_cpu_ids + 31) / 32;
28172829

28182830
if (!(layer_cpumask = lookup_layer_cpumask(id)))
28192831
return;
28202832

2821-
bpf_for(cpu, 0, scx_bpf_nr_cpu_ids()) {
2822-
if (!(p = MEMBER_VPTR(buf, [cpu])))
2823-
break;
2824-
if (bpf_cpumask_test_cpu(cpu, layer_cpumask))
2825-
*p = '0' + cpu % 10;
2826-
else
2827-
*p = '.';
2833+
bpf_for(word, 0, nr_words) {
2834+
if (word)
2835+
scx_bpf_dump(",");
2836+
dump_cpumask_word(nr_words - word - 1, layer_cpumask);
28282837
}
2829-
buf[sizeof(buf) - 1] = '\0';
2830-
2831-
scx_bpf_dump("%s", buf);
28322838
}
28332839

28342840
void BPF_STRUCT_OPS(layered_dump, struct scx_dump_ctx *dctx)
@@ -2852,12 +2858,12 @@ void BPF_STRUCT_OPS(layered_dump, struct scx_dump_ctx *dctx)
28522858
continue;
28532859

28542860
dsq_id = layer_dsq_id(layer->id, j);
2855-
scx_bpf_dump("LAYER[%d][%s]DSQ[%llx] nr_cpus=%u nr_queued=%d %+lldms cpus=",
2861+
scx_bpf_dump("LAYER[%d](%s)-DSQ[%llx] nr_cpus=%u nr_queued=%d %+lldms\n",
28562862
i, layer->name, dsq_id, layer->nr_cpus,
28572863
scx_bpf_dsq_nr_queued(dsq_id),
28582864
dsq_first_runnable_at_ms(dsq_id, now));
2859-
scx_bpf_dump("\n");
28602865
}
2866+
scx_bpf_dump("LAYER[%d](%s) CPUS=", i, layer->name);
28612867
dump_layer_cpumask(i);
28622868
scx_bpf_dump("\n");
28632869
}

0 commit comments

Comments
 (0)