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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C81DCC83F05 for ; Wed, 2 Jul 2025 16:06:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56F176B00DB; Wed, 2 Jul 2025 12:06:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 520196B00DE; Wed, 2 Jul 2025 12:06:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 436726B00DF; Wed, 2 Jul 2025 12:06:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2C8096B00DB for ; Wed, 2 Jul 2025 12:06:48 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BA7111402F3 for ; Wed, 2 Jul 2025 16:06:47 +0000 (UTC) X-FDA: 83619802854.11.74783D2 Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) by imf08.hostedemail.com (Postfix) with ESMTP id 7EC4316000E for ; Wed, 2 Jul 2025 16:06:45 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=A39qaWfe; spf=pass (imf08.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.177 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751472406; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=srTNbsweal/ZTMihhkqr7z7S4H0d6CYN8w3bSn5u8Xk=; b=o2iMDg597DcpnWRfApO7QimiV/hL9FxnQI7+j5kHIrn2Y0AAwZ1PUwr9C2+d9sZzbBGU2Y +hao/aUpV7PdBYkHCqIGdMLmchwynVca4WbCEzGUNZ9oLA50a8gix0i0gsFBHeuPtKi6Qw oHXPqqqzwSow6BeNC3hgLTU/jq3xSr8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751472406; a=rsa-sha256; cv=none; b=yKmMSecIEesouwH8M6Hx3541QGyPbKYEHuZOIXICO8pgDJLm80JzsUu7EyiOwmUH1AgjnE 25cpCQjmZjx7B3X++g1N5dp8SI0cxIpOMGWSt1aXWzEswhf6Mm1lKhDEjRTHpkmYA++kTZ baZ3AMLwPqNhehUpYjuzfqDniKQsjvw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=A39qaWfe; spf=pass (imf08.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.177 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Wed, 2 Jul 2025 09:06:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1751472403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=srTNbsweal/ZTMihhkqr7z7S4H0d6CYN8w3bSn5u8Xk=; b=A39qaWfe2ddBeltU2pFOoAwv6donCRWRvZDOgD8qmVSQrt4qnlrAd4ekZPSwWXTghLDzVi pKmXJZ+XL+6XDWnKML/XT/EwXwvE1YzpkNh+bLXrXYFJ+uAaHX0g1BNM7mv/fGYhgs2cD5 z6fNQMDxZWl6I/amQzQystCjf7mgaig= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Dave Airlie Cc: dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Johannes Weiner , Christian Koenig , Dave Chinner , Kairui Song , Dave Airlie Subject: Re: [PATCH 08/17] memcg: add support for GPU page counters. Message-ID: References: <20250630045005.1337339-1-airlied@gmail.com> <20250630045005.1337339-9-airlied@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250630045005.1337339-9-airlied@gmail.com> X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7EC4316000E X-Stat-Signature: zrdhcqqoijh9ctkpez3fcyhutyr5ceqr X-Rspam-User: X-HE-Tag: 1751472405-596490 X-HE-Meta: U2FsdGVkX19vvnt5CUem7fgjY7L7aIBheFUL3Un27lDKNb6NDxBSZpqpX3SzMP51pKbXfrIyhPPjHw0F8jLChnGtcg6InzQrx19qcSdCMknjyH5lTC50/HN5w34vt6mo1LLo50rMLs4nEc0KUnmeMxk+gVnJKjpu/LKdqe5pfZiGTp1Kbun2VQggJgmqfr6LilNzp2AixRTpJkdETcBsA3VMDBtAPkfgf5+OITrJFhrRkfXNAoMfbERSYP8IDkc0qCFnE8AfED+tEFZMhD4eWKF1hVi8wMjTta3953gYm6nuwVnSAjPMKNWwcUELEFFUiijwpMUkJ+Trhgn7L+YuXxkOeBo49kmsv5U5d/oiM0NjTllR8i504lijqcTrXVSq5RIXjwTkVHarMBKkeyfPMKwGR63q1qf5IDDgpS9CESY4oB8FNQj4Hq4gKtjBT+QDvbLWuH9pbduwu9CkDOxYc0DsZFXxpWpUqwTgjxf7G9j2/XJvs+0/1pHYb/qLMb5eIqmqJW+qhuISn0tsvSJ4BaD/zpig6tHkjNGgXL3GWt0yJX2RoxIene82SJTqb5SIYNxwlylt8sm4HtHW+bFEAUjYjyS+WP3/nvUxs5KJWhjvQ5dMz6OL40u0PfcIZ8x3Z+udRcGXlbB6tylfQxjGFC4d0o/NoZuo7gDGgWbawIeC5M8LQHRTvSHz4V5FQt5x9VMMithUyGBwKka+XVUQM9yt2Z0HhBbvhZRm4snQ4sGvB6VAxlwjk5wMhQH+64VfxFnvCbsGR5mVat8ElZdooxvPSRzfwPpQARzo1kgS1I7x5hVZ2+7IbPbsE/ZZ+p/1OY4e8+YlM6t3+ZQgHXnzI5j78+9GK3C+PZVkTfKApfEB8honXs3ukKpGcI4DxkbKUgE/JiITgN4UazY3WD/Oqr5RcjEvRgu3qy4G7KTvb9VAFY9ewDj3flWc5KMsOoi4IrAXPNWa0c8lXlMJu+L BWmr1BS7 peF2H0B2D4nZ4dhUrTrwYAPeIX+4DXTuoZRJG5QZV1su9vLrmxuRcA8rK25GCrR+KVTbdHYkV5wSa5MJTxfffMZzgFR0/SnqmcJTeOgWAU6Cb9tPrOGyda/LD0tytgwwKjfHF9SQQbYqobCgNj8POvo4EEzDFM9mV0XBf7BIqh0Y6pUYsT94LaV8KTCXO0TXTQDdn1fpN4Hk3c0IUrVze6bVc67SujptsKi2ouk2JNT7kTKN+EvvFN3UwfoDpQFWSWB/z5QVTDVcunqQ= 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: On Mon, Jun 30, 2025 at 02:49:27PM +1000, Dave Airlie wrote: > From: Dave Airlie > > This introduces 2 new statistics and 3 new memcontrol APIs for dealing > with GPU system memory allocations. > > The stats corresponds to the same stats in the global vmstat, > for number of active GPU pages, and number of pages in pools that > can be reclaimed. > > The first API charges a order of pages to a objcg, and sets > the objcg on the pages like kmem does, and updates the active/reclaim > statistic. > > The second API uncharges a page from the obj cgroup it is currently charged > to. > > The third API allows moving a page to/from reclaim and between obj cgroups. > When pages are added to the pool lru, this just updates accounting. > When pages are being removed from a pool lru, they can be taken from > the parent objcg so this allows them to be uncharged from there and transferred > to a new child objcg. > > Signed-off-by: Dave Airlie > --- > Documentation/admin-guide/cgroup-v2.rst | 6 ++ > include/linux/memcontrol.h | 14 +++ > mm/memcontrol.c | 110 ++++++++++++++++++++++++ > 3 files changed, 130 insertions(+) > > diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst > index 0cc35a14afbe..d6f057c4fe2e 100644 > --- a/Documentation/admin-guide/cgroup-v2.rst > +++ b/Documentation/admin-guide/cgroup-v2.rst > @@ -1542,6 +1542,12 @@ The following nested keys are defined. > vmalloc (npn) > Amount of memory used for vmap backed memory. > > + gpu (npn) > + Amount of system memory used for GPU devices. > + > + gpu_reclaim (npn) > + Amount of system memory cached for GPU devices. > + > shmem > Amount of cached filesystem data that is swap-backed, > such as tmpfs, shm segments, shared anonymous mmap()s > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 87b6688f124a..ff82d603910d 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -36,6 +36,8 @@ enum memcg_stat_item { > MEMCG_SOCK, > MEMCG_PERCPU_B, > MEMCG_VMALLOC, > + MEMCG_GPU, > + MEMCG_GPU_RECLAIM, You already added node level counters i.e. GPUActive & GPUReclaim, just use those instead of these. Add them to memcg_node_stat_items[].