<div dir="ltr"><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 20, 2022 at 11:09 AM Alex Deucher <<a href="mailto:alexander.deucher@amd.com">alexander.deucher@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Certain GL unit tests for large textures can cause problems<br>
with the OOM killer since there is no way to link this memory<br>
to a process. This was originally mitigated (but not necessarily<br>
eliminated) by limiting the GTT size. The problem is this limit<br>
is often too low for many modern games so just make the limit 1/2<br>
of system memory. The OOM accounting needs to be addressed, but<br>
we shouldn't prevent common 3D applications from being usable<br>
just to potentially mitigate that corner case.<br>
<br>
Set default GTT size to max(3G, 1/2 of system ram) by default.<br>
<br>
v2: drop previous logic and default to 3/4 of ram<br>
v3: default to half of ram to align with ttm<br>
<br>
Signed-off-by: Alex Deucher <<a href="mailto:alexander.deucher@amd.com" target="_blank">alexander.deucher@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 20 ++++++++++++++------<br>
1 file changed, 14 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
index d2b5cccb45c3..7195ed77c85a 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
@@ -1798,18 +1798,26 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)<br>
DRM_INFO("amdgpu: %uM of VRAM memory ready\n",<br>
(unsigned) (adev->gmc.real_vram_size / (1024 * 1024)));<br>
<br>
- /* Compute GTT size, either bsaed on 3/4th the size of RAM size<br>
+ /* Compute GTT size, either bsaed on 1/2 the size of RAM size<br>
* or whatever the user passed on module init */<br>
if (amdgpu_gtt_size == -1) {<br>
struct sysinfo si;<br>
<br>
si_meminfo(&si);<br>
- gtt_size = min(max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),<br>
- adev->gmc.mc_vram_size),<br>
- ((uint64_t)si.totalram * si.mem_unit * 3/4));<br>
- }<br>
- else<br>
+ /* Certain GL unit tests for large textures can cause problems<br>
+ * with the OOM killer since there is no way to link this memory<br>
+ * to a process. This was originally mitigated (but not necessarily<br>
+ * eliminated) by limiting the GTT size. The problem is this limit<br>
+ * is often too low for many modern games so just make the limit 1/2<br>
+ * of system memory which aligns with TTM. The OOM accounting needs<br>
+ * to be addressed, but we shouldn't prevent common 3D applications<br>
+ * from being usable just to potentially mitigate that corner case.<br>
+ */<br>
+ gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),<br>
+ (u64)si.totalram * si.mem_unit / 2);<br>
+ } else {<br>
gtt_size = (uint64_t)amdgpu_gtt_size << 20;<br>
+ }<br>
<br>
/* Initialize GTT memory pool */<br>
r = amdgpu_gtt_mgr_init(adev, gtt_size);<br>
-- <br>
2.35.3<br>
<br>
</blockquote></div>