From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00EFAE77170 for ; Wed, 4 Dec 2024 13:44:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF07210ED2E; Wed, 4 Dec 2024 13:44:19 +0000 (UTC) Received: from mblankhorst.nl (lankhorst.se [141.105.120.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3AD3F10ED27 for ; Wed, 4 Dec 2024 13:44:18 +0000 (UTC) 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 0/7] kernel/cgroups: Add "dmem" memory accounting cgroup. Date: Wed, 4 Dec 2024 14:44:00 +0100 Message-ID: <20241204134410.1161769-1-dev@lankhorst.se> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" New update. Instead of calling it the 'dev' cgroup, it's now the 'dmem' cgroup. Because it only deals with memory regions, the UAPI has been updated to use dmem.min/low/max/current, and to make the API cleaner, the names are changed too. dmem.current could contain a line like: "drm/0000:03:00.0/vram0 1073741824" But I think using "drm/card0/vram0" instead of PCIID would perhaps be good too. I'm open to changing it to that based on feedback. I've created an IGT test for min and max, and found the changes from Friedrich Vock sent as feedback were needed. I've integrated those into the first patch. Maarten Lankhorst (5): kernel/cgroup: Add "dmem" memory accounting cgroup drm/ttm: Handle cgroup based eviction in TTM drm/xe: Implement cgroup for vram drm/amdgpu: Add cgroups implementation drm/xe: Hack to test with mapped pages instead of vram. Maxime Ripard (2): drm/drv: Add drmm managed registration helper for dmem cgroups. drm/gem: Add cgroup memory accounting for VRAM helper. Documentation/admin-guide/cgroup-v2.rst | 58 +- Documentation/core-api/cgroup.rst | 9 + Documentation/core-api/index.rst | 1 + Documentation/gpu/drm-compute.rst | 54 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 4 + drivers/gpu/drm/drm_drv.c | 32 + drivers/gpu/drm/drm_gem_vram_helper.c | 15 +- drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 18 +- .../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 4 +- drivers/gpu/drm/ttm/tests/ttm_resource_test.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c | 54 +- drivers/gpu/drm/ttm/ttm_resource.c | 23 +- drivers/gpu/drm/xe/xe_ttm_sys_mgr.c | 5 + drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 8 + include/drm/drm_drv.h | 5 + include/drm/ttm/ttm_resource.h | 12 +- include/linux/cgroup_dmem.h | 67 ++ include/linux/cgroup_subsys.h | 4 + include/linux/page_counter.h | 2 +- init/Kconfig | 10 + kernel/cgroup/Makefile | 1 + kernel/cgroup/dmem.c | 861 ++++++++++++++++++ mm/page_counter.c | 4 +- 23 files changed, 1219 insertions(+), 34 deletions(-) create mode 100644 Documentation/core-api/cgroup.rst create mode 100644 Documentation/gpu/drm-compute.rst create mode 100644 include/linux/cgroup_dmem.h create mode 100644 kernel/cgroup/dmem.c -- 2.43.0