All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: dri-devel@lists.freedesktop.org, Leo.Liu@amd.com,
	amd-gfx@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [PATCH] drm/ttm: stop warning on TT shrinker failure
Date: Fri, 19 Mar 2021 20:06:21 +0100	[thread overview]
Message-ID: <YFT2LSR97rkkPyEP@phenom.ffwll.local> (raw)
In-Reply-To: <2831bfcc-140e-dade-1f50-a6431e495e9d@gmail.com>

On Fri, Mar 19, 2021 at 07:53:48PM +0100, Christian König wrote:
> Am 19.03.21 um 18:52 schrieb Daniel Vetter:
> > On Fri, Mar 19, 2021 at 03:08:57PM +0100, Christian König wrote:
> > > Don't print a warning when we fail to allocate a page for swapping things out.
> > > 
> > > Also rely on memalloc_nofs_save/memalloc_nofs_restore instead of GFP_NOFS.
> > Uh this part doesn't make sense. Especially since you only do it for the
> > debugfs file, not in general. Which means you've just completely broken
> > the shrinker.
> 
> Are you sure? My impression is that GFP_NOFS should now work much more out
> of the box with the memalloc_nofs_save()/memalloc_nofs_restore().

Yeah, if you'd put it in the right place :-)

But also -mm folks are very clear that memalloc_no*() family is for dire
situation where there's really no other way out. For anything where you
know what you're doing, you really should use explicit gfp flags.

> > If this is just to paper over the seq_printf doing the wrong allocations,
> > then just move that out from under the fs_reclaim_acquire/release part.
> 
> No, that wasn't the problem.
> 
> We have just seen to many failures to allocate pages for swapout and I think
> that would improve this because in a lot of cases we can then immediately
> swap things out instead of having to rely on upper layers.

Yeah, you broke it. Now the real shrinker is running with GFP_KERNEL,
because your memalloc_no is only around the debugfs function. And ofc it's
much easier to allocate with GFP_KERNEL, right until you deadlock :-)

Shrinking is hard, there's no easy way out here.

Cheers, Daniel

> 
> Regards,
> Christian.
> 
> 
> > 
> > __GFP_NOWARN should be there indeed I think.
> > -Daniel
> > 
> > > Signed-off-by: Christian König <christian.koenig@amd.com>
> > > ---
> > >   drivers/gpu/drm/ttm/ttm_tt.c | 5 ++++-
> > >   1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> > > index 2f0833c98d2c..86fa3e82dacc 100644
> > > --- a/drivers/gpu/drm/ttm/ttm_tt.c
> > > +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> > > @@ -369,7 +369,7 @@ static unsigned long ttm_tt_shrinker_scan(struct shrinker *shrink,
> > >   	};
> > >   	int ret;
> > > -	ret = ttm_bo_swapout(&ctx, GFP_NOFS);
> > > +	ret = ttm_bo_swapout(&ctx, GFP_KERNEL | __GFP_NOWARN);
> > >   	return ret < 0 ? SHRINK_EMPTY : ret;
> > >   }
> > > @@ -389,10 +389,13 @@ static unsigned long ttm_tt_shrinker_count(struct shrinker *shrink,
> > >   static int ttm_tt_debugfs_shrink_show(struct seq_file *m, void *data)
> > >   {
> > >   	struct shrink_control sc = { .gfp_mask = GFP_KERNEL };
> > > +	unsigned int flags;
> > >   	fs_reclaim_acquire(GFP_KERNEL);
> > > +	flags = memalloc_nofs_save();
> > >   	seq_printf(m, "%lu/%lu\n", ttm_tt_shrinker_count(&mm_shrinker, &sc),
> > >   		   ttm_tt_shrinker_scan(&mm_shrinker, &sc));
> > > +	memalloc_nofs_restore(flags);
> > >   	fs_reclaim_release(GFP_KERNEL);
> > >   	return 0;
> > > -- 
> > > 2.25.1
> > > 
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 

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

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: dri-devel@lists.freedesktop.org, Leo.Liu@amd.com,
	amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: stop warning on TT shrinker failure
Date: Fri, 19 Mar 2021 20:06:21 +0100	[thread overview]
Message-ID: <YFT2LSR97rkkPyEP@phenom.ffwll.local> (raw)
In-Reply-To: <2831bfcc-140e-dade-1f50-a6431e495e9d@gmail.com>

On Fri, Mar 19, 2021 at 07:53:48PM +0100, Christian König wrote:
> Am 19.03.21 um 18:52 schrieb Daniel Vetter:
> > On Fri, Mar 19, 2021 at 03:08:57PM +0100, Christian König wrote:
> > > Don't print a warning when we fail to allocate a page for swapping things out.
> > > 
> > > Also rely on memalloc_nofs_save/memalloc_nofs_restore instead of GFP_NOFS.
> > Uh this part doesn't make sense. Especially since you only do it for the
> > debugfs file, not in general. Which means you've just completely broken
> > the shrinker.
> 
> Are you sure? My impression is that GFP_NOFS should now work much more out
> of the box with the memalloc_nofs_save()/memalloc_nofs_restore().

Yeah, if you'd put it in the right place :-)

But also -mm folks are very clear that memalloc_no*() family is for dire
situation where there's really no other way out. For anything where you
know what you're doing, you really should use explicit gfp flags.

> > If this is just to paper over the seq_printf doing the wrong allocations,
> > then just move that out from under the fs_reclaim_acquire/release part.
> 
> No, that wasn't the problem.
> 
> We have just seen to many failures to allocate pages for swapout and I think
> that would improve this because in a lot of cases we can then immediately
> swap things out instead of having to rely on upper layers.

Yeah, you broke it. Now the real shrinker is running with GFP_KERNEL,
because your memalloc_no is only around the debugfs function. And ofc it's
much easier to allocate with GFP_KERNEL, right until you deadlock :-)

Shrinking is hard, there's no easy way out here.

Cheers, Daniel

> 
> Regards,
> Christian.
> 
> 
> > 
> > __GFP_NOWARN should be there indeed I think.
> > -Daniel
> > 
> > > Signed-off-by: Christian König <christian.koenig@amd.com>
> > > ---
> > >   drivers/gpu/drm/ttm/ttm_tt.c | 5 ++++-
> > >   1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> > > index 2f0833c98d2c..86fa3e82dacc 100644
> > > --- a/drivers/gpu/drm/ttm/ttm_tt.c
> > > +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> > > @@ -369,7 +369,7 @@ static unsigned long ttm_tt_shrinker_scan(struct shrinker *shrink,
> > >   	};
> > >   	int ret;
> > > -	ret = ttm_bo_swapout(&ctx, GFP_NOFS);
> > > +	ret = ttm_bo_swapout(&ctx, GFP_KERNEL | __GFP_NOWARN);
> > >   	return ret < 0 ? SHRINK_EMPTY : ret;
> > >   }
> > > @@ -389,10 +389,13 @@ static unsigned long ttm_tt_shrinker_count(struct shrinker *shrink,
> > >   static int ttm_tt_debugfs_shrink_show(struct seq_file *m, void *data)
> > >   {
> > >   	struct shrink_control sc = { .gfp_mask = GFP_KERNEL };
> > > +	unsigned int flags;
> > >   	fs_reclaim_acquire(GFP_KERNEL);
> > > +	flags = memalloc_nofs_save();
> > >   	seq_printf(m, "%lu/%lu\n", ttm_tt_shrinker_count(&mm_shrinker, &sc),
> > >   		   ttm_tt_shrinker_scan(&mm_shrinker, &sc));
> > > +	memalloc_nofs_restore(flags);
> > >   	fs_reclaim_release(GFP_KERNEL);
> > >   	return 0;
> > > -- 
> > > 2.25.1
> > > 
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 

-- 
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-03-19 19:06 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19 14:08 [PATCH] drm/ttm: stop warning on TT shrinker failure Christian König
2021-03-19 14:08 ` Christian König
2021-03-19 17:19 ` Deucher, Alexander
2021-03-19 17:19   ` Deucher, Alexander
2021-03-19 17:52 ` Daniel Vetter
2021-03-19 17:52   ` Daniel Vetter
2021-03-19 18:53   ` Christian König
2021-03-19 18:53     ` Christian König
2021-03-19 19:06     ` Daniel Vetter [this message]
2021-03-19 19:06       ` Daniel Vetter
2021-03-20  9:04       ` Christian König
2021-03-20  9:04         ` Christian König
2021-03-20 13:17         ` Daniel Vetter
2021-03-20 13:17           ` Daniel Vetter
2021-03-21 14:18           ` Christian König
2021-03-21 14:18             ` Christian König
2021-03-22 13:49             ` Daniel Vetter
2021-03-22 13:49               ` Daniel Vetter
2021-03-22 13:49               ` Daniel Vetter
2021-03-22 14:05               ` Matthew Wilcox
2021-03-22 14:05                 ` Matthew Wilcox
2021-03-22 14:05                 ` Matthew Wilcox
2021-03-22 14:22                 ` Daniel Vetter
2021-03-22 14:22                   ` Daniel Vetter
2021-03-22 14:22                   ` Daniel Vetter
2021-03-22 15:57                 ` Michal Hocko
2021-03-22 15:57                   ` Michal Hocko
2021-03-22 15:57                   ` Michal Hocko
2021-03-22 17:02                   ` Daniel Vetter
2021-03-22 17:02                     ` Daniel Vetter
2021-03-22 17:02                     ` Daniel Vetter
2021-03-22 19:34                     ` Christian König
2021-03-22 19:34                       ` Christian König
2021-03-22 19:34                       ` Christian König
2021-03-23  7:38                       ` Michal Hocko
2021-03-23  7:38                         ` Michal Hocko
2021-03-23  7:38                         ` Michal Hocko
2021-03-23 11:28                         ` Daniel Vetter
2021-03-23 11:28                           ` Daniel Vetter
2021-03-23 11:28                           ` Daniel Vetter
2021-03-23 11:46                           ` Michal Hocko
2021-03-23 11:46                             ` Michal Hocko
2021-03-23 11:46                             ` Michal Hocko
2021-03-23 11:51                             ` Christian König
2021-03-23 11:51                               ` Christian König
2021-03-23 11:51                               ` Christian König
2021-03-23 12:00                               ` Daniel Vetter
2021-03-23 12:00                                 ` Daniel Vetter
2021-03-23 12:00                                 ` Daniel Vetter
2021-03-23 12:05                               ` Michal Hocko
2021-03-23 12:05                                 ` Michal Hocko
2021-03-23 12:05                                 ` Michal Hocko
2021-03-23 11:48                           ` Christian König
2021-03-23 11:48                             ` Christian König
2021-03-23 11:48                             ` Christian König
2021-03-23 12:04                             ` Michal Hocko
2021-03-23 12:04                               ` Michal Hocko
2021-03-23 12:04                               ` Michal Hocko
2021-03-23 12:21                               ` Christian König
2021-03-23 12:21                                 ` Christian König
2021-03-23 12:21                                 ` Christian König
2021-03-23 12:37                                 ` Michal Hocko
2021-03-23 12:37                                   ` Michal Hocko
2021-03-23 12:37                                   ` Michal Hocko
2021-03-23 13:06                                   ` Christian König
2021-03-23 13:06                                     ` Christian König
2021-03-23 13:06                                     ` Christian König
2021-03-23 13:41                                     ` Michal Hocko
2021-03-23 13:41                                       ` Michal Hocko
2021-03-23 13:41                                       ` Michal Hocko
2021-03-23 13:56                                       ` Christian König
2021-03-23 13:56                                         ` Christian König
2021-03-23 13:56                                         ` Christian König
2021-03-23 15:13                                         ` Michal Hocko
2021-03-23 15:13                                           ` Michal Hocko
2021-03-23 15:13                                           ` Michal Hocko
2021-03-23 15:45                                           ` Christian König
2021-03-23 15:45                                             ` Christian König
2021-03-23 15:45                                             ` Christian König
2021-03-24 10:19                                             ` Thomas Hellström (Intel)
2021-03-24 10:19                                               ` Thomas Hellström (Intel)
2021-03-24 10:19                                               ` Thomas Hellström (Intel)
2021-03-24 11:55                                               ` Daniel Vetter
2021-03-24 11:55                                                 ` Daniel Vetter
2021-03-24 11:55                                                 ` Daniel Vetter
2021-03-24 12:00                                                 ` Christian König
2021-03-24 12:00                                                   ` Christian König
2021-03-24 12:00                                                   ` Christian König
2021-03-24 12:01                                                   ` Daniel Vetter
2021-03-24 12:01                                                     ` Daniel Vetter
2021-03-24 12:01                                                     ` Daniel Vetter
2021-03-24 12:07                                                     ` Christian König
2021-03-24 12:07                                                       ` Christian König
2021-03-24 12:07                                                       ` Christian König
2021-03-24 19:20                                                       ` Daniel Vetter
2021-03-24 19:20                                                         ` Daniel Vetter
2021-03-24 19:20                                                         ` Daniel Vetter
2021-03-23 13:15                               ` Daniel Vetter
2021-03-23 13:15                                 ` Daniel Vetter
2021-03-23 13:15                                 ` Daniel Vetter
2021-03-23 13:48                                 ` Michal Hocko
2021-03-23 13:48                                   ` Michal Hocko
2021-03-23 13:48                                   ` Michal Hocko

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=YFT2LSR97rkkPyEP@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=Leo.Liu@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.