From patchwork Wed Dec 4 13:44:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 13893797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87ED9E7716E for ; Wed, 4 Dec 2024 13:44:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CBB96B0082; Wed, 4 Dec 2024 08:44:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 606D76B0092; Wed, 4 Dec 2024 08:44:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4322C6B0093; Wed, 4 Dec 2024 08:44:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 233D16B0082 for ; Wed, 4 Dec 2024 08:44:23 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CEA7FA1013 for ; Wed, 4 Dec 2024 13:44:22 +0000 (UTC) X-FDA: 82857395334.01.F1CFBB8 Received: from mblankhorst.nl (lankhorst.se [141.105.120.124]) by imf23.hostedemail.com (Postfix) with ESMTP id A5BFA140016 for ; Wed, 4 Dec 2024 13:44:11 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=none; spf=none (imf23.hostedemail.com: domain of mlankhorst@mblankhorst.nl has no SPF policy when checking 141.105.120.124) smtp.mailfrom=mlankhorst@mblankhorst.nl ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733319854; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eAGAWWI9/OdV0u06PcgfcWfFfFAMuLNi0u0msVee0/o=; b=miJjNsPwqvzjJvhR3VuVLiWCFhODYa/y7afAZaT6AEjwK5hhxSnTPmyYjVF9aOLXsmCqtF Wo2xJOad+7umjdJvwhhYQ+LwWUgRwDukntrC96Veb2uxNe2Zu7rY6TKPC4S6glgnlG+gtH cLHBi4WRcH6gjogCR6w+vlh1Qq7X5EA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733319854; a=rsa-sha256; cv=none; b=GihdUB2mJgqmsJ3FZPeTvmCNVPLKWh6IbfzXX8Y66hNKFHFPGOatiPonJC9mJ0aCwHrsVm drHBzA8AHFT3f11lm7zRFLG1yjBPvy8zPce8JkWdOvGDTXkgxDUG0sazi1cEB6Tc9IRGKV obZRnEzxOaORxah3FmNnxEv+I/L8h+A= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=none; spf=none (imf23.hostedemail.com: domain of mlankhorst@mblankhorst.nl has no SPF policy when checking 141.105.120.124) smtp.mailfrom=mlankhorst@mblankhorst.nl From: Maarten Lankhorst To: linux-kernel@vger.kernel.org, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Tejun Heo , Zefan Li , Johannes Weiner , Andrew Morton , Friedrich Vock , Maxime Ripard Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, Maarten Lankhorst , Maarten Lankhorst Subject: [PATCH v2 4/7] drm/xe: Implement cgroup for vram Date: Wed, 4 Dec 2024 14:44:04 +0100 Message-ID: <20241204134410.1161769-5-dev@lankhorst.se> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204134410.1161769-1-dev@lankhorst.se> References: <20241204134410.1161769-1-dev@lankhorst.se> MIME-Version: 1.0 X-Stat-Signature: g8w5iid6tp4p98oyjd9rqjadtq119zch X-Rspamd-Queue-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Qj/zuE1kpmFCegyntnaPM8UahH4FIPiigWrhaJbszCXYwnEbojubSqidrCarUZas/oq2YMZD53yyUTmqvx8Qe/Jz36M2VQ8IR9LEj/CIoCOIo0eh+oPcI26TEWBcFUHgHI/rD03LZLSfB2lEZF9T6fNUCA+8X X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add vram based cgroup eviction to Xe. Most hardware with VRAM uses TTM for its management, and can be similarly trivially enabled. Co-developed-by: Maxime Ripard Signed-off-by: Maxime Ripard Signed-off-by: Maarten Lankhorst Acked-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c index c95728c45ea48..f4a16e5fa7700 100644 --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -311,6 +312,13 @@ int __xe_ttm_vram_mgr_init(struct xe_device *xe, struct xe_ttm_vram_mgr *mgr, struct ttm_resource_manager *man = &mgr->manager; int err; + if (mem_type != XE_PL_STOLEN) { + const char *name = mem_type == XE_PL_VRAM0 ? "vram0" : "vram1"; + man->cg = drmm_cgroup_register_region(&xe->drm, name, size); + if (IS_ERR(man->cg)) + return PTR_ERR(man->cg); + } + man->func = &xe_ttm_vram_mgr_func; mgr->mem_type = mem_type; mutex_init(&mgr->lock);