From: Peter Zijlstra <peterz@infradead.org>
To: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
x86@kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, robclark@gmail.com,
rostedt@goodmis.org, tglx@linutronix.de, mingo@elte.hu,
linux-media@vger.kernel.org, Dave Airlie <airlied@redhat.com>
Subject: Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3
Date: Mon, 27 May 2013 11:13:33 +0200 [thread overview]
Message-ID: <20130527091333.GH2781@laptop> (raw)
In-Reply-To: <51A318BF.7010109@canonical.com>
On Mon, May 27, 2013 at 10:26:39AM +0200, Maarten Lankhorst wrote:
> Op 27-05-13 10:00, Peter Zijlstra schreef:
> > On Wed, May 22, 2013 at 07:24:38PM +0200, Maarten Lankhorst wrote:
> >>>> +- Functions to only acquire a single w/w mutex, which results in the exact same
> >>>> + semantics as a normal mutex. These functions have the _single postfix.
> >>> This is missing rationale.
> >> trylock_single is useful when iterating over a list, and you want to evict a bo, but only the first one that can be acquired.
> >> lock_single is useful when only a single bo needs to be acquired, for example to lock a buffer during mmap.
> > OK, so given that its still early, monday and I haven't actually spend
> > much time thinking on this; would it be possible to make:
> > ww_mutex_lock(.ctx=NULL) act like ww_mutex_lock_single()?
> >
> > The idea is that if we don't provide a ctx, we'll get a different
> > lockdep annotation; mutex_lock() vs mutex_lock_nest_lock(). So if we
> > then go and make a mistake, lockdep should warn us.
> >
> > Would that work or should I stock up on morning juice?
> >
> It's easy to merge unlock_single and unlock, which I did in the next version I'll post.
> Lockdep will already warn if ww_mutex_lock and ww_mutex_lock_single are both
> used. ww_test_block_context and ww_test_context_block in lib/locking-selftest.c
> are the testcases for this.
>
> The locking paths are too different, it will end up with doing "if (ctx == NULL) mutex_lock(); else ww_mutex_lock();"
I was more thinking like:
int __sched ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
{
might_sleep();
return __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE, 0,
ctx ? ctx->dep_map : NULL, _RET_IP_,
ctx, 0);
}
That should make ww_mutex_lock(.ctx=NULL) equivalent to
mutex_lock(&lock->base), no?
Anyway, implementation aside, it would again reduce the interface some.
next prev parent reply other threads:[~2013-05-27 9:13 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-28 17:03 [PATCH v3 0/3] Wait/wound mutex implementation, v3 Maarten Lankhorst
2013-04-28 17:03 ` [PATCH v3 1/3] arch: make __mutex_fastpath_lock_retval return whether fastpath succeeded or not Maarten Lankhorst
2013-04-28 17:04 ` [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3 Maarten Lankhorst
2013-04-28 17:04 ` Maarten Lankhorst
2013-04-30 19:14 ` Daniel Vetter
2013-04-30 19:14 ` Daniel Vetter
2013-05-22 11:18 ` Maarten Lankhorst
2013-05-22 11:18 ` Maarten Lankhorst
2013-05-22 11:37 ` Peter Zijlstra
2013-05-22 11:37 ` Peter Zijlstra
2013-05-22 11:47 ` Maarten Lankhorst
2013-05-22 11:47 ` Maarten Lankhorst
2013-05-22 12:07 ` Peter Zijlstra
2013-05-22 16:18 ` Peter Zijlstra
2013-05-22 16:49 ` Daniel Vetter
2013-05-22 16:49 ` Daniel Vetter
2013-05-27 8:29 ` Peter Zijlstra
2013-05-27 8:29 ` Peter Zijlstra
2013-05-22 17:24 ` Maarten Lankhorst
2013-05-23 9:13 ` Maarten Lankhorst
2013-05-23 9:13 ` Maarten Lankhorst
2013-05-23 10:45 ` [Linaro-mm-sig] " Daniel Vetter
2013-05-23 10:45 ` Daniel Vetter
2013-05-27 8:00 ` Peter Zijlstra
2013-05-27 8:26 ` Maarten Lankhorst
2013-05-27 8:26 ` Maarten Lankhorst
2013-05-27 9:13 ` Peter Zijlstra [this message]
2013-05-27 9:58 ` Maarten Lankhorst
2013-05-27 8:21 ` Peter Zijlstra
2013-05-27 8:21 ` Peter Zijlstra
2013-05-27 10:01 ` Maarten Lankhorst
2013-05-27 10:24 ` Peter Zijlstra
2013-05-27 10:52 ` Maarten Lankhorst
2013-05-27 11:15 ` Peter Zijlstra
2013-05-27 11:24 ` Maarten Lankhorst
2013-05-27 14:47 ` Daniel Vetter
2013-05-27 14:47 ` Daniel Vetter
2013-05-27 14:55 ` Daniel Vetter
2013-05-27 14:55 ` Daniel Vetter
2013-04-28 17:04 ` [PATCH v3 3/3] mutex: Add ww tests to lib/locking-selftest.c. v3 Maarten Lankhorst
2013-04-28 17:04 ` Maarten Lankhorst
2013-04-30 18:45 ` [PATCH] [RFC] mutex: w/w mutex slowpath debugging Daniel Vetter
2013-04-30 18:45 ` Daniel Vetter
2013-04-30 19:29 ` Steven Rostedt
2013-04-30 19:29 ` Steven Rostedt
2013-04-30 20:38 ` Daniel Vetter
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=20130527091333.GH2781@laptop \
--to=peterz@infradead.org \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maarten.lankhorst@canonical.com \
--cc=mingo@elte.hu \
--cc=robclark@gmail.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).