public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Matthew Brost <matthew.brost@intel.com>,
	Daniel Colascione <dancol@dancol.org>
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	"Huang Rui" <ray.huang@amd.com>,
	"Matthew Auld" <matthew.auld@intel.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] Limit reclaim to avoid TTM desktop stutter under mem pressure
Date: Tue, 7 Apr 2026 09:43:30 +0200	[thread overview]
Message-ID: <d8e8f290-c2bd-483f-ba0f-735c503e269a@amd.com> (raw)
In-Reply-To: <adQfdL0zV7SOo+al@gsse-cloud1.jf.intel.com>

On 4/6/26 23:02, Matthew Brost wrote:
> On Tue, Mar 31, 2026 at 10:08:58PM -0400, Daniel Colascione wrote:
...
>> -
>> -       /*
>> -        * Do not add latency to the allocation path for allocations orders
>> -        * device tolds us do not bring them additional performance gains.
>> -        */
>> -       if (beneficial_order && order > beneficial_order)
>> -               gfp_flags &= ~__GFP_DIRECT_RECLAIM;
>> +               if (beneficial_order && order > beneficial_order)
>> +                       gfp_flags &= ~__GFP_DIRECT_RECLAIM;
>> +               if (order > max_reclaim_order)
>> +                       gfp_flags &= ~__GFP_RECLAIM;
> 
> I’m not very familiar with this code, but at first glance it doesn’t
> seem quite right.
> 
> Would setting Xe’s beneficial to 9, similar to AMD’s, along with this
> diff, help?

No, not really. The problem is that giving 9 as beneficial order only saves us avoiding direct reclaim for 10 (>=11 is usually not used in a x86 linux kernel anyway).

> 
> If I’m understanding this correctly, we would try a single allocation
> attempt with __GFP_DIRECT_RECLAIM cleared for the size we care about,
> still attempt allocations from the pools, and then finally fall back to
> allocating single pages one at a time.

Well the code is a bit broken, but the general idea is not so bad.

What we could do is to use beneficial_order as sweet spot and set __GFP_DIRECT_RECLAIM only for the allocations with that order.

This would skip setting it for order 1..8, which are nice to have as well but not so necessary that we always need to trigger reclaim for them.

Regards,
Christian.

> 
> Matt
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
> index aa41099c5ecf..f1f430aba0c1 100644
> --- a/drivers/gpu/drm/ttm/ttm_pool.c
> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
> @@ -714,6 +714,7 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
>                             struct ttm_pool_alloc_state *alloc,
>                             struct ttm_pool_tt_restore *restore)
>  {
> +       const unsigned int beneficial_order = ttm_pool_beneficial_order(pool);
>         enum ttm_caching page_caching;
>         gfp_t gfp_flags = GFP_USER;
>         pgoff_t caching_divide;
> @@ -757,7 +758,8 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
>                 if (!p) {
>                         page_caching = ttm_cached;
>                         allow_pools = false;
> -                       p = ttm_pool_alloc_page(pool, gfp_flags, order);
> +                       if (!order || order >= beneficial_order)
> +                               p = ttm_pool_alloc_page(pool, gfp_flags, order);
>                 }
>                 /* If that fails, lower the order if possible and retry. */
>                 if (!p) {
> 
> 
>> +       }
>>  
>>         if (!ttm_pool_uses_dma_alloc(pool)) {
>>                 p = alloc_pages_node(pool->nid, gfp_flags, order);


  parent reply	other threads:[~2026-04-07  7:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  2:08 [RFC PATCH] Limit reclaim to avoid TTM desktop stutter under mem pressure Daniel Colascione
2026-04-01  7:35 ` Thomas Hellström
2026-04-01 10:16 ` Christian König
2026-04-03 15:12 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
2026-04-06 21:02 ` [RFC PATCH] " Matthew Brost
2026-04-06 21:53   ` Matthew Brost
2026-04-07  7:43   ` Christian König [this message]
2026-04-07 17:34     ` Matthew Brost
2026-04-08  8:00       ` Christian König
2026-04-09  5:12         ` Matthew Brost

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=d8e8f290-c2bd-483f-ba0f-735c503e269a@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@gmail.com \
    --cc=dancol@dancol.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mripard@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=simona@ffwll.ch \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tzimmermann@suse.de \
    /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