[PATCH v3 05/11] sched_ext: Add an event, SCX_EV_ENQ_SKIP_EXITING

Changwoo Min posted 11 patches 1 year ago
There is a newer version of this series
[PATCH v3 05/11] sched_ext: Add an event, SCX_EV_ENQ_SKIP_EXITING
Posted by Changwoo Min 1 year ago
Add a core event, SCX_EV_ENQ_SKIP_EXITING, which represents how many
times a task is enqueued to a local DSQ when exiting if
SCX_OPS_ENQ_EXITING is not set.

__scx_add_event() is used since the caller holds an rq lock,
so the preemption has already been disabled.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
---
 kernel/sched/ext.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 7147f730850b..37f86a84ac5d 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1461,6 +1461,12 @@ struct scx_event_stats {
 	 * continued to run because there were no other tasks on the CPU.
 	 */
 	u64		SCX_EV_DISPATCH_KEEP_LAST;
+
+	/*
+	 * If SCX_OPS_ENQ_EXITING is not set, the number of times that a task
+	 * is dispatched to a local DSQ when exiting.
+	 */
+	u64		SCX_EV_ENQ_SKIP_EXITING;
 };
 
 /*
@@ -2068,8 +2074,10 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
 
 	/* see %SCX_OPS_ENQ_EXITING */
 	if (!static_branch_unlikely(&scx_ops_enq_exiting) &&
-	    unlikely(p->flags & PF_EXITING))
+	    unlikely(p->flags & PF_EXITING)) {
+		__scx_add_event(SCX_EV_ENQ_SKIP_EXITING, 1);
 		goto local;
+	}
 
 	if (!SCX_HAS_OP(enqueue))
 		goto global;
@@ -4986,6 +4994,7 @@ static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
 	scx_dump_event(s, &events, SCX_EV_SELECT_CPU_FALLBACK);
 	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);
 
 	if (seq_buf_has_overflowed(&s) && dump_len >= sizeof(trunc_marker))
 		memcpy(ei->dump + dump_len - sizeof(trunc_marker),
-- 
2.48.1
Re: [PATCH v3 05/11] sched_ext: Add an event, SCX_EV_ENQ_SKIP_EXITING
Posted by Tejun Heo 1 year ago
On Fri, Jan 31, 2025 at 04:09:32PM +0900, Changwoo Min wrote:
> Add a core event, SCX_EV_ENQ_SKIP_EXITING, which represents how many
> times a task is enqueued to a local DSQ when exiting if
> SCX_OPS_ENQ_EXITING is not set.
> 
> __scx_add_event() is used since the caller holds an rq lock,
> so the preemption has already been disabled.
> 
> Signed-off-by: Changwoo Min <changwoo@igalia.com>
> ---
>  kernel/sched/ext.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 7147f730850b..37f86a84ac5d 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -1461,6 +1461,12 @@ struct scx_event_stats {
>  	 * continued to run because there were no other tasks on the CPU.
>  	 */
>  	u64		SCX_EV_DISPATCH_KEEP_LAST;
> +
> +	/*
> +	 * If SCX_OPS_ENQ_EXITING is not set, the number of times that a task
> +	 * is dispatched to a local DSQ when exiting.
> +	 */
> +	u64		SCX_EV_ENQ_SKIP_EXITING;
>  };
>  
>  /*
> @@ -2068,8 +2074,10 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
>  
>  	/* see %SCX_OPS_ENQ_EXITING */
>  	if (!static_branch_unlikely(&scx_ops_enq_exiting) &&
> -	    unlikely(p->flags & PF_EXITING))
> +	    unlikely(p->flags & PF_EXITING)) {
> +		__scx_add_event(SCX_EV_ENQ_SKIP_EXITING, 1);
>  		goto local;
> +	}
>  
>  	if (!SCX_HAS_OP(enqueue))
>  		goto global;
> @@ -4986,6 +4994,7 @@ static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
>  	scx_dump_event(s, &events, SCX_EV_SELECT_CPU_FALLBACK);
>  	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);
>  
>  	if (seq_buf_has_overflowed(&s) && dump_len >= sizeof(trunc_marker))
>  		memcpy(ei->dump + dump_len - sizeof(trunc_marker),

Missing agg call?

-- 
tejun
Re: [PATCH v3 05/11] sched_ext: Add an event, SCX_EV_ENQ_SKIP_EXITING
Posted by Changwoo Min 1 year ago
Hello,

On 25. 2. 3. 02:20, Tejun Heo wrote:
> On Fri, Jan 31, 2025 at 04:09:32PM +0900, Changwoo Min wrote:
> Missing agg call?
Ah, you are right. Will fix it.

Regards,
Changwoo Min