From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>,
Davidlohr Bueso <dave@stgolabs.net>,
daniel.vetter@intel.com, jani.nikula@linux.intel.com,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [Intel-gfx] [rfc PATCH] drm/i915: Simplify shrinker_lock
Date: Tue, 19 Jul 2016 09:03:17 +0200 [thread overview]
Message-ID: <20160719070317.GI17101@phenom.ffwll.local> (raw)
In-Reply-To: <20160717215451.GB21839@nuc-i3427.alporthouse.com>
On Sun, Jul 17, 2016 at 10:54:51PM +0100, Chris Wilson wrote:
> On Sun, Jul 17, 2016 at 11:45:44AM -0700, Davidlohr Bueso wrote:
> > In addition, we can simplify the overall function wrt (2), by first
> > checking if we are the lock owner, then address the trylock and
> > deal with (2) if locked/contended by a traditional mutex_lock().
> > This should be safe considering that if current is the lock owner,
> > then we are guaranteed not to race with the counter->owner updates
> > (the counter is updated first which sets the mutex to be visibly locked).
>
> However, that is then subject to an indirect ABBA deadlock, between the
> shrinker lock and the struct mutex (or at least that used to be the case
> where the kswapd reclaim would be blocked on the mutex and an alloc
> blocked on kswapd).
>
> Unravelling the gross locking is an ongoing task, with one of the chief
> goals being able to reclaim memory whenever required. It is not pretty
> and often fails under pressure.
Yeah, what we need is to split up the dev->struct_mutex Big Driver Lock to
separate concerns. What's propably needed is a low-level mm lock (under
which we never ever allocate anything to avoid the deadlock with reclaim).
Plus probably per-object locks (using ww_mutex) to be able to protect
buffer against both from the shrinker (which would trylock, considering
locked objects busy) against threads and each another. We also might need
per-submission context locks to avoid havoc there, but not sure.
The reason this is taking forever to get done is that compared to the
existing locking, this new scheme is even more complex ;-)
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
prev parent reply other threads:[~2016-07-19 7:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-17 18:45 Davidlohr Bueso
2016-07-17 21:54 ` Chris Wilson
2016-07-19 7:03 ` Daniel Vetter [this message]
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=20160719070317.GI17101@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@intel.com \
--cc=dave@stgolabs.net \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.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
Powered by JetHome