[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121206161850.GA6710@redhat.com>
Date: Thu, 6 Dec 2012 17:18:50 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: "Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
Cc: tj@...nel.org, tglx@...utronix.de, peterz@...radead.org,
paulmck@...ux.vnet.ibm.com, rusty@...tcorp.com.au,
mingo@...nel.org, akpm@...ux-foundation.org, namhyung@...nel.org,
vincent.guittot@...aro.org, sbw@....edu, amit.kucheria@...aro.org,
rostedt@...dmis.org, rjw@...k.pl, wangyun@...ux.vnet.ibm.com,
xiaoguangrong@...ux.vnet.ibm.com, nikunj@...ux.vnet.ibm.com,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v2 01/10] CPU hotplug: Provide APIs for "light"
atomic readers to prevent CPU offline
On 12/06, Srivatsa S. Bhat wrote:
>
> +void get_online_cpus_atomic(void)
> +{
> + int c, old;
> +
> + preempt_disable();
> + read_lock(&hotplug_rwlock);
Confused... Why it also takes hotplug_rwlock?
> +
> + for (;;) {
> + c = atomic_read(&__get_cpu_var(atomic_reader_refcount));
> + if (unlikely(writer_active(c))) {
> + cpu_relax();
> + continue;
> + }
> +
> + old = atomic_cmpxchg(&__get_cpu_var(atomic_reader_refcount),
> + c, c + 1);
> +
> + if (likely(old == c))
> + break;
> +
> + c = old;
> + }
> +}
while (!atomic_inc_unless_negative(...))
cpu_relax();
and atomic_dec_unless_positive() in disable_atomic_reader().
Obviously you can't use get_online_cpus_atomic() under rq->lock or
task->pi_lock or any other lock CPU_DYING can take. Probably this is
fine, but perhaps it makes sense to add the lockdep annotations.
Oleg.
--
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