From: Himal prasad Ghimiray <himal.prasad.ghimiray@intel.com>
To: "Matthew Auld" <matthew.auld@intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Stuart Summers" <stuart.summers@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 3/5] drm/xe: Add a userptr repin timeout sysfs attribute
Date: Fri, 20 Nov 2026 16:19:47 +0530 [thread overview]
Message-ID: <f4a16f86-e56e-404c-9c54-8e080e95f909@intel.com> (raw)
In-Reply-To: <96526285-1b9a-43b7-9eff-37f36f9e6431@intel.com>
On 20-11-2026 16:13, Matthew Auld wrote:
> On 19/11/2026 16:38, Himal prasad Ghimiray wrote:
>>
>> On 19-11-2026 16:44, Matthew Auld wrote:
>>> From: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>>>
>>> Add a per-device sysfs attribute, userptr_repin_timeout_ms, to be used
>>> to bound the overall time a userptr repin is retried when the CPU
>>> mappings keep changing during the repin. The default is 100000 ms and
>>> zero means retry indefinitely. The value can be changed at any time and
>>> is read each time the timeout is checked.
>>>
>>> v2 (Matt):
>>> - Reject values above INT_MAX (or reaching MAX_JIFFY_OFFSET) with
>>> -EINVAL in userptr_repin_timeout_ms_store() so msecs_to_jiffies()
>>> does
>>> not treat them as an infinite timeout.
>>>
>>> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>>> ---
>>> drivers/gpu/drm/xe/xe_device.c | 2 ++
>>> drivers/gpu/drm/xe/xe_device.h | 2 ++
>>> drivers/gpu/drm/xe/xe_device_sysfs.c | 56
>>> ++++++++++++++++++++++++++ ++++++++++
>>> drivers/gpu/drm/xe/xe_device_types.h | 8 ++++++
>>> 4 files changed, 68 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/
>>> xe_device.c
>>> index 616e02066ae6..4e54a1b7fc51 100644
>>> --- a/drivers/gpu/drm/xe/xe_device.c
>>> +++ b/drivers/gpu/drm/xe/xe_device.c
>>> @@ -437,6 +437,8 @@ struct xe_device *xe_device_create(struct
>>> pci_dev *pdev)
>>> if (err)
>>> return ERR_PTR(err);
>>> + xe->userptr_repin_timeout_ms =
>>> XE_USERPTR_REPIN_TIMEOUT_MS_DEFAULT;
>>> +
>>> return xe;
>>> }
>>> ALLOW_ERROR_INJECTION(xe_device_create, ERRNO); /* See
>>> xe_pci_probe() */
>>> diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/
>>> xe_device.h
>>> index 7a7632e2d56b..128fe51bede7 100644
>>> --- a/drivers/gpu/drm/xe/xe_device.h
>>> +++ b/drivers/gpu/drm/xe/xe_device.h
>>> @@ -43,6 +43,8 @@ static inline struct xe_device
>>> *ttm_to_xe_device(struct ttm_device *ttm)
>>> return container_of(ttm, struct xe_device, ttm);
>>> }
>>> +#define XE_USERPTR_REPIN_TIMEOUT_MS_DEFAULT 100000h
>>
>> Isn't the default too high, if device is connected to no numa node
>> host ?
>
> We could lower this to 30s? That should still be more than enough, I
> would hope. Also, maybe we can have two different timeouts for NUMA vs
> non-NUMA?
I am aligned on different timeouts for NUMA vs non-NUMA.
>
> So what about:
>
> #define XE_USERPTR_REPIN_TIMEOUT_MS_DEFAULT 10000
> #define XE_USERPTR_REPIN_TIMEOUT_MS_NUMA_DEFAULT 30000
>
> And then:
>
> xe->userptr_repin_timeout_ms = num_online_nodes() > 1 ?
> XE_USERPTR_REPIN_TIMEOUT_MS_NUMA_DEFAULT :
> XE_USERPTR_REPIN_TIMEOUT_MS_DEFAULT;
+1
>
>>
>>> +
>>> struct xe_device *xe_device_create(struct pci_dev *pdev);
>>> int xe_device_init_early(struct xe_device *xe);
>>> int xe_device_probe_early(struct xe_device *xe);
>>> diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/
>>> xe/xe_device_sysfs.c
>>> index ff5d25dd867c..52111b4458f4 100644
>>> --- a/drivers/gpu/drm/xe/xe_device_sysfs.c
>>> +++ b/drivers/gpu/drm/xe/xe_device_sysfs.c
>>> @@ -4,7 +4,9 @@
>>> */
>>> #include <linux/device.h>
>>> +#include <linux/jiffies.h>
>>> #include <linux/kobject.h>
>>> +#include <linux/limits.h>
>>> #include <linux/pci.h>
>>> #include <linux/sysfs.h>
>>> @@ -38,6 +40,15 @@
>>> * reclaimed by the shrinker. Higher values reduce reclaim
>>> pressure on
>>> * non-purgeable buffer objects. Valid values are 1 to 64.
>>> Defaults to
>>> * CONFIG_DRM_XE_SHRINKER_NON_PURGEABLE_SEEKS.
>>> + *
>>> + * userptr_repin_timeout_ms - Report/change the overall time, in
>>> + * milliseconds, a userptr repin is retried, with all locks dropped
>>> between
>>> + * the attempts, when the CPU mappings keep changing during the
>>> repin. The
>>> + * time is measured from the first repin attempt after an
>>> invalidation. When
>>> + * it expires the repin fails with -EBUSY. Zero means retry
>>> indefinitely.
>>> + * Valid values are 0 to INT_MAX (capped by MAX_JIFFY_OFFSET). The
>>> value is
>>> + * read each time the timeout is checked, so a change takes effect
>>> + * immediately. Defaults to 100000.
>>> */
>>> static ssize_t
>>> @@ -340,6 +351,47 @@ static const struct attribute_group
>>> shrinker_attr_group = {
>>> .attrs = shrinker_attrs,
>>> };
>>> +static ssize_t
>>> +userptr_repin_timeout_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-
>>> >userptr_repin_timeout_ms));
>>> +}
>>> +
>>> +static ssize_t
>>> +userptr_repin_timeout_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));
>>> + u32 val;
>>> + int ret;
>>> +
>>> + ret = kstrtou32(buf, 0, &val);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + if (val > INT_MAX || msecs_to_jiffies(val) >= MAX_JIFFY_OFFSET)
>>> + return -EINVAL;
>>> +
>>> + WRITE_ONCE(xe->userptr_repin_timeout_ms, val);
>>> +
>>> + return count;
>>> +}
>>> +
>>> +static DEVICE_ATTR_RW(userptr_repin_timeout_ms);
>>> +
>>> +static struct attribute *userptr_attrs[] = {
>>> + &dev_attr_userptr_repin_timeout_ms.attr,
>>> + NULL
>>> +};
>>> +
>>> +static const struct attribute_group userptr_attr_group = {
>>> + .attrs = userptr_attrs,
>>> +};
>>> +
>>> int xe_device_sysfs_init(struct xe_device *xe)
>>> {
>>> struct device *dev = xe->drm.dev;
>>> @@ -349,6 +401,10 @@ int xe_device_sysfs_init(struct xe_device *xe)
>>> if (ret)
>>> return ret;
>>> + ret = devm_device_add_group(dev, &userptr_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 8f2a31949073..fc80cd2c766e 100644
>>> --- a/drivers/gpu/drm/xe/xe_device_types.h
>>> +++ b/drivers/gpu/drm/xe/xe_device_types.h
>>> @@ -437,6 +437,14 @@ struct xe_device {
>>> u16 idx[__XE_CACHE_LEVEL_COUNT];
>>> } pat;
>>> + /**
>>> + * @userptr_repin_timeout_ms: Overall time in milliseconds a
>>> userptr
>>> + * repin is retried before failing with -EBUSY. Zero means retry
>>> + * indefinitely. Accessed with READ_ONCE() / WRITE_ONCE() and
>>> tunable
>>> + * through sysfs.
>>> + */
>>> + u32 userptr_repin_timeout_ms;
>>> +
>>> /** @d3cold: Encapsulate d3cold related stuff */
>>> struct {
>>> /** @d3cold.capable: Indicates if root port is d3cold
>>> capable */
>>>
>
next prev parent reply other threads:[~2026-11-20 10:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 11:14 [PATCH 0/5] Non-fatal repin retries and NUMA-local rebind worker Matthew Auld
2026-11-19 11:14 ` [PATCH 1/5] drm/xe/vm: restore userptr invalidations on VMA op unwind Matthew Auld
2026-11-19 12:48 ` Thomas Hellström
2026-11-19 16:35 ` Himal prasad Ghimiray
2026-11-19 11:14 ` [PATCH 2/5] drm/xe: Requeue the rebind worker instead of retrying in-line on -EAGAIN Matthew Auld
2026-11-19 12:51 ` Thomas Hellström
2026-11-19 16:29 ` Matthew Auld
2026-11-19 17:26 ` Thomas Hellström
2026-11-19 17:38 ` Matthew Auld
2026-11-19 16:36 ` Himal prasad Ghimiray
2026-11-19 11:14 ` [PATCH 3/5] drm/xe: Add a userptr repin timeout sysfs attribute Matthew Auld
2026-11-19 16:38 ` Himal prasad Ghimiray
2026-11-20 10:43 ` Matthew Auld
2026-11-20 10:49 ` Himal prasad Ghimiray [this message]
2026-11-19 11:14 ` [PATCH 4/5] drm/xe/userptr: Make the repin retry loop non-fatal Matthew Auld
2026-11-19 13:03 ` Thomas Hellström
2026-11-19 17:10 ` Himal prasad Ghimiray
2026-11-19 11:14 ` [PATCH 5/5] drm/xe: run compute rebind worker on device NUMA node Matthew Auld
2026-11-19 13:11 ` Thomas Hellström
2026-11-19 13:38 ` Matthew Auld
2026-11-19 13:16 ` ✓ CI.KUnit: success for Non-fatal repin retries and NUMA-local rebind worker Patchwork
2026-11-19 13:54 ` ✓ Xe.CI.BAT: " 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=f4a16f86-e56e-404c-9c54-8e080e95f909@intel.com \
--to=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=stuart.summers@intel.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