mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-25 04:00:24 +00:00
scx/compat.bpf.h: Fix __COMPAT_scx_bpf_consume_task() and improve scx_qmap example
__COMPAT_scx_bpf_consume_task() wasn't calling scx_bpf_consume_task() at all and was always returning false. Fix it. Also, update scx_qmap usage example so that it matches cgroup ID rather than comm prefix. This should make testing with multiple processes a bit easier.
This commit is contained in:
parent
dfe0ffb312
commit
1012e3a6db
@ -38,7 +38,7 @@ const volatile u32 stall_kernel_nth;
|
||||
const volatile u32 dsp_inf_loop_after;
|
||||
const volatile u32 dsp_batch;
|
||||
const volatile bool print_shared_dsq;
|
||||
const volatile char exp_prefix[17];
|
||||
const volatile u64 exp_cgid;
|
||||
const volatile s32 disallow_tgid;
|
||||
const volatile bool suppress_dump;
|
||||
|
||||
@ -267,7 +267,7 @@ static bool consume_shared_dsq(void)
|
||||
struct task_struct *p;
|
||||
bool consumed;
|
||||
|
||||
if (exp_prefix[0] == '\0')
|
||||
if (!exp_cgid)
|
||||
return scx_bpf_consume(SHARED_DSQ);
|
||||
|
||||
/*
|
||||
@ -278,12 +278,7 @@ static bool consume_shared_dsq(void)
|
||||
*/
|
||||
consumed = false;
|
||||
__COMPAT_DSQ_FOR_EACH(p, SHARED_DSQ, 0) {
|
||||
char comm[sizeof(exp_prefix)];
|
||||
|
||||
memcpy(comm, p->comm, sizeof(exp_prefix) - 1);
|
||||
|
||||
if (!bpf_strncmp(comm, sizeof(exp_prefix),
|
||||
(const char *)exp_prefix) &&
|
||||
if (p->cgroups->dfl_cgrp->kn->id == exp_cgid &&
|
||||
__COMPAT_scx_bpf_consume_task(BPF_FOR_EACH_ITER, p)) {
|
||||
consumed = true;
|
||||
__sync_fetch_and_add(&nr_expedited, 1);
|
||||
|
@ -29,8 +29,7 @@ const char help_fmt[] =
|
||||
" -l COUNT Trigger dispatch infinite looping after COUNT dispatches\n"
|
||||
" -b COUNT Dispatch upto COUNT tasks together\n"
|
||||
" -P Print out DSQ content to trace_pipe every second, use with -b\n"
|
||||
" -E PREFIX Expedite consumption of threads w/ matching comm, use with -b\n"
|
||||
" (e.g. match shell on a loaded system)\n"
|
||||
" -E CGID Expedite consumption of threads in a cgroup, use with -b\n"
|
||||
" -d PID Disallow a process from switching into SCHED_EXT (-1 for self)\n"
|
||||
" -D LEN Set scx_exit_info.dump buffer length\n"
|
||||
" -S Suppress qmap-specific debug dump\n"
|
||||
@ -89,8 +88,7 @@ int main(int argc, char **argv)
|
||||
skel->rodata->print_shared_dsq = true;
|
||||
break;
|
||||
case 'E':
|
||||
strncpy(skel->rodata->exp_prefix, optarg,
|
||||
sizeof(skel->rodata->exp_prefix) - 1);
|
||||
skel->rodata->exp_cgid = strtoull(optarg, NULL, 0);
|
||||
break;
|
||||
case 'd':
|
||||
skel->rodata->disallow_tgid = strtol(optarg, NULL, 0);
|
||||
@ -116,7 +114,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!__COMPAT_HAS_DSQ_ITER &&
|
||||
(skel->rodata->print_shared_dsq || strlen(skel->rodata->exp_prefix)))
|
||||
(skel->rodata->print_shared_dsq || skel->rodata->exp_cgid))
|
||||
fprintf(stderr, "kernel doesn't support DSQ iteration\n");
|
||||
|
||||
SCX_OPS_LOAD(skel, qmap_ops, scx_qmap, uei);
|
||||
|
@ -27,7 +27,10 @@
|
||||
static inline bool __COMPAT_scx_bpf_consume_task(struct bpf_iter_scx_dsq *it,
|
||||
struct task_struct *p)
|
||||
{
|
||||
return false;
|
||||
if (bpf_ksym_exists(__scx_bpf_consume_task))
|
||||
return scx_bpf_consume_task(it, p);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user