[PATCH v2 11/11] sched_ext: Print core event count in scx_central scheduler

Changwoo Min posted 11 patches 1 year ago
There is a newer version of this series
[PATCH v2 11/11] sched_ext: Print core event count in scx_central scheduler
Posted by Changwoo Min 1 year ago
Modify the scx_central scheduler to print the core event counter
every second.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
---
 tools/sched_ext/scx_central.bpf.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/sched_ext/scx_central.bpf.c b/tools/sched_ext/scx_central.bpf.c
index 50bc1737c167..96b3c08132ea 100644
--- a/tools/sched_ext/scx_central.bpf.c
+++ b/tools/sched_ext/scx_central.bpf.c
@@ -256,6 +256,7 @@ static int central_timerfn(void *map, int *key, struct bpf_timer *timer)
 	u64 now = scx_bpf_now();
 	u64 nr_to_kick = nr_queued;
 	s32 i, curr_cpu;
+	struct scx_event_stats events;
 
 	curr_cpu = bpf_get_smp_processor_id();
 	if (timer_pinned && (curr_cpu != central_cpu)) {
@@ -291,6 +292,26 @@ static int central_timerfn(void *map, int *key, struct bpf_timer *timer)
 
 	bpf_timer_start(timer, TIMER_INTERVAL_NS, BPF_F_TIMER_CPU_PIN);
 	__sync_fetch_and_add(&nr_timers, 1);
+
+	/* print event counters every second */
+	if (nr_timers % 1000 == 0) {
+		scx_bpf_event_stats(&events, sizeof(events));
+
+		bpf_printk("%30s: %llu\n", "SELECT_CPU_FALLBACK",
+			   scx_read_event(&events, SELECT_CPU_FALLBACK));
+		bpf_printk("%30s: %llu\n", "DISPATCH_LOCAL_DSQ_OFFLINE",
+			   scx_read_event(&events, DISPATCH_LOCAL_DSQ_OFFLINE));
+		bpf_printk("%30s: %llu\n", "DISPATCH_KEEP_LAST",
+			   scx_read_event(&events, DISPATCH_KEEP_LAST));
+		bpf_printk("%30s: %llu\n", "ENQ_SKIP_EXITING",
+			   scx_read_event(&events, ENQ_SKIP_EXITING));
+		bpf_printk("%30s: %llu\n", "BYPASS_DURATION",
+			   scx_read_event(&events, BYPASS_DURATION));
+		bpf_printk("%30s: %llu\n", "BYPASS_DISPATCH",
+			   scx_read_event(&events, BYPASS_DISPATCH));
+		bpf_printk("%30s: %llu\n", "BYPASS_ACTIVATE",
+			   scx_read_event(&events, BYPASS_ACTIVATE));
+	}
 	return 0;
 }
 
-- 
2.48.1
Re: [PATCH v2 11/11] sched_ext: Print core event count in scx_central scheduler
Posted by Tejun Heo 1 year ago
On Sun, Jan 26, 2025 at 07:16:14PM +0900, Changwoo Min wrote:
> Modify the scx_central scheduler to print the core event counter
> every second.

Can you add it to scx_qmap too? That's used as the dumping ground for all
the niche features, so it'd be nice to have an example there too.

Thanks.

-- 
tejun
Re: [PATCH v2 11/11] sched_ext: Print core event count in scx_central scheduler
Posted by Changwoo Min 1 year ago
Hello,

On 25. 1. 28. 05:08, Tejun Heo wrote:
> On Sun, Jan 26, 2025 at 07:16:14PM +0900, Changwoo Min wrote:
>> Modify the scx_central scheduler to print the core event counter
>> every second.
> 
> Can you add it to scx_qmap too? That's used as the dumping ground for all
> the niche features, so it'd be nice to have an example there too.

Sure, I will add the event dump feature to monitor_timerfn() in scx_qmap.

Regards,
Changwoo Min