From: Peter Zijlstra <peterz@infradead.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Kernel development list <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>,
Paul E McKenney <paulmck@linux.vnet.ibm.com>
Subject: Re: Semphore -> mutex in the device tree
Date: Thu, 17 Apr 2008 17:45:53 +0200 [thread overview]
Message-ID: <1208447153.7115.23.camel@twins> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0804171117450.18040-100000@iolanthe.rowland.org>
On Thu, 2008-04-17 at 11:22 -0400, Alan Stern wrote:
> Peter:
>
> The obstacle to converting the semaphore in struct device to a mutex
> has been that its tree-oriented usage pattern isn't compatible with
> lockdep.
>
> In order to get around this and at least begin the conversion process,
> how about adding a provision for making some classes of mutex invisible
> to lockdep? I know it doesn't solve the fundamental problem, but maybe
> it's a step in the right direction.
the device lock has two problems with lockdep:
1) on suspend it takes more than MAX_LOCK_DEPTH (48) locks
2) tree nesting
Lets start with the easy one first; would a similar solution to the
radix tree locking as found in -rt work?
http://programming.kicks-ass.net/kernel-patches/concurrent-pagecache/23-rc1-rt/radix-concurrent-lockdep.patch
That does mean you have to set an effective max depth to the tree, is
that a practical issue?
The harder part is 1), holding _that_ many locks. Would something
obscene like this work for you:
struct device_suspend {
wait_queue_head_t wait_queue;
struct srcu_struct srcu;
int suspend;
} dev_suspend_state;
void device_lock(struct device *dev)
{
again:
srcu_read_lock(&dev_suspend_state.srcu);
if (unlikely(rcu_dereference(dev_suspend_state.suspend))) {
srcu_read_unlock(&dev_suspend_state.srcu);
wait_event(&dev_suspend_state.wait_queue,
!dev_suspend_state.suspend);
goto again;
}
mutex_lock(&dev->mutex);
}
void device_unlock(struct device *dev)
{
mutex_unlock(&dev->mutex);
srcu_read_unlock(&dev_suspend_state.srcu);
}
void device_suspend(void)
{
rcu_assign_pointer(dev_suspend_state.suspend, 1);
synchronize_srcu(&dev_suspend_state.srcu);
}
void device_resume(void)
{
rcu_assign_pointer(dev_suspend_state.suspend, 0);
wake_up_all(&dev_suspend_state.wait_queue);
}
next prev parent reply other threads:[~2008-04-17 15:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-17 15:22 Semphore -> mutex in the device tree Alan Stern
2008-04-17 15:45 ` Peter Zijlstra [this message]
2008-04-17 16:11 ` Alan Stern
2008-04-17 16:17 ` Peter Zijlstra
2008-04-17 18:43 ` Alan Stern
2008-04-18 6:32 ` Peter Zijlstra
2008-04-18 14:27 ` Alan Stern
2008-04-18 15:32 ` Peter Zijlstra
2008-04-18 21:45 ` Alan Stern
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=1208447153.7115.23.camel@twins \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--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