public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: void@manifault.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
	mingo@redhat.com, Tejun Heo <tj@kernel.org>
Subject: [PATCH 1/6] sched_ext: Simplify scx_can_stop_tick() invocation in sched_can_stop_tick()
Date: Sat,  3 Aug 2024 16:40:08 -1000	[thread overview]
Message-ID: <20240804024047.100355-2-tj@kernel.org> (raw)
In-Reply-To: <20240804024047.100355-1-tj@kernel.org>

The way sched_can_stop_tick() used scx_can_stop_tick() was rather confusing
and the behavior wasn't ideal when SCX is enabled in partial mode. Simplify
it so that:

- scx_can_stop_tick() can say no if scx_enabled().

- CFS tests rq->cfs.nr_running > 1 instead of rq->nr_running.

This is easier to follow and leads to the correct answer whether SCX is
disabled, enabled in partial mode or all tasks are switched to SCX.

Peter, note that this is a bit different from your suggestion where
sched_can_stop_tick() unconditionally returns scx_can_stop_tick() iff
scx_switched_all(). The problem is that in partial mode, tick can be stopped
when there is only one SCX task even if the BPF scheduler didn't ask and
isn't ready for it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
---
 kernel/sched/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 22f86d5e9231..7994118eee53 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1267,10 +1267,10 @@ bool sched_can_stop_tick(struct rq *rq)
 	 * left. For CFS, if there's more than one we need the tick for
 	 * involuntary preemption. For SCX, ask.
 	 */
-	if (!scx_switched_all() && rq->nr_running > 1)
+	if (scx_enabled() && !scx_can_stop_tick(rq))
 		return false;
 
-	if (scx_enabled() && !scx_can_stop_tick(rq))
+	if (rq->cfs.nr_running > 1)
 		return false;
 
 	/*
-- 
2.46.0


  reply	other threads:[~2024-08-04  2:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-04  2:40 [PATCHSET sched_ext/for-6.12] sched_ext: Misc updates Tejun Heo
2024-08-04  2:40 ` Tejun Heo [this message]
2024-08-05 17:55   ` [PATCH 1/6] sched_ext: Simplify scx_can_stop_tick() invocation in sched_can_stop_tick() David Vernet
2024-08-04  2:40 ` [PATCH 2/6] sched_ext: Add scx_enabled() test to @start_class promotion in put_prev_task_balance() Tejun Heo
2024-08-05 17:57   ` David Vernet
2024-08-04  2:40 ` [PATCH 3/6] sched_ext: Use update_curr_common() in update_curr_scx() Tejun Heo
2024-08-05 18:23   ` David Vernet
2024-08-04  2:40 ` [PATCH 4/6] sched_ext: Simplify UP support by enabling sched_class->balance() in UP Tejun Heo
2024-08-05 19:49   ` David Vernet
2024-08-04  2:40 ` [PATCH 5/6] sched_ext: Improve comment on idle_sched_class exception in scx_task_iter_next_locked() Tejun Heo
2024-08-05 19:50   ` David Vernet
2024-08-04  2:40 ` [PATCH 6/6] sched_ext: Make task_can_run_on_remote_rq() use common task_allowed_on_cpu() Tejun Heo
2024-08-05 19:55   ` David Vernet
2024-08-06  8:12   ` Peter Zijlstra
2024-08-06 17:04     ` Tejun Heo
2024-08-06 19:39   ` [PATCH v2 " Tejun Heo
2024-08-06  8:13 ` [PATCHSET sched_ext/for-6.12] sched_ext: Misc updates Peter Zijlstra
2024-08-06 19:39 ` Tejun Heo

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=20240804024047.100355-2-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=void@manifault.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