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 F0ED0C3ABC3 for ; Mon, 12 May 2025 06:19:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6941B10E2AB; Mon, 12 May 2025 06:19:49 +0000 (UTC) Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id BFCF910E2AB for ; Mon, 12 May 2025 06:19:48 +0000 (UTC) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-301-eWFOCJYqNxKQz7p6cI5-Zg-1; Mon, 12 May 2025 02:19:42 -0400 X-MC-Unique: eWFOCJYqNxKQz7p6cI5-Zg-1 X-Mimecast-MFC-AGG-ID: eWFOCJYqNxKQz7p6cI5-Zg_1747030781 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ACEBE1800446; Mon, 12 May 2025 06:19:40 +0000 (UTC) Received: from dreadlord.redhat.com (unknown [10.64.136.70]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6EBF019560B0; Mon, 12 May 2025 06:19:35 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org, tj@kernel.org, christian.koenig@amd.com, Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song Cc: cgroups@vger.kernel.org, Waiman Long , simona@ffwll.ch Subject: [PATCH 3/7] memcg: add GPU statistic Date: Mon, 12 May 2025 16:12:09 +1000 Message-ID: <20250512061913.3522902-4-airlied@gmail.com> In-Reply-To: <20250512061913.3522902-1-airlied@gmail.com> References: <20250512061913.3522902-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ac2Zh661L1YhbRwpEkDlCdQwuj4NBsE9BauMCdDeCmQ_1747030781 X-Mimecast-Originator: gmail.com Content-Transfer-Encoding: quoted-printable content-type: text/plain; charset=WINDOWS-1252; x-default=true X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Discrete and Integrated GPUs can use system RAM instead of VRAM for all or some allocations. These allocations happen via drm/ttm subsystem and are currently not accounted for in cgroups. Add a gpu statistic to allow a place to visualise allocations once they are supported. Signed-off-by: Dave Airlie --- Documentation/admin-guide/cgroup-v2.rst | 3 +++ include/linux/memcontrol.h | 1 + mm/memcontrol.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-= guide/cgroup-v2.rst index 1a16ce68a4d7..e10a1dfa6051 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1480,6 +1480,9 @@ The following nested keys are defined. =09 vmalloc (npn) =09=09Amount of memory used for vmap backed memory. =20 +=09 gpu (npn) +=09=09Amount of memory used for GPU device system RAM. + =09 shmem =09=09Amount of cached filesystem data that is swap-backed, =09=09such as tmpfs, shm segments, shared anonymous mmap()s diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 53364526d877..4058d4bd94ed 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -36,6 +36,7 @@ enum memcg_stat_item { =09MEMCG_SOCK, =09MEMCG_PERCPU_B, =09MEMCG_VMALLOC, +=09MEMCG_GPU, =09MEMCG_KMEM, =09MEMCG_ZSWAP_B, =09MEMCG_ZSWAPPED, diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c96c1f2b9cf5..25471a0fd0be 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -326,6 +326,7 @@ static const unsigned int memcg_stat_items[] =3D { =09MEMCG_SOCK, =09MEMCG_PERCPU_B, =09MEMCG_VMALLOC, +=09MEMCG_GPU, =09MEMCG_KMEM, =09MEMCG_ZSWAP_B, =09MEMCG_ZSWAPPED, @@ -1358,6 +1359,7 @@ static const struct memory_stat memory_stats[] =3D { =09{ "percpu",=09=09=09MEMCG_PERCPU_B=09=09=09}, =09{ "sock",=09=09=09MEMCG_SOCK=09=09=09}, =09{ "vmalloc",=09=09=09MEMCG_VMALLOC=09=09=09}, +=09{ "gpu",=09=09=09MEMCG_GPU=09=09=09}, =09{ "shmem",=09=09=09NR_SHMEM=09=09=09}, #ifdef CONFIG_ZSWAP =09{ "zswap",=09=09=09MEMCG_ZSWAP_B=09=09=09}, --=20 2.49.0