From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out0-211.mail.aliyun.com (out0-211.mail.aliyun.com [140.205.0.211]) (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 B7BC920B20 for ; Wed, 8 Jan 2025 04:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736309675; cv=none; b=rq25AC5KeLWYUVWsLsl+6QmE47fPVMfQchjqVTwIqx2DoGrWSArH1nTDlKkR2rpCDQcAoTnXPMJF5jjsDLLFszaDG9w24aL0/9OAgnCejFxnAKesb+e6By2yYYO67JnbIPE2yaBlEIbSmdob7PTAsO9oqgOXxgvpWKy1xqFJsz8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736309675; c=relaxed/simple; bh=Rlra8FVcENsD1rj7hetW2WeaVgousBaBFRiP73YKP+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q6D8aAi0yrbdQtMcfkV5K6z5HFb/MYdgFt7irxtgFCWddUgavwG/e6Pyzt1v3bg2YnelS1LEelpxhv1a3PfzT91wFg1fYSSTXRZRirVAU5hviowwvZjEldaBr4vj76waxfvM54h3LvdfQL4cofiSQZPNMx8lDhvWBygzkIA+Q0I= 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=TwDcNRtU; arc=none smtp.client-ip=140.205.0.211 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="TwDcNRtU" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1736309668; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=2+WWwEq13ec35u0hwoo1VDxWyWq7OQLaLtoXaOjohtE=; b=TwDcNRtU0DI+Xm5C3Myb1DVl9ZIqzcTHb7oO2LCpa9gxyazGA88LEVwrNydalLIv653MyjMQmMGdN4uaqbTh19Ucvv/xK9Lu+7eHhmLP4XXMbu/vYweqfe7pvmGQ8Y1ZbIKN2CGfqxXkIhY9kfGr/vmsHkWzMBWK/hV7VqNjSEw= Received: from localhost(mailfrom:henry.hj@antgroup.com fp:SMTPD_---.aygtPSW_1736309350 cluster:ay29) by smtp.aliyun-inc.com; Wed, 08 Jan 2025 12:09:10 +0800 From: "Henry Huang" To: tj@kernel.org Cc: "Henry Huang" , "=?UTF-8?B?6LCI6Ym06ZSL?=" , , , "=?UTF-8?B?WWFuIFlhbihjYWlsaW5nKQ==?=" Subject: Re: [PATCH v1] sched_ext: keep running prev when prev->scx.slice != 0 Date: Wed, 08 Jan 2025 12:09:04 +0800 Message-ID: <20250108040904.22613-1-henry.hj@antgroup.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Tue, 7 Jan 2025 11:20:58 -1000, Tejun Heo wrote: > Update current->scx.slice from ops.dispatch() is the recommended way of > extending the current execution and the current behavior is just buggy > especially when scx_ops_enq_last is set. > > While the above change fixes the case where ops.dispatch() updates > current->scx.slice without dispatching any task, it's still theoretically > wrong in that if ops.dispatch() updates current->scx.slice and dispatches > tasks, we should keep running current before moving onto other tasks. > > To fix this properly, I think what should be done is adding something like > the following. (untested and we probably should cache SCX_TASK_QUEUED > testing result). Can you test whether the following fixes the issues you're > seeing and if so update the patch accordingly? > > diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c > index 19d2699cf638..48deb5d5510e 100644 > --- a/kernel/sched/ext.c > +++ b/kernel/sched/ext.c > @@ -2813,6 +2813,10 @@ static int balance_one(struct rq *rq, struct task_struct *prev) > > flush_dispatch_buf(rq); > > + if ((prev->scx.flags & SCX_TASK_QUEUED) && prev->scx.slice) { > + rq->scx.flags |= SCX_RQ_BAL_KEEP; > + goto has_tasks; > + } > if (rq->scx.local_dsq.nr) > goto has_tasks; > if (consume_global_dsq(rq)) Thanks, I'll try this. If it works fine, I'll update this patch soon. -- Henry