Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1470609

Re: [RFC][PATCH -v2 1/4] locking/drm/i915: Kill mutex trickery

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [RFC][PATCH -v2 1/4] locking/drm/i915: Kill mutex trickery
Date 2016-08-26 11:20 +0200
Message-ID <salsR-54s-7@gated-at.bofh.it> (permalink)
References <sag0a-1Bc-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Aug 26, 2016 at 05:25:09AM +0200, Andreas Mohr wrote:
> > Another alternative is to provide a standard mutex API that returns the
> > owner of the lock if there is a real need for this capability. Peeking
> > into lock internal is not a good practice.


> So, it seems the most we could provide which would offer a reliable,
> non-racy API protocol is something like:
> 
> static bool mutex_is_locked_by_us(struct mutex *mutex)
> 
> since during execution of this processing it would be guaranteed that:
> - either we do have the lock, thus *we* *RELIABLY* are and will be "the owner"
> - or we simply do not have it, thus *we* *RELIABLY* are and will be "not the owner"

Right, and that is exactly what they attempted and need. And the new
mutex implementation could actually do this much better than the old
one.

But yes, such an interface should be part of the mutex implementation
proper, not something hacked on in random places.

Fwiw, the build bot seems to have found another instance of this thing
:/ drivers/gpu/drm/msm/msm_gem_shrinker.c includes an exact copy.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [RFC][PATCH -v2 1/4] locking/drm/i915: Kill mutex trickery Andreas Mohr <andi@lisas.de> - 2016-08-26 05:30 +0200
  Re: [RFC][PATCH -v2 1/4] locking/drm/i915: Kill mutex trickery Peter Zijlstra <peterz@infradead.org> - 2016-08-26 11:20 +0200

csiph-web