From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out187-22.us.a.mail.aliyun.com (out187-22.us.a.mail.aliyun.com [47.90.187.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A22A158520 for ; Tue, 7 Jan 2025 05:27:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.90.187.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736227652; cv=none; b=IGZZC8o74J8yIAiCrRr5qR9qPErGFkqHkCnxvtsMVf6b/59E0ROGeNAD6oTHnB4z7Vi8htvNCoBFMBsCJBz8G/efPbaNcGrNjY71AoUihLDZz/EPpkk7j7+xNX01gu1Wu6QRN6/HCZojqwxsAtcaJQmf7ZIMtjo5qsOQ0XU0WsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736227652; c=relaxed/simple; bh=s6zpP9APELp0Cs1P2atR5/GPdCEYjbQ/bBIJtFF4m2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HeFEOrvb+e5TjbIzWSdFKoFvEV5p9P1CxAWDRjKOpYA2TNeS1EEOmgTzTm2pB2RkpOHIeXO1w8B3TdqnSea9upQhD6sbda7WBBOWsAI1DLbWXe5oykK4PP6WJmQMkPkd+pNhJwqbRlbsGrByZ/BFjPznDSrcmETAe6JDVPS+oFY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=dQyfZe/R; arc=none smtp.client-ip=47.90.187.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="dQyfZe/R" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1736227635; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=BVcbUGEn3PN1MYvaQDU3SWaFdNbsn1L62R6PGShaIxU=; b=dQyfZe/R6r7ZgJqZq2sAFxM10t/dCIaLvCTEzErSG4eQqIAMAp9CXwj+h+PZ4+IHfTEn6QWWdhnX3X/LedE7n6o3gNYmQuSTkEarU4IgPwK0x2TzGH0+ascaEdVpdQwA8j/tOWXZcd7Wh1mDUoLkouxk93ALcHdWYZZGXeNXn9o= Received: from localhost(mailfrom:henry.hj@antgroup.com fp:SMTPD_---.axbNIPI_1736223970 cluster:ay29) by smtp.aliyun-inc.com; Tue, 07 Jan 2025 12:26:10 +0800 From: "Henry Huang" To: tj@kernel.org, void@manifault.com Cc: "=?UTF-8?B?6LCI6Ym06ZSL?=" , "=?UTF-8?B?WWFuIFlhbihjYWlsaW5nKQ==?=" , , "Henry Huang" Subject: [PATCH v1] sched_ext: keep running prev when prev->scx.slice != 0 Date: Tue, 07 Jan 2025 12:25:55 +0800 Message-ID: <20250107042555.67051-2-henry.hj@antgroup.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250107042555.67051-1-henry.hj@antgroup.com> References: <20250107042555.67051-1-henry.hj@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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