[PATCH] drm/amdgpu: Adjust logic around GTT size

Alex Deucher alexdeucher at gmail.com
Thu May 19 18:37:32 UTC 2022


On Thu, May 19, 2022 at 1:15 PM Felix Kuehling <felix.kuehling at amd.com> wrote:
>
>
> Am 2022-05-19 um 10:34 schrieb Alex Deucher:
> > The current somewhat strange logic is in place because certain
> > GL unit tests for large textures can cause problems with the
> > OOM killer since there is no way to link this memory to a
> > process.  The problem is this limit is often too low for many
> > modern games on systems with more memory so limit the logic to
> > systems with less than 8GB of main memory.  For systems with 8
> > or more GB of system memory, set the GTT size to 3/4 of system
> > memory.
>
> Well, I've been railing against this limit for years, and was always
> told it's unchangeable for reasons. So we found other ways to use more
> system memory in ROCm. Good to see that I'm no longer the only one who
> thinks this GTT limit is a problem.
>
> Acked-by: Felix Kuehling <Felix.Kuehling at amd.com>

After further discussions with Marek, I just sent a v2 to simplify this further.

Alex


>
>
> >
> > Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 25 ++++++++++++++++++++-----
> >   1 file changed, 20 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > index 4b9ee6e27f74..daa0babcf869 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > @@ -1801,15 +1801,30 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
> >       /* Compute GTT size, either bsaed on 3/4th the size of RAM size
> >        * or whatever the user passed on module init */
> >       if (amdgpu_gtt_size == -1) {
> > +             const u64 eight_GB = 8192ULL * 1024 * 1024;
> >               struct sysinfo si;
> > +             u64 total_memory, default_gtt_size;
> >
> >               si_meminfo(&si);
> > -             gtt_size = min(max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),
> > -                            adev->gmc.mc_vram_size),
> > -                            ((uint64_t)si.totalram * si.mem_unit * 3/4));
> > -     }
> > -     else
> > +             total_memory = (u64)si.totalram * si.mem_unit;
> > +             default_gtt_size = total_memory * 3 / 4;
> > +             /* This somewhat strange logic is in place because certain GL unit
> > +              * tests for large textures can cause problems with the OOM killer
> > +              * since there is no way to link this memory to a process.
> > +              * The problem is this limit is often too low for many modern games
> > +              * on systems with more memory so limit the logic to systems with
> > +              * less than 8GB of main memory.
> > +              */
> > +             if (total_memory < eight_GB) {
> > +                     gtt_size = min(max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),
> > +                                        adev->gmc.mc_vram_size),
> > +                                    default_gtt_size);
> > +             } else {
> > +                     gtt_size = default_gtt_size;
> > +             }
> > +     } else {
> >               gtt_size = (uint64_t)amdgpu_gtt_size << 20;
> > +     }
> >
> >       /* Initialize GTT memory pool */
> >       r = amdgpu_gtt_mgr_init(adev, gtt_size);


More information about the amd-gfx mailing list