From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>,
<intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v8 2/6] drm/xe/debugfs: add page-size allocation mode knob
Date: Fri, 24 Jul 2026 01:08:54 +0530 [thread overview]
Message-ID: <dbcbefb0-ff38-45ab-b91b-0cf4e6ba5890@intel.com> (raw)
In-Reply-To: <20260722143759.1718600-3-naresh.kumar.g@intel.com>
On 22-07-2026 20:07, Nareshkumar Gollakoti wrote:
> Expose a debugfs control to override the page-size allocation mode used
> for user BOs.
>
> The interface allows switching between the default allocation policy,
> forced 2M, forced 1G, and mixed allocation modes at runtime. This
> provides a simple way to validate behavior and debug page-size-dependent
> allocation flows.
>
> The debugfs entry is built only when CONFIG_DRM_XE_DEBUG_PAGE_SIZE is
> enabled.
>
> v2
> - update changelog to match mutex-based cur_index handling
> - reset cur_index when switching to mixed mode (sashiko)
>
> v3
> - add CONFIG guard for page-size allocation debugfs support (Himal)
> - create debugfs entry under CONFIG_DRM_XE_DEBUG_PAGE_SIZE
>
> v4
> - reorderd this patch with kconfig patch to ensure patch builds
> - Gurding this debug knob for only discrete graphics
>
> v5(Himal)
> - Guard all page size calls with CONFIG_DRM_XE_DEBUG_PAGE_SIZE
>
> v8(Himal)
> - For read/show used READ_ONCE instead lock
> - to match Reader used WRITE_ONCE under lock protection
> - change modes to string format to read/writer for debugfs
>
> Signed-off-by: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
> ---
> drivers/gpu/drm/xe/xe_debugfs.c | 88 +++++++++++++++++++++++++++++++++
> 1 file changed, 88 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
> index 5a3877fcb0f0..a1da0e0e6190 100644
> --- a/drivers/gpu/drm/xe/xe_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_debugfs.c
> @@ -614,6 +614,82 @@ static const struct file_operations disable_late_binding_fops = {
> .write = disable_late_binding_set,
> };
>
> +#ifdef CONFIG_DRM_XE_DEBUG_PAGE_SIZE
> +
> +static const struct {
> + const char *mode_name;
> + enum xe_page_size_alloc_ctrl_mode mode;
> +} page_size_alloc_modes[] = {
> + { "none", XE_PAGE_SIZE_ALLOC_CTRL_MODE_NONE },
> + { "only_2m", XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_2M },
> + { "only_1g", XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_1G },
> + { "mixed", XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED },
> +};
> +
> +static ssize_t page_size_alloc_mode_show(struct file *f, char __user *ubuf,
> + size_t size, loff_t *pos)
> +{
> + struct xe_device *xe = file_inode(f)->i_private;
> + char buf[32];
> + int len;
> + enum xe_page_size_alloc_ctrl_mode mode;
> + size_t i;
> +
> + mode = READ_ONCE(xe->page_size_alloc_ctrl.mode);
> +
OOB check for mode
> + for (i = 0; i < ARRAY_SIZE(page_size_alloc_modes); i++) {
> + if (page_size_alloc_modes[i].mode == mode)
> + break;
> + }
these for loops really looks overhead, possible to use
page_size_alloc_modes[mode].mode_name
static const char * const page_size_alloc_mode_names[] = {
[XE_PAGE_SIZE_ALLOC_CTRL_MODE_NONE] = "none",
[XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_2M] = "only_2m",
[XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_1G] = "only_1g",
[XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED] = "mixed",
};
> +
> + len = scnprintf(buf, sizeof(buf), "%s\n",
> + page_size_alloc_modes[i].mode_name);
> + return simple_read_from_buffer(ubuf, size, pos, buf, len);
> +}
> +
> +static ssize_t page_size_alloc_mode_set(struct file *f, const char __user *ubuf,
> + size_t size, loff_t *pos)
> +{
> + struct xe_device *xe = file_inode(f)->i_private;
> + int ret;
> + char buf[32];
> + size_t i;
> +
> + if (*pos)
> + return -ESPIPE;
> +
> + if (size > sizeof(buf) - 1)
> + return -EINVAL;
> +
> + ret = simple_write_to_buffer(buf, sizeof(buf) - 1, pos, ubuf, size);
> + if (ret < 0)
> + return ret;
> + buf[ret] = '\0';
mode = sysfs_match_string(page_size_alloc_mode_names, buf);
if (mode < 0)
return mode;
mutex_lock(&xe->page_size_alloc_ctrl.lock);
if (mode == XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED)
xe->page_size_alloc_ctrl.cur_index = 0;
WRITE_ONCE(xe->page_size_alloc_ctrl.mode, mode);
mutex_unlock(&xe->page_size_alloc_ctrl.lock);
return size;
> +
> + for (i = 0; i < ARRAY_SIZE(page_size_alloc_modes); i++) {
> + if (sysfs_streq(buf, page_size_alloc_modes[i].mode_name)) {
> + mutex_lock(&xe->page_size_alloc_ctrl.lock);
> + if (page_size_alloc_modes[i].mode ==
> + XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED)
> + xe->page_size_alloc_ctrl.cur_index = 0;
> +
> + WRITE_ONCE(xe->page_size_alloc_ctrl.mode,
> + page_size_alloc_modes[i].mode);
> + mutex_unlock(&xe->page_size_alloc_ctrl.lock);
> + return size;
> + }
> + }
> +
> + return -EINVAL;
> +}
> +
> +static const struct file_operations page_size_alloc_mode_fops = {
> + .owner = THIS_MODULE,
> + .read = page_size_alloc_mode_show,
> + .write = page_size_alloc_mode_set,
> +};
> +#endif
> +
> void xe_debugfs_register(struct xe_device *xe)
> {
> struct ttm_device *bdev = &xe->ttm;
> @@ -665,6 +741,18 @@ void xe_debugfs_register(struct xe_device *xe)
> debugfs_create_file("disable_late_binding", 0600, root, xe,
> &disable_late_binding_fops);
>
> +#ifdef CONFIG_DRM_XE_DEBUG_PAGE_SIZE
> + /*
> + * Expose a debugfs knob to control user BO page-size allocation:
> + * "none" - default behavior
> + * "only_2m" - force 2M page allocations
> + * "only_1g" - force 1G page allocations
> + * "mixed" - select 4K, 64K, 2M, and 1G in round-robin order
> + */
> + if (xe_debug_page_size_supported(xe))
> + debugfs_create_file("page_size_alloc_mode", 0600, root, xe,
> + &page_size_alloc_mode_fops);
> +#endif
> /*
> * Don't expose page reclaim configuration file if not supported by the
> * hardware initially.
next prev parent reply other threads:[~2026-07-23 19:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 14:37 [PATCH v8 0/6] drm/xe: add page size allocation mode control and coverage Nareshkumar Gollakoti
2026-07-22 14:37 ` [PATCH v8 1/6] drm/xe: add page size allocation control state to xe_device Nareshkumar Gollakoti
2026-07-23 18:52 ` Ghimiray, Himal Prasad
2026-07-22 14:37 ` [PATCH v8 2/6] drm/xe/debugfs: add page-size allocation mode knob Nareshkumar Gollakoti
2026-07-23 19:38 ` Ghimiray, Himal Prasad [this message]
2026-07-22 14:37 ` [PATCH v8 3/6] drm/xe: add XE_BO_FLAG_NEEDS_1G for minimum page-size sizing Nareshkumar Gollakoti
2026-07-22 14:37 ` [PATCH v8 4/6] drm/xe: apply debug page-size allocation policy to user BOs Nareshkumar Gollakoti
2026-07-23 20:10 ` Ghimiray, Himal Prasad
2026-07-22 14:37 ` [PATCH v8 5/6] drm/xe/pt: allow selecting the bind leaf PTE level Nareshkumar Gollakoti
2026-07-23 20:50 ` Ghimiray, Himal Prasad
2026-07-22 14:37 ` [PATCH v8 6/6] drm/xe/tests: add live KUnit coverage for BO page-size allocation modes Nareshkumar Gollakoti
2026-07-22 19:42 ` ✓ CI.KUnit: success for drm/xe: add page size allocation mode control and coverage (rev6) Patchwork
2026-07-22 20:07 ` ✗ CI.checksparse: warning " Patchwork
2026-07-22 20:35 ` ✓ Xe.CI.BAT: success " Patchwork
2026-07-23 18:02 ` ✓ 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=dbcbefb0-ff38-45ab-b91b-0cf4e6ba5890@intel.com \
--to=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=naresh.kumar.g@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