From: James Morse <james.morse@arm.com>
To: Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: get_online_cpus() from a preemptible() context (bug?)
Date: Fri, 03 Nov 2017 14:45:45 +0000 [thread overview]
Message-ID: <59FC8119.8030608@arm.com> (raw)
Hi Thomas, Peter,
I'm trying to work out what stops a thread being pre-empted and migrated between
calling get_online_cpus() and put_online_cpus().
According to __percpu_down_read(), its the pre-empt count:
> * Due to having preemption disabled the decrement happens on
> * the same CPU as the increment, avoiding the
> * increment-on-one-CPU-and-decrement-on-another problem.
So this:
> void cpus_read_lock(void)
> {
> percpu_down_read(&cpu_hotplug_lock);
> +
> + /* Can we migrated before we release this per-cpu lock? */
> + WARN_ON(preemptible());
> }
should never fire?
It does, some of the offenders:
> kmem_cache_create
> apply_workqueue_attrs
> stop_machine
> static_key_enable
> lru_add_drain_all
> __cpuhp_setup_state
> kmem_cache_shrink
> vmstat_shepherd
> __cpuhp_state_add_instance
Trying to leave preempt disabled between the down/up leads to
scheduling-while-atomic instead.
Can you point out what I've missed here?
Thanks,
James
next reply other threads:[~2017-11-03 14:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-03 14:45 James Morse [this message]
2017-11-06 10:32 ` get_online_cpus() from a preemptible() context (bug?) Peter Zijlstra
2017-11-06 10:40 ` Peter Zijlstra
2017-11-06 18:51 ` James Morse
2017-11-06 21:07 ` Peter Zijlstra
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=59FC8119.8030608@arm.com \
--to=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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.