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 AD55A606A32D for ; Thu, 3 Dec 2026 18:27:21 +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=jPhkr+fu Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 70A9D10E0DB; Thu, 3 Dec 2026 18:27:16 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A6AB10E0DB; Thu, 3 Dec 2026 18:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796322430; x=1827858430; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=CrUefrr/xcvypmYbfhpL+HoqpfCcLGbPNudw0+pAk40=; b=jPhkr+fuP2wPtG1IpD7Xnm1rrPh1mIq3eeDR1YFFHZ8hnkR1Gv7h/Hg3 XSXMm68r9DKkawB4h4mBnnBcIGBkN5kPG0rWHtxQR38JqiuVzUfspUGRg sbjqph8GmQxb+8aecBdPm6YL+F+1RQWRj+CfrN2D8eEcnj0wvPP+MNUVt 7SFJUtiCUR7AeZrsMGA4WuFiJY6gwLqwGACyDb/LppyvjuT6Y1QPkcZ49 qnqcwZGIsxeCR8BCsc1FNZa+x3P9OEUVqHZrHZIysjkNB7L/agE2xOibb qusiRH4IXk+hwHUoB9hgqB2nkIc67BSSLquLgLosUjKzbZgs+Xh9anuRD w==; X-CSE-ConnectionGUID: MgHJv+G3QOuGJa2R4Afi7w== X-CSE-MsgGUID: FpLKUVh3Qj62Ih9QVs9jqg== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5267553" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5267553" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 10:27:08 -0800 X-CSE-ConnectionGUID: R+2A6ATATCGneZZA7s77EQ== X-CSE-MsgGUID: 01ZrjVKySM+IUPS8aQ+yoA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="13795071" Received: from fmsmsx902.amr.corp.intel.com ([10.18.126.91]) by orviesa006.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 10:27:08 -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.57; Thu, 3 Dec 2026 10:27:07 -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.57 via Frontend Transport; Thu, 3 Dec 2026 10:27:07 -0800 Received: from DM1PR04CU001.outbound.protection.outlook.com (52.101.61.56) 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 10:27:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nWD8B29mjR8KT0WLqu3NUzkWS8N5Q+LSejr+G5iwHn2+5CKskdDhPYFhOyvQtOu0NolbJSWUrVNjBg8xIdjEObf+UxVS2W+hOx1kbmJ4iArHQehHHfTHBbWqSFEuifxrrVTJhfe3/b6IHJ6U99IZVsnL8/odCuRf3ufHDEOIsfKnnChRvCBDgNDD82dtv1l5SGo/R8cDmL+hqS8cMw4QYr/2I3YH+QrFGwwJn2WcuWiLpid9eKQ/cqDz8nIJMK+HnfOl6KMGXOA/shXv5QN26SArQD4bjy1OS8YK44NYuQqUjl6w+mUyJ2yNm3pQvIcOGUTXh2AS3nUtKHewBg4ZiQ== 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=NCaL0t10DLPZyIEJx80gK78bdDT+RrWwqJwU58VPCBY=; b=GnkaXZG/H57PRDYBuJagMOXU0q1SOeGgvAvFqgrIlUL6RYEuEkjEbdAMNMQBWxqPsdSImcdUnUwq2YtEFjz6Q/TGkakWyLgUMLGaxMMheHUQpnz46WwIrBDvcA6uOIIvyxVbrcV4bJgdRz5DIG6ItEb2EFmLttLiGc/Rjbc8AZJxZ3EpF7GcdrbhGdETQtrcQ8HV6Ws8ksOMsWBV6kZNTC3AkI5e3qddHXO2AM9zDTu7GMAiP7EQkxDgr1BSta2XKfP3KlSe3G03gNi9fla1B29yxf7JeeRi1592vqc+OkKxojG+rSoT8MvST+LTebMUKY5e3r5U5BYhMQfitDXQcg== 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 IA3PR11MB8987.namprd11.prod.outlook.com (2603:10b6:208:574::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Thu, 3 Dec 2026 18:27:02 +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.011; Thu, 3 Dec 2026 18:27:02 +0000 Date: Thu, 3 Dec 2026 10:26:59 -0800 From: Matthew Brost To: Niranjana Vishwanathapura 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 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: BY3PR10CA0026.namprd10.prod.outlook.com (2603:10b6:a03:255::31) 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_|IA3PR11MB8987:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f0e1275-2cc6-4b78-9950-08df516b0653 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|366016|23010399003|376014|1800799024|11063799006|4143699003|6133799003|261009223027099003|22082099003|18002099003|3023799007|10067099003|56012099006|261102123227099003|261028144727099003|261022105027099003|261021121427099003|261021123027099003|261026140227099003|261026121527099003|261022075727099003; X-Microsoft-Antispam-Message-Info: UrvWihtnwqMvvwCZnEjsgcg+jXki8HX/+jRy2vopYufx1234G4G9W4OZql6fAQedFu0HbICrM2YgOfneJOuwV6BYw/8t7sMUiC6ApGRHsRWqLSYPI7XB36LyDa+t+XeBYQlB0DtTgiFkuFmVpCSgs6eju5r3zY8ErIc3A+mLBBoE4GtPzUL2+WHxK8sqZzXrABTJLxkEp4/XlnYb9PqK/fo8aZ3AcGiCwYhOaXirsyEd47FKYzQINqJ+8DBmZGiQSI1aOvf1Ajt7TRX1cB2DIVqjImRjYHb/G+sQ6F4KHpVRLg3Rem20c/ZQjNUEFFijGRBWJdwZx3G5PqbjhacepcGSyiDz14bwGZf7nyFbtxmNEwycQr66TRUyZYGrhchhUeRsBWQeBNTPMFKcKbb9XDzi+Z5UWzJOvKYIUGhViX7/ObbXTU2YLlQNqBjJD2vFG3dymLd2nIZc//4g0Ke4Q4AxuVZPXn3OXf12SWV/dz1lFdPBum8ghI6eMRrQMaH7CLfdOsMq/8qh8pOOMsC/DO4qWof5pzaO/ThhdOt/HUg3IPZS5VzWPAD9wpqcfruQ7FhQFI5/9VD42Rhp6rp74fHRQZeCA916CkUz3jhFJyDfvOqFOtrkOdO9V2Hs6jwpQGP/vwUP72hrnHMNEF5Xjqr89XG3VzjNx0zouZ3NMgY= 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)(366016)(23010399003)(376014)(1800799024)(11063799006)(4143699003)(6133799003)(261009223027099003)(22082099003)(18002099003)(3023799007)(10067099003)(56012099006)(261102123227099003)(261028144727099003)(261022105027099003)(261021121427099003)(261021123027099003)(261026140227099003)(261026121527099003)(261022075727099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?sLbKhhp1A3hVsn8YIxzPByA+bWhm0nUhcb6Ibu2nty4zZuVGJoVl0JhW8l?= =?iso-8859-1?Q?Tla9z28NOj6lC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0PpoyrZjeFtoN+eIDJ44HI=3D?= X-Exchange-RoutingPolicyChecked: pXAnG0kxgyadvncPUpq/U/E+oXapcKYj7ZZPJbUpfhfMvHO2DRtHqYnVPVE1I6Jpveh9M8k4MlokOyrfQPxsISzpp4rHLNCv9SUMKbc/WzBqvSPRGyKI0Ryi8BHoVJ36DIt5NvNHJRMV4nqc5w39JU71r3N/XPddJLGZc1V5ll0vpEf4ojStDGW/nPsmaKbOokYUNQuF1RxrowasMR5Op8+VrkbHHsDI/OF68V3bU1G5XFzWKb9xDpAbDYgm1+T8eRwGd1EOnM8fvZZjd9RL3zkgS0kyYgqcnirTyOpoAOWrr748wNTXiZiepoLScXy/lrrXQpsNIMo5kM43mCeBPQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 4f0e1275-2cc6-4b78-9950-08df516b0653 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 18:27:02.1424 (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: gKgBknL/7GJLAvy+1x0TnKPLIS62wn/Z72mHgrU3pL/LzFkWJ0Z0XNL+o/Hg35RLZo+yWltYLx2L6sOgdA5+sA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR11MB8987 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=ham 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 Thu, Dec 03, 2026 at 09:35:23AM -0800, Niranjana Vishwanathapura wrote: > 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? > The only way the locking can fail is on user signal (e.g., ctrl-c), once this occurs we should stop what we are doing and abort. I don't think we need to over engineer this case and partial print is fine. Matt > > + 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 > >