From: Andrea Arcangeli <aarcange@redhat.com>
To: "J. R. Okajima" <hooanon05g@gmail.com>
Cc: joonas.lahtinen@linux.intel.com, chris@chris-wilson.co.uk,
daniel.vetter@ffwll.ch, jani.nikula@intel.com,
linux-kernel@vger.kernel.org
Subject: Re: Q. drm/i915 shrinker, synchronize_rcu_expedited() from handlers
Date: Sun, 30 Apr 2017 11:43:48 +0200 [thread overview]
Message-ID: <20170430094348.GA5970@redhat.com> (raw)
In-Reply-To: <7743.1493532478@jrobl>
On Sun, Apr 30, 2017 at 03:07:58PM +0900, J. R. Okajima wrote:
> Hello,
>
> Since v4.11-rc7 I can see the workqueue stops on my development/test system.
> Git-bisecting tells me the suspicious commit is
> c053b5a 2017-04-11 drm/i915: Don't call synchronize_rcu_expedited under struct_mutex
>
> I am not sure whether this is the real cause or not of my problem, but I
> have a question.
> By the commit, the shrinker handlers ->scan_objects() and
> ->count_objects() both calls synchronize_rcu_expedited()
> unconditionally. Is it a legal RCU bahavour?
It's actually not legal because the workqueue RCU uses is not reclaim
safe, simply lockdep is unable to notice it because RCU won't use
flush_workqueue to wait for completion but it waits a wakeup from the
workqueue instead (and lockdep can't possibly notice that).
To fix it and allow both RCU and flush_workqueue (both needed to wait
the memory to be freed), i915 and RCU must both start using their own
private workqueue and not share the system-wide one and then set
WQ_MEM_RECLAIM on their private workqueue. (and of course they should
only call it when they're not recursing on the struct mutex)
The alternative is to drop it all and behave like in the mutex
recursion case. However reclaim cannot possibly throttle on the memory
freeing externally unless RCU is changed to stop using the system
workqueue so the idea that the throttling can be offloaded to the
reclaim code doesn't move the needle in terms of being able to
throttle. Perhaps no throttling is necessary at all and we can just go
inaccurate and it'll work fine though.
> I know dev->struct_mutex is unlocked now, but before the commit, these
> two handlers were not calling synchronize_rcu_expedited().
Yes I already reported this, my original fix was way more efficient
(and also safer considering the above) than what landed upstream. My
feedback was ignored though.
https://lists.freedesktop.org/archives/intel-gfx/2017-April/125414.html
Thanks,
Andrea
next prev parent reply other threads:[~2017-04-30 9:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-30 6:07 Q. drm/i915 shrinker, synchronize_rcu_expedited() from handlers J. R. Okajima
2017-04-30 9:43 ` Andrea Arcangeli [this message]
2017-05-01 2:05 ` J. R. Okajima
2017-05-05 9:39 ` Joonas Lahtinen
2017-05-05 21:57 ` Hugh Dickins
2017-05-08 8:04 ` Joonas Lahtinen
2017-05-10 3:04 ` Hugh Dickins
2017-05-10 9:54 ` Joonas Lahtinen
2017-05-10 10:43 ` Andrea Arcangeli
2017-05-10 11:01 ` Joonas Lahtinen
2017-05-05 23:28 ` J. R. Okajima
2017-05-20 1:56 ` J. R. Okajima
2017-05-22 6:02 ` Joonas Lahtinen
2017-05-30 20:00 ` Hugh Dickins
2017-05-31 7:10 ` Jani Nikula
2017-05-31 7:27 ` Joonas Lahtinen
2017-06-14 23:05 ` J. R. Okajima
2017-06-15 7:07 ` Jani Nikula
2017-06-26 23:15 ` J. R. Okajima
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=20170430094348.GA5970@redhat.com \
--to=aarcange@redhat.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=hooanon05g@gmail.com \
--cc=jani.nikula@intel.com \
--cc=joonas.lahtinen@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;
as well as URLs for NNTP newsgroup(s).