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 4F8F5C83F1B for ; Mon, 14 Jul 2025 05:23:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8F4D6B007B; Mon, 14 Jul 2025 01:23:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A40396B0089; Mon, 14 Jul 2025 01:23:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 955E56B008A; Mon, 14 Jul 2025 01:23:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 83ABC6B007B for ; Mon, 14 Jul 2025 01:23:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E40DF59353 for ; Mon, 14 Jul 2025 05:23:02 +0000 (UTC) X-FDA: 83661726204.18.5E7C22D Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by imf29.hostedemail.com (Postfix) with ESMTP id 1DB89120009 for ; Mon, 14 Jul 2025 05:23:00 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (imf29.hostedemail.com: 205.139.111.44 is neither permitted nor denied by domain of airlied@gmail.com) smtp.mailfrom=airlied@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752470581; 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: references; bh=GVS5OLZKXFIApwNubAkb7eaokFsVgt23ODzrmTY0BII=; b=ZsyeqWXf/XESbZ3DlFIsUyiFNN4rwHI0ZgHQ19/aUw3kT5w6dGqTXqtsY51l385HhOXGbu kOckqTl8PYSG5uphpYCLj+3qm+qNkQBMTG//PnSax44uTtDdqlvJA4PJN1yL9lNSl74tGM A05RRXKTqoaisUusDrNz1gXeDmloYdM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752470581; a=rsa-sha256; cv=none; b=DxpjuPYFGilEqUm9iLn0QCJ7Csvmk6O/eu8FGM8eG4e9lXkEfJvj6f7txJEOvT5R0b3ylx K4hhjmF94J3Ztkdz3dOIoE/PenbC6kN9H3/1FrcoVpurvOGESQhiMi/w7b2IA7M5PYeqOv RqxyhMJLmcT7ofF6bqmbZQGw2t36Iwo= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (imf29.hostedemail.com: 205.139.111.44 is neither permitted nor denied by domain of airlied@gmail.com) smtp.mailfrom=airlied@gmail.com Received: from mx-prod-mc-08.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-378-aru52YbuN2-Olr9ghVvh_Q-1; Mon, 14 Jul 2025 01:22:55 -0400 X-MC-Unique: aru52YbuN2-Olr9ghVvh_Q-1 X-Mimecast-MFC-AGG-ID: aru52YbuN2-Olr9ghVvh_Q_1752470574 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4DA8318089B5; Mon, 14 Jul 2025 05:22:53 +0000 (UTC) Received: from dreadlord.redhat.com (unknown [10.67.32.31]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E97691977000; Mon, 14 Jul 2025 05:22:48 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Johannes Weiner , Christian Koenig Cc: Dave Chinner , Kairui Song Subject: drm/ttm/memcg/lru: enable memcg tracking for ttm and amdgpu driver (complete series v2) Date: Mon, 14 Jul 2025 15:18:15 +1000 Message-ID: <20250714052243.1149732-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: _taUzjHXY063i06FQ6kLg8JVwJOikkGq6PpdGHjU-DE_1752470574 X-Mimecast-Originator: gmail.com Content-Transfer-Encoding: quoted-printable content-type: text/plain; charset=WINDOWS-1252; x-default=true X-Rspamd-Queue-Id: 1DB89120009 X-Stat-Signature: u9ijudr39z8kprbaridr4cxxoaxwb8dw X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1752470580-678021 X-HE-Meta: U2FsdGVkX1/Xi4bIHyIb3Ejo0ZeBLt3anhQghJ8SinjInkJBIB8IHOHYbV0eEU9x+HO8m/mdyT+/HEhOJHUaF2ZN9VxJiFkBJF15+oEgoD6ZBmOZUVmsn4mnVNup4BxhPHnYlx4/bELS6U02tXpsUoxiOdMu5jEGF155jiavOY6gr3wiPTGmI2Z/ChdosKNs1KDXU9nOR4lUe+i8Ps8970OnIFkNaZh6FuB88cijW6qh/FvycGt2IeqsjzOEGhPU7gpgu9/Q0f/TNe5kxHjIdaldGGtyDu97l39wMZOmu5qYa6q3meth57VHHHKE2feXiCpUBn0h1TflORfsRlGLukKqNJisk0xlLLvm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ogosity: 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: Hi all, This is a repost with some fixes and cleanups. Differences since last posting: 1. Added patch 18: add a module option to allow pooled pages to not be stor= ed in the lru per-memcg (Requested by Christian Konig) 2. Converged the naming and stats between vmstat and memcg (Suggested by Sh= akeel Butt) 3. Cleaned up the charge/uncharge code and some other bits. Dave. Original cover letter: tl;dr: start using list_lru/numa/memcg in GPU driver core and amdgpu driver= for now. This is a complete series of patches, some of which have been sent before a= nd reviewed, but I want to get the complete picture for others, and try to figure out ho= w best to land this. There are 3 pieces to this: 01->02: add support for global gpu stat counters (previously posted, patch = 2 is newer) 03->07: port ttm pools to list_lru for numa awareness 08->14: add memcg stats + gpu apis, then port ttm pools to memcg aware list= _lru and shrinker 15->17: enable amdgpu to use new functionality. The biggest difference in the memcg code from previously is I discovered wh= at obj cgroups were designed for and I'm reusing the page/objcg intergration t= hat=20 already exists, to avoid reinventing that wheel right now. There are some igt-gpu-tools tests I've written at: https://gitlab.freedesktop.org/airlied/igt-gpu-tools/-/tree/amdgpu-cgroups?= ref_type=3Dheads One problem is there are a lot of delayed action, that probably means the t= esting needs a bit more robustness, but the tests validate all the basic paths. Regards, Dave.