From: "Yadav, Arvind" <arvind.yadav@intel.com>
To: Tejas Upadhyay <tejas.upadhyay@intel.com>,
<intel-xe@lists.freedesktop.org>
Cc: <himal.prasad.ghimiray@intel.com>, <matthew.brost@intel.com>
Subject: Re: [PATCH V3 1/3] drm/xe/vram: add decay-based reinstatement of soft-offlined VRAM pages
Date: Mon, 30 Nov 2026 14:54:39 +0530 [thread overview]
Message-ID: <764028c2-d0f3-4d56-9a85-a2ee440f5b7a@intel.com> (raw)
In-Reply-To: <158dae12-29ea-4b74-be54-48bbe4d35aff@intel.com>
On 30-11-2026 14:44, Yadav, Arvind wrote:
>
> On 26-11-2026 16:15, Tejas Upadhyay wrote:
>> The existing bad-page flow soft-offlines a VRAM page on the first HW
>> report and promotes it to a permanent (hard) retirement on the second
>> report at the same address. Once soft-offlined a page stays offline
>> forever, which over-punishes transient DBE errors: a single hit caused
>> by a one-off environmental disturbance keeps the page reserved until
>> the next reboot / probe.
>>
>> This change adds a per VRAM-manager decay timer so that a SOFT-offlined
>> page is automatically reinstated after the configured decay window
>> (default 24 hours) of no further reports at that address. HARD-offlined
>> pages continue to be permanent.
>>
>> Also adds the xe_page_offline_mode enum (SOFT/HARD) and per-entry mode
>> tracking with SOFT->HARD promotion on second hit at the same address.
>>
>> Configuration via configfs bad_page_decay_secs (default 86400, 0
>> disables).
>>
>> IGT coverage:
>> https://patchwork.freedesktop.org/patch/765064/
>>
>> v3:
>> - Arm decay_gc_work when a queued (previously busy) page is promoted
>> to offlined in xe_ttm_vram_retry_queued_pages(), not just on the
>> immediate-offline path (review comment).
>> - Also promote queued_pages entries SOFT->HARD on a repeat fault,
>> mirroring the offlined_pages promotion (review comment).
>> - Fix xe_ttm_vram_decay_gc_period() so the 60s floor clamp can never
>> push the poll period above the configured decay interval itself
>> (review comment).
>
>
> LGTM.
> Reviewed-by: Arvind Yadav <arvind.yadav@intel.com>
>
>>
>> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
>> ---
>> drivers/gpu/drm/xe/xe_configfs.c | 55 +++++++++++++++
>> drivers/gpu/drm/xe/xe_configfs.h | 1 +
>> drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 80 +++++++++++++++++++++-
>> drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h | 16 +++++
>> 4 files changed, 150 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_configfs.c
>> b/drivers/gpu/drm/xe/xe_configfs.c
>> index 801b22fe3c36..7133e69d790e 100644
>> --- a/drivers/gpu/drm/xe/xe_configfs.c
>> +++ b/drivers/gpu/drm/xe/xe_configfs.c
>> @@ -313,6 +313,7 @@ struct xe_config_group_device {
>> bool enable_psmi;
>> bool enable_multi_queue;
>> bool disable_vram_page_offline;
>> + u32 bad_page_decay_secs;
>> struct {
>> unsigned int max_vfs;
>> bool admin_only_pf;
>> @@ -336,6 +337,7 @@ static const struct xe_config_device
>> device_defaults = {
>> .enable_psmi = false,
>> .enable_multi_queue = true,
>> .disable_vram_page_offline = false,
>> + .bad_page_decay_secs = 24 * 60 * 60,
>> .sriov = {
>> .max_vfs = XE_DEFAULT_MAX_VFS,
>> .admin_only_pf = XE_DEFAULT_ADMIN_ONLY_PF,
>> @@ -737,6 +739,36 @@ static ssize_t
>> disable_vram_page_offline_store(struct config_item *item,
>> return len;
>> }
>> +static ssize_t bad_page_decay_secs_show(struct config_item *item,
>> char *page)
>> +{
>> + struct xe_config_group_device *dev =
>> to_xe_config_group_device(item);
>> +
>> + return sprintf(page, "%u\n", dev->config.bad_page_decay_secs);
>> +}
>> +
>> +static ssize_t bad_page_decay_secs_store(struct config_item *item,
>> + const char *page, size_t len)
>> +{
>> + struct xe_config_group_device *dev =
>> to_xe_config_group_device(item);
>> + u32 val;
>> + int ret;
>> +
>> + ret = kstrtou32(page, 0, &val);
>> + if (ret)
>> + return ret;
>> +
>> + if (val > jiffies_to_msecs(MAX_JIFFY_OFFSET) / 1000)
val is already in seconds. Can we compare it directly with
MAX_JIFFY_OFFSET / HZ? Converting the limit to milliseconds first can
make it too small and it could reject valid timeouts. When converting
val to jiffies, We can use (unsigned long)val * HZ to avoid 32-bit overflow.
Thanks,
Arvind.
>> + return -EINVAL;
>> +
>> + guard(mutex)(&dev->lock);
>> + if (is_bound(dev))
>> + return -EBUSY;
>> +
>> + dev->config.bad_page_decay_secs = val;
>> +
>> + return len;
>> +}
>> +
>> static bool wa_bb_read_advance(bool dereference, char **p,
>> const char *append, size_t len,
>> size_t *max_size)
>> @@ -978,6 +1010,7 @@ CONFIGFS_ATTR(, enable_multi_queue);
>> CONFIGFS_ATTR(, migrate_ulls_period_ms);
>> CONFIGFS_ATTR(, enable_psmi);
>> CONFIGFS_ATTR(, disable_vram_page_offline);
>> +CONFIGFS_ATTR(, bad_page_decay_secs);
>> CONFIGFS_ATTR(, engines_allowed);
>> CONFIGFS_ATTR(, gt_types_allowed);
>> CONFIGFS_ATTR(, survivability_mode);
>> @@ -990,6 +1023,7 @@ static struct configfs_attribute
>> *xe_config_device_attrs[] = {
>> &attr_migrate_ulls_period_ms,
>> &attr_enable_psmi,
>> &attr_disable_vram_page_offline,
>> + &attr_bad_page_decay_secs,
>> &attr_engines_allowed,
>> &attr_gt_types_allowed,
>> &attr_survivability_mode,
>> @@ -1279,6 +1313,7 @@ static void dump_custom_dev_config(struct
>> pci_dev *pdev,
>> PRI_CUSTOM_ATTR("%d", enable_multi_queue);
>> PRI_CUSTOM_ATTR("%d", enable_psmi);
>> PRI_CUSTOM_ATTR("%d", disable_vram_page_offline);
>> + PRI_CUSTOM_ATTR("%u", bad_page_decay_secs);
>> PRI_CUSTOM_ATTR("%d", survivability_mode);
>> PRI_CUSTOM_ATTR("%d", force_ocode_load);
>> PRI_CUSTOM_ATTR("%u", sriov.admin_only_pf);
>> @@ -1485,6 +1520,26 @@ bool
>> xe_configfs_get_disable_vram_page_offline(struct pci_dev *pdev)
>> return ret;
>> }
>> +/**
>> + * xe_configfs_get_bad_page_decay_secs - get configfs
>> bad_page_decay_secs setting
>> + * @pdev: pci device
>> + *
>> + * Return: bad_page_decay_secs setting in configfs
>> + */
>> +u32 xe_configfs_get_bad_page_decay_secs(struct pci_dev *pdev)
>> +{
>> + struct xe_config_group_device *dev =
>> find_xe_config_group_device(pdev);
>> + u32 ret;
>> +
>> + if (!dev)
>> + return device_defaults.bad_page_decay_secs;
>> +
>> + ret = dev->config.bad_page_decay_secs;
>> + config_group_put(&dev->group);
>> +
>> + return ret;
>> +}
>> +
>> /**
>> * xe_configfs_get_ctx_restore_mid_bb - get configfs
>> ctx_restore_mid_bb setting
>> * @pdev: pci device
>> diff --git a/drivers/gpu/drm/xe/xe_configfs.h
>> b/drivers/gpu/drm/xe/xe_configfs.h
>> index 3f0d68bfb9c9..5dd0d1d71fd6 100644
>> --- a/drivers/gpu/drm/xe/xe_configfs.h
>> +++ b/drivers/gpu/drm/xe/xe_configfs.h
>> @@ -26,6 +26,7 @@ bool xe_configfs_get_psmi_enabled(struct pci_dev
>> *pdev);
>> bool xe_configfs_get_enable_multi_queue(struct pci_dev *pdev);
>> u32 xe_configfs_get_migrate_ulls_period_ms(struct pci_dev *pdev);
>> bool xe_configfs_get_disable_vram_page_offline(struct pci_dev *pdev);
>> +u32 xe_configfs_get_bad_page_decay_secs(struct pci_dev *pdev);
>> u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev,
>> enum xe_engine_class class,
>> const u32 **cs);
>> diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
>> b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
>> index 36d47de8b11b..30c3fe00c0f3 100644
>> --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
>> +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
>> @@ -229,6 +229,8 @@ static void xe_ttm_vram_buddy_free(struct
>> xe_ttm_vram_mgr *mgr,
>> *
>> * Called with @mgr->lock held.
>> */
>> +static unsigned long xe_ttm_vram_decay_gc_period(struct
>> xe_ttm_vram_mgr *mgr);
>> +
>> static void xe_ttm_vram_retry_queued_pages(struct xe_ttm_vram_mgr
>> *mgr)
>> {
>> struct xe_ttm_vram_offline_resource *pos, *n;
>> @@ -247,6 +249,11 @@ static void
>> xe_ttm_vram_retry_queued_pages(struct xe_ttm_vram_mgr *mgr)
>> list_del(&pos->queued_link);
>> ++mgr->n_offlined_pages;
>> list_add(&pos->offlined_link, &mgr->offlined_pages);
>> +
>> + if (pos->mode == XE_PAGE_OFFLINE_SOFT &&
>> mgr->decay_interval_jiffies &&
>> + !delayed_work_pending(&mgr->decay_gc_work))
>> + schedule_delayed_work(&mgr->decay_gc_work,
>> + xe_ttm_vram_decay_gc_period(mgr));
>> }
>> }
>> @@ -355,6 +362,54 @@ static const struct ttm_resource_manager_func
>> xe_ttm_vram_mgr_func = {
>> .debug = xe_ttm_vram_mgr_debug
>> };
>> +static unsigned long xe_ttm_vram_decay_gc_period(struct
>> xe_ttm_vram_mgr *mgr)
>> +{
>> + unsigned long decay = mgr->decay_interval_jiffies;
>> + unsigned long period = decay / 8;
>> + unsigned long floor = msecs_to_jiffies(60 * 1000);
>> +
>> + /* Never poll less often than the configured decay itself. */
>> + if (period < floor)
>> + period = min(floor, decay);
>> + return period;
>> +}
>> +
>> +static void xe_ttm_vram_decay_gc_worker(struct work_struct *work)
>> +{
>> + struct xe_ttm_vram_mgr *mgr = container_of(to_delayed_work(work),
>> + struct xe_ttm_vram_mgr,
>> + decay_gc_work);
>> + struct xe_ttm_vram_offline_resource *pos, *n;
>> + struct xe_device *xe = ttm_to_xe_device(mgr->manager.bdev);
>> + unsigned long now = jiffies;
>> + unsigned long decay;
>> +
>> + mutex_lock(&mgr->lock);
>> + decay = mgr->decay_interval_jiffies;
>> + if (!decay)
>> + goto reschedule;
>> +
>> + list_for_each_entry_safe(pos, n, &mgr->offlined_pages,
>> offlined_link) {
>> + if (pos->mode != XE_PAGE_OFFLINE_SOFT)
>> + continue;
>> + if (!time_after(now, pos->last_seen + decay))
>> + continue;
>> +
>> + list_del(&pos->offlined_link);
>> + xe_ttm_vram_buddy_free(mgr, &pos->blocks,
>> pos->used_visible_size);
>> + --mgr->n_offlined_pages;
>> + drm_info(&xe->drm,
>> + "decay: reinstated soft-offlined page 0x%llx\n",
>> + pos->addr);
>> + kfree(pos);
>> + }
>> +
>> +reschedule:
>> + schedule_delayed_work(&mgr->decay_gc_work,
>> + xe_ttm_vram_decay_gc_period(mgr));
>> + mutex_unlock(&mgr->lock);
>> +}
>> +
>> static const struct dmem_cgroup_ops xe_ttm_vram_mgr_dmem_ops;
>> static int xe_ttm_vram_mgr_dmem_reclaim(struct
>> dmem_cgroup_pool_state *pool,
>> @@ -415,6 +470,8 @@ static void xe_ttm_vram_mgr_fini(struct
>> drm_device *dev, void *arg)
>> struct xe_ttm_vram_mgr *mgr = arg;
>> struct ttm_resource_manager *man = &mgr->manager;
>> + cancel_delayed_work_sync(&mgr->decay_gc_work);
>> +
>> mutex_lock(&mgr->lock);
>> xe_ttm_vram_free_bad_pages(mgr);
>> mutex_unlock(&mgr->lock);
>> @@ -438,6 +495,7 @@ int __xe_ttm_vram_mgr_init(struct xe_device *xe,
>> struct xe_ttm_vram_mgr *mgr,
>> struct ttm_resource_manager *man = &mgr->manager;
>> struct dmem_cgroup_region *cg;
>> const char *name;
>> + u32 decay_secs;
>> int err;
>> man->func = &xe_ttm_vram_mgr_func;
>> @@ -447,6 +505,9 @@ int __xe_ttm_vram_mgr_init(struct xe_device *xe,
>> struct xe_ttm_vram_mgr *mgr,
>> return err;
>> INIT_LIST_HEAD(&mgr->offlined_pages);
>> INIT_LIST_HEAD(&mgr->queued_pages);
>> + INIT_DELAYED_WORK(&mgr->decay_gc_work,
>> xe_ttm_vram_decay_gc_worker);
>> + decay_secs =
>> xe_configfs_get_bad_page_decay_secs(to_pci_dev(xe->drm.dev));
>> + mgr->decay_interval_jiffies = secs_to_jiffies(decay_secs);
>> mgr->default_page_size = default_page_size;
>> mgr->visible_size = io_size;
>> mgr->visible_avail = io_size;
>> @@ -725,13 +786,21 @@ static bool
>> xe_ttm_vram_page_already_processed(struct xe_ttm_vram_mgr *mgr,
>> lockdep_assert_held(&mgr->lock);
>> list_for_each_entry(pos, &mgr->offlined_pages, offlined_link) {
>> - if (pos->addr == addr)
>> + if (pos->addr == addr) {
>> + if (pos->mode == XE_PAGE_OFFLINE_SOFT)
>> + pos->mode = XE_PAGE_OFFLINE_HARD;
>> + pos->last_seen = jiffies;
>> return true;
>> + }
>> }
>> list_for_each_entry(pos, &mgr->queued_pages, queued_link) {
>> - if (pos->addr == addr)
>> + if (pos->addr == addr) {
>> + if (pos->mode == XE_PAGE_OFFLINE_SOFT)
>> + pos->mode = XE_PAGE_OFFLINE_HARD;
>> + pos->last_seen = jiffies;
>> return true;
>> + }
>> }
>> return false;
>> @@ -804,6 +873,8 @@ static int
>> xe_ttm_vram_reserve_page_at_addr(struct xe_device *xe, u64 addr,
>> INIT_LIST_HEAD(&nentry->blocks);
>> nentry->status = XE_PAGE_RESERVE_PENDING;
>> nentry->addr = addr;
>> + nentry->mode = XE_PAGE_OFFLINE_SOFT;
>> + nentry->last_seen = jiffies;
>> if (block) {
>> pbo = xe_ttm_vram_block_owner_get(xe, block);
>> @@ -843,6 +914,11 @@ static int
>> xe_ttm_vram_reserve_page_at_addr(struct xe_device *xe, u64 addr,
>> }
>> ++vram_mgr->n_offlined_pages;
>> list_add(&nentry->offlined_link,
>> &vram_mgr->offlined_pages);
>> + if (vram_mgr->decay_interval_jiffies &&
>> + !delayed_work_pending(&vram_mgr->decay_gc_work)) {
>> + schedule_delayed_work(&vram_mgr->decay_gc_work,
>> + xe_ttm_vram_decay_gc_period(vram_mgr));
>> + }
>> return ret;
>> }
>> }
>> diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h
>> b/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h
>> index 4a2cd27a5b61..0a6d8f8c2aa8 100644
>> --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h
>> +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h
>> @@ -7,8 +7,16 @@
>> #define _XE_TTM_VRAM_MGR_TYPES_H_
>> #include <linux/gpu_buddy.h>
>> +#include <linux/workqueue.h>
>> #include <drm/ttm/ttm_device.h>
>> +#define XE_BAD_PAGE_DECAY_SECS_DEFAULT (24 * 60 * 60)
>> +
>> +enum xe_page_offline_mode {
>> + XE_PAGE_OFFLINE_SOFT = 0,
>> + XE_PAGE_OFFLINE_HARD,
>> +};
>> +
>> /**
>> * struct xe_ttm_vram_mgr - Xe TTM VRAM manager
>> *
>> @@ -37,6 +45,10 @@ struct xe_ttm_vram_mgr {
>> struct mutex lock;
>> /** @mem_type: The TTM memory type */
>> u32 mem_type;
>> + /** @decay_gc_work: reinstates expired soft-offlined pages */
>> + struct delayed_work decay_gc_work;
>> + /** @decay_interval_jiffies: soft-offline decay interval */
>> + unsigned long decay_interval_jiffies;
>> };
>> /**
>> @@ -79,6 +91,10 @@ struct xe_ttm_vram_offline_resource {
>> u64 addr;
>> /** @status: buddy reservation status */
>> enum xe_page_reserve_status status;
>> + /** @mode: soft or hard offline mode */
>> + enum xe_page_offline_mode mode;
>> + /** @last_seen: most recent hardware report time */
>> + unsigned long last_seen;
>> };
>> #endif
next prev parent reply other threads:[~2026-11-30 9:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 10:45 [PATCH V3 0/3] drm/xe/vram: decay-based reinstatement of soft-offlined VRAM pages Tejas Upadhyay
2026-11-26 10:45 ` [PATCH V3 1/3] drm/xe/vram: add " Tejas Upadhyay
2026-11-30 9:14 ` Yadav, Arvind
2026-11-30 9:24 ` Yadav, Arvind [this message]
2026-11-26 10:45 ` [PATCH V3 2/3] drm/xe/vram: don't let firmware-confirmed permanent bad pages decay back in Tejas Upadhyay
2026-11-30 9:25 ` Yadav, Arvind
2026-11-26 10:45 ` [PATCH V3 3/3] drm/xe/vram: stop decay worker from rescheduling itself forever Tejas Upadhyay
2026-11-30 9:28 ` Yadav, Arvind
2026-11-26 14:53 ` ✓ CI.KUnit: success for drm/xe/vram: decay-based reinstatement of soft-offlined VRAM pages (rev2) Patchwork
2026-11-26 15:30 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-26 22:37 ` ✓ Xe.CI.FULL: " 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=764028c2-d0f3-4d56-9a85-a2ee440f5b7a@intel.com \
--to=arvind.yadav@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=tejas.upadhyay@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.