From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out187-21.us.a.mail.aliyun.com (out187-21.us.a.mail.aliyun.com [47.90.187.21]) (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 CDCDA1D47A2 for ; Wed, 8 Jan 2025 08:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.90.187.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736326054; cv=none; b=VumGmLM2h3RmnOBbzd5W82KS5oQQEFQ8ySd6gT3OTZz/EOuGBhecSGqSh5nXPGDn2RqswC8MmteADfnyfzrwo2RulXJMzAkuIx0ysGvAc9qN4BbtNAmvGhkN5/1WksJdRONGgQ0M0WG0UXw89WNwnOH9jWaFkp0DF7/KXt3+ah0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736326054; c=relaxed/simple; bh=dLD+XQkajgTd+vQ7vq2e/60PQ6+PZC7N542RwBlHfnw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=V0ifrL4nt6nNQIbX3frlmmj1CfxVEd56IUyNSb8vN5xjUB2HPc1l62C17GBClelIhLq6nNbtq0xOxo9oqqL0hrOV4Mf1MZDLJBUA8mfXrYaoj+2mI1V+XfjdvgOBl9fww6llYar9wjCfAbBelQebxf6TzHatDsWp1WNR8EmI01g= 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=JvcQq28E; arc=none smtp.client-ip=47.90.187.21 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="JvcQq28E" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1736326033; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=4cM8FmVwIO4CcMwIOvJNgFg9UktZRqZOeuQxXHnj4r4=; b=JvcQq28E8/dwtYzrKWgksmWsIQDAGDGpcWlTcJTSeZvhGYRSKaIZlr8OrnmLDOjRQw1Qkh+eXEt+1yQGAath0Pg9FyNe7k0GWM8ZLFeYBwUTDxXY8bDj/04kVuD+3v/e2RpmAc9cgxBVCSYr5/xBJie3HhYosWw7rk15Ima0e90= Received: from localhost(mailfrom:henry.hj@antgroup.com fp:SMTPD_---.ayw4oxJ_1736326032 cluster:ay29) by smtp.aliyun-inc.com; Wed, 08 Jan 2025 16:47:13 +0800 From: "Henry Huang" To: tj@kernel.org, void@manifault.com Cc: "=?UTF-8?B?6LCI6Ym06ZSL?=" , "=?UTF-8?B?WWFuIFlhbihjYWlsaW5nKQ==?=" , , "Henry Huang" Subject: [PATCH v2] sched_ext: keep running prev when prev->scx.slice != 0 Date: Wed, 08 Jan 2025 16:47:09 +0800 Message-ID: <20250108084710.42747-1-henry.hj@antgroup.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In our environment, we have various types of tasks. Some tasks can keep running after their slice is exhausted, while others need to be dispatched into the global DSQ for rescheduling. Therefore, we set %SCX_OPS_ENQ_LAST. However, we encountered a problem: Because put_prev_task_scx() is executed after pick_task_scx(), @prev only has the opportunity to be dispatched into local DSQ in put_prev_task_scx(). Since pick_task_scx returns NULL, the CPU enters the idle state instead of running @prev. Our current workaround is to set a value to @prev->scx.slice in ops.dispatch() and call scx_bpf_kick_cpu(cpu, 0) to trigger a reschedule. Of course, this approach introduces some overhead. Our solution: When %SCX_OPS_ENQ_LAST is set and prev->scx.slice != 0, we only need to set %SCX_RQ_BAL_KEEP in blance_one to ensure pick_task_scx() can pick the correct task. For v2: - set %SCX_RQ_BAL_KEEP in dispatch loop. - cache prev->scx.flags & SCX_TASK_QUEUED result. Henry Huang (1): sched_ext: keep running prev when prev->scx.slice != 0 kernel/sched/ext.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- Henry