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 DC28F606A322 for ; Thu, 3 Dec 2026 17:35:56 +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=KqFjHBGP Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2092F112A8A; Thu, 3 Dec 2026 17:35:51 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5CA8A10E2F0; Thu, 3 Dec 2026 17:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796319345; x=1827855345; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=mjI5ZIoYBTMK+uYspYS3ciQRNBIG8ujlygKgFtdtq90=; b=KqFjHBGPdfLnxVbUWM6wQUvq7J89ONkUbLdbgT31u2bxBtE9gPKeTcNP 4IY+uDWvdnQhhFCxi9mg59hKwO4xbinAzLKjd4I0dO44T6jMFPAhsLIZe L5LZ853AIMpqIfH0d3pJScVM9hW1SKNoXu3cOM5DeuDzDStjXaw4tT871 Wo9VBQTeAjzmJgtZ0wyWt8ZSZU/GiIlfNxFHEeW6Rs2/zGavtLNtwhwR6 ics0FzF1genv3bilYemGKsfmkdVHPXVBmtfPeutAH58yX0pvcmQKuxGhc 1v2C2ZVTI3owolN6fxX/3hes5dUa+qCJXB9WbUIxjeTGBNKsKwSNR5Thu w==; X-CSE-ConnectionGUID: zBWE5RAmQxCSGlZSoBoTuA== X-CSE-MsgGUID: dFgtIBACQNiVwAcq6ZL6bQ== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5188061" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5188061" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 09:35:31 -0800 X-CSE-ConnectionGUID: RJG3P/kqTNaHIAug5BOUqA== X-CSE-MsgGUID: PSBEtTLGSeSVgbDQhok2HA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="13869297" Received: from fmsmsx903.amr.corp.intel.com ([10.18.126.92]) by orviesa002.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 09:35:31 -0800 Received: from FMSMSX902.amr.corp.intel.com (10.18.126.91) by fmsmsx903.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 09:35:30 -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; Thu, 3 Dec 2026 09:35:30 -0800 Received: from BN8PR05CU002.outbound.protection.outlook.com (52.101.57.20) 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; Thu, 3 Dec 2026 09:35:29 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dr9tyWpusAECtc3e4434u+3ANr38vD2yBYYCwxa6cdpu+dl2lHgsHLMZBSIfbcgfXhPz6lC+HfSjc3dSUhMarSAuh1Z0AndmiNG0art6BMgI0s45tNxYve00DR1hfY+iJGOLtksfJqguDjhjFVs+Mwqj2g6MtOYk/hOQ9TRn7cChfG+Dp8l2zI3Hh1CtY713pdnlVnyGefS9TooozC+jm79JlA+vnXDLr7Pzvi00zWNN8TtekpZilUN2VdCC3Ld52t8mGT8AhFNdw9sGBzFPTT0omaWrp8Yz0CHK8qDkmJZAKmBXWKet4afcDt7ch+dONO5gko3U7dPmHD42HLXbXA== 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=mYrWE2AQ56TsGWD5EOFKMz66iQqKOS+wirA0A2UOa0A=; b=ye+UjsBjqFt/Y2AG+kg5XCgLsbJThG1hNxsBq2DpUZ9qh0NGy4mMbM/rdIyHcwAzhQ9OQZbHRfJFQWrD19uP10BjvnDRvI5qgwlLiTfqsUrfpQkz0jKY8R6+j6SZ9m/5b5yMab5vOpSDJLPf42pQnZDHxVs0jPF1GE+ssWR5fiarbJiDg/HAl4W0cgeOimVn1Rtnx71r8xRocDF3Kun7us62hB+Y5BRixX5gCGrkI/vbcF0SdXXBnAMLabJY9gn4rtIpicwqdMSYcqTY3iUOWgvjR9gPCb8opeQDpKlaE7n1EsRtt5e1B1vmL4QDIbR5wiKlzEWZDqk9x3RMmUZfuQ== 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 MW3PR11MB4684.namprd11.prod.outlook.com (2603:10b6:303:5d::14) by SJ0PR11MB5166.namprd11.prod.outlook.com (2603:10b6:a03:2d8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.11; Thu, 3 Dec 2026 17:35:26 +0000 Received: from MW3PR11MB4684.namprd11.prod.outlook.com ([fe80::2f5a:96ce:f7e4:c315]) by MW3PR11MB4684.namprd11.prod.outlook.com ([fe80::2f5a:96ce:f7e4:c315%7]) with mapi id 15.21.0688.011; Thu, 3 Dec 2026 17:35:25 +0000 Date: Thu, 3 Dec 2026 09:35:23 -0800 From: Niranjana Vishwanathapura To: Matthew Brost CC: , , Carlos Santa , Ryan Neph , Matthew Auld , Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Natalie Vock , "Arun Pravin" Subject: Re: [PATCH v5 35/36] drm/xe: Add bo_defrag debugfs entry Message-ID: References: <20261202233323.3743190-1-matthew.brost@intel.com> <20261202233323.3743190-36-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261202233323.3743190-36-matthew.brost@intel.com> X-ClientProxiedBy: BYAPR07CA0089.namprd07.prod.outlook.com (2603:10b6:a03:60::22) To MW3PR11MB4684.namprd11.prod.outlook.com (2603:10b6:303:5d::14) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR11MB4684:EE_|SJ0PR11MB5166:EE_ X-MS-Office365-Filtering-Correlation-Id: d3d19dd7-312e-49fa-9e97-08df5163d029 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|366016|1800799024|376014|22082099003|18002099003|10067099003|56012099006|261102123227099003|261022075727099003|261022105027099003|261021123027099003|261021121427099003|261026121527099003|261026140227099003|261028144727099003|261009223027099003|11063799006|4143699003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: aO9VgWXzemB4oyDQBJsN+kkPFQRKb7ZWDIAD2vWf5XU3NXMB5hEa4oCHgJJOtzG96s6OJasZHmMwxoWBEnUnuEEpozIGuU0WHaDYEsqantAJy8GANVwZEZnP8UpFBDB2eoYNqb9jwIZ2kUBS32rFUxruLmf7SB1qBadmSE7aJ8p9D9hlodxheCkdqK4YWuFCvLcVw8LmnEK5dtiXfiM+A+DFZKM7tR1E0JF3hNIM5edx8zFbZkky2YFEBz60yQcZ1DQgkaJoOL14CX9OD83wBFV5K6wxBd+MmxeKX+xS8QuhwQVbCuBjUSdjAQim3xJOljGih93XWci312VNrtDSpArGiYfRZKx9ZyL21543uCCDsk5e+vTxy0fQA28RpDmbqZaSGS7ovHvjcyZYT3GbdxqrbjSo3H8pDCGbUGk2yzdGdjF6UYQ/PIAM9/HLLtZn+WL4sxzuwDwOQDY0DlgfF1eMVsjRuwNwEdLRkFMWFaz6szzcm+qn5EeM6Nj0zuL5ICAm+H6+3DmX7umuCcp38kuqF4dERocQCeDfgXXVaUd8Mtjc8wv+Zlqqih7spbSbb32LIKAPRR4wvFf5Ko1kKiPPyqW7kBZ2VdDKFju8wnbIL6phCPVLscG4UNNfhjtu9C0WGUaZQfCXTSrMjCfCxLXRDTv38VsiBwgYr/b+H9E= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW3PR11MB4684.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(366016)(1800799024)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(261102123227099003)(261022075727099003)(261022105027099003)(261021123027099003)(261021121427099003)(261026121527099003)(261026140227099003)(261028144727099003)(261009223027099003)(11063799006)(4143699003)(6133799003)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?QTzU0oGz4OWmNWTPB6Wzl2/RLH3cLxxLm7cw9+/MRNEdpgfVJtcen3/wj1?=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20S0QV29j63cefGOxu7Wdn/q0/LUM12Q3hcSIZ0K?= X-Exchange-RoutingPolicyChecked: eVj52JHJAt0cGKy6q+vz1Ln01w6KKFMJdMPLtJFmjVtwQe7bVXf85I97aONHCUqPNSAGb7nA90NrXeprfA9s51so3clrM04EVDOPFiBKjt+zpGWZDWHpITj2TPZLjSz1bzmltCbexJrBcJl5equ2oC5kVimcg2lHZvsHaUOh1M3r0zNi3LgCvYZDblWyHf+tqpQKRDdI4UKiqDowoty2JIEkIWYm9WuHsdqrNfT/TYJFHoeJJDymYv7LTn+cVnbHnfK5S9saDksqHalVx47pS5fQIboUsc9PzdSwSgRxv4P67bhuxquHEFFXrA2y6JST2RC9mJtZHzi+G0JeUE3Cew== X-MS-Exchange-CrossTenant-Network-Message-Id: d3d19dd7-312e-49fa-9e97-08df5163d029 X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4684.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 17:35:24.6861 (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: 39s5AzNjmZy2W/4DRidzeoN2OiKEb/wcOTIohY3BUiKLitae/dCoHI4nDvm4BBD8BfwX0yVBFBF25yL8D+ikrvZGYF1ilUwfyOWgeVjjPhUu/SokHoKgWwQJk43UYWUg X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5166 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" 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 Wed, Dec 02, 2026 at 03:33:22PM -0800, Matthew Brost wrote: >Add a bo_defrag debugfs file to inspect the state of the BO >defragmentation worker. It reports whether defrag is supported, the >beneficial page order, the per-run size limit, the current (possibly >backed-off) worker interval along with its default and maximum, whether >the worker is pending (and when it will next run), running or idle, and >the number of BOs on the defrag list. > >Each BO on the defrag list is then printed with its size, the number of >bytes still backed below the beneficial order (the bytes a defrag move >would reallocate) and whether it still needs defrag, followed by totals. > >A reference to each listed BO is taken under the defrag list lock and >the BO is then locked to sample its backing, as the tt can be torn down >while the BO is still on the list. The per-BO output is therefore a >best-effort snapshot. > >Cc: Carlos Santa >Cc: Ryan Neph >Cc: Matthew Auld >Cc: Thomas Hellström >Cc: Natalie Vock >Cc: Arun Pravin >Signed-off-by: Matthew Brost >--- > drivers/gpu/drm/xe/xe_bo.c | 97 +++++++++++++++++++++++++++++++++ > drivers/gpu/drm/xe/xe_bo.h | 1 + > drivers/gpu/drm/xe/xe_debugfs.c | 9 +++ > 3 files changed, 107 insertions(+) > >diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c >index 65ab974c56ac..85552da80bf5 100644 >--- a/drivers/gpu/drm/xe/xe_bo.c >+++ b/drivers/gpu/drm/xe/xe_bo.c >@@ -2476,6 +2476,103 @@ static void xe_bo_defrag_update(struct xe_bo *bo) > xe_bo_defrag_remove(bo); > } > >+/** >+ * xe_bo_defrag_print() - Print the BO defragmentation state >+ * @xe: xe device instance >+ * @p: The drm_printer to print to >+ * >+ * Print the defrag worker configuration and state, followed by each BO on the >+ * defrag list with its size and the bytes still backed below the beneficial >+ * order (i.e. the bytes a defrag move would reallocate). A reference to each >+ * listed BO is taken under the list lock and the BO is then locked to sample >+ * its backing, so the per-BO output is a best-effort snapshot. >+ * >+ * Return: 0 on success, negative error code on failure. >+ */ >+int xe_bo_defrag_print(struct xe_device *xe, struct drm_printer *p) >+{ >+ struct delayed_work *dwork = &xe->mem.defrag.worker; >+ u64 total_size = 0, total_subopt = 0; >+ unsigned int count = 0, nr = 0, i; >+ unsigned int interval_ms; >+ struct xe_bo **bos, *bo; >+ int err = 0; >+ >+ drm_printf(p, "supported: %s\n", >+ str_yes_no(xe_bo_defrag_supported(xe))); >+ if (!xe_bo_defrag_supported(xe)) >+ return 0; >+ >+ scoped_guard(spinlock, &xe->mem.defrag.lock) { >+ interval_ms = xe->mem.defrag.interval_ms; >+ list_for_each_entry(bo, &xe->mem.defrag.list, defrag_link) >+ count++; >+ } >+ >+ drm_printf(p, "beneficial_order: %u\n", >+ ttm_pool_prealloc_order(&xe->ttm.pool)); >+ drm_printf(p, "size_limit: %llu\n", (u64)XE_BO_DEFRAG_SIZE_LIMIT); >+ drm_printf(p, "interval_ms: %u (default %u, max %u)\n", interval_ms, >+ XE_BO_DEFRAG_INTERVAL_MS, XE_BO_DEFRAG_INTERVAL_MAX_MS); >+ if (delayed_work_pending(dwork)) { >+ long delay = (long)(READ_ONCE(dwork->timer.expires) - jiffies); >+ >+ drm_printf(p, "worker: pending, next run in %u ms\n", >+ jiffies_to_msecs(max(delay, 0L))); >+ } else { >+ drm_printf(p, "worker: %s\n", >+ work_busy(&dwork->work) ? "running" : "idle"); >+ } >+ drm_printf(p, "list_count: %u\n", count); >+ if (!count) >+ return 0; >+ >+ bos = kvmalloc_array(count, sizeof(*bos), GFP_KERNEL); >+ if (!bos) >+ return -ENOMEM; >+ >+ /* The list may have changed while unlocked; snapshot at most @count. */ >+ scoped_guard(spinlock, &xe->mem.defrag.lock) { >+ list_for_each_entry(bo, &xe->mem.defrag.list, defrag_link) { >+ if (nr == count) >+ break; >+ bos[nr] = xe_bo_get_unless_zero(bo); >+ if (bos[nr]) >+ nr++; >+ } >+ } >+ >+ for (i = 0; i < nr; i++) { >+ u64 size, subopt = 0; >+ bool needs; >+ >+ bo = bos[i]; >+ if (!err) >+ err = xe_bo_lock(bo, true); >+ if (!err) { >+ size = xe_bo_size(bo); >+ if (bo->ttm.ttm) >+ subopt = (u64)ttm_tt_suboptimal_pages(bo->ttm.ttm) << >+ PAGE_SHIFT; >+ needs = xe_bo_needs_defrag(bo); >+ xe_bo_unlock(bo); >+ >+ drm_printf(p, " bo[%u] %p: size=%llu suboptimal=%llu needs_defrag=%s\n", >+ i, bo, size, subopt, str_yes_no(needs)); >+ total_size += size; >+ total_subopt += subopt; >+ } >+ xe_bo_put(bo); >+ } >+ kvfree(bos); >+ >+ if (!err) >+ drm_printf(p, "total: bos=%u size=%llu suboptimal=%llu\n", >+ nr, total_size, total_subopt); >+ NIT...so, in case of a BO locking error in the middle of the above loop, we will endup with prining BO info of some BOs (before the error) and will not print the totals, which is also not clean. May be we should just skip the BO that ran into error and continue printing the rest and the totals? As any difference between 'count' printed above and 'bos' printed here will tell it is best-effort snapshot? >+ return err; >+} NIT...Also, the patch 36 updates some fields of this function. May be it is cleaner to swap the order of patches to minimize such changes. In anycase, Reviewed-by: Niranjana Vishwanathapura >+ > /* > * Attempt to defragment a single BO by forcing a move that reallocates its > * backing at the device's beneficial order. @budget bounds how many bytes of >diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h >index 871d1aa1425c..28325341b4d1 100644 >--- a/drivers/gpu/drm/xe/xe_bo.h >+++ b/drivers/gpu/drm/xe/xe_bo.h >@@ -241,6 +241,7 @@ int xe_bo_defrag_init(struct xe_device *xe); > void xe_bo_defrag_suspend(struct xe_device *xe); > void xe_bo_defrag_resume(struct xe_device *xe); > void xe_bo_defrag_kick(struct xe_device *xe); >+int xe_bo_defrag_print(struct xe_device *xe, struct drm_printer *p); > int xe_bo_validate(struct xe_bo *bo, struct xe_vm *vm, bool allow_res_evict, > struct drm_exec *exec); > >diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c >index be533435097f..b070835b8d24 100644 >--- a/drivers/gpu/drm/xe/xe_debugfs.c >+++ b/drivers/gpu/drm/xe/xe_debugfs.c >@@ -372,11 +372,20 @@ static int dma_mapped_pages_show(struct seq_file *m, void *data) > } > DEFINE_SHOW_ATTRIBUTE(dma_mapped_pages); > >+static int bo_defrag(struct seq_file *m, void *data) >+{ >+ struct xe_device *xe = node_to_xe(m->private); >+ struct drm_printer p = drm_seq_file_printer(m); >+ >+ return xe_bo_defrag_print(xe, &p); >+} >+ > static const struct drm_info_list debugfs_list[] = { > {"info", info, 0}, > { .name = "sriov_info", .show = sriov_info, }, > { .name = "workarounds", .show = workaround_info, }, > { .name = "pagefault_info", .show = pagefault_info, }, >+ { .name = "bo_defrag", .show = bo_defrag, }, > }; > > static const struct drm_info_list pcode_info_debugfs[] = { >-- >2.34.1 >