[PATCH 3/7] sched_ext: Add an event, SCX_EVENT_CNTD_RUN_WO_ENQ

Changwoo Min posted 7 patches 11 months ago
There is a newer version of this series
[PATCH 3/7] sched_ext: Add an event, SCX_EVENT_CNTD_RUN_WO_ENQ
Posted by Changwoo Min 11 months ago
Add a core event, SCX_EVENT_CNTD_RUN_WO_ENQ, which represents how many
times a task is continued to run without ops.enqueue() when SCX_OPS_ENQ_LAST
is not set.

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

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 8054e4e5ed0c..909f12a41934 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1473,6 +1473,12 @@ struct scx_event_stat {
 	 * the meantime. In this case, the task is bounced to the global DSQ.
 	 */
 	u64		OFFLINE_LOCAL_DSQ;
+
+	/*
+	 * If SCX_OPS_ENQ_LAST is not set, the number of times that a task
+	 * continued to run because there were no other tasks on the CPU.
+	 */
+	u64		CNTD_RUN_WO_ENQ;
 };
 
 #define SCX_EVENT_IDX(e)	(offsetof(struct scx_event_stat, e)/sizeof(u64))
@@ -1486,12 +1492,14 @@ enum scx_event_kind {
 	SCX_EVENT_BEGIN = 0,
 	SCX_EVENT_DEFINE(INVAL_SELECT_CPU),
 	SCX_EVENT_DEFINE(OFFLINE_LOCAL_DSQ),
+	SCX_EVENT_DEFINE(CNTD_RUN_WO_ENQ),
 	SCX_EVENT_END = SCX_EVENT_END_IDX(),
 };
 
 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",
 };
 
 /*
@@ -2914,6 +2922,7 @@ static int balance_one(struct rq *rq, struct task_struct *prev)
 	if (prev_on_rq && (!static_branch_unlikely(&scx_ops_enq_last) ||
 	     scx_rq_bypassing(rq))) {
 		rq->scx.flags |= SCX_RQ_BAL_KEEP;
+		scx_add_event(CNTD_RUN_WO_ENQ, 1);
 		goto has_tasks;
 	}
 	rq->scx.flags &= ~SCX_RQ_IN_BALANCE;
-- 
2.48.1
Re: [PATCH 3/7] sched_ext: Add an event, SCX_EVENT_CNTD_RUN_WO_ENQ
Posted by Tejun Heo 11 months ago
On Fri, Jan 17, 2025 at 12:15:39AM +0900, Changwoo Min wrote:
> Add a core event, SCX_EVENT_CNTD_RUN_WO_ENQ, which represents how many
> times a task is continued to run without ops.enqueue() when SCX_OPS_ENQ_LAST
> is not set.
> 
> Signed-off-by: Changwoo Min <changwoo@igalia.com>
> ---
>  kernel/sched/ext.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 8054e4e5ed0c..909f12a41934 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -1473,6 +1473,12 @@ struct scx_event_stat {
>  	 * the meantime. In this case, the task is bounced to the global DSQ.
>  	 */
>  	u64		OFFLINE_LOCAL_DSQ;
> +
> +	/*
> +	 * If SCX_OPS_ENQ_LAST is not set, the number of times that a task
> +	 * continued to run because there were no other tasks on the CPU.
> +	 */
> +	u64		CNTD_RUN_WO_ENQ;

DISPATCH_KEEP_LAST?

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

On 25. 1. 17. 10:39, Tejun Heo wrote:
> On Fri, Jan 17, 2025 at 12:15:39AM +0900, Changwoo Min wrote:
>> Add a core event, SCX_EVENT_CNTD_RUN_WO_ENQ, which represents how many
>> times a task is continued to run without ops.enqueue() when SCX_OPS_ENQ_LAST
>> is not set.
>>
>> Signed-off-by: Changwoo Min <changwoo@igalia.com>
>> ---
>>   kernel/sched/ext.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
>> index 8054e4e5ed0c..909f12a41934 100644
>> --- a/kernel/sched/ext.c
>> +++ b/kernel/sched/ext.c
>> @@ -1473,6 +1473,12 @@ struct scx_event_stat {
>>   	 * the meantime. In this case, the task is bounced to the global DSQ.
>>   	 */
>>   	u64		OFFLINE_LOCAL_DSQ;
>> +
>> +	/*
>> +	 * If SCX_OPS_ENQ_LAST is not set, the number of times that a task
>> +	 * continued to run because there were no other tasks on the CPU.
>> +	 */
>> +	u64		CNTD_RUN_WO_ENQ;
> 
> DISPATCH_KEEP_LAST?

That's good.

Regards,
Changwoo Min