From: Peter Zijlstra <peterz@infradead.org>
To: James Morse <james.morse@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: get_online_cpus() from a preemptible() context (bug?)
Date: Mon, 6 Nov 2017 22:07:18 +0100 [thread overview]
Message-ID: <20171106210718.GB3326@worktop> (raw)
In-Reply-To: <5A00AF37.7030606@arm.com>
On Mon, Nov 06, 2017 at 06:51:35PM +0000, James Morse wrote:
> > If you look at percpu_down_read(), you'll note it'll disable preemption
> > before calling __percpu_down_read().
>
> Yes, this is how __percpu_down_read() protects the combination of it's fast/slow
> paths.
>
> But next percpu_down_read() calls preempt_enable(), I can't see what stops us
> migrating before percpu_up_read() preempt_disable()s to call __this_cpu_dec(),
> which now affects a different variable.
>
Ah, so the two operations that comment talks about are:
percpu_down_read_preempt_disable()
preempt_disable();
1) __this_cpu_inc(*sem->read_count);
if (unlikely(!rcu_sync_is_idle(&sem->rss)))
__percpu_down_read()
smp_mb()
if (likely(!smp_load_acquire(&sem->readers_block))) // false
__percpu_up_read()
smp_mb()
2) __this_cpu_dec(*sem->read_count);
rcuwait_wake_up(&sem->writer);
preempt_enable_no_resched();
If you want more detail on this, I'll actually have to go think :-)
next prev parent reply other threads:[~2017-11-06 21:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-03 14:45 get_online_cpus() from a preemptible() context (bug?) James Morse
2017-11-06 10:32 ` Peter Zijlstra
2017-11-06 10:40 ` Peter Zijlstra
2017-11-06 18:51 ` James Morse
2017-11-06 21:07 ` Peter Zijlstra [this message]
2017-11-08 16:07 ` James Morse
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=20171106210718.GB3326@worktop \
--to=peterz@infradead.org \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.