[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4A232662.5030308@cn.fujitsu.com>
Date: Mon, 01 Jun 2009 08:52:50 +0800
From: Lai Jiangshan <laijs@...fujitsu.com>
To: Oleg Nesterov <oleg@...hat.com>
CC: Andrew Morton <akpm@...ux-foundation.org>, rusty@...tcorp.com.au,
mingo@...e.hu, paulmck@...ux.vnet.ibm.com,
linux-kernel@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Gautham R Shenoy <ego@...ibm.com>
Subject: Re: [PATCH 1/2] cpuhotplug: use rw_semaphore for cpu_hotplug
Oleg Nesterov wrote:
> On 05/29, Andrew Morton wrote:
>> On Fri, 29 May 2009 16:29:30 +0800
>> Lai Jiangshan <laijs@...fujitsu.com> wrote:
>>
>>> Current get_online_cpus()/put_online_cpus() re-implement
>>> a rw_semaphore,
>>> so it is converted to a real rw_semaphore in this fix.
>>> It simplifies codes, and is good for read.
>>> static struct {
>>> - struct task_struct *active_writer;
>>> - struct mutex lock; /* Synchronizes accesses to refcount, */
>>> /*
>>> - * Also blocks the new readers during
>>> - * an ongoing cpu hotplug operation.
>>> + * active_writer makes get_online_cpus()/put_online_cpus() are allowd
>>> + * to be nested in cpu_hotplug_begin()/cpu_hotplug_done().
>>> + *
>>> + * Thus, get_online_cpus()/put_online_cpus() can be called in
>>> + * CPU notifiers.
>>> */
>>> - int refcount;
>>> + struct task_struct *active_writer;
>>> + struct rw_semaphore rwlock;
>>> } cpu_hotplug;
>
> But, afaics, down_write() blocks new readers.
>
> This means that with this patch get_online_cpus() is not recursive, no?
>
down_read()/up_read() can be nested within down_read()/up_read(),
so get_online_cpus() is recursive.
And thanks to cpu_hotplug.active_writer, get_online_cpus()/put_online_cpus()
are allowd to be nested in cpu_hotplug_begin()/cpu_hotplug_done().
So cpu_hotplug_begin() DO NOT blocks readers who are in CPU notifiers.
--
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