mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
tools/sched_ext: scx_qmap - Add init fault injection modes
Add -J init-fail which makes ops.init_task() fail with -ENOMEM for tasks whose comm starts with "qmfail", and -J cgrp-init-fail which does the same in ops.cgroup_init() for cgroups named "qmfail*". The former exercises the migration veto path: the cgroup.procs write must fail with the injected errno while the destination sched stays up and the task stays put. The latter exercises the ownership-return failure path: a parent failing to re-init a returned cgroup leaves it unowned, and moves and set_* ops against it must be skipped instead of dereferencing the missing owner. Matching on "qmfail" names keeps the injecting scheduler's own enable unaffected. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Andrea Righi <arighi@nvidia.com>
This commit is contained in:
parent
29ac3ae9ab
commit
01cad83043
|
|
@ -888,6 +888,10 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(qmap_init_task, struct task_struct *p,
|
|||
struct task_ctx_stor_val *v;
|
||||
task_ctx_t *taskc;
|
||||
|
||||
if (qa.inject_mode == QMAP_INJ_INIT_FAIL &&
|
||||
!bpf_strncmp(p->comm, 6, "qmfail"))
|
||||
return -ENOMEM;
|
||||
|
||||
if (p->tgid == disallow_tgid)
|
||||
p->scx.disallow = true;
|
||||
|
||||
|
|
@ -1012,10 +1016,21 @@ void BPF_STRUCT_OPS(qmap_dump_task, struct scx_dump_ctx *dctx, struct task_struc
|
|||
|
||||
s32 BPF_STRUCT_OPS(qmap_cgroup_init, struct cgroup *cgrp, struct scx_cgroup_init_args *args)
|
||||
{
|
||||
QMAP_TOUCH_ARENA();
|
||||
|
||||
if (print_msgs)
|
||||
bpf_printk("CGRP INIT %llu weight=%u period=%lu quota=%ld burst=%lu",
|
||||
cgrp->kn->id, args->weight, args->bw_period_us,
|
||||
args->bw_quota_us, args->bw_burst_us);
|
||||
|
||||
if (qa.inject_mode == QMAP_INJ_CGRP_INIT_FAIL) {
|
||||
char name[7] = {};
|
||||
|
||||
bpf_probe_read_kernel_str(name, sizeof(name), cgrp->kn->name);
|
||||
if (!bpf_strncmp(name, 6, "qmfail"))
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,9 @@ const char help_fmt[] =
|
|||
" -C MODE cid-override test (shuffle|bad-dup|bad-range|bad-mono)\n"
|
||||
" -i SEC Stats interval, seconds (default 5)\n"
|
||||
" -R MS Round-robin period for time-shared cpus, ms (default 200)\n"
|
||||
" -J MODE Fault injection (wrong-cid: dispatch to a cid not held)\n"
|
||||
" -J MODE Fault injection (wrong-cid: dispatch to a cid not held,\n"
|
||||
" init-fail/cgrp-init-fail: fail init_task/cgroup_init for\n"
|
||||
" \"qmfail*\" comms/cgroups)\n"
|
||||
" -v Print libbpf debug messages\n"
|
||||
" -h Display this help and exit\n";
|
||||
|
||||
|
|
@ -391,6 +393,10 @@ int main(int argc, char **argv)
|
|||
case 'J':
|
||||
if (!strcmp(optarg, "wrong-cid"))
|
||||
inject_mode = QMAP_INJ_WRONG_CID;
|
||||
else if (!strcmp(optarg, "init-fail"))
|
||||
inject_mode = QMAP_INJ_INIT_FAIL;
|
||||
else if (!strcmp(optarg, "cgrp-init-fail"))
|
||||
inject_mode = QMAP_INJ_CGRP_INIT_FAIL;
|
||||
else
|
||||
inject_mode = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ struct qmap_fifo {
|
|||
enum qmap_inject {
|
||||
QMAP_INJ_OFF = 0,
|
||||
QMAP_INJ_WRONG_CID = 1, /* dispatch to a cid we don't hold */
|
||||
QMAP_INJ_INIT_FAIL = 2, /* fail init_task for "qmfail*" comms */
|
||||
QMAP_INJ_CGRP_INIT_FAIL = 3, /* fail cgroup_init for "qmfail*" cgroups */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user