[PATCH 4/7] sched_ext: Add an event, SCX_EVENT_ENQ_LOCAL_EXITING

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

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

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 909f12a41934..094e19f5fb78 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1479,6 +1479,12 @@ struct scx_event_stat {
 	 * continued to run because there were no other tasks on the CPU.
 	 */
 	u64		CNTD_RUN_WO_ENQ;
+
+	/*
+	 * If SCX_OPS_ENQ_EXITING is not set, the number of times that a task
+	 * is dispatched to a local DSQ when exiting.
+	 */
+	u64		ENQ_LOCAL_EXITING;
 };
 
 #define SCX_EVENT_IDX(e)	(offsetof(struct scx_event_stat, e)/sizeof(u64))
@@ -1493,6 +1499,7 @@ enum scx_event_kind {
 	SCX_EVENT_DEFINE(INVAL_SELECT_CPU),
 	SCX_EVENT_DEFINE(OFFLINE_LOCAL_DSQ),
 	SCX_EVENT_DEFINE(CNTD_RUN_WO_ENQ),
+	SCX_EVENT_DEFINE(ENQ_LOCAL_EXITING),
 	SCX_EVENT_END = SCX_EVENT_END_IDX(),
 };
 
@@ -1500,6 +1507,7 @@ static const char *scx_event_stat_str[] = {
 	[SCX_EVENT_INVAL_SELECT_CPU]	= "invalid_select_cpu",
 	[SCX_EVENT_OFFLINE_LOCAL_DSQ]	= "offline_local_dsq",
 	[SCX_EVENT_CNTD_RUN_WO_ENQ]	= "cntd_run_wo_enq",
+	[SCX_EVENT_ENQ_LOCAL_EXITING]	= "enq_local_exiting",
 };
 
 /*
@@ -2087,8 +2095,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(ENQ_LOCAL_EXITING, 1);
 		goto local;
+	}
 
 	if (!SCX_HAS_OP(enqueue))
 		goto global;
-- 
2.48.1
Re: [PATCH 4/7] sched_ext: Add an event, SCX_EVENT_ENQ_LOCAL_EXITING
Posted by Tejun Heo 11 months ago
On Fri, Jan 17, 2025 at 12:15:40AM +0900, Changwoo Min wrote:
> Add a core event, SCX_EVENT_ENQ_LOCAL_EXITING, which represents how many
> times a task is enqueued to a local DSQ when exiting if SCX_OPS_ENQ_EXITING
> is not set.
> 
> Signed-off-by: Changwoo Min <changwoo@igalia.com>
> ---
>  kernel/sched/ext.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 909f12a41934..094e19f5fb78 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -1479,6 +1479,12 @@ struct scx_event_stat {
>  	 * continued to run because there were no other tasks on the CPU.
>  	 */
>  	u64		CNTD_RUN_WO_ENQ;
> +
> +	/*
> +	 * If SCX_OPS_ENQ_EXITING is not set, the number of times that a task
> +	 * is dispatched to a local DSQ when exiting.
> +	 */
> +	u64		ENQ_LOCAL_EXITING;

ENQ_SKIP_EXITING?

-- 
tejun
Re: [PATCH 4/7] sched_ext: Add an event, SCX_EVENT_ENQ_LOCAL_EXITING
Posted by Changwoo Min 11 months ago
Hello,

On 25. 1. 17. 10:40, Tejun Heo wrote:
> On Fri, Jan 17, 2025 at 12:15:40AM +0900, Changwoo Min wrote:
>> Add a core event, SCX_EVENT_ENQ_LOCAL_EXITING, which represents how many
>> times a task is enqueued to a local DSQ when exiting if SCX_OPS_ENQ_EXITING
>> is not set.
>>
>> Signed-off-by: Changwoo Min <changwoo@igalia.com>
>> ---
>>   kernel/sched/ext.c | 12 +++++++++++-
>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
>> index 909f12a41934..094e19f5fb78 100644
>> --- a/kernel/sched/ext.c
>> +++ b/kernel/sched/ext.c
>> @@ -1479,6 +1479,12 @@ struct scx_event_stat {
>>   	 * continued to run because there were no other tasks on the CPU.
>>   	 */
>>   	u64		CNTD_RUN_WO_ENQ;
>> +
>> +	/*
>> +	 * If SCX_OPS_ENQ_EXITING is not set, the number of times that a task
>> +	 * is dispatched to a local DSQ when exiting.
>> +	 */
>> +	u64		ENQ_LOCAL_EXITING;
> 
> ENQ_SKIP_EXITING?

Will change it as suggested.

Regards,
Changwoo Min