From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D3D3606A320 for ; Tue, 1 Dec 2026 18:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=C1Cn3cju Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 236B910EA35; Tue, 1 Dec 2026 18:53:54 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE95010EA0A; Tue, 1 Dec 2026 18:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796151223; x=1827687223; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=eZWydc5qAydToexHiUCxhPJFCFUJJRIBPYUZ6/5RYnk=; b=C1Cn3cjuxFXNTIEOfvT3O4uFvPRi4V6tfGH2B4d5YAnaknWC6b56Nh7X v9deL1au5DmAf+YwpF3Y12p2Is731A2YGQpVJVY2o5NwKsXQme7pZwWfA MPcFf4sBejuLqf6odJRJ5wo3eDSckpFAbxueK46QXntO+EI9KqpSgIptU hxSOajMzDuH7Z5ItIdul39W7ULQxzKEImLQOgc4Omm0fY0Fge2n542ixZ uNTjjC4t7wv7Ru7A30rxE3R2TXR+pPaFdr6qnbfn2Zn4T0INyiyf12KDJ lFJI+KZos1CDKXnCxDT/wgttAKO6BQlpi4zwGVejboKR3KDM3CAL3OqLI Q==; X-CSE-ConnectionGUID: KpDgJPNTQiOewzOibXpM9g== X-CSE-MsgGUID: QDMa/etkRHydM1uBsF7kJw== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="4956014" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="4956014" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 10:53:38 -0800 X-CSE-ConnectionGUID: 4noZGCj2Q8KGO29Q6x/azQ== X-CSE-MsgGUID: cPKkYBG6S0adT886RMrMXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="4760086" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 10:53:37 -0800 Received: from FMSMSX902.amr.corp.intel.com (10.18.126.91) 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.57; Tue, 1 Dec 2026 10:53:36 -0800 Received: from fmsedg901.ED.cps.intel.com (10.1.192.143) 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.57 via Frontend Transport; Tue, 1 Dec 2026 10:53:36 -0800 Received: from CY3PR05CU001.outbound.protection.outlook.com (40.93.201.48) 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.57; Tue, 1 Dec 2026 10:53:36 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SKkttH7PeGCjm0SEuRghzbAJ1i6ySg1OH0u3OIwxu+DwParVmDe9rMdfpTL6qJyrpD4r5l41ZAQjGcjOCUsi0YNcAjUKUgiHoQ6tXqLYkC0vd2WDCAQkAQRRWsP6qAGHHRsMThXifEe6r4j+stKTwOCLbE7nLh62h/ZzoEWwAOoVOKNICZcoB7mQJWEKVOeQG0F4K/bTc4pIL4xq2kpQQLy1FOch+0Vv+gteYhZFLtZjBxZWsm7SQ3yBJF3KmNiihX9gjLtNZ+VCEix3LnfJtGNpuQGcB6Sn98+2HvEjU2xqskwD7q5BMaEbHVSRreqyy+oike+bJhP4Cyztye8bKA== 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=x8ledzUIJkbvEtfC5LwkFCqFoHoL3IF5XxWI20Y3ENI=; b=Qnzb15h21oNo489VkLOlY9eDkVyZTGzgSB0nE0h1ZfvxQyA7UGiZ7RyuPcefJu48PyujFYVjxTapGrhqukPqu+FEzbLllmLHpcTul1vZo1Ap/edgIzRdqvTA0yxcMvA8iTgF049DA0xOYRv/snvmlvYYWsAudL1piQefGVWnDgUD/X6qow33i7iAaDrV9uVk7tBPRWVyIq3fcH/SQb7VDlCQV7qkZWkEPvyWhi9ggUtoseV2bgDMk40Pnw/XhOFimqXpAHPPRhuvdHuTebVeXkLUje8CNFajVT7Yuqr759oA1SaxD+SupIYQQ8B33OsXCRYT1T1tKnRl9Hsiip82UQ== 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: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) by SJ1PR11MB6298.namprd11.prod.outlook.com (2603:10b6:a03:457::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Tue, 1 Dec 2026 18:53:33 +0000 Received: from CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd]) by CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd%4]) with mapi id 15.21.0688.009; Tue, 1 Dec 2026 18:53:33 +0000 Date: Tue, 1 Dec 2026 10:53:30 -0800 From: Matthew Brost To: Niranjana Vishwanathapura CC: , , Carlos Santa , Ryan Neph , Christian Koenig , Huang Rui , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , , Thomas =?iso-8859-1?Q?Hellstr=F6m?= Subject: Re: [PATCH v3 24/33] drm/xe: Add defrag profiling tracepoints Message-ID: References: <20260711025619.2540575-1-matthew.brost@intel.com> <20260711025619.2540575-25-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: SJ0PR03CA0119.namprd03.prod.outlook.com (2603:10b6:a03:333::34) To CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB4787:EE_|SJ1PR11MB6298:EE_ X-MS-Office365-Filtering-Correlation-Id: 1aa2ccdb-b485-4ff5-e4cc-08df4fdc65ba X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|1800799024|366016|376014|7416014|4143699003|18002099003|6133799003|22082099003|56012099006|10067099003|11063799006|261102123227099003|261028144727099003|261021123027099003|261026121527099003|261022105027099003|261021121427099003|261026140227099003|261022075727099003|261009223027099003; X-Microsoft-Antispam-Message-Info: 9EUf47CbGeNBEl5qkkB7txWRkDJzYNuy5kVJaPtMeeEQh4xPAy/eG+O1ZhH1t+hoqwtjvuirUVw+tk5S/6Sj9uKeHZNSxu6ZNxdaLQTFwGChpSMPffpSI6ifRsCy6U1hX2iTTDWoh+cLpmezJS6R8IDK4Mu8ESExbS36clXulIJJd62XsPLHXoxVIlk55sYFoVAc0f0FLSLiy5qmH5g6W03A8s+mIdPUZJe+hvhqd+OpXyrfUnmeWgfp19VA3EH9BDv6XFKyx5lnycaYJras9OzkU4WThGRy3tPy4wA8BjpjfsVUuxMXom7iILY3IUHEjllnVIwsTtBX6g3QaQ4vyB751xa8diUYlFvFzZLwAhI1qEXCDueN38C92SNcRiy5JmNZZ8hZ1IpjLAE09T5AWRgJYo5x9kBOT0i4laRgsR3gWxyPU/IP1hs9OSgc/ZDvghnASv0kgrC76OIT3qkwz7EL0zwYafWU4PvnUWJ9Nr+qbPTzacH7NNfzZUn8R/E1mqFodgfX2/3S1kVvSstNmlAnIkxS2qTRKkQXkyz+2GyIxxs0QDfY6L3OkqnLz7b06aaMic10nx2MMJgYc3NDqxBFfrtlpimuy0a3zy3H1gWpxLRiegkZtBIUTu7S4Nc0RfMHtuzgzblxWeJVHHF5oleVYYaIgQf/j2QTvNMnJE4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB4787.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(1800799024)(366016)(376014)(7416014)(4143699003)(18002099003)(6133799003)(22082099003)(56012099006)(10067099003)(11063799006)(261102123227099003)(261028144727099003)(261021123027099003)(261026121527099003)(261022105027099003)(261021121427099003)(261026140227099003)(261022075727099003)(261009223027099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?Dm7S4D+12DLIympEcbb97TaNE48npwCcJZVTPlP1ob8UPViA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?iso-8859-1?Q?5wo1e7SFwi61xsBVEezd9evZ30fzCsQ=3D?= X-Exchange-RoutingPolicyChecked: knLBngELIk6i4i0CUX+BPtnwzpfXUyJzqXKsDcdorT14pEDS/GW24W4MlQDfi8kriHzYrveNmyoUsU95JTuR8RaTxFJkxvrjeeYH2vxghvOeFC5uFD49ECQ/KSxPU1dATtKIDUBlGhOOkkzzqnj76trXUZtVzGhfGHVZhYNPUsjUYeRbhOSlcbvlo29NbFlZenjfkgRfCZNTykZwMOl1GEFlrJIpTQ4YJbv4gRuGcwQwFieRQvFVvTFjReTfDggpWl/uYYKbAOwUOcK82PRGGIT1rAQ8Y/nrShwvxQ+jWzdNCubWDWJzt3uZWg7OsSJ+SS+Yuo2LviL3Gp0vXB+J+g== X-MS-Exchange-CrossTenant-Network-Message-Id: 1aa2ccdb-b485-4ff5-e4cc-08df4fdc65ba X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 18:53:32.9672 (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: doTdvx777AFWyRDIxjcGvKi3adymNTJtIric/2n7aq+jjL1F4QmrBWhSGFke12wiphwwGY0stEn2JCOAnLxUSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR11MB6298 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-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Mon, Nov 30, 2026 at 01:13:54PM -0800, Niranjana Vishwanathapura wrote: > On Tue, Nov 24, 2026 at 12:42:30PM -0800, Matthew Brost wrote: > > On Sun, Nov 08, 2026 at 08:34:18PM -0800, Niranjana Vishwanathapura wrote: > > > On Fri, Jul 10, 2026 at 07:56:10PM -0700, Matthew Brost wrote: > > > > Add two tracepoints to profile the page defragmentation worker: > > > > > > > > - xe_bo_defrag_worker: emitted on worker entry and exit with the > > > > current defrag list count and the bytes processed in the run. > > > > - xe_bo_defrag_one: emitted per BO with the run budget, the prealloc > > > > fill ratio (got/want) and the lock-held, lock-wait and prealloc > > > > durations, plus the bytes consumed and the result. > > > > > > > > These break down the cost of a defrag attempt into its locked vs > > > > unlocked phases, making it possible to confirm that the expensive > > > > beneficial-order allocation and cpu cache mode change happen outside > > > > the BO dma-resv lock and that the residual lock-held time is copy-bound > > > > (with the tail dominated by lock-wait behind active rendering). > > > > > > > > Cc: Carlos Santa > > > > Cc: Ryan Neph > > > > Cc: Christian Koenig > > > > Cc: Huang Rui > > > > Cc: Matthew Auld > > > > Cc: Maarten Lankhorst > > > > Cc: Maxime Ripard > > > > Cc: Thomas Zimmermann > > > > Cc: David Airlie > > > > Cc: Simona Vetter > > > > Cc: dri-devel@lists.freedesktop.org > > > > Cc: linux-kernel@vger.kernel.org > > > > Cc: Thomas Hellström > > > > Assisted-by: GitHub_Copilot:claude-opus-4.8 > > > > Signed-off-by: Matthew Brost > > > > > > > > --- > > > > > > > > v3: > > > > - Move the ns-to-us division into TP_fast_assign() to avoid a 64-bit > > > > divide in TP_printk() (Sashiko) > > > > --- > > > > drivers/gpu/drm/xe/xe_bo.c | 18 +++++++++- > > > > drivers/gpu/drm/xe/xe_trace_bo.h | 59 ++++++++++++++++++++++++++++++++ > > > > 2 files changed, 76 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > > > > index 8b89d34f37d4..25e5b72f870c 100644 > > > > --- a/drivers/gpu/drm/xe/xe_bo.c > > > > +++ b/drivers/gpu/drm/xe/xe_bo.c > > > > @@ -1263,7 +1263,9 @@ static int xe_bo_defrag_one(struct xe_device *xe, struct xe_bo *bo, > > > > struct ttm_placement placement; > > > > struct ttm_place place; > > > > enum ttm_caching tt_caching; > > > > - unsigned int order, want = 0; > > > > + unsigned int order, want = 0, got = 0; > > > > + u64 lock_ns = 0, prealloc_ns = 0, lockwait_ns = 0; > > > > + ktime_t t0; > > > > int ret = 0; > > > > > > > > *consumed = 0; > > > > @@ -1294,6 +1296,7 @@ static int xe_bo_defrag_one(struct xe_device *xe, struct xe_bo *bo, > > > > > > > > /* Phase 2: preallocate outside the lock; */ > > > > if (want) { > > > > + t0 = ktime_get(); > > > > ret = ttm_pool_prealloc_fill(pool, tt_caching, &pp, want); > > > > if (ret || !pp.count) { > > > > ret = ret ?: -ENOMEM; > > > > @@ -1301,12 +1304,16 @@ static int xe_bo_defrag_one(struct xe_device *xe, struct xe_bo *bo, > > > > XE_GT_STATS_ID_DEFRAG_FAILED_COUNT, 1); > > > > goto out_err; > > > > } > > > > + prealloc_ns = ktime_to_ns(ktime_sub(ktime_get(), t0)); > > > > } > > > > > > > > /* > > > > * Phase 3: re-take the lock, re-check, and validate using the prealloc. > > > > */ > > > > + t0 = ktime_get(); > > > > xe_bo_lock(bo, false); > > > > + lockwait_ns = ktime_to_ns(ktime_sub(ktime_get(), t0)); > > > > + t0 = ktime_get(); > > > > > > Here only phase 3 locking is profiled. What about phase 1 locking? > > > > > > > Phase 1 consists of a series of very small, time bounded checks > > performed under lock for stability, which should be extremely fast. > > > > Phase 3 is interesting part as we perform dma mapping, formulate a copy > > job, and internally update the TTM bookkeeping. If this part takes too > > long (several ms) we could risk missing page flips as compositor could > > be waiting on the same lock. Fortunately iirc for most BOs the lock is > > held for less than 100us. So this is part we really need ftrace points > > for profiling. > > > > Ok, but, given phase 1 involves locking, we might spend significant time > waiting for the lock. Not sure how useful this phase 1 locking time profiling > will be though. > Maybe it makes sense for phase 1 to also contribute to lockwait_ns too - any spikes in lockwait_ns generally means something has gone wrong and need a bit of investigation. Matt > Niranjana > > > Matt > > > > > Niranjana > > > > > > > > > > > if (!xe_bo_needs_defrag(bo)) { > > > > xe_bo_defrag_remove(bo); > > > > @@ -1362,9 +1369,13 @@ static int xe_bo_defrag_one(struct xe_device *xe, struct xe_bo *bo, > > > > > > > > unlock: > > > > xe_bo_unlock(bo); > > > > + lock_ns = ktime_to_ns(ktime_sub(ktime_get(), t0)); > > > > + got = pp.used; > > > > out_err: > > > > ttm_pool_prealloc_fini(pool, &pp); > > > > out: > > > > + trace_xe_bo_defrag_one(bo, budget, want, got, lock_ns, prealloc_ns, > > > > + lockwait_ns, *consumed, ret); > > > > return ret; > > > > } > > > > > > > > @@ -1396,6 +1407,9 @@ static void xe_bo_defrag_worker(struct work_struct *w) > > > > return; > > > > } > > > > > > > > + trace_xe_bo_defrag_worker(xe, 0, atomic_read(&xe->mem.defrag.count), > > > > + true); > > > > + > > > > /* > > > > * Process at most XE_BO_DEFRAG_SIZE_LIMIT bytes of newly (re)allocated > > > > * backing per run rather than draining the whole list in one go. Only > > > > @@ -1503,6 +1517,8 @@ static void xe_bo_defrag_worker(struct work_struct *w) > > > > > > > > xe_pm_runtime_put(xe); > > > > drm_dev_exit(idx); > > > > + trace_xe_bo_defrag_worker(xe, defrag_bytes, > > > > + atomic_read(&xe->mem.defrag.count), false); > > > > } > > > > > > > > static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict, > > > > diff --git a/drivers/gpu/drm/xe/xe_trace_bo.h b/drivers/gpu/drm/xe/xe_trace_bo.h > > > > index 86323cf3be2c..b159d37d39a1 100644 > > > > --- a/drivers/gpu/drm/xe/xe_trace_bo.h > > > > +++ b/drivers/gpu/drm/xe/xe_trace_bo.h > > > > @@ -85,6 +85,65 @@ TRACE_EVENT(xe_bo_move, > > > > __get_str(new_placement_name), __get_str(device_id)) > > > > ); > > > > > > > > +TRACE_EVENT(xe_bo_defrag_worker, > > > > + TP_PROTO(struct xe_device *xe, u64 defrag_bytes, int count, > > > > + bool enter), > > > > + TP_ARGS(xe, defrag_bytes, count, enter), > > > > + TP_STRUCT__entry( > > > > + __string(dev, dev_name(xe->drm.dev)) > > > > + __field(u64, defrag_bytes) > > > > + __field(int, count) > > > > + __field(bool, enter) > > > > + ), > > > > + TP_fast_assign( > > > > + __assign_str(dev); > > > > + __entry->defrag_bytes = defrag_bytes; > > > > + __entry->count = count; > > > > + __entry->enter = enter; > > > > + ), > > > > + TP_printk("dev=%s %s defrag_bytes=%llu count=%d", > > > > + __get_str(dev), __entry->enter ? "enter" : "exit", > > > > + __entry->defrag_bytes, __entry->count) > > > > +); > > > > + > > > > +TRACE_EVENT(xe_bo_defrag_one, > > > > + TP_PROTO(struct xe_bo *bo, u64 budget, unsigned int prealloc_want, > > > > + unsigned int prealloc_got, u64 lock_ns, u64 prealloc_ns, > > > > + u64 lockwait_ns, u64 consumed, int ret), > > > > + TP_ARGS(bo, budget, prealloc_want, prealloc_got, lock_ns, > > > > + prealloc_ns, lockwait_ns, consumed, ret), > > > > + TP_STRUCT__entry( > > > > + __string(dev, __dev_name_bo(bo)) > > > > + __field(size_t, size) > > > > + __field(u64, budget) > > > > + __field(unsigned int, prealloc_want) > > > > + __field(unsigned int, prealloc_got) > > > > + __field(u64, lock_us) > > > > + __field(u64, prealloc_us) > > > > + __field(u64, lockwait_us) > > > > + __field(u64, consumed) > > > > + __field(int, ret) > > > > + ), > > > > + TP_fast_assign( > > > > + __assign_str(dev); > > > > + __entry->size = xe_bo_size(bo); > > > > + __entry->budget = budget; > > > > + __entry->prealloc_want = prealloc_want; > > > > + __entry->prealloc_got = prealloc_got; > > > > + __entry->lock_us = div_u64(lock_ns, 1000); > > > > + __entry->prealloc_us = div_u64(prealloc_ns, 1000); > > > > + __entry->lockwait_us = div_u64(lockwait_ns, 1000); > > > > + __entry->consumed = consumed; > > > > + __entry->ret = ret; > > > > + ), > > > > + TP_printk("dev=%s size=%zu budget=%llu prealloc=%u/%u lock_us=%llu lockwait_us=%llu prealloc_us=%llu consumed=%llu ret=%d", > > > > + __get_str(dev), __entry->size, __entry->budget, > > > > + __entry->prealloc_got, __entry->prealloc_want, > > > > + __entry->lock_us, __entry->lockwait_us, > > > > + __entry->prealloc_us, __entry->consumed, > > > > + __entry->ret) > > > > +); > > > > + > > > > DECLARE_EVENT_CLASS(xe_vma, > > > > TP_PROTO(struct xe_vma *vma), > > > > TP_ARGS(vma), > > > > -- > > > > 2.34.1 > > > >