Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3557498iog; Mon, 27 Jun 2022 19:57:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uzmOlYPk56qZQ+csHu/M0j8971N8mbkqzgzVS2VfDuXrjANiDPZp1h9dlfliD7jTAlnTRL X-Received: by 2002:a17:906:8315:b0:726:38da:f0f with SMTP id j21-20020a170906831500b0072638da0f0fmr15802410ejx.462.1656385057889; Mon, 27 Jun 2022 19:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656385057; cv=none; d=google.com; s=arc-20160816; b=Dg0nADBm31NW+SXgoHrYNYXuF2VuPqiwrQgHqaN9rNbjl4i+sg89WVeDKESnTkJmIl 8Uz3kCXNYw470ins1jbX2mjKdwX4X1X6pI+ReIPhniM3goA/CdZREQulmMU952IYUTOp hd1X6UYf2HFdxhZXiobhqlEnf4rGdeUGRctEvQo2xdQgaiwu2gZTy1fGV2DilN5FoD14 Acg+llMxxI2VTjxMIF1YNHb5zgfbsJEPk6fcTUqniqWT3K4bneBGt0O9xz6WCEf6SzFK 50b5dRyPnW+Ej+Aa60+aORYchI7jwWpb4UCgmR1gBl5AkKh+1jJtg5Umma3Sg09zxZ0Q talQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Nh7bnq/gqCdH7cLNunDLRVmv6sj1l7IfRkqxqOyQicI=; b=MUZiWBSuFlT+hxLGVujEllp0BzwF5kNaQkeKkKv5AYeWrWmUjuV5kmtiFr/SQuQjN0 sIPBDgLOzIfVG4iu3NAA6f7DYgM17PrFGF/vp6Db5FyDFqui4t2zhsx7YRkleAwnKWL/ mhydLifHaMiwK+ILtBWOT5ohuTyTjJKZDt86OE6US3V3JBmZ6rQGqtu8Hy1dfRFHReiw mw2KZCu27qPQEW5RFtvnpChb1QyjuYG1d1RQQYxO8NUnPTx2SdswuhZQaext+ZDdrKEx vtm7VZr44ZQBMi7uhymEh4TC+DfipqpC5nVpnU2CH+fC+hEO+uFg2QLFqaTCSpTIOga8 Mj4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eSWIYEGO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a50f0c4000000b00435640bfdc8si168777edm.199.2022.06.27.19.57.05; Mon, 27 Jun 2022 19:57:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eSWIYEGO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244165AbiF1CYn (ORCPT + 99 others); Mon, 27 Jun 2022 22:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243930AbiF1CXH (ORCPT ); Mon, 27 Jun 2022 22:23:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90727237F6; Mon, 27 Jun 2022 19:22:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3BD7DB81C13; Tue, 28 Jun 2022 02:22:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F0AAC34115; Tue, 28 Jun 2022 02:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656382956; bh=n/Xg72I2PqpNn+JH5KABFsDCJC+bAbLU0o98dCwubN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eSWIYEGO8dwbf353OvuDKUI3LCdg4FtOvZ1Sf9YXLsweaeOo9DffswjwXPCAlT32s Ahf0kzJctVgxu9w9FdunDXPaWgaQQYBHMC8tGaxzVx2JJpswrgz6rTJ4RjcffkUeCo 3i9RxQ5BPMjytgDxaYpFIw93inQoFGjvCV6DjcXM5c/5lM+THv162wQCyj0P2jAdjM SR5ZoZcF3+SQMCknfHwjhVdZnq+dWW0Ep4qh/DLQfGexD6BwXJ9W8JYtXMNxEvbXOg RPmBkfTPAeNllcZKnTJG5RY3KOd3zWESIFXzAuBt4GRtcp2Pr1v55PmRistQmiySrm LQtsCSGgvvQ8w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alex Deucher , =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@linux.ie, daniel@ffwll.ch, Felix.Kuehling@amd.com, nirmoy.das@amd.com, jonathan.kim@amd.com, matthew.auld@intel.com, kevin1.wang@amd.com, zackr@vmware.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.15 38/41] drm/amdgpu: Adjust logic around GTT size (v3) Date: Mon, 27 Jun 2022 22:20:57 -0400 Message-Id: <20220628022100.595243-38-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220628022100.595243-1-sashal@kernel.org> References: <20220628022100.595243-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Deucher [ Upstream commit f15345a377c6ea9c7cc74f079616af8856aff37f ] 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. 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. Set default GTT size to max(3G, 1/2 of system ram) by default. v2: drop previous logic and default to 3/4 of ram v3: default to half of ram to align with ttm v4: fix spelling in comment (Kent) Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1942 Reviewed-by: Marek Olšák Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 51c76d6322c9..d6c30eaf4fcd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1747,18 +1747,26 @@ 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 bsaed on 3/4th the size of RAM size + /* 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); - 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 + /* 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 { gtt_size = (uint64_t)amdgpu_gtt_size << 20; + } /* Initialize GTT memory pool */ r = amdgpu_gtt_mgr_init(adev, gtt_size); -- 2.35.1