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 71613C77B7C for ; Thu, 3 Jul 2025 17:58:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E84AC6B0204; Thu, 3 Jul 2025 13:58:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5DCD6B0205; Thu, 3 Jul 2025 13:58:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D99766B0206; Thu, 3 Jul 2025 13:58:29 -0400 (EDT) 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 C9DBE6B0204 for ; Thu, 3 Jul 2025 13:58:29 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 57A0F1069C3 for ; Thu, 3 Jul 2025 17:58:29 +0000 (UTC) X-FDA: 83623713138.26.9A7A698 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) by imf07.hostedemail.com (Postfix) with ESMTP id 59DF940004 for ; Thu, 3 Jul 2025 17:58:27 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ASETi4vW; spf=pass (imf07.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.182 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=1751565507; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8Fj6KQclZqeFpLN0gNLDvbr5suNhr7xIeUAIdEMiKF8=; b=lFTYjf00aGGinp7z4iDr990o3nij2LNNbdEMM42qWox2xBjz3SXh+l6AXLEOQ9gy1TYGym mNIRZE2ikaN7AJX/glaA2ALYAlUICGW1oPtnCYcjIG8BrPPOngm+4B5R2RvAc+/HWWp6Za Hjw4nxLoDJ54pyqhYtSx1sbIbZdhre0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751565507; a=rsa-sha256; cv=none; b=7IeCAnBKaJJsrS9GhzPMYLoE3pZUW449mlk3zagLtz5GvldqEOzRQDbsxuxxy1jRmERvtN 6QdirYH+q/LB5X/8vdNvu+sS8m6scDG5QTtlsM32ZAxmcogS3ye1+rzzKXuLPtdCsCNt6O Uh2uF5IszkeXUrh5BCImjITMjXqbbhU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ASETi4vW; spf=pass (imf07.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.182 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Thu, 3 Jul 2025 10:58:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1751565505; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Fj6KQclZqeFpLN0gNLDvbr5suNhr7xIeUAIdEMiKF8=; b=ASETi4vWcvHEzx3XHwii/YSR4SXC9Sj4YcHmcUNyhYZluQHNo7k1vculs7t0mdTUbMY2w9 R0QWVOQXEL9eNyq+3XVFgXukCmefvP1ebFWAecD9d2m4E67UP4YxZUkHF3q4wUGWO2NepZ 9v2om1BSV5Er8cV5BCaRGzxgtMVJ0w4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: David Airlie Cc: Dave Airlie , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Johannes Weiner , Christian Koenig , Dave Chinner , Kairui Song Subject: Re: [PATCH 17/17] amdgpu: add support for memory cgroups Message-ID: <3b5t4djauhnbvhqjwuktrcphlvahpdyi2b6j3ktoapakxcvpgz@zjpokeykiwy7> References: <20250630045005.1337339-1-airlied@gmail.com> <20250630045005.1337339-18-airlied@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 59DF940004 X-Stat-Signature: uqw9ynoxgccwefzjsrad3ge3fibkb79z X-HE-Tag: 1751565507-974347 X-HE-Meta: U2FsdGVkX1/zFJgLwCD+0Okk1xwlUI5f+Izp6SFEFoMGt/qrvdIuKe4CGR8gF7z4eat2RltH8ZsD9H+oqsnku58Imx9JM4+W2yQG16CzTW5Zd2bn77Jc3JQFAwfDh/gxUlZL/QNt5aNWJdXJ7Ths8cdZnPNI8DGH9CP41FF1lo97xiWDhbTLd5EF/8UuRzVUkWAzUiv4xAJEw1SczvXRebIe7RRIb7ANQY13RBj/llx29kaMLR8p+rMDkrCzV9kbBeLpdLaE0D+BlqY/+yvV075YQ4Vb0zGuFyWk2nQoSkEHVI2PImYOyNKAXaJSHbjFz98cT3AN054Yt2nGQzJw+zVpp4I89bM3hn3qQMxaoqlmjI6L7STqbx8CmY+G446iyKHHehCQ+Xif3rEjk9v9mT0nb6Gpr43Osx1uDAQJBzlef1bAbUJ+TbAy5U3hq+UUUh80RsgSOjNtwwAkImfLL7Vd5bOA0mRR1voFBQXd0cDITB8jaDxI0i9JTgY3g7fjQCsSOXpouJ4l5k1edSoIX7A3STp7bFDGqdc+3XhX0mCqCwI/8otG1yuMGC3gKbaVJ5Wk28aNX0byCWSkGdEpmh5HBK7y4eAz2B/bd9hrgUXgkBITi9qPhrMxy3mcU7n9D469dLpntycKKuXt8TPxtPthJYtDwtizAMgqU/9H+yJxMeQi1vQnmmwvS1tng7FbjW0cCxZhBS5y1ZeaJJkuTNzJwY9Ycr3CPuURcvdzUM7PiFvXYErRfSeImAaaZloTy8/M63UElG6YQFON2BdDhjhZhANBWACSqRpg5TafwIIe12yCWNdG0wbGXchbwKI4uHzbOy5y2His7eGlW7wMoMIS3QZT/yfn5sOLZEUgq6M4FkDaCcz0PtZNQ1fwKEOLNA80DyKSDZmzEEjPGV0bXvupI1je25tSE7Zc16P67Mv8YgMFGqEHpwlwTmJuXa+++eKCzMvMAf5KnSjT52d SQSbxJmD hSR5EIZrt+UhpaXgypoNhiUq1fVmTYxB9wL5Jw9riPBn1wL4Dle9PzPbm8do9aZMNB0MCqN9NqPt2A3MXAinZuMA2TeI3ibvsL9v4sEq754SuSw7cHxqZYdbHbT0ZkV8gguBGCJaB1Koun3v7fbSAAxffMF4wnzGn4qlWu+r44NiVBkzPteO+87vY4w6lMO+snzRmdej0YLZSSdV3nS46EL58oPZlT0Wcm4divFL4BBjfYvHGQBnkNawWeL22x/MoB8EYdqC2/+epV4s= 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 Thu, Jul 03, 2025 at 12:53:44PM +1000, David Airlie wrote: > On Thu, Jul 3, 2025 at 2:03 AM Shakeel Butt wrote: > > > > On Mon, Jun 30, 2025 at 02:49:36PM +1000, Dave Airlie wrote: > > > From: Dave Airlie > > > > > > This adds support for adding a obj cgroup to a buffer object, > > > and passing in the placement flags to make sure it's accounted > > > properly. > > > > > > Signed-off-by: Dave Airlie > > > --- > > > drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 ++ > > > drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13 +++++++++---- > > > drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + > > > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 ++ > > > 4 files changed, 14 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > > > index e5e33a68d935..d250183bab03 100644 > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > > > @@ -198,6 +198,7 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) > > > struct amdgpu_bo *aobj = gem_to_amdgpu_bo(gobj); > > > > > > amdgpu_hmm_unregister(aobj); > > > + obj_cgroup_put(aobj->tbo.objcg); > > > ttm_bo_put(&aobj->tbo); > > > } > > > > > > @@ -225,6 +226,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, > > > bp.domain = initial_domain; > > > bp.bo_ptr_size = sizeof(struct amdgpu_bo); > > > bp.xcp_id_plus1 = xcp_id_plus1; > > > + bp.objcg = get_obj_cgroup_from_current(); > > > > In what context this function is called? Is that the same for > > ttm_pool_alloc_page()? Is remote charging happening in > > ttm_pool_alloc_page()? > > > > No, this function is called from userspace ioctl paths that allocate > GPU objects (GEM objects). > > The objects are lazily allocated, so this might not trigger any pages > being bound to the object, until it is populated, either via mapping + > page faults or by being used in a GPU command submission, which is > when the ttm_pool_alloc_page happens. > For the mapping + page fault or GPU command submission, can there be a case where 'current' is not in the same cgroup as the task which has called amdgpu_gem_object_create() through ioctl? Can the allocation happen in kthread or workqueue or irq?