sched_ext: Implement event counter infrastructure
authorChangwoo Min <changwoo@igalia.com>
Fri, 31 Jan 2025 07:09:28 +0000 (16:09 +0900)
committerTejun Heo <tj@kernel.org>
Sun, 2 Feb 2025 17:23:18 +0000 (07:23 -1000)
commit17103b8504de68958b0ff412ed2ae2e6484fa65f
treea8fbe7349b4f1a3ba6fdfb5c4d618619ca1b4166
parent337d1b354a297155579dea970fff9dd10ed32f77
sched_ext: Implement event counter infrastructure

Collect the statistics of specific types of behavior in the sched_ext core,
which are not easily visible but still interesting to an scx scheduler.

An event type is defined in 'struct scx_event_stats.' When an event occurs,
its counter is accumulated using 'scx_add_event()' and '__scx_add_event()'
to per-CPU 'struct scx_event_stats' for efficiency. 'scx_bpf_events()'
aggregates all the per-CPU counters and exposes a system-wide counters.

For convenience and readability of the code, 'scx_agg_event()' and
'scx_dump_event()' are provided.

The collected events can be observed after a BPF scheduler is unloaded
beforea new BPF scheduler is loaded so the per-CPU 'struct scx_event_stats'
are reset.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c