mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Henry Huang" <henry.hj@antgroup.com>
To: tj@kernel.org, void@manifault.com
Cc: 谈鉴锋 <henry.tjf@antgroup.com>,
	"Yan Yan(cailing)" <yanyan.yan@antgroup.com>,
	linux-kernel@vger.kernel.org,
	"Henry Huang" <henry.hj@antgroup.com>
Subject: [PATCH v1] sched_ext: keep running prev when prev->scx.slice != 0
Date: Tue, 07 Jan 2025 12:25:55 +0800	[thread overview]
Message-ID: <20250107042555.67051-2-henry.hj@antgroup.com> (raw)
In-Reply-To: <20250107042555.67051-1-henry.hj@antgroup.com>

When %SCX_OPS_ENQ_LAST is set and prev->scx.slice != 0,
@prev will be dispacthed into the local DSQ in put_prev_task_scx().
However, pick_task_scx() is executed before put_prev_task_scx(),
so it will not pick @prev.
Set %SCX_RQ_BAL_KEEP in balance_one() to ensure that pick_task_scx()
can pick @prev.

Signed-off-by: Henry Huang <henry.hj@antgroup.com>
---
 kernel/sched/ext.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 81da76a..5f6eb45 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2837,10 +2837,15 @@ static int balance_one(struct rq *rq, struct task_struct *prev)
 	/*
 	 * Didn't find another task to run. Keep running @prev unless
 	 * %SCX_OPS_ENQ_LAST is in effect.
+	 *
+	 * If %SCX_OPS_ENQ_LAST is set and prev->scx.slice != 0 (configured in ops.dispatch()),
+	 * @prev would be dispatched into the local DSQ in put_prev_task_scx()
+	 * (excuted after pick_task_scx()). Set %SCX_RQ_BAL_KEEP to ensure that @prev
+	 * would be picked in pick_task_scx()
 	 */
 	if ((prev->scx.flags & SCX_TASK_QUEUED) &&
 	    (!static_branch_unlikely(&scx_ops_enq_last) ||
-	     scx_rq_bypassing(rq))) {
+	     scx_rq_bypassing(rq) || prev->scx.slice)) {
 		rq->scx.flags |= SCX_RQ_BAL_KEEP;
 		goto has_tasks;
 	}
-- 
1.8.3.1


  reply	other threads:[~2025-01-07  5:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-07  4:25 Henry Huang
2025-01-07  4:25 ` Henry Huang [this message]
2025-01-07 21:20   ` Tejun Heo
2025-01-08  4:09     ` Henry Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250107042555.67051-2-henry.hj@antgroup.com \
    --to=henry.hj@antgroup.com \
    --cc=henry.tjf@antgroup.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    --cc=yanyan.yan@antgroup.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®