From: Qais Yousef <qais.yousef@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Dave Jones <davej@codemonkey.org.uk>,
Mel Gorman <mgorman@techsingularity.net>,
Linux Kernel <linux-kernel@vger.kernel.org>,
mingo@kernel.org, Linus Torvalds <torvalds@linux-foundation.org>,
paul.gortmaker@windriver.com, valentin.schneider@arm.com
Subject: Re: weird loadavg on idle machine post 5.7
Date: Tue, 7 Jul 2020 10:20:05 +0100 [thread overview]
Message-ID: <20200707092004.jviycpvzb4l5ytiz@e107158-lin.cambridge.arm.com> (raw)
In-Reply-To: <20200706145952.GB597537@hirez.programming.kicks-ass.net>
On 07/06/20 16:59, Peter Zijlstra wrote:
[...]
> @@ -4104,12 +4108,19 @@ static void __sched notrace __schedule(bool preempt)
> local_irq_disable();
> rcu_note_context_switch(preempt);
>
> + prev_state = prev->state;
> +
> /*
> - * Make sure that signal_pending_state()->signal_pending() below
> - * can't be reordered with __set_current_state(TASK_INTERRUPTIBLE)
> - * done by the caller to avoid the race with signal_wake_up().
> + * __set_current_state(@state)
> + * schedule() signal_wake_up()
> + * prev_state = p->state set_tsk_thread_flag(p, TIF_SIGPENDING)
> + * wake_up_state()
> + * LOCK rq->lock LOCK p->pi_state
> + * smp_mb__after_spinlock() smp_mb__after_spinlock()
> + * if (signal_pending_state() if (p->state & @state)
> + *
> *
> - * The membarrier system call requires a full memory barrier
> + * Also, the membarrier system call requires a full memory barrier
> * after coming from user-space, before storing to rq->curr.
> */
> rq_lock(rq, &rf);
> @@ -4120,10 +4131,30 @@ static void __sched notrace __schedule(bool preempt)
> update_rq_clock(rq);
>
> switch_count = &prev->nivcsw;
> - if (!preempt && prev->state) {
> - if (signal_pending_state(prev->state, prev)) {
> + /*
> + * We must re-load p->state in case ttwu_runnable() changed it
> + * before we acquired rq->lock.
> + */
> + if (!preempt && prev_state && prev_state == prev->state) {
I think the compiler won't optimize `prev_state == prev->state` out because of
the smp_mb__after_spinlock() which implies a compiler barrier. Still not sure
if it's worth making prev->state accesses a READ_ONCE()?
Thanks
--
Qais Yousef
next prev parent reply other threads:[~2020-07-07 9:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 17:15 weird loadavg on idle machine post 5.7 Dave Jones
2020-07-02 19:46 ` Dave Jones
2020-07-02 21:15 ` Paul Gortmaker
2020-07-03 13:23 ` Paul Gortmaker
2020-07-02 21:36 ` Mel Gorman
2020-07-02 23:11 ` Michal Kubecek
2020-07-02 23:24 ` Dave Jones
2020-07-03 9:02 ` Peter Zijlstra
2020-07-03 10:40 ` Peter Zijlstra
2020-07-03 20:51 ` Dave Jones
2020-07-06 14:59 ` Peter Zijlstra
2020-07-06 21:20 ` Dave Jones
2020-07-07 7:48 ` Peter Zijlstra
2020-07-06 23:56 ` Valentin Schneider
2020-07-07 8:17 ` Peter Zijlstra
2020-07-07 10:20 ` Valentin Schneider
2020-07-07 10:29 ` Peter Zijlstra
2020-07-08 9:46 ` [tip: sched/urgent] sched: Fix loadavg accounting race tip-bot2 for Peter Zijlstra
2020-07-07 9:20 ` Qais Yousef [this message]
2020-07-07 9:47 ` weird loadavg on idle machine post 5.7 Peter Zijlstra
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=20200707092004.jviycpvzb4l5ytiz@e107158-lin.cambridge.arm.com \
--to=qais.yousef@arm.com \
--cc=davej@codemonkey.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@techsingularity.net \
--cc=mingo@kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=valentin.schneider@arm.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;
as well as URLs for NNTP newsgroup(s).