From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: "Carlos Santa" <carlos.santa@intel.com>,
"Ryan Neph" <ryanneph@google.com>,
"Matthew Auld" <matthew.auld@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Natalie Vock" <nat@pixelcluster.dev>,
"Arun Pravin" <arunpravin.paneerselvam@amd.com>,
Copilot <223556219+Copilot@users.noreply.github.com>
Subject: [PATCH v4 33/33] drm/xe: Make BO defrag tunables configurable via sysfs
Date: Tue, 1 Dec 2026 15:49:15 -0800 [thread overview]
Message-ID: <20261201234915.3305331-34-matthew.brost@intel.com> (raw)
In-Reply-To: <20261201234915.3305331-1-matthew.brost@intel.com>
The BO defrag per-run size limit, default worker interval and maximum
backed off worker interval are currently fixed at build time via
Kconfig. Tuning them requires a rebuild, which makes experimenting with
defrag behaviour on a running system painful.
Add defrag_size_limit, defrag_interval_ms and defrag_interval_max_ms
device sysfs attributes, defaulting to the Kconfig values. Writes are
validated against the Kconfig ranges, the size limit must be 2M aligned,
and the default interval may not exceed the maximum interval. Lowering
the size limit below 2M (disabling defrag) remains a build time only
decision, so the attributes are only exposed when defrag is supported.
Report the runtime values in the bo_defrag debugfs entry.
Cc: Carlos Santa <carlos.santa@intel.com>
Cc: Ryan Neph <ryanneph@google.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Natalie Vock <nat@pixelcluster.dev>
Cc: Arun Pravin <arunpravin.paneerselvam@amd.com>
Assisted-by: LLM
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
drivers/gpu/drm/xe/Kconfig.profile | 9 +-
drivers/gpu/drm/xe/xe_bo.c | 136 +++++++++++++++++++++++----
drivers/gpu/drm/xe/xe_bo.h | 5 +
drivers/gpu/drm/xe/xe_device_sysfs.c | 122 ++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_device_types.h | 24 ++++-
5 files changed, 273 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/xe/Kconfig.profile b/drivers/gpu/drm/xe/Kconfig.profile
index 32bc358e6968..ea46e34e3957 100644
--- a/drivers/gpu/drm/xe/Kconfig.profile
+++ b/drivers/gpu/drm/xe/Kconfig.profile
@@ -115,7 +115,9 @@ config DRM_XE_BO_DEFRAG_SIZE_LIMIT
number of BOs become eligible at once, processing them all in one
worker run would hold things up for a long, unbounded stretch.
Instead, cap the work done per run and requeue, spreading the defrag
- effort out over time.
+ effort out over time. This is the default; when defrag is enabled it
+ can be changed at runtime (2M to 1G) via the defrag_size_limit
+ device sysfs attribute.
config DRM_XE_BO_DEFRAG_INTERVAL_MS
int "Default delay before defrag worker run (ms)"
@@ -123,6 +125,8 @@ config DRM_XE_BO_DEFRAG_INTERVAL_MS
range 1 1000
help
Default delay before (re)running the defrag worker, in milliseconds.
+ Can be changed at runtime via the defrag_interval_ms device sysfs
+ attribute.
config DRM_XE_BO_DEFRAG_INTERVAL_MAX_MS
int "Upper bound for defrag worker interval (ms)"
@@ -131,4 +135,5 @@ config DRM_XE_BO_DEFRAG_INTERVAL_MAX_MS
help
Upper bound for the (exponentially backed off) defrag worker interval,
in milliseconds, so repeated failures don't push the retry arbitrarily
- far out. 15000 ms = 15 seconds.
+ far out. 15000 ms = 15 seconds. Can be changed at runtime via the
+ defrag_interval_max_ms device sysfs attribute.
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 9c218b03210a..165453328931 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -93,6 +93,12 @@
#define XE_BO_DEFRAG_INTERVAL_MAX_MS 15000 /* 15 seconds */
#endif
+/* Bounds for the values tunable at runtime via sysfs. */
+#define XE_BO_DEFRAG_SIZE_LIMIT_MAX SZ_1G
+#define XE_BO_DEFRAG_INTERVAL_MS_MAX 1000
+#define XE_BO_DEFRAG_INTERVAL_MAX_MS_MIN 100
+#define XE_BO_DEFRAG_INTERVAL_MAX_MS_MAX 1000000
+
static void xe_bo_defrag_worker(struct work_struct *w);
static void xe_place_from_ttm_type(u32 mem_type, struct ttm_place *place);
@@ -1689,8 +1695,6 @@ static struct ttm_tt *xe_ttm_tt_create(struct ttm_buffer_object *ttm_bo,
return tt;
}
-static bool xe_bo_defrag_supported(struct xe_device *xe);
-
static int xe_ttm_tt_populate(struct ttm_device *ttm_dev, struct ttm_tt *tt,
struct ttm_operation_ctx *ctx)
{
@@ -2239,6 +2243,9 @@ int xe_bo_defrag_init_early(struct xe_device *xe)
spin_lock_init(&xe->mem.defrag.lock);
INIT_LIST_HEAD(&xe->mem.defrag.list);
+ xe->mem.defrag.size_limit = XE_BO_DEFRAG_SIZE_LIMIT;
+ xe->mem.defrag.interval_default_ms = XE_BO_DEFRAG_INTERVAL_MS;
+ xe->mem.defrag.interval_max_ms = XE_BO_DEFRAG_INTERVAL_MAX_MS;
xe->mem.defrag.interval_ms = XE_BO_DEFRAG_INTERVAL_MS;
INIT_DELAYED_WORK(&xe->mem.defrag.worker, xe_bo_defrag_worker);
@@ -2299,7 +2306,8 @@ void xe_bo_defrag_resume(struct xe_device *xe)
scoped_guard(spinlock, &xe->mem.defrag.lock) {
if (!list_empty(&xe->mem.defrag.list)) {
- xe->mem.defrag.interval_ms = XE_BO_DEFRAG_INTERVAL_MS;
+ xe->mem.defrag.interval_ms =
+ xe->mem.defrag.interval_default_ms;
kick = true;
}
}
@@ -2308,23 +2316,105 @@ void xe_bo_defrag_resume(struct xe_device *xe)
xe_bo_defrag_schedule(xe);
}
-/*
+/**
* xe_bo_defrag_supported() - Whether background defragmentation is usable
* @xe: xe device instance
*
- * Defragmentation is not supported if XE_BO_DEFRAG_SIZE_LIMIT is less than 2M.
+ * Defragmentation is not supported if the default size limit
+ * (CONFIG_DRM_XE_BO_DEFRAG_SIZE_LIMIT) is less than 2M. The runtime size limit
+ * can't be lowered below 2M, so it can't change whether defragmentation is
+ * supported.
*
* Defragmentation forces TTM moves that reallocate a BO's backing. On a VF with
* CCS save/restore enabled this interacts badly with CCS metadata migration
* (which is currently broken for VF migration), so disable it there: gate BOs
* out of the defrag list and skip the up-front reclaim backoff that assumes a
* later in-place upgrade.
+ *
+ * Return: true if background defragmentation is supported, false otherwise.
*/
-static bool xe_bo_defrag_supported(struct xe_device *xe)
+bool xe_bo_defrag_supported(struct xe_device *xe)
{
return XE_BO_DEFRAG_SIZE_LIMIT >= SZ_2M && !IS_VF_CCS_READY(xe);
}
+/**
+ * xe_bo_defrag_set_size_limit() - Set the defrag worker per-run byte budget
+ * @xe: xe device instance
+ * @size_limit: New maximum number of bytes to defrag per worker run
+ *
+ * Takes effect from the next worker run.
+ *
+ * Return: 0 on success, -EINVAL if @size_limit is out of range or not 2M
+ * aligned.
+ */
+int xe_bo_defrag_set_size_limit(struct xe_device *xe, u64 size_limit)
+{
+ if (size_limit < SZ_2M || size_limit > XE_BO_DEFRAG_SIZE_LIMIT_MAX ||
+ !IS_ALIGNED(size_limit, SZ_2M))
+ return -EINVAL;
+
+ WRITE_ONCE(xe->mem.defrag.size_limit, size_limit);
+
+ return 0;
+}
+
+/**
+ * xe_bo_defrag_set_interval_ms() - Set the default defrag worker interval
+ * @xe: xe device instance
+ * @interval_ms: New default delay before (re)running the defrag worker
+ *
+ * The new value is used the next time the worker interval is reset, i.e. on
+ * forward progress or when the defrag list transitions to non-empty.
+ *
+ * Return: 0 on success, -EINVAL if @interval_ms is out of range or exceeds
+ * the maximum interval.
+ */
+int xe_bo_defrag_set_interval_ms(struct xe_device *xe, unsigned int interval_ms)
+{
+ if (!interval_ms || interval_ms > XE_BO_DEFRAG_INTERVAL_MS_MAX)
+ return -EINVAL;
+
+ guard(spinlock)(&xe->mem.defrag.lock);
+
+ if (interval_ms > xe->mem.defrag.interval_max_ms)
+ return -EINVAL;
+
+ WRITE_ONCE(xe->mem.defrag.interval_default_ms, interval_ms);
+
+ return 0;
+}
+
+/**
+ * xe_bo_defrag_set_interval_max_ms() - Set the maximum defrag worker interval
+ * @xe: xe device instance
+ * @interval_max_ms: New upper bound for the backed off worker interval
+ *
+ * The current interval is clamped to the new maximum, taking effect the next
+ * time the worker is scheduled.
+ *
+ * Return: 0 on success, -EINVAL if @interval_max_ms is out of range or is
+ * less than the default interval.
+ */
+int xe_bo_defrag_set_interval_max_ms(struct xe_device *xe,
+ unsigned int interval_max_ms)
+{
+ if (interval_max_ms < XE_BO_DEFRAG_INTERVAL_MAX_MS_MIN ||
+ interval_max_ms > XE_BO_DEFRAG_INTERVAL_MAX_MS_MAX)
+ return -EINVAL;
+
+ guard(spinlock)(&xe->mem.defrag.lock);
+
+ if (interval_max_ms < xe->mem.defrag.interval_default_ms)
+ return -EINVAL;
+
+ WRITE_ONCE(xe->mem.defrag.interval_max_ms, interval_max_ms);
+ xe->mem.defrag.interval_ms = min(xe->mem.defrag.interval_ms,
+ interval_max_ms);
+
+ return 0;
+}
+
static bool xe_bo_needs_defrag(struct xe_bo *bo)
{
struct ttm_buffer_object *ttm_bo = &bo->ttm;
@@ -2355,7 +2445,8 @@ static void xe_bo_defrag_add(struct xe_bo *bo)
/* Kick the worker when the list transitions to non-empty. */
kick = list_empty(&xe->mem.defrag.list);
if (kick)
- xe->mem.defrag.interval_ms = XE_BO_DEFRAG_INTERVAL_MS;
+ xe->mem.defrag.interval_ms =
+ xe->mem.defrag.interval_default_ms;
list_add_tail(&bo->defrag_link, &xe->mem.defrag.list);
xe_gt_stats_incr(xe_root_mmio_gt(xe),
XE_GT_STATS_ID_DEFRAG_ADDED_COUNT, 1);
@@ -2433,7 +2524,7 @@ 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;
+ unsigned int interval_ms, interval_default_ms, interval_max_ms;
struct xe_bo **bos, *bo;
int err = 0;
@@ -2444,15 +2535,18 @@ int xe_bo_defrag_print(struct xe_device *xe, struct drm_printer *p)
scoped_guard(spinlock, &xe->mem.defrag.lock) {
interval_ms = xe->mem.defrag.interval_ms;
+ interval_default_ms = xe->mem.defrag.interval_default_ms;
+ interval_max_ms = xe->mem.defrag.interval_max_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, "size_limit: %llu\n",
+ READ_ONCE(xe->mem.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);
+ interval_default_ms, interval_max_ms);
if (delayed_work_pending(dwork)) {
long delay = (long)(READ_ONCE(dwork->timer.expires) - jiffies);
@@ -2662,6 +2756,7 @@ static void xe_bo_defrag_worker(struct work_struct *w)
struct delayed_work *dwork = to_delayed_work(w);
struct xe_device *xe =
container_of(dwork, struct xe_device, mem.defrag.worker);
+ u64 size_limit = READ_ONCE(xe->mem.defrag.size_limit);
u64 defrag_bytes = 0;
bool requeue = false;
int idx;
@@ -2683,7 +2778,7 @@ static void xe_bo_defrag_worker(struct work_struct *w)
trace_xe_bo_defrag_worker(xe, 0, true);
/*
- * Process at most XE_BO_DEFRAG_SIZE_LIMIT bytes of newly (re)allocated
+ * Process at most @mem.defrag.size_limit bytes of newly (re)allocated
* backing per run rather than draining the whole list in one go. Only
* the pages a move actually reallocates are charged - pages harvested
* (borrowed) from the old backing are free and do not count - so the
@@ -2694,7 +2789,7 @@ static void xe_bo_defrag_worker(struct work_struct *w)
* active work make progress; any remaining work is handled by a
* follow-up run scheduled below.
*/
- while (defrag_bytes < XE_BO_DEFRAG_SIZE_LIMIT) {
+ while (defrag_bytes < size_limit) {
struct xe_bo *first, *bo;
u64 consumed = 0;
bool needs_more = false;
@@ -2705,7 +2800,8 @@ static void xe_bo_defrag_worker(struct work_struct *w)
/* Progress, reset interval */
if (defrag_bytes)
- xe->mem.defrag.interval_ms = XE_BO_DEFRAG_INTERVAL_MS;
+ xe->mem.defrag.interval_ms =
+ xe->mem.defrag.interval_default_ms;
do {
first = list_first_entry_or_null(&xe->mem.defrag.list,
@@ -2728,7 +2824,7 @@ static void xe_bo_defrag_worker(struct work_struct *w)
* beneficial harvests, so each run only spends budget on new
* forward progress.
*/
- ret = xe_bo_defrag_one(xe, bo, XE_BO_DEFRAG_SIZE_LIMIT - defrag_bytes,
+ ret = xe_bo_defrag_one(xe, bo, size_limit - defrag_bytes,
&consumed, &needs_more);
defrag_bytes += consumed;
@@ -2742,10 +2838,11 @@ static void xe_bo_defrag_worker(struct work_struct *w)
*/
xe->mem.defrag.interval_ms =
min(xe->mem.defrag.interval_ms * 2,
- (unsigned int)XE_BO_DEFRAG_INTERVAL_MAX_MS);
+ xe->mem.defrag.interval_max_ms);
else
/* Progress, reset interval */
- xe->mem.defrag.interval_ms = XE_BO_DEFRAG_INTERVAL_MS;
+ xe->mem.defrag.interval_ms =
+ xe->mem.defrag.interval_default_ms;
}
xe_bo_put(bo);
@@ -2760,7 +2857,7 @@ static void xe_bo_defrag_worker(struct work_struct *w)
* Decide whether to reschedule:
*
* - The loop hit its per-run limit (defrag_bytes >=
- * XE_BO_DEFRAG_SIZE_LIMIT): we stopped early to spread the work out,
+ * size_limit): we stopped early to spread the work out,
* so requeue at the default interval (reset here since this run made
* progress) whenever the list still has entries.
*
@@ -2770,13 +2867,14 @@ static void xe_bo_defrag_worker(struct work_struct *w)
* - The loop drained the list (broke on the empty list): nothing left to
* do, so stop scheduling. A fresh enqueue will kick the worker again.
*/
- if (defrag_bytes >= XE_BO_DEFRAG_SIZE_LIMIT) {
+ if (defrag_bytes >= size_limit) {
struct xe_bo *bo;
scoped_guard(spinlock, &xe->mem.defrag.lock) {
bo = list_first_entry_or_null(&xe->mem.defrag.list,
struct xe_bo, defrag_link);
- xe->mem.defrag.interval_ms = XE_BO_DEFRAG_INTERVAL_MS;
+ xe->mem.defrag.interval_ms =
+ xe->mem.defrag.interval_default_ms;
}
if (bo)
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index d0e72d244eae..ef6d21d91724 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -239,6 +239,11 @@ void xe_bo_unpin_account(struct xe_bo *bo);
int xe_bo_defrag_init_early(struct xe_device *xe);
int xe_bo_defrag_init(struct xe_device *xe);
void xe_bo_defrag_resume(struct xe_device *xe);
+bool xe_bo_defrag_supported(struct xe_device *xe);
+int xe_bo_defrag_set_size_limit(struct xe_device *xe, u64 size_limit);
+int xe_bo_defrag_set_interval_ms(struct xe_device *xe, unsigned int interval_ms);
+int xe_bo_defrag_set_interval_max_ms(struct xe_device *xe,
+ unsigned int interval_max_ms);
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_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c
index 9b734aeefd33..c94592576408 100644
--- a/drivers/gpu/drm/xe/xe_device_sysfs.c
+++ b/drivers/gpu/drm/xe/xe_device_sysfs.c
@@ -11,6 +11,7 @@
#include <linux/sysfs.h>
#include "regs/xe_regs.h"
+#include "xe_bo.h"
#include "xe_device.h"
#include "xe_device_sysfs.h"
#include "xe_mmio.h"
@@ -56,6 +57,24 @@
* back it up. BOs evicted to system memory are never protected. Defaults to
* CONFIG_DRM_XE_SHRINKER_MIN_AGE_MS, 0 disables. This applies at every
* reclaim priority, so a non-zero value can lead to OOM.
+ *
+ * defrag_size_limit - Report/change the maximum number of bytes the BO
+ * defragmentation worker reallocates per run. Valid values are 2M aligned,
+ * 2M to 1G.
+ * Defaults to CONFIG_DRM_XE_BO_DEFRAG_SIZE_LIMIT. Exposed only if BO
+ * defragmentation is supported.
+ *
+ * defrag_interval_ms - Report/change the default delay, in milliseconds,
+ * before (re)running the BO defragmentation worker. Valid values are 1 to
+ * 1000 and must not exceed defrag_interval_max_ms. Defaults to
+ * CONFIG_DRM_XE_BO_DEFRAG_INTERVAL_MS. Exposed only if BO defragmentation is
+ * supported.
+ *
+ * defrag_interval_max_ms - Report/change the upper bound, in milliseconds, of
+ * the exponentially backed off BO defragmentation worker interval. Valid
+ * values are 100 to 1000000 and must not be less than defrag_interval_ms.
+ * Defaults to CONFIG_DRM_XE_BO_DEFRAG_INTERVAL_MAX_MS. Exposed only if BO
+ * defragmentation is supported.
*/
static ssize_t
@@ -428,6 +447,103 @@ static const struct attribute_group userptr_attr_group = {
.attrs = userptr_attrs,
};
+static ssize_t
+defrag_size_limit_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
+
+ return sysfs_emit(buf, "%llu\n", READ_ONCE(xe->mem.defrag.size_limit));
+}
+
+static ssize_t
+defrag_size_limit_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
+ u64 size_limit;
+ int ret;
+
+ ret = kstrtou64(buf, 0, &size_limit);
+ if (ret)
+ return ret;
+
+ ret = xe_bo_defrag_set_size_limit(xe, size_limit);
+
+ return ret ?: count;
+}
+
+static DEVICE_ATTR_RW(defrag_size_limit);
+
+static ssize_t
+defrag_interval_ms_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
+
+ return sysfs_emit(buf, "%u\n",
+ READ_ONCE(xe->mem.defrag.interval_default_ms));
+}
+
+static ssize_t
+defrag_interval_ms_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
+ unsigned int interval_ms;
+ int ret;
+
+ ret = kstrtouint(buf, 0, &interval_ms);
+ if (ret)
+ return ret;
+
+ ret = xe_bo_defrag_set_interval_ms(xe, interval_ms);
+
+ return ret ?: count;
+}
+
+static DEVICE_ATTR_RW(defrag_interval_ms);
+
+static ssize_t
+defrag_interval_max_ms_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
+
+ return sysfs_emit(buf, "%u\n",
+ READ_ONCE(xe->mem.defrag.interval_max_ms));
+}
+
+static ssize_t
+defrag_interval_max_ms_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
+ unsigned int interval_max_ms;
+ int ret;
+
+ ret = kstrtouint(buf, 0, &interval_max_ms);
+ if (ret)
+ return ret;
+
+ ret = xe_bo_defrag_set_interval_max_ms(xe, interval_max_ms);
+
+ return ret ?: count;
+}
+
+static DEVICE_ATTR_RW(defrag_interval_max_ms);
+
+static struct attribute *defrag_attrs[] = {
+ &dev_attr_defrag_size_limit.attr,
+ &dev_attr_defrag_interval_ms.attr,
+ &dev_attr_defrag_interval_max_ms.attr,
+ NULL
+};
+
+static const struct attribute_group defrag_attr_group = {
+ .attrs = defrag_attrs,
+};
+
int xe_device_sysfs_init(struct xe_device *xe)
{
struct device *dev = xe->drm.dev;
@@ -441,6 +557,12 @@ int xe_device_sysfs_init(struct xe_device *xe)
if (ret)
return ret;
+ if (xe_bo_defrag_supported(xe)) {
+ ret = devm_device_add_group(dev, &defrag_attr_group);
+ if (ret)
+ return ret;
+ }
+
if (xe->d3cold.capable) {
ret = devm_device_add_group(dev, &vram_attr_group);
if (ret)
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 07aa84888d4a..252dc42e063f 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -345,10 +345,30 @@ struct xe_device {
*/
struct delayed_work worker;
/**
- * @mem.defrag.interval_ms: Reschedule interval for
- * @mem.defrag.worker, in milliseconds.
+ * @mem.defrag.interval_ms: Current (possibly backed off)
+ * reschedule interval for @mem.defrag.worker, in
+ * milliseconds. Protected by @mem.defrag.lock.
*/
unsigned int interval_ms;
+ /**
+ * @mem.defrag.interval_default_ms: Interval that
+ * @mem.defrag.interval_ms is reset to on forward progress,
+ * in milliseconds. Tunable via sysfs. Written under
+ * @mem.defrag.lock.
+ */
+ unsigned int interval_default_ms;
+ /**
+ * @mem.defrag.interval_max_ms: Upper bound for the
+ * backed off @mem.defrag.interval_ms, in milliseconds.
+ * Tunable via sysfs. Written under @mem.defrag.lock.
+ */
+ unsigned int interval_max_ms;
+ /**
+ * @mem.defrag.size_limit: Maximum number of newly
+ * (re)allocated bytes the worker defrags per run.
+ * Tunable via sysfs.
+ */
+ u64 size_limit;
/**
* @mem.defrag.iova_sched: Dependency scheduler used to
* run the post-copy IOVA finalize job for defrag moves
--
2.34.1
next prev parent reply other threads:[~2026-12-01 23:50 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 23:48 [PATCH v4 00/33] drm/ttm, drm/xe: Avoid foreground high-order reclaim and defragment sub-optimally backed BOs Matthew Brost
2026-12-01 23:48 ` [PATCH v4 01/33] drm/ttm/pool: Allow backing off reclaim at the beneficial order Matthew Brost
2026-12-01 23:48 ` [PATCH v4 02/33] drm/ttm/pool: Add ttm_pool_page_order_nodma() helper Matthew Brost
2026-12-01 23:48 ` [PATCH v4 03/33] drm/ttm: Record sub-optimal page order allocations in ttm_tt Matthew Brost
2026-12-01 23:48 ` [PATCH v4 04/33] drm/ttm: Introduce ttm_pool_alloc_iter for __ttm_pool_alloc() Matthew Brost
2026-12-01 23:59 ` sashiko-bot
2026-12-01 23:48 ` [PATCH v4 05/33] drm/ttm: Support defragmentation moves Matthew Brost
2026-12-01 23:48 ` [PATCH v4 06/33] drm/ttm: Add fault injection for beneficial-order allocation failures Matthew Brost
2026-12-01 23:48 ` [PATCH v4 07/33] drm/ttm: Harvest beneficial-order pages on defragmentation moves Matthew Brost
2026-12-01 23:48 ` [PATCH v4 08/33] drm/ttm: Bound page (re)allocation per defragmentation move Matthew Brost
2026-12-01 23:48 ` [PATCH v4 09/33] drm/ttm: Preallocate beneficial-order defrag pages outside the lock Matthew Brost
2026-12-01 23:48 ` [PATCH v4 10/33] drm/ttm: Add full out-of-lock preallocation for ttm_pool_alloc() Matthew Brost
2026-12-01 23:48 ` [PATCH v4 11/33] drm/gpusvm: Add a DMA-mapping accounting callback Matthew Brost
2026-12-01 23:48 ` [PATCH v4 12/33] drm/xe: Add debugfs stats for DMA-mapped pages per order Matthew Brost
2026-12-01 23:48 ` [PATCH v4 13/33] drm/xe: Flush L2 asynchronously in xe_bo_trigger_rebind() Matthew Brost
2026-12-01 23:48 ` [PATCH v4 14/33] drm/xe: Track BOs backed at a sub-optimal page order Matthew Brost
2026-12-01 23:48 ` [PATCH v4 15/33] drm/xe: Add xe_migrate_copy_defrag() for on-GPU defrag copies Matthew Brost
2026-12-01 23:48 ` [PATCH v4 16/33] drm/xe: Handle defrag moves in xe_bo_move() Matthew Brost
2026-12-01 23:48 ` [PATCH v4 17/33] drm/xe: Skip self-copies for borrowed pages on defrag moves Matthew Brost
2026-12-01 23:49 ` [PATCH v4 18/33] drm/xe: Add a page defragmentation worker Matthew Brost
2026-12-01 23:49 ` [PATCH v4 19/33] drm/xe: Add defrag GT stats Matthew Brost
2026-12-01 23:49 ` [PATCH v4 20/33] drm/xe: Add Kconfig.profile options for BO defrag configuration Matthew Brost
2026-12-01 23:49 ` [PATCH v4 21/33] drm/xe: Defrag using out-of-lock page preallocation Matthew Brost
2026-12-01 23:49 ` [PATCH v4 22/33] drm/xe: Add defrag profiling tracepoints Matthew Brost
2026-12-01 23:49 ` [PATCH v4 23/33] drm/xe: Preallocate system BO backing outside the dma-resv lock Matthew Brost
2026-12-01 23:49 ` [PATCH v4 24/33] drm/xe: Add tracepoint for xe_gem_create_ioctl Matthew Brost
2026-12-01 23:49 ` [PATCH v4 25/33] drm/xe: Add IOVA-based xe_res_cursor variant Matthew Brost
2026-12-01 23:49 ` [PATCH v4 26/33] drm/xe: Use IOVA-based DMA mapping for eligible tt BOs Matthew Brost
2026-12-01 23:49 ` [PATCH v4 27/33] drm/xe: Add per-device dependency scheduler for IOVA defrag finalize Matthew Brost
2026-12-01 23:49 ` [PATCH v4 28/33] drm/xe: Add packed copy-step IOVA mapping for defrag Matthew Brost
2026-12-01 23:49 ` [PATCH v4 29/33] drm/xe: Blit src-natural to dst-packed for defrag-IOVA copies Matthew Brost
2026-12-01 23:49 ` [PATCH v4 30/33] drm/xe: Finalize defrag-IOVA moves with post-copy job Matthew Brost
2026-12-01 23:49 ` [PATCH v4 31/33] drm/xe: Grow the USM batch pool to 2M and map it via a single PDE Matthew Brost
2026-12-01 23:49 ` [PATCH v4 32/33] drm/xe: Add bo_defrag debugfs entry Matthew Brost
2026-12-01 23:49 ` Matthew Brost [this message]
2026-12-01 23:58 ` ✗ CI.checkpatch: warning for drm/ttm, drm/xe: Avoid foreground high-order reclaim and defragment sub-optimally backed BOs Patchwork
2026-12-02 0:00 ` ✓ CI.KUnit: success " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201234915.3305331-34-matthew.brost@intel.com \
--to=matthew.brost@intel.com \
--cc=223556219+Copilot@users.noreply.github.com \
--cc=arunpravin.paneerselvam@amd.com \
--cc=carlos.santa@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=nat@pixelcluster.dev \
--cc=ryanneph@google.com \
--cc=thomas.hellstrom@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox