All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates
@ 2025-02-08  8:42 Tejun Heo
  2025-02-08  8:42 ` [PATCH 1/3] tool/sched_ext: Event counter dumping updates Tejun Heo
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Tejun Heo @ 2025-02-08  8:42 UTC (permalink / raw)
  To: void, arighi, multics69; +Cc: linux-kernel, sched-ext

Hello,

This patchset contains the following three event counter updates:

 0001-tool-sched_ext-Event-counter-dumping-updates.patch
 0002-sched_ext-Count-SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE-in.patch
 0003-sched_ext-Add-SCX_EV_ENQ_SKIP_MIGRATION_DISABLED.patch

This patchset depends on two pending migration disabled handling patches on
top of sched_ext/for-614-fixes and the event counter addition in
sched_ext/for-6.15 and thus is on top of:

 sched_ext/for-6.14-fixes
 + Two migration disabled handling update patches
   http://lkml.kernel.org/r/Z6Zz79AUub1YuHwD@slm.duckdns.org
 + sched_ext/for-6.15

The following branch shows how these patches will be applied:

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git scx-evs

diffstat follows. Thanks.

 kernel/sched/ext.c                |   25 +++++++++++++++++++------
 tools/sched_ext/scx_central.bpf.c |   21 ---------------------
 tools/sched_ext/scx_qmap.bpf.c    |   16 ++++++++--------
 3 files changed, 27 insertions(+), 35 deletions(-)

--
tejun

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] tool/sched_ext: Event counter dumping updates
  2025-02-08  8:42 [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Tejun Heo
@ 2025-02-08  8:42 ` Tejun Heo
  2025-02-08  8:42 ` [PATCH 2/3] sched_ext: Count SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE in the right spot Tejun Heo
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2025-02-08  8:42 UTC (permalink / raw)
  To: void, arighi, multics69; +Cc: linux-kernel, sched-ext, Tejun Heo

- There's no need to dump event counters from both scx_qmap and scx_central.
  Drop counter dumping from scx_central.

- bpf_printk() implies a trailing new line and the explicit new line leads
  to double new lines. Drop the explicit new lines.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
 tools/sched_ext/scx_central.bpf.c | 21 ---------------------
 tools/sched_ext/scx_qmap.bpf.c    | 16 ++++++++--------
 2 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/tools/sched_ext/scx_central.bpf.c b/tools/sched_ext/scx_central.bpf.c
index 907a844723c1..5c165af1fa27 100644
--- a/tools/sched_ext/scx_central.bpf.c
+++ b/tools/sched_ext/scx_central.bpf.c
@@ -293,27 +293,6 @@ 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_events(&events, sizeof(events));
-
-		bpf_printk("%35s: %llu\n", "SCX_EV_SELECT_CPU_FALLBACK",
-			   scx_read_event(&events, SCX_EV_SELECT_CPU_FALLBACK));
-		bpf_printk("%35s: %llu\n", "SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE",
-			   scx_read_event(&events, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE));
-		bpf_printk("%35s: %llu\n", "SCX_EV_DISPATCH_KEEP_LAST",
-			   scx_read_event(&events, SCX_EV_DISPATCH_KEEP_LAST));
-		bpf_printk("%35s: %llu\n", "SCX_EV_ENQ_SKIP_EXITING",
-			   scx_read_event(&events, SCX_EV_ENQ_SKIP_EXITING));
-		bpf_printk("%35s: %llu\n", "SCX_EV_ENQ_SLICE_DFL",
-			   scx_read_event(&events, SCX_EV_ENQ_SLICE_DFL));
-		bpf_printk("%35s: %llu\n", "SCX_EV_BYPASS_DURATION",
-			   scx_read_event(&events, SCX_EV_BYPASS_DURATION));
-		bpf_printk("%35s: %llu\n", "SCX_EV_BYPASS_DISPATCH",
-			   scx_read_event(&events, SCX_EV_BYPASS_DISPATCH));
-		bpf_printk("%35s: %llu\n", "SCX_EV_BYPASS_ACTIVATE",
-			   scx_read_event(&events, SCX_EV_BYPASS_ACTIVATE));
-	}
 	return 0;
 }
 
diff --git a/tools/sched_ext/scx_qmap.bpf.c b/tools/sched_ext/scx_qmap.bpf.c
index 7d9d1e5d2358..e0e766d402e1 100644
--- a/tools/sched_ext/scx_qmap.bpf.c
+++ b/tools/sched_ext/scx_qmap.bpf.c
@@ -776,21 +776,21 @@ static int monitor_timerfn(void *map, int *key, struct bpf_timer *timer)
 
 	scx_bpf_events(&events, sizeof(events));
 
-	bpf_printk("%35s: %llu\n", "SCX_EV_SELECT_CPU_FALLBACK",
+	bpf_printk("%35s: %llu", "SCX_EV_SELECT_CPU_FALLBACK",
 		   scx_read_event(&events, SCX_EV_SELECT_CPU_FALLBACK));
-	bpf_printk("%35s: %llu\n", "SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE",
+	bpf_printk("%35s: %llu", "SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE",
 		   scx_read_event(&events, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE));
-	bpf_printk("%35s: %llu\n", "SCX_EV_DISPATCH_KEEP_LAST",
+	bpf_printk("%35s: %llu", "SCX_EV_DISPATCH_KEEP_LAST",
 		   scx_read_event(&events, SCX_EV_DISPATCH_KEEP_LAST));
-	bpf_printk("%35s: %llu\n", "SCX_EV_ENQ_SKIP_EXITING",
+	bpf_printk("%35s: %llu", "SCX_EV_ENQ_SKIP_EXITING",
 		   scx_read_event(&events, SCX_EV_ENQ_SKIP_EXITING));
-	bpf_printk("%35s: %llu\n", "SCX_EV_ENQ_SLICE_DFL",
+	bpf_printk("%35s: %llu", "SCX_EV_ENQ_SLICE_DFL",
 		   scx_read_event(&events, SCX_EV_ENQ_SLICE_DFL));
-	bpf_printk("%35s: %llu\n", "SCX_EV_BYPASS_DURATION",
+	bpf_printk("%35s: %llu", "SCX_EV_BYPASS_DURATION",
 		   scx_read_event(&events, SCX_EV_BYPASS_DURATION));
-	bpf_printk("%35s: %llu\n", "SCX_EV_BYPASS_DISPATCH",
+	bpf_printk("%35s: %llu", "SCX_EV_BYPASS_DISPATCH",
 		   scx_read_event(&events, SCX_EV_BYPASS_DISPATCH));
-	bpf_printk("%35s: %llu\n", "SCX_EV_BYPASS_ACTIVATE",
+	bpf_printk("%35s: %llu", "SCX_EV_BYPASS_ACTIVATE",
 		   scx_read_event(&events, SCX_EV_BYPASS_ACTIVATE));
 
 	bpf_timer_start(timer, ONE_SEC_IN_NS, 0);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] sched_ext: Count SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE in the right spot
  2025-02-08  8:42 [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Tejun Heo
  2025-02-08  8:42 ` [PATCH 1/3] tool/sched_ext: Event counter dumping updates Tejun Heo
@ 2025-02-08  8:42 ` Tejun Heo
  2025-02-08  8:42 ` [PATCH 3/3] sched_ext: Add SCX_EV_ENQ_SKIP_MIGRATION_DISABLED Tejun Heo
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2025-02-08  8:42 UTC (permalink / raw)
  To: void, arighi, multics69; +Cc: linux-kernel, sched-ext, Tejun Heo

SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE wasn't quite right in two aspects:

- It counted both migration disabled and offline events.

- It didn't count events from scx_bpf_dsq_move() path.

Fix it by moving the counting into task_can_run_on_remote_rq() which is
shared by both paths and can distinguish the different rejection conditions.
The argument @trigger_error is renamed to @enforce as it now does more than
just triggering error.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/sched/ext.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 5dfcba6adcda..310db8484b77 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2431,7 +2431,7 @@ static void move_remote_task_to_local_dsq(struct task_struct *p, u64 enq_flags,
  * The caller must ensure that @p and @rq are on different CPUs.
  */
 static bool task_can_run_on_remote_rq(struct task_struct *p, struct rq *rq,
-				      bool trigger_error)
+				      bool enforce)
 {
 	int cpu = cpu_of(rq);
 
@@ -2444,7 +2444,7 @@ static bool task_can_run_on_remote_rq(struct task_struct *p, struct rq *rq,
 	 * picked CPU is outside the allowed mask.
 	 */
 	if (!task_allowed_on_cpu(p, cpu)) {
-		if (trigger_error)
+		if (enforce)
 			scx_ops_error("SCX_DSQ_LOCAL[_ON] verdict target cpu %d not allowed for %s[%d]",
 				      cpu_of(rq), p->comm, p->pid);
 		return false;
@@ -2456,8 +2456,11 @@ static bool task_can_run_on_remote_rq(struct task_struct *p, struct rq *rq,
 	 */
 	SCHED_WARN_ON(is_migration_disabled(p));
 
-	if (!scx_rq_online(rq))
+	if (!scx_rq_online(rq)) {
+		if (enforce)
+			__scx_add_event(SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE, 1);
 		return false;
+	}
 
 	return true;
 }
@@ -2527,7 +2530,7 @@ static bool consume_remote_task(struct rq *this_rq, struct task_struct *p,
 }
 #else	/* CONFIG_SMP */
 static inline void move_remote_task_to_local_dsq(struct task_struct *p, u64 enq_flags, struct rq *src_rq, struct rq *dst_rq) { WARN_ON_ONCE(1); }
-static inline bool task_can_run_on_remote_rq(struct task_struct *p, struct rq *rq, bool trigger_error) { return false; }
+static inline bool task_can_run_on_remote_rq(struct task_struct *p, struct rq *rq, bool enforce) { return false; }
 static inline bool consume_remote_task(struct rq *this_rq, struct task_struct *p, struct scx_dispatch_q *dsq, struct rq *task_rq) { return false; }
 #endif	/* CONFIG_SMP */
 
@@ -2717,7 +2720,6 @@ static void dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
 	    unlikely(!task_can_run_on_remote_rq(p, dst_rq, true))) {
 		dispatch_enqueue(find_global_dsq(p), p,
 				 enq_flags | SCX_ENQ_CLEAR_OPSS);
-		__scx_add_event(SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE, 1);
 		return;
 	}
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] sched_ext: Add SCX_EV_ENQ_SKIP_MIGRATION_DISABLED
  2025-02-08  8:42 [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Tejun Heo
  2025-02-08  8:42 ` [PATCH 1/3] tool/sched_ext: Event counter dumping updates Tejun Heo
  2025-02-08  8:42 ` [PATCH 2/3] sched_ext: Count SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE in the right spot Tejun Heo
@ 2025-02-08  8:42 ` Tejun Heo
  2025-02-08  9:12 ` [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Changwoo Min
  2025-02-09  6:40 ` Tejun Heo
  4 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2025-02-08  8:42 UTC (permalink / raw)
  To: void, arighi, multics69; +Cc: linux-kernel, sched-ext, Tejun Heo

Count the number of times a migration disabled task is automatically
dispatched to its local DSQ.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/sched/ext.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 310db8484b77..b2378e29f45a 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1483,6 +1483,13 @@ struct scx_event_stats {
 	 */
 	u64		SCX_EV_ENQ_SKIP_EXITING;
 
+	/*
+	 * If SCX_OPS_ENQ_MIGRATION_DISABLED is not set, the number of times a
+	 * migration disabled task skips ops.enqueue() and is dispatched to its
+	 * local DSQ.
+	 */
+	u64		SCX_EV_ENQ_SKIP_MIGRATION_DISABLED;
+
 	/*
 	 * The total number of tasks enqueued (or pick_task-ed) with a
 	 * default time slice (SCX_SLICE_DFL).
@@ -2119,8 +2126,10 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
 
 	/* see %SCX_OPS_ENQ_MIGRATION_DISABLED */
 	if (!static_branch_unlikely(&scx_ops_enq_migration_disabled) &&
-	    is_migration_disabled(p))
+	    is_migration_disabled(p)) {
+		__scx_add_event(SCX_EV_ENQ_SKIP_MIGRATION_DISABLED, 1);
 		goto local;
+	}
 
 	if (!SCX_HAS_OP(enqueue))
 		goto global;
@@ -5067,6 +5076,7 @@ static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
 	scx_dump_event(s, &events, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE);
 	scx_dump_event(s, &events, SCX_EV_DISPATCH_KEEP_LAST);
 	scx_dump_event(s, &events, SCX_EV_ENQ_SKIP_EXITING);
+	scx_dump_event(s, &events, SCX_EV_ENQ_SKIP_MIGRATION_DISABLED);
 	scx_dump_event(s, &events, SCX_EV_ENQ_SLICE_DFL);
 	scx_dump_event(s, &events, SCX_EV_BYPASS_DURATION);
 	scx_dump_event(s, &events, SCX_EV_BYPASS_DISPATCH);
@@ -7210,6 +7220,7 @@ __bpf_kfunc void scx_bpf_events(struct scx_event_stats *events,
 		scx_agg_event(&e_sys, e_cpu, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE);
 		scx_agg_event(&e_sys, e_cpu, SCX_EV_DISPATCH_KEEP_LAST);
 		scx_agg_event(&e_sys, e_cpu, SCX_EV_ENQ_SKIP_EXITING);
+		scx_agg_event(&e_sys, e_cpu, SCX_EV_ENQ_SKIP_MIGRATION_DISABLED);
 		scx_agg_event(&e_sys, e_cpu, SCX_EV_ENQ_SLICE_DFL);
 		scx_agg_event(&e_sys, e_cpu, SCX_EV_BYPASS_DURATION);
 		scx_agg_event(&e_sys, e_cpu, SCX_EV_BYPASS_DISPATCH);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates
  2025-02-08  8:42 [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Tejun Heo
                   ` (2 preceding siblings ...)
  2025-02-08  8:42 ` [PATCH 3/3] sched_ext: Add SCX_EV_ENQ_SKIP_MIGRATION_DISABLED Tejun Heo
@ 2025-02-08  9:12 ` Changwoo Min
  2025-02-09  6:40 ` Tejun Heo
  4 siblings, 0 replies; 6+ messages in thread
From: Changwoo Min @ 2025-02-08  9:12 UTC (permalink / raw)
  To: Tejun Heo; +Cc: void, arighi, linux-kernel, sched-ext

Hello,


On 25. 2. 8. 17:42, Tejun Heo wrote:
> Hello,
> 
> This patchset contains the following three event counter updates:
> 
>   0001-tool-sched_ext-Event-counter-dumping-updates.patch
>   0002-sched_ext-Count-SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE-in.patch
>   0003-sched_ext-Add-SCX_EV_ENQ_SKIP_MIGRATION_DISABLED.patch
> 
> This patchset depends on two pending migration disabled handling patches on
> top of sched_ext/for-614-fixes and the event counter addition in
> sched_ext/for-6.15 and thus is on top of:
> 
>   sched_ext/for-6.14-fixes
>   + Two migration disabled handling update patches
>     http://lkml.kernel.org/r/Z6Zz79AUub1YuHwD@slm.duckdns.org
>   + sched_ext/for-6.15
> 
> The following branch shows how these patches will be applied:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git scx-evs
> 
> diffstat follows. Thanks.
> 
>   kernel/sched/ext.c                |   25 +++++++++++++++++++------
>   tools/sched_ext/scx_central.bpf.c |   21 ---------------------
>   tools/sched_ext/scx_qmap.bpf.c    |   16 ++++++++--------
>   3 files changed, 27 insertions(+), 35 deletions(-)
> 
> --
> tejun

Looks good to me. Thanks!

Acked-by: Changwoo Min <changwoo@igalia.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates
  2025-02-08  8:42 [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Tejun Heo
                   ` (3 preceding siblings ...)
  2025-02-08  9:12 ` [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Changwoo Min
@ 2025-02-09  6:40 ` Tejun Heo
  4 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2025-02-09  6:40 UTC (permalink / raw)
  To: void, arighi, multics69; +Cc: linux-kernel, sched-ext

On Fri, Feb 07, 2025 at 10:42:14PM -1000, Tejun Heo wrote:
> Hello,
> 
> This patchset contains the following three event counter updates:
> 
>  0001-tool-sched_ext-Event-counter-dumping-updates.patch
>  0002-sched_ext-Count-SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE-in.patch
>  0003-sched_ext-Add-SCX_EV_ENQ_SKIP_MIGRATION_DISABLED.patch

Applied to sched_ext/for-6.15.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-02-09  6:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-08  8:42 [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Tejun Heo
2025-02-08  8:42 ` [PATCH 1/3] tool/sched_ext: Event counter dumping updates Tejun Heo
2025-02-08  8:42 ` [PATCH 2/3] sched_ext: Count SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE in the right spot Tejun Heo
2025-02-08  8:42 ` [PATCH 3/3] sched_ext: Add SCX_EV_ENQ_SKIP_MIGRATION_DISABLED Tejun Heo
2025-02-08  9:12 ` [PATCHSET sched_ext/for-6.15] sched_ext: Event counter updates Changwoo Min
2025-02-09  6:40 ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.