lkml.org 
[lkml]   [2009]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] cpuhotplug: use rw_semaphore for cpu_hotplug
Oleg Nesterov wrote:
> On 05/29, Oleg Nesterov wrote:
>> On 05/29, Andrew Morton wrote:
>>> On Fri, 29 May 2009 16:29:30 +0800
>>> Lai Jiangshan <laijs@cn.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?
>
> And please note that the current code drops mutex when get_online_cpus()
> succeeds. With your patch (if I read it correctly) the code under get_()
> runs with cpu_hotplug->rwlock held for reading. I'm afraid this creates
> the new possibilities for deadlocks.
>

The current code drops mutex when get_online_cpus() succeeds, BUT it
increases the counter as what down_read() does. I think the current
code has the same deadlocks which the down_read()-implement has.

Since the current code use mutex + counter to implement a "down_read()",
why not use the down_read() directly?
And down_read() can be checked by lockdep.

Lai.



\
 
 \ /
  Last update: 2009-06-01 03:11    [from the cache]
©2003-2011 Jasper Spaans