[PATCH 2/7] sched_ext: Add an event, SCX_EVENT_OFFLINE_LOCAL_DSQ

Changwoo Min posted 7 patches 11 months ago
There is a newer version of this series
[PATCH 2/7] sched_ext: Add an event, SCX_EVENT_OFFLINE_LOCAL_DSQ
Posted by Changwoo Min 11 months ago
Add a core event, SCX_EVENT_OFFLINE_LOCAL_DSQ, which represents how many
times a BPF scheduler tries to dispatch to an offlined local DSQ.

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 7e12d5b8322e..8054e4e5ed0c 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1467,6 +1467,12 @@ struct scx_event_stat {
 	 * the core scheduler code silently picks a fallback CPU.
 	 */
 	u64		INVAL_SELECT_CPU;
+
+	/*
+	 * When dispatching to a local DSQ, the CPU may have gone offline in
+	 * the meantime. In this case, the task is bounced to the global DSQ.
+	 */
+	u64		OFFLINE_LOCAL_DSQ;
 };
 
 #define SCX_EVENT_IDX(e)	(offsetof(struct scx_event_stat, e)/sizeof(u64))
@@ -1479,11 +1485,13 @@ struct scx_event_stat {
 enum scx_event_kind {
 	SCX_EVENT_BEGIN = 0,
 	SCX_EVENT_DEFINE(INVAL_SELECT_CPU),
+	SCX_EVENT_DEFINE(OFFLINE_LOCAL_DSQ),
 	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",
 };
 
 /*
@@ -2651,6 +2659,7 @@ static void dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
 	if (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(OFFLINE_LOCAL_DSQ, 1);
 		return;
 	}
 
-- 
2.48.1
Re: [PATCH 2/7] sched_ext: Add an event, SCX_EVENT_OFFLINE_LOCAL_DSQ
Posted by Tejun Heo 11 months ago
On Fri, Jan 17, 2025 at 12:15:38AM +0900, Changwoo Min wrote:
...
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 7e12d5b8322e..8054e4e5ed0c 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -1467,6 +1467,12 @@ struct scx_event_stat {
>  	 * the core scheduler code silently picks a fallback CPU.
>  	 */
>  	u64		INVAL_SELECT_CPU;
> +
> +	/*
> +	 * When dispatching to a local DSQ, the CPU may have gone offline in
> +	 * the meantime. In this case, the task is bounced to the global DSQ.
> +	 */
> +	u64		OFFLINE_LOCAL_DSQ;

Let's do components in descending order + event:

- SELECT_CPU_INVAL (or SELECT_CPU_FALLBACK)
- DISPATCH_LOCAL_DSQ_OFFLINE

Thanks.

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

On 25. 1. 17. 10:37, Tejun Heo wrote:
> On Fri, Jan 17, 2025 at 12:15:38AM +0900, Changwoo Min wrote:
> ...
>> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
>> index 7e12d5b8322e..8054e4e5ed0c 100644
>> --- a/kernel/sched/ext.c
>> +++ b/kernel/sched/ext.c
>> @@ -1467,6 +1467,12 @@ struct scx_event_stat {
>>   	 * the core scheduler code silently picks a fallback CPU.
>>   	 */
>>   	u64		INVAL_SELECT_CPU;
>> +
>> +	/*
>> +	 * When dispatching to a local DSQ, the CPU may have gone offline in
>> +	 * the meantime. In this case, the task is bounced to the global DSQ.
>> +	 */
>> +	u64		OFFLINE_LOCAL_DSQ;
> 
> Let's do components in descending order + event:
> 
> - SELECT_CPU_INVAL (or SELECT_CPU_FALLBACK)
> - DISPATCH_LOCAL_DSQ_OFFLINE

Sure. Will change it in the next version.

Regards,
Changwoo Min