mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
sched_ext: Add tracepoint for scheduler exit
sched_ext schedulers have state in BPF programs and kernel. scx_dump provides kernel state and BPF program state on error, but this is static in what it can provide. Add a sched_ext_exit tracepoint in scx_claim_exit() so that BPF programs can dynamically inspect scheduler specific state at the moment of exit. Pass the exiting scx_sched so attached programs can read its state, and, since exits propagate through a hierarchy of sub-schedulers, identify which scheduler each event belongs to. Signed-off-by: Pat Somaru <patso@likewhatevs.io> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
3d1519011e
commit
cbcda14b12
|
|
@ -84,6 +84,34 @@ TRACE_EVENT(sched_ext_bypass_lb,
|
|||
)
|
||||
);
|
||||
|
||||
TRACE_EVENT(sched_ext_exit,
|
||||
|
||||
TP_PROTO(struct scx_sched *sch, __u32 kind),
|
||||
|
||||
TP_ARGS(sch, kind),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__string( name, sch->ops.name )
|
||||
__field( __s32, level )
|
||||
__field( __u64, sub_cgroup_id )
|
||||
__string( cgrp_path, sch_cgrp_path(sch) )
|
||||
__field( __u32, kind )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__assign_str(name);
|
||||
__entry->level = sch->level;
|
||||
__entry->sub_cgroup_id = sch->ops.sub_cgroup_id;
|
||||
__assign_str(cgrp_path);
|
||||
__entry->kind = kind;
|
||||
),
|
||||
|
||||
TP_printk("sched %s level %d sub_cgroup_id %llu cgrp_path %s kind %u",
|
||||
__get_str(name), __entry->level, __entry->sub_cgroup_id,
|
||||
__get_str(cgrp_path), __entry->kind
|
||||
)
|
||||
);
|
||||
|
||||
#endif /* _TRACE_SCHED_EXT_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
|
|
|||
|
|
@ -5753,6 +5753,8 @@ static bool scx_claim_exit(struct scx_sched *sch, enum scx_exit_kind kind)
|
|||
*/
|
||||
WRITE_ONCE(sch->aborting, true);
|
||||
|
||||
trace_sched_ext_exit(sch, kind);
|
||||
|
||||
/*
|
||||
* Propagate exits to descendants immediately. Each has a dedicated
|
||||
* helper kthread and can run in parallel. While most of disabling is
|
||||
|
|
|
|||
|
|
@ -25,11 +25,17 @@ void scx_sub_disable(struct scx_sched *sch);
|
|||
void scx_sub_enable_workfn(struct kthread_work *work);
|
||||
bool scx_bpf_sub_dispatch(u64 cgroup_id, const struct bpf_prog_aux *aux);
|
||||
|
||||
static inline const char *sch_cgrp_path(struct scx_sched *sch)
|
||||
{
|
||||
return sch->cgrp_path;
|
||||
}
|
||||
|
||||
#else /* CONFIG_EXT_SUB_SCHED */
|
||||
|
||||
static inline struct scx_sched *scx_next_descendant_pre(struct scx_sched *pos, struct scx_sched *root) { return pos ? NULL : root; }
|
||||
static inline void scx_set_task_sched(struct task_struct *p, struct scx_sched *sch) {}
|
||||
static inline struct cgroup *sch_cgroup(struct scx_sched *sch) { return NULL; }
|
||||
static inline const char *sch_cgrp_path(struct scx_sched *sch) { return "/"; }
|
||||
static inline void set_cgroup_sched(struct cgroup *cgrp, struct scx_sched *sch) {}
|
||||
static inline void drain_descendants(struct scx_sched *sch) { }
|
||||
static inline void scx_sub_disable(struct scx_sched *sch) { }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user