sched_ext: Event counter updates
Subsystems (2)
Tejun Heo
reviewerPATCH 1/1 sched_ext: Event counter updates
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/[email protected]
+ 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
Tejun Heo
reviewerPATCH 1/3 tool/sched_ext: Event counter dumping updates
- 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.
--- tools/sched_ext/scx_central.bpf.c | 21 --------------------- tools/sched_ext/scx_qmap.bpf.c | 16 ++++++++-------- 2 files changed, 8 insertions(+), 29 deletions(-)
tools/sched_ext/scx_central.bpf.c +0 -21
@@ -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 ; }
tools/sched_ext/scx_qmap.bpf.c +8 -8
@@ -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 );
Signature · 1 line
2.48.1
Tejun Heo
reviewerPATCH 2/3 sched_ext: Count SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE in the right spot
In reply to Tejun HeoSCX_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.
--- kernel/sched/ext.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
kernel/sched/ext.c +7 -5
@@ -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 ; }
Signature · 1 line
2.48.1
Tejun Heo
reviewerPATCH 3/3 sched_ext: Add SCX_EV_ENQ_SKIP_MIGRATION_DISABLED
In reply to Tejun HeoCount the number of times a migration disabled task is automatically dispatched to its local DSQ.
--- kernel/sched/ext.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
kernel/sched/ext.c +12 -1
@@ -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 );
Signature · 1 line
2.48.1
Hello,
Quoted 23 lines · Tejun Heo
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/[email protected]
+ sched_ext/for-6.15The following branch shows how these patches will be applied:
git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.gitscx-evsdiffstat follows. Thanks.
Quoted 7 lines
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!
Quoted 7 lines · Tejun Heo
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.
Signature · 1 line
tejun