From: Jarek Poplawski <jarkao2@gmail.com>
To: Dave Young <hidave.darkstar@gmail.com>
Cc: Greg KH <gregkh@suse.de>,
stefanr@s5r6.in-berlin.de, david-b@pacbell.net,
stern@rowland.harvard.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 7/7] driver-core : convert semaphore to mutex in struct class
Date: Thu, 17 Jan 2008 09:38:10 +0100 [thread overview]
Message-ID: <20080117083810.GA1710@ff.dom.local> (raw)
In-Reply-To: <a8e1da0801161717r4cdc1e9cn6a8ec1731c8f831b@mail.gmail.com>
On 17-01-2008 02:17, Dave Young wrote:
> On Jan 16, 2008 4:34 PM, Jarek Poplawski <jarkao2@gmail.com> wrote:
>> On Wed, Jan 16, 2008 at 09:03:03AM +0800, Dave Young wrote:
>> ...
>>> The lockdep warining was posted in the below thread, actually, I have
>>> built and run this patced kernel for several days, there's no more
>>> warnings.
>>> http://lkml.org/lkml/2008/1/3/2
>> Right... But, with something like this:
>>
>> ... have_some_fun(... cls)
>> {
>> mutex_lock_nested(&cls->mutex, SINGLE_DEPTH_NESTING);
>> have_other_fun(cls);
>> mutex_unlock(&cls->mutex);
>>
>> }
>>
>> ... have_more_fun(...)
>> {
>> ...
>>
>> mutex_init(&cls->mutex);
>>
>> mutex_lock(&cls->mutex);
>> have_some_fun(cls);
>> mutex_unlock(&cls->mutex);
>> }
>>
>> probably you wouldn't get any lockdep warning too...
>
> Sorry for late reply.
> Actually, I don't know much about lockdep. Could you tell how to use
> it properly in this scenario?
As you have noticed while working on this patch, if two different
instances of the same structure containig some lock are created in
the same place, lockdep will treat this one (the same) lock. It looks
strange, but actually it's a feature which enables to track
dependencies between different locks on 'class' level instead of
instance 'level'. The downside is that lockdep is very often too
sensitive by default, so you have to 'annotate' when instancess are
actually on different level (e.g. parents and children here) and
could be locked at the same time or in some order.
You can use e.g. mutex_lock_nested() or lockdep_set_class*() for this.
Then lockdep simply trusts you, and starts to think they are different
locks. If you do it wrong there will be simply no more warnings, but
undercover lockups still possible (and diagnosing a bit harder then).
So, since in your patch there are two levels of locking, and you
started to annotate lockdep about a child taking parent's class lock
with:
mutex_lock_nested(&parent_class->mutex, SINGLE_DEPTH_NESTING);
you should do the same everywhere in a situation like this.
lockdep will treat this simply as lock B vs. A (mutex_lock(&cls))
dependencies.
Regards,
Jarek P.
PS: BTW, it seems after this patch 1/1 the locking was changed a bit,
so these previous tests could be not enough.
next prev parent reply other threads:[~2008-01-17 8:31 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-12 10:05 [PATCH 7/7] driver-core : convert semaphore to mutex in struct class Dave Young
2008-01-15 9:15 ` Dave Young
2008-01-15 13:56 ` Jarek Poplawski
2008-01-16 1:03 ` Dave Young
2008-01-16 8:34 ` Jarek Poplawski
2008-01-17 1:17 ` Dave Young
2008-01-17 8:38 ` Jarek Poplawski [this message]
2008-01-17 8:56 ` Dave Young
2008-01-16 15:27 ` Alan Stern
2008-01-17 0:01 ` Jarek Poplawski
2008-01-17 1:18 ` Dave Young
2008-01-17 15:16 ` Alan Stern
2008-01-17 19:47 ` Jarek Poplawski
2008-01-17 19:57 ` Alan Stern
2008-01-17 20:31 ` Jarek Poplawski
2008-01-17 22:02 ` Jarek Poplawski
2008-01-17 23:26 ` Jarek Poplawski
2008-01-18 1:42 ` Dave Young
2008-01-18 1:55 ` Kay Sievers
2008-01-18 2:28 ` Dave Young
2008-01-18 3:18 ` Kay Sievers
2008-01-18 6:25 ` Greg KH
[not found] ` <a8e1da0801172131h57097622h6d111133b6a0773d@mail.gmail.com>
2008-01-18 7:38 ` Jarek Poplawski
2008-01-18 7:48 ` Dave Young
2008-01-18 8:23 ` Jarek Poplawski
2008-01-18 9:07 ` Dave Young
2008-01-19 9:39 ` Jarek Poplawski
2008-01-21 1:19 ` Dave Young
2008-01-21 1:30 ` Dave Young
2008-01-21 1:43 ` Dave Young
2008-01-21 8:36 ` Jarek Poplawski
2008-01-21 8:44 ` Dave Young
2008-01-21 9:03 ` Jarek Poplawski
2008-01-21 21:16 ` Jarek Poplawski
2008-01-22 0:55 ` Dave Young
2008-01-22 5:15 ` Greg KH
2008-01-22 6:13 ` Dave Young
2008-01-22 7:45 ` Jarek Poplawski
2008-01-18 10:45 ` Kay Sievers
2008-01-18 11:40 ` Jarek Poplawski
2008-01-18 8:00 ` Jarek Poplawski
2008-01-18 8:39 ` Jarek Poplawski
2008-01-17 21:11 ` Greg KH
2008-01-17 21:55 ` Jarek Poplawski
2008-01-18 1:45 ` Dave Young
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=20080117083810.GA1710@ff.dom.local \
--to=jarkao2@gmail.com \
--cc=david-b@pacbell.net \
--cc=gregkh@suse.de \
--cc=hidave.darkstar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stefanr@s5r6.in-berlin.de \
--cc=stern@rowland.harvard.edu \
/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