diff options
author | Changwoo Min <changwoo@igalia.com> | 2025-02-14 12:57:36 +0300 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2025-02-14 20:15:41 +0300 |
commit | ad3b301aa05af408462775368bd25d2a05409fe1 (patch) | |
tree | 7e00d999ef1ec42d3ef8ef30d6f1539aad906528 | |
parent | 3539c6411a7c9d6c5895f78750f93160705cd250 (diff) | |
download | linux-ad3b301aa05af408462775368bd25d2a05409fe1.tar.xz |
sched_ext: Provides a sysfs 'events' to expose core event counters
Add a sysfs entry at /sys/kernel/sched_ext/root/events to expose core
event counters through the files system interface. Each line of the file
shows the event name and its counter value.
In addition, the format of scx_dump_event() is adjusted as the event name
gets longer.
Signed-off-by: Changwoo Min <changwoo@igalia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | kernel/sched/ext.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 2e1a1e4fc304..aec098efd6fb 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -1576,7 +1576,7 @@ static DEFINE_PER_CPU(struct scx_event_stats, event_stats_cpu); * @kind: a kind of event to dump */ #define scx_dump_event(s, events, kind) do { \ - dump_line(&(s), "%30s: %16llu", #kind, (events)->kind); \ + dump_line(&(s), "%40s: %16llu", #kind, (events)->kind); \ } while (0) @@ -4383,8 +4383,33 @@ static ssize_t scx_attr_ops_show(struct kobject *kobj, } SCX_ATTR(ops); +#define scx_attr_event_show(buf, at, events, kind) ({ \ + sysfs_emit_at(buf, at, "%s %llu\n", #kind, (events)->kind); \ +}) + +static ssize_t scx_attr_events_show(struct kobject *kobj, + struct kobj_attribute *ka, char *buf) +{ + struct scx_event_stats events; + int at = 0; + + scx_bpf_events(&events, sizeof(events)); + at += scx_attr_event_show(buf, at, &events, SCX_EV_SELECT_CPU_FALLBACK); + at += scx_attr_event_show(buf, at, &events, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE); + at += scx_attr_event_show(buf, at, &events, SCX_EV_DISPATCH_KEEP_LAST); + at += scx_attr_event_show(buf, at, &events, SCX_EV_ENQ_SKIP_EXITING); + at += scx_attr_event_show(buf, at, &events, SCX_EV_ENQ_SKIP_MIGRATION_DISABLED); + at += scx_attr_event_show(buf, at, &events, SCX_EV_ENQ_SLICE_DFL); + at += scx_attr_event_show(buf, at, &events, SCX_EV_BYPASS_DURATION); + at += scx_attr_event_show(buf, at, &events, SCX_EV_BYPASS_DISPATCH); + at += scx_attr_event_show(buf, at, &events, SCX_EV_BYPASS_ACTIVATE); + return at; +} +SCX_ATTR(events); + static struct attribute *scx_sched_attrs[] = { &scx_attr_ops.attr, + &scx_attr_events.attr, NULL, }; ATTRIBUTE_GROUPS(scx_sched); |