[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJhHMCDwxmNS0vA_9LqRKHxOVo=4RY-oHt2mPaVQK7MZJQ97=w@mail.gmail.com>
Date: Wed, 29 Oct 2014 13:56:01 -0400
From: Pranith Kumar <bobby.prani@...il.com>
To: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Lai Jiangshan <laijs@...fujitsu.com>,
Dipankar Sarma <dipankar@...ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Josh Triplett <josh@...htriplett.org>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Steven Rostedt <rostedt@...dmis.org>,
David Howells <dhowells@...hat.com>,
Eric Dumazet <edumazet@...gle.com>, dvhart@...ux.intel.com,
Frédéric Weisbecker <fweisbec@...il.com>,
Oleg Nesterov <oleg@...hat.com>
Subject: Re: [PATCH tip/core/rcu 10/10] cpu: Avoid puts_pending overflow
On Tue, Oct 28, 2014 at 5:53 PM, Paul E. McKenney
<paulmck@...ux.vnet.ibm.com> wrote:
> From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
>
> A long string of get_online_cpus() with each followed by a
> put_online_cpu() that fails to acquire cpu_hotplug.lock can result in
> overflow of the cpu_hotplug.puts_pending counter. Although this is
> perhaps improbably, a system with absolutely no CPU-hotplug operations
> will have an arbitrarily long time in which this overflow could occur.
> This commit therefore adds overflow checks to get_online_cpus() and
> try_get_online_cpus().
>
> Signed-off-by: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
This patch seems to be missing in the cover letter.
Reviewed-by: Pranith Kumar <bobby.prani@...il.com>
> ---
> kernel/cpu.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 90a3d017b90c..5d220234b3ca 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -86,6 +86,16 @@ static struct {
> #define cpuhp_lock_acquire() lock_map_acquire(&cpu_hotplug.dep_map)
> #define cpuhp_lock_release() lock_map_release(&cpu_hotplug.dep_map)
>
> +static void apply_puts_pending(int max)
> +{
> + int delta;
> +
> + if (atomic_read(&cpu_hotplug.puts_pending) >= max) {
> + delta = atomic_xchg(&cpu_hotplug.puts_pending, 0);
> + cpu_hotplug.refcount -= delta;
> + }
> +}
> +
> void get_online_cpus(void)
> {
> might_sleep();
> @@ -93,6 +103,7 @@ void get_online_cpus(void)
> return;
> cpuhp_lock_acquire_read();
> mutex_lock(&cpu_hotplug.lock);
> + apply_puts_pending(65536);
> cpu_hotplug.refcount++;
> mutex_unlock(&cpu_hotplug.lock);
> }
> @@ -105,6 +116,7 @@ bool try_get_online_cpus(void)
> if (!mutex_trylock(&cpu_hotplug.lock))
> return false;
> cpuhp_lock_acquire_tryread();
> + apply_puts_pending(65536);
> cpu_hotplug.refcount++;
> mutex_unlock(&cpu_hotplug.lock);
> return true;
> @@ -161,12 +173,7 @@ void cpu_hotplug_begin(void)
> cpuhp_lock_acquire();
> for (;;) {
> mutex_lock(&cpu_hotplug.lock);
> - if (atomic_read(&cpu_hotplug.puts_pending)) {
> - int delta;
> -
> - delta = atomic_xchg(&cpu_hotplug.puts_pending, 0);
> - cpu_hotplug.refcount -= delta;
> - }
> + apply_puts_pending(1);
> if (likely(!cpu_hotplug.refcount))
> break;
> __set_current_state(TASK_UNINTERRUPTIBLE);
> --
> 1.8.1.5
>
--
Pranith
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists