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 10BCBD0D171 for ; Wed, 7 Jan 2026 20:35:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2EDC10E086; Wed, 7 Jan 2026 20:35:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="bpHJ9O2v"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1AE2B10E086 for ; Wed, 7 Jan 2026 20:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1767818156; x=1799354156; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=f2PHOhgscuiU0VP+0OQ2ECTaG3iMpsBTe9FweuXzDUk=; b=bpHJ9O2vmcssR+Nr5PjWyQw16mekqRmdkPv2nCMwrLHfymWlnoK8SqQM spTgv1CbGLhokWk3JrWtQ0gik3p4wAcs+BrYb4CBs+yrD/Ik2eIbqBE4R F5i7U1Umnkub4qzOuUtCrjY1e0EcHobqfHxLK/gP2YD/onWa20X9UWf/X bHkE8uDPO3SDQf/iw9O0MhAV9JSnPn3ZyCpUydjLFxnNFLuzHRYP8I70d B8tCfJqjmoXXoS14NjGcuN4awn5laJIbQ9Cjr+oCMwHdBdVxBijxRTopB Ub2mnrjm5y6gnSoXQWf32Hg9R7Y4IXiUWTd/RSZsiX8fSg4xoaMIf+MqO w==; X-CSE-ConnectionGUID: +9jkKbNRTySsg5FczUf4iQ== X-CSE-MsgGUID: Dtjmxq6KTWy3goCs1Y7Y+A== X-IronPort-AV: E=McAfee;i="6800,10657,11664"; a="69272157" X-IronPort-AV: E=Sophos;i="6.21,209,1763452800"; d="scan'208";a="69272157" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jan 2026 12:35:55 -0800 X-CSE-ConnectionGUID: wW44xfVtTOOm+AQaCKAoCQ== X-CSE-MsgGUID: 6DmQTRiCRhe5yIa37U/yqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,209,1763452800"; d="scan'208";a="203073007" Received: from fmsmsx902.amr.corp.intel.com ([10.18.126.91]) by orviesa008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jan 2026 12:35:55 -0800 Received: from FMSMSX901.amr.corp.intel.com (10.18.126.90) by fmsmsx902.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 7 Jan 2026 12:35:54 -0800 Received: from fmsedg901.ED.cps.intel.com (10.1.192.143) by FMSMSX901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29 via Frontend Transport; Wed, 7 Jan 2026 12:35:54 -0800 Received: from CO1PR03CU002.outbound.protection.outlook.com (52.101.46.25) by edgegateway.intel.com (192.55.55.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 7 Jan 2026 12:35:45 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cyzqwH2qkEOJ4dg25j35KkklXj5HJ5cMKliD/qk7ZRWnZAwRTv22RuSKgRVByjhamlcMApLFl8r0oiJOvJ9k6s9eExB1YwqRPYc0HKq4JZ032oIZovdokRhJBxrW56C5nyveI32BM9MNswd9r/Q343zSoFILf17VzQmmrfOyuJT65ETUgOu1pdehL55K6Dbi1iSe5yC7PapwZ45WMNLty7eg8Umj4HGKkIWJGTMovcb6438HvBJchy3B+/wfS2tCT5X781RXOZCUGdri+j2rUM6MAUw03pro8EsocMWp6W61bAIuJx7kpJ8teXtvWATjTbCxmReAybjX/2hRndl+Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7LrpBWIhEY8kF1IU7zcc/QKDLPlrPIrOBB41BK/LimQ=; b=O8P23A0rlKa7+pFN7hrfQBp7pd5aw3qe19uTJf1DSvcn2ApF1Z/tnDLTSP2kp1MAIemw2/lr8yzQlwnkMeSBsv1q/5AYo0VrgpPQt29TAbn3Lglt+K+NsqaMa3NjF5LEQ2kmy+Ir/T1qvPAbHEDypRehAg29bH/UwDt463F/KR56frMrmajDd4+VQWV/QCV3l13nl8vJoXKsu499cAAJrZsSK5JxnYwyN9foYGsssqvLq9QNrzx9pHsOXhxIng2FH76Da5n5UH8IHYbIJ/E0IJ8+yiuqzEgeJk3vttzeinbuOkekdWDLtIQ7yeBVasFcimhgXAGsiV6lt606sKY8DA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH7PR11MB6522.namprd11.prod.outlook.com (2603:10b6:510:212::12) by SA2PR11MB4874.namprd11.prod.outlook.com (2603:10b6:806:f9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.2; Wed, 7 Jan 2026 20:35:43 +0000 Received: from PH7PR11MB6522.namprd11.prod.outlook.com ([fe80::9e94:e21f:e11a:332]) by PH7PR11MB6522.namprd11.prod.outlook.com ([fe80::9e94:e21f:e11a:332%7]) with mapi id 15.20.9456.015; Wed, 7 Jan 2026 20:35:43 +0000 Date: Wed, 7 Jan 2026 12:35:40 -0800 From: Matthew Brost To: "Summers, Stuart" CC: "intel-xe@lists.freedesktop.org" , "stable@vger.kernel.org" , "Alvi, Arselan" Subject: Re: [PATCH] drm/xe: Tie page count tracepoints to TTM accounting functions Message-ID: References: <20260107002154.1934332-1-matthew.brost@intel.com> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: SJ0PR05CA0155.namprd05.prod.outlook.com (2603:10b6:a03:339::10) To PH7PR11MB6522.namprd11.prod.outlook.com (2603:10b6:510:212::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR11MB6522:EE_|SA2PR11MB4874:EE_ X-MS-Office365-Filtering-Correlation-Id: f69b5350-54cc-43ee-527d-08de4e2c53ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?Q?5LQ41v83CoviSybdK2t1AX/FU1lDcxweT3CB7jfEx9k5m4yB94pXayqu+I?= =?iso-8859-1?Q?C4BZhuD820kYQL+5PT2LWF24mapPDawJAe5xwlmdveeZHxQ/ASlqZmF41+?= =?iso-8859-1?Q?kvOb5IZJSIPh+9DOdnOXUUecR1BxWAKzqR0dIjQJqKHTzXWgGp0DH7luwH?= =?iso-8859-1?Q?Ya86Yp95wE6OCpPvrX/IMFwxFBngBFC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Q?DDZJ4UmLh3SXOs+IW+YPEfqEXfoq6OBynQg5WJEdcgZeRq3ECrNFGqHstq?= =?iso-8859-1?Q?yblnJmpfub+v5VjDnyIKqbeHXgnxlBnex5BgU1pQVB5umyHszBwbkOq3Gk?= =?iso-8859-1?Q?CdZ6o7J1nPZLRT4Sld42ENaGwJtvO+sVUczHGA6hjrHjiU2Gtv+LS7yj1+?= =?iso-8859-1?Q?atRT96bVvZDOWfi4bJ2/GMBQEwfoSnBXXHGXCMvTeY6ZhpAW2R5I2Dni0a?= =?iso-8859-1?Q?wzLr4elkVcZbqhVNDTpip+XgB5eWIODdIakUR6TeDwKTTadWcqFY4sTHST?= =?iso-8859-1?Q?UftHRh6aIu2U/z5qoafBPqosDYdZLGvMZk82QkfK37koJDHUxABC6zLbh6?= =?iso-8859-1?Q?dAkPe9yx3aUklMvlp6HHnp3yFyXdJdUCEhCJ8ax1Es7y4VtDqGzl5LaRlp?= =?iso-8859-1?Q?J40WKzsVgVX/OGoqKunIwj?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH7PR11MB6522.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?c5AJ1ONdMd8U9oLjgzJ1GVshwV8IO12V00Yd5MQDXlmCPSaHjctP+sGYA5?= =?iso-8859-1?Q?Z6Zk/ECVlHtpYvhMMt2bIuFPVYqMgSwab9bPPpc6idbhst+Ti/sMJLmluq?= =?iso-8859-1?Q?lUUInRFFjg0q8+jM9pBwyOXMQPH3/dKwxNNhIfELnw5qlr8ulxplHUXs80?= =?iso-8859-1?Q?45XheYjEW+ODknAdNDsjF+2CS2MTD0vnxDKsPBvhY2weGR87KU50pjPAYC?= =?iso-8859-1?Q?IQKzqWGsHZrZ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= =?iso-8859-1?Q?tyKLaKkH98jfLtzNP8Yo4AofmpF8wvcfO7U+Op4UOJ5EYIPCbVCS7QRTtv?= =?iso-8859-1?Q?ZQWc+rIF2sucAUx99itSifukh/xY6VV+Y56LX4Lmd3vop7gmKzxBjutBrU?= =?iso-8859-1?Q?uU258r0S2xKEWLwnJTeD4fNfx30+UMN38KRwMnYZ/2dt29p7dB8oYG5UZf?= =?iso-8859-1?Q?rCGamQGe5u68kIDmrgEMTOvLepafwETDlORiaEIwMgCVgQWIOeyh5dA2+0?= =?iso-8859-1?Q?RhiKVsVBA3jRbRDNWudixvYUqFCMY/PcMryRTqZi2x6ehb9GmxoBZjqyUO?= =?iso-8859-1?Q?vY3qsG+FoFr9TOFgYC0TV49cqy1l8sSMcQQexJyKCAzcZf08KtKXUFa22B?= =?iso-8859-1?Q?IldMGMBb214TNZjK1BNzEgloUPAec0felEmlVbR0aYMYVPFCH/+7oz5BN8?= =?iso-8859-1?Q?uEPL5zBcg+8aojWohkYQz3L0eh7Vk3UdlPT/4HH4JG0hOg6PpTS4waBtYT?= =?iso-8859-1?Q?J11UVc/CXZjAPq9wK/Kiu395kDi+miHqMfaCmoKQU4dERwAVmPb8WnAqcT?= =?iso-8859-1?Q?kGlH90xloCSqWenRPy8HIVecqNV0gw3e1o/i+Xddt6MKlnIeKswUIOEuvl?= =?iso-8859-1?Q?USX4kXSm2gYJ8gJ+Qg8TdHTk2jRNuxhuja/J7UD6x6RkC7LK+SI7ysdWUv?= =?iso-8859-1?Q?E8UM2eRSVIP/Cg+V/CLJfoc6gPnKgeU=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: f69b5350-54cc-43ee-527d-08de4e2c53ff X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB6522.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2026 20:35:42.9462 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5RFy3vn1SRlYG7jq4BNDFC0OQTKDRx5WEmxjaeO9iv4mFQOFesb0ndyMLY+19foQs/BdhvNIt7+XsBUVOGli1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB4874 X-OriginatorOrg: intel.com 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" On Wed, Jan 07, 2026 at 01:01:12PM -0700, Summers, Stuart wrote: > On Tue, 2026-01-06 at 16:21 -0800, Matthew Brost wrote: > > Page accounting can change via the shrinker without calling > > xe_ttm_tt_unpopulate(), but those paths already update accounting > > through the xe_ttm_tt_account_*() helpers. > > I see this is getting also called through the xe_bo_pin/unpin functions > with a check for ttm_tt_is_populated(). Does that mean after this > change we'd get a double accounting in those cases? > Ah, good catch. It would actually be the inverse of that - we'd not account for pinned pages in global page counter. Let me fix this. Matt > Thanks, > Stuart > > > > > Move the page count tracepoints into xe_ttm_tt_account_add() and > > xe_ttm_tt_account_subtract() so accounting updates are recorded > > consistently, regardless of whether pages are populated, unpopulated, > > or reclaimed via the shrinker. > > > > This avoids missing page count updates and keeps global accounting > > balanced across all TT lifecycle paths. > > > > Cc: stable@vger.kernel.org > > Fixes: ce3d39fae3d3 ("drm/xe/bo: add GPU memory trace points") > > Signed-off-by: Matthew Brost > > --- > >  drivers/gpu/drm/xe/xe_bo.c | 7 +++++-- > >  1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > > index 8b6474cd3eaf..33afaee38f48 100644 > > --- a/drivers/gpu/drm/xe/xe_bo.c > > +++ b/drivers/gpu/drm/xe/xe_bo.c > > @@ -432,6 +432,9 @@ struct sg_table *xe_bo_sg(struct xe_bo *bo) > >         return xe_tt->sg; > >  } > >   > > +static void update_global_total_pages(struct ttm_device *ttm_dev, > > +                                     long num_pages); > > + > >  /* > >   * Account ttm pages against the device shrinker's shrinkable and > >   * purgeable counts. > > @@ -440,6 +443,7 @@ static void xe_ttm_tt_account_add(struct > > xe_device *xe, struct ttm_tt *tt) > >  { > >         struct xe_ttm_tt *xe_tt = container_of(tt, struct xe_ttm_tt, > > ttm); > >   > > +       update_global_total_pages(&xe->ttm, tt->num_pages); > >         if (xe_tt->purgeable) > >                 xe_shrinker_mod_pages(xe->mem.shrinker, 0, tt- > > >num_pages); > >         else > > @@ -450,6 +454,7 @@ static void xe_ttm_tt_account_subtract(struct > > xe_device *xe, struct ttm_tt *tt) > >  { > >         struct xe_ttm_tt *xe_tt = container_of(tt, struct xe_ttm_tt, > > ttm); > >   > > +       update_global_total_pages(&xe->ttm, -(long)tt->num_pages); > >         if (xe_tt->purgeable) > >                 xe_shrinker_mod_pages(xe->mem.shrinker, 0, -(long)tt- > > >num_pages); > >         else > > @@ -575,7 +580,6 @@ static int xe_ttm_tt_populate(struct ttm_device > > *ttm_dev, struct ttm_tt *tt, > >   > >         xe_tt->purgeable = false; > >         xe_ttm_tt_account_add(ttm_to_xe_device(ttm_dev), tt); > > -       update_global_total_pages(ttm_dev, tt->num_pages); > >   > >         return 0; > >  } > > @@ -592,7 +596,6 @@ static void xe_ttm_tt_unpopulate(struct > > ttm_device *ttm_dev, struct ttm_tt *tt) > >   > >         ttm_pool_free(&ttm_dev->pool, tt); > >         xe_ttm_tt_account_subtract(xe, tt); > > -       update_global_total_pages(ttm_dev, -(long)tt->num_pages); > >  } > >   > >  static void xe_ttm_tt_destroy(struct ttm_device *ttm_dev, struct > > ttm_tt *tt) >