From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
rusty@rustcorp.com.au, mingo@elte.hu, paulmck@linux.vnet.ibm.com,
linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Gautham R Shenoy <ego@in.ibm.com>
Subject: Re: [PATCH 1/2] cpuhotplug: use rw_semaphore for cpu_hotplug
Date: Mon, 01 Jun 2009 09:04:37 +0800 [thread overview]
Message-ID: <4A232925.1010706@cn.fujitsu.com> (raw)
In-Reply-To: <20090529211734.GA13868@redhat.com>
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.
next prev parent reply other threads:[~2009-06-01 1:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-29 8:29 [PATCH 1/2] cpuhotplug: use rw_semaphore for cpu_hotplug Lai Jiangshan
2009-05-29 20:23 ` Andrew Morton
2009-05-29 21:07 ` Oleg Nesterov
2009-05-29 21:17 ` Oleg Nesterov
2009-06-01 1:04 ` Lai Jiangshan [this message]
2009-06-01 0:52 ` Lai Jiangshan
2009-06-01 2:22 ` Lai Jiangshan
2009-05-30 1:53 ` Paul E. McKenney
2009-05-30 4:37 ` Gautham R Shenoy
2009-06-04 6:58 ` [PATCH] cpuhotplug: introduce try_get_online_cpus() take 2 Lai Jiangshan
2009-06-04 20:49 ` Oleg Nesterov
2009-06-05 1:32 ` Lai Jiangshan
2009-06-05 2:14 ` Oleg Nesterov
2009-06-05 15:37 ` Paul E. McKenney
2009-06-08 2:36 ` Lai Jiangshan
2009-06-08 4:19 ` Gautham R Shenoy
2009-06-08 14:25 ` Paul E. McKenney
2009-06-09 12:07 ` [PATCH -mm] cpuhotplug: introduce try_get_online_cpus() take 3 Lai Jiangshan
2009-06-09 19:34 ` Andrew Morton
2009-06-09 23:47 ` Paul E. McKenney
2009-06-10 1:13 ` [PATCH -mm resend] " Lai Jiangshan
2009-06-10 1:42 ` Andrew Morton
2009-06-11 8:41 ` Lai Jiangshan
2009-06-11 18:50 ` Paul E. McKenney
2009-06-15 4:04 ` Gautham R Shenoy
2009-06-10 0:57 ` [PATCH -mm] " Lai Jiangshan
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=4A232925.1010706@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=ego@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox