public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Hao Jia <jiahao.os@bytedance.com>
Cc: mingo@redhat.com, mingo@kernel.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, vschneid@redhat.com,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Igor Raits <igor.raits@gmail.com>,
	Bagas Sanjaya <bagasdotme@gmail.com>
Subject: Re: [External] Re: [PATCH] sched/core: Fix wrong warning check in rq_clock_start_loop_update()
Date: Tue, 10 Oct 2023 15:53:40 +0200	[thread overview]
Message-ID: <20231010135340.GK377@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <979f948c-7611-b137-a06a-ca09ff63f919@bytedance.com>

On Sat, Oct 07, 2023 at 04:44:46PM +0800, Hao Jia wrote:

> > That is, would not something like the below make more sense?
> 
> If we understand correctly, this may not work.
> 
> After applying this patch, the following situation will trigger the
> rq->clock_update_flags < RQCF_ACT_SKIP warning.
> 
> If rq_clock_skip_update() is called before __schedule(), so RQCF_REQ_SKIP of
> rq->clock_update_flags is set.
> 
> 
> 
> 
> __schedule() {
> 	rq_lock(rq, &rf); [rq->clock_update_flags is RQCF_REQ_SKIP]
> 	rq->clock_update_flags <<= 1;
> 	update_rq_clock(rq); [rq->clock_update_flags is RQCF_ACT_SKIP]
> + 	rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
> 	* At this time, rq->clock_update_flags = 0; *

Fixed easily enough, just change to:

	rq->clock_updated_flags = RQCF_UPDATED;

> 
>          pick_next_task_fair
>          set_next_entity
>          update_load_avg
>          	assert_clock_updated() <---
> }

---
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a0a582c8cf8c..cf9eb1a26c22 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5357,8 +5357,6 @@ context_switch(struct rq *rq, struct task_struct *prev,
 	/* switch_mm_cid() requires the memory barriers above. */
 	switch_mm_cid(rq, prev, next);
 
-	rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
-
 	prepare_lock_switch(rq, next, rf);
 
 	/* Here we just switch the register state and the stack. */
@@ -6596,6 +6594,7 @@ static void __sched notrace __schedule(unsigned int sched_mode)
 	/* Promote REQ to ACT */
 	rq->clock_update_flags <<= 1;
 	update_rq_clock(rq);
+	rq->clock_update_flags = RQCF_UPDATED;
 
 	switch_count = &prev->nivcsw;
 
@@ -6675,8 +6674,6 @@ static void __sched notrace __schedule(unsigned int sched_mode)
 		/* Also unlocks the rq: */
 		rq = context_switch(rq, prev, next, &rf);
 	} else {
-		rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
-
 		rq_unpin_lock(rq, &rf);
 		__balance_callbacks(rq);
 		raw_spin_rq_unlock_irq(rq);

  reply	other threads:[~2023-10-10 13:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-13  8:24 [PATCH] sched/core: Fix wrong warning check in rq_clock_start_loop_update() Hao Jia
2023-09-28 11:41 ` Peter Zijlstra
2023-10-07  8:44   ` [External] " Hao Jia
2023-10-10 13:53     ` Peter Zijlstra [this message]
2023-10-12  9:04       ` Hao Jia

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=20231010135340.GK377@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bagasdotme@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=igor.raits@gmail.com \
    --cc=jiahao.os@bytedance.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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