Message ID | 20230426015251.551223-2-mukul.joshi@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] drm/ttm: Helper function to get TTM mem limit | expand |
Looks you can drop macro 'AMDGPU_DEFAULT_GTT_SIZE_MB' as well. Regards, Guchun > -----Original Message----- > From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of > Mukul Joshi > Sent: Wednesday, April 26, 2023 9:53 AM > To: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org > Cc: Joshi, Mukul <Mukul.Joshi@amd.com>; Kuehling, Felix > <Felix.Kuehling@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> > Subject: [PATCH 2/3] drm/amdgpu: Set GTT size equal to TTM mem limit > > Use the helper function in TTM to get TTM mem limit and set GTT size to be > equal to TTL mem limit. > > Signed-off-by: Mukul Joshi <mukul.joshi@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 25 ++++++------------------- > 1 file changed, 6 insertions(+), 19 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index ce34b73d05bc..ac220c779fc8 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -1807,26 +1807,13 @@ int amdgpu_ttm_init(struct amdgpu_device > *adev) > DRM_INFO("amdgpu: %uM of VRAM memory ready\n", > (unsigned) (adev->gmc.real_vram_size / (1024 * 1024))); > > - /* Compute GTT size, either based on 1/2 the size of RAM size > - * or whatever the user passed on module init */ > - if (amdgpu_gtt_size == -1) { > - struct sysinfo si; > - > - si_meminfo(&si); > - /* 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. This was originally mitigated (but not > necessarily > - * eliminated) by limiting the GTT size. The problem is this > limit > - * is often too low for many modern games so just make the > limit 1/2 > - * of system memory which aligns with TTM. The OOM > accounting needs > - * to be addressed, but we shouldn't prevent common 3D > applications > - * from being usable just to potentially mitigate that corner > case. > - */ > - gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), > - (u64)si.totalram * si.mem_unit / 2); > - } else { > + /* Compute GTT size, either based on TTM limit > + * or whatever the user passed on module init. > + */ > + if (amdgpu_gtt_size == -1) > + gtt_size = ttm_tt_pages_limit() << PAGE_SHIFT; > + else > gtt_size = (uint64_t)amdgpu_gtt_size << 20; > - } > > /* Initialize GTT memory pool */ > r = amdgpu_gtt_mgr_init(adev, gtt_size); > -- > 2.35.1
[AMD Official Use Only - General] > -----Original Message----- > From: Chen, Guchun <Guchun.Chen@amd.com> > Sent: Wednesday, April 26, 2023 2:00 AM > To: Joshi, Mukul <Mukul.Joshi@amd.com>; amd-gfx@lists.freedesktop.org; > dri-devel@lists.freedesktop.org > Cc: Joshi, Mukul <Mukul.Joshi@amd.com>; Kuehling, Felix > <Felix.Kuehling@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> > Subject: RE: [PATCH 2/3] drm/amdgpu: Set GTT size equal to TTM mem limit > > Looks you can drop macro 'AMDGPU_DEFAULT_GTT_SIZE_MB' as well. > Thanks for catching this. Sorry I missed it. I will remove and send a v2. Regards, Mukul > Regards, > Guchun > > > -----Original Message----- > > From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of > > Mukul Joshi > > Sent: Wednesday, April 26, 2023 9:53 AM > > To: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org > > Cc: Joshi, Mukul <Mukul.Joshi@amd.com>; Kuehling, Felix > > <Felix.Kuehling@amd.com>; Koenig, Christian > <Christian.Koenig@amd.com> > > Subject: [PATCH 2/3] drm/amdgpu: Set GTT size equal to TTM mem limit > > > > Use the helper function in TTM to get TTM mem limit and set GTT size > > to be equal to TTL mem limit. > > > > Signed-off-by: Mukul Joshi <mukul.joshi@amd.com> > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 25 > > ++++++------------------- > > 1 file changed, 6 insertions(+), 19 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > index ce34b73d05bc..ac220c779fc8 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > @@ -1807,26 +1807,13 @@ int amdgpu_ttm_init(struct amdgpu_device > > *adev) > > DRM_INFO("amdgpu: %uM of VRAM memory ready\n", > > (unsigned) (adev->gmc.real_vram_size / (1024 * 1024))); > > > > - /* Compute GTT size, either based on 1/2 the size of RAM size > > - * or whatever the user passed on module init */ > > - if (amdgpu_gtt_size == -1) { > > - struct sysinfo si; > > - > > - si_meminfo(&si); > > - /* 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. This was originally mitigated (but not > > necessarily > > - * eliminated) by limiting the GTT size. The problem is this > > limit > > - * is often too low for many modern games so just make the > > limit 1/2 > > - * of system memory which aligns with TTM. The OOM > > accounting needs > > - * to be addressed, but we shouldn't prevent common 3D > > applications > > - * from being usable just to potentially mitigate that corner > > case. > > - */ > > - gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), > > - (u64)si.totalram * si.mem_unit / 2); > > - } else { > > + /* Compute GTT size, either based on TTM limit > > + * or whatever the user passed on module init. > > + */ > > + if (amdgpu_gtt_size == -1) > > + gtt_size = ttm_tt_pages_limit() << PAGE_SHIFT; > > + else > > gtt_size = (uint64_t)amdgpu_gtt_size << 20; > > - } > > > > /* Initialize GTT memory pool */ > > r = amdgpu_gtt_mgr_init(adev, gtt_size); > > -- > > 2.35.1
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index ce34b73d05bc..ac220c779fc8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1807,26 +1807,13 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) DRM_INFO("amdgpu: %uM of VRAM memory ready\n", (unsigned) (adev->gmc.real_vram_size / (1024 * 1024))); - /* Compute GTT size, either based on 1/2 the size of RAM size - * or whatever the user passed on module init */ - if (amdgpu_gtt_size == -1) { - struct sysinfo si; - - si_meminfo(&si); - /* 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. This was originally mitigated (but not necessarily - * eliminated) by limiting the GTT size. The problem is this limit - * is often too low for many modern games so just make the limit 1/2 - * of system memory which aligns with TTM. The OOM accounting needs - * to be addressed, but we shouldn't prevent common 3D applications - * from being usable just to potentially mitigate that corner case. - */ - gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), - (u64)si.totalram * si.mem_unit / 2); - } else { + /* Compute GTT size, either based on TTM limit + * or whatever the user passed on module init. + */ + if (amdgpu_gtt_size == -1) + gtt_size = ttm_tt_pages_limit() << PAGE_SHIFT; + else gtt_size = (uint64_t)amdgpu_gtt_size << 20; - } /* Initialize GTT memory pool */ r = amdgpu_gtt_mgr_init(adev, gtt_size);
Use the helper function in TTM to get TTM mem limit and set GTT size to be equal to TTL mem limit. Signed-off-by: Mukul Joshi <mukul.joshi@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-)