dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: optimize the pool shrinker a bit
Date: Fri, 9 Apr 2021 09:41:40 +0200	[thread overview]
Message-ID: <YHAFNDp81oK8QHnP@phenom.ffwll.local> (raw)
In-Reply-To: <ede33f9c-e86d-7859-74d6-b28067080573@gmail.com>

On Thu, Apr 08, 2021 at 02:44:16PM +0200, Christian König wrote:
> Am 08.04.21 um 13:31 schrieb Daniel Vetter:
> > On Thu, Apr 08, 2021 at 01:17:32PM +0200, Christian König wrote:
> > > Am 08.04.21 um 13:08 schrieb Daniel Vetter:
> > > > On Thu, Apr 01, 2021 at 03:54:13PM +0200, Christian König wrote:
> > > > > [SNIP]
> > > > >    EXPORT_SYMBOL(unregister_shrinker);
> > > > > +/**
> > > > > + * sync_shrinker - Wait for all running shrinkers to complete.
> > > > > + */
> > > > > +void sync_shrinkers(void)
> > > > This one should probably be in its own patch, with a bit more commit
> > > > message about why we need it and all that. I'd assume that just
> > > > unregistering the shrinker should sync everything we needed to sync
> > > > already, and for other sync needs we can do locking within our own
> > > > shrinker?
> > > Correct. Reason why we need the barrier is that we need to destroy the
> > > device (during hotplug) before the shrinker is unregistered (during module
> > > unload).
> > > 
> > > Going to separate that, write something up in the commit message and send it
> > > to the appropriate audience.
> > Hm why do we need that?
> 
> When the shrinker runs in parallel with (for example) a hotplug event and
> unmaps pages from the devices IOMMU I must make sure that you can't destroy
> the device or pool structure at the same time.
> 
> Previously holding the mutex while updating the IOMMU would take care of
> that, but now we need to prevent this otherwise.
> 
> Could be that this is also handled somewhere else, but I'm better save than
> sorry here and grabbing/releasing write side of the shrinker_rwsem is rather
> lightweight.

I forgot that we don't have a per-pool (or at least per-device) shrinker,
but one global one for all ttm device. So yeah with that design a
sync_shrinker is needed.
-Daniel

> 
> > Either way sounds like an orthogonal series for
> > the hotunplug work, not just shrinker optimization.
> 
> It is unrelated to the hotplug work in general.
> 
> Regards,
> Christian.
> 
> > -Daniel
> > 
> > > Thanks,
> > > Christian.
> > > 
> > > > -Daniel
> > > > 
> > > > > +{
> > > > > +	down_write(&shrinker_rwsem);
> > > > > +	up_write(&shrinker_rwsem);
> > > > > +}
> > > > > +EXPORT_SYMBOL(sync_shrinkers);
> > > > > +
> > > > >    #define SHRINK_BATCH 128
> > > > >    static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
> > > > > -- 
> > > > > 2.25.1
> > > > > 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2021-04-09  7:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01 13:54 [PATCH] drm/ttm: optimize the pool shrinker a bit Christian König
2021-04-02  4:18 ` kernel test robot
2021-04-08 11:08 ` Daniel Vetter
2021-04-08 11:17   ` Christian König
2021-04-08 11:31     ` Daniel Vetter
2021-04-08 12:44       ` Christian König
2021-04-09  7:41         ` 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=YHAFNDp81oK8QHnP@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.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).