Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v10 0/6] drm/xe: add page size allocation mode control and coverage
@ 2026-07-29  8:40 Nareshkumar Gollakoti
  2026-07-29  8:40 ` [PATCH v10 1/6] drm/xe: add page size allocation control state to xe_device Nareshkumar Gollakoti
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Nareshkumar Gollakoti @ 2026-07-29  8:40 UTC (permalink / raw)
  To: intel-xe; +Cc: himal.prasad.ghimiray, naresh.kumar.g

Some platforms support multiple page sizes for user BO allocations,
including 4K, 64K, 2M, and 1G

For validation and debug, it is useful to control the page size
selection policy for user BOs so that specific allocation paths can be
exercised deterministically. In particular, this makes it possible to
force allocations into 2M-only, 1G-only, or mixed modes.

In mixed mode, allocations are distributed across the supported page
sizes in a round-robin manner. For example, for four user BOs, the
selected page sizes would be:
  - BO1: 4K
  - BO2: 64K
  - BO3: 2M
  - BO4: 1G

This series adds debug page-size allocation control for user BO in xe

This series includes:
 - debug control state in xe_device
 - a debugfs knob to select allocation mode
 - 1G BO alignment flag handling
 - debug policy application at user BO create time
 - PT bind support for selecting leaf level (4K/64K, 2M, 1G paths)
 - add live Kunit coverage for BO page size allocation

The default path is unchanged when the debug control is not enabled.

v2
-- addressed v1 comments at 
   https://patchwork.freedesktop.org/series/169640/

v3
- refactor the design
- update patches based on review feedback
- due to space missing after drm/xe: it created a new series
  https://patchwork.freedesktop.org/series/170246/

v4
- initialize page-size control state before userspace-visible registration
- add Kconfig support before CONFIG_DRM_XE_DEBUG_PAGE_SIZE users
- limit debugfs and BO policy handling to supported dGFX VRAM paths
- add fast-path mode checks and ALIGN() overflow handling
- preserve existing BO NEEDS_* flags
- defer mixed-mode index advancement until successful
  BO create ioctl completion
- replace 2M/1G vma_flags propagation with stable target_leaf_level state
- propagate target_leaf_level from bind op to VMA and into PT bind
- allow smaller huge-page fallback and fix clear_pt handling in PT walk
- skip VRAM-only live KUnit tests on non-dGFX
  and restore state on all exits

v5:
- Guard debug page-size control support with CONFIG_DRM_XE_DEBUG_PAGE_SIZE
- Fix kernel-doc warnings in xe_device_types.h for page_size_alloc_ctrl
- Keep the normal BO creation path unchanged when no debug mode is selected
- Reword commit messages for clarity and to match the implementation

v6:
- Add Gaurd to kunit tests

v7:
- CI build failure

v8:
- use drmm_mutext_init instead mutex_init
- Ensure calling xe_debug_page_size_alloc_ctrl_init
  unconditionally
- refactor helper routine names xe_debug_page_size_mode_not_none()
  xe_debug_page_size_mode_is_mixed()
- use READ_ONCE for lockless wherever needed for readers and also
  match WRITE_ONCE to align READ_ONCE for protected writers
- Make debugfs mode options more readable for that use string fromat like,
  "none", "only_2m", "only_1g" and "mixed" mode
- simplify repeatative loop of mixed mode flag and align check on
  get_flag_from_cur_index_in_mixed_mode()
- drop https://patchwork.freedesktop.org/patch/740059/?series=168905&rev=5
  as this can be managed to get from bo flags on PT layer
- populate xe_walk.target_leaf_level from bo flags through
  xe_pt_target_leaf_level_from_bo()

v9:
- Make sure probe fail upon drmm_mutex_init failure of pagesize alloc
  init
- Add an OOB guard for mode in page_size_alloc_mode_show().
  This check makes the function display "unknown" if mode has been
  maliciously altered by KMD, preventing out-of-bounds access.
  Under normal operation, values set through debugfs are validated,
  so OOB values should not occur.
- simplify mode-to-string lookup using page_size_alloc_mode_names[]
- use sysfs_match_string() to parse page_size_alloc_mode writes

v10:
- use xe_bo_is_vram() instead of raw VRAM flag checks
  so huge-page selection is based on BO VRAM placement.

Nareshkumar Gollakoti (6):
  drm/xe: add page size allocation control state to xe_device
  drm/xe/debugfs: add page-size allocation mode knob
  drm/xe: add XE_BO_FLAG_NEEDS_1G for minimum page-size sizing
  drm/xe: apply debug page-size allocation policy to user BOs
  drm/xe/pt: allow selecting the bind leaf PTE level
  drm/xe/tests: add live KUnit coverage for BO page-size allocation
    modes

 drivers/gpu/drm/xe/Kconfig.debug            |  16 ++
 drivers/gpu/drm/xe/tests/xe_bo.c            | 242 ++++++++++++++++++++
 drivers/gpu/drm/xe/tests/xe_live_test_mod.c |   6 +
 drivers/gpu/drm/xe/xe_bo.c                  | 160 ++++++++++++-
 drivers/gpu/drm/xe/xe_bo.h                  |   1 +
 drivers/gpu/drm/xe/xe_debugfs.c             |  78 +++++++
 drivers/gpu/drm/xe/xe_device.c              |  25 ++
 drivers/gpu/drm/xe/xe_device.h              |  48 ++++
 drivers/gpu/drm/xe/xe_device_types.h        |  31 +++
 drivers/gpu/drm/xe/xe_pt.c                  |  76 +++++-
 10 files changed, 679 insertions(+), 4 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH v10 0/6] drm/xe: add page size allocation mode control and coverage
@ 2026-07-29 12:18 Nareshkumar Gollakoti
  2026-07-29 12:18 ` [PATCH v10 2/6] drm/xe/debugfs: add page-size allocation mode knob Nareshkumar Gollakoti
  0 siblings, 1 reply; 8+ messages in thread
From: Nareshkumar Gollakoti @ 2026-07-29 12:18 UTC (permalink / raw)
  To: intel-xe; +Cc: himal.prasad.ghimiray, naresh.kumar.g

Some platforms support multiple page sizes for user BO allocations,
including 4K, 64K, 2M, and 1G

For validation and debug, it is useful to control the page size
selection policy for user BOs so that specific allocation paths can be
exercised deterministically. In particular, this makes it possible to
force allocations into 2M-only, 1G-only, or mixed modes.

In mixed mode, allocations are distributed across the supported page
sizes in a round-robin manner. For example, for four user BOs, the
selected page sizes would be:
  - BO1: 4K
  - BO2: 64K
  - BO3: 2M
  - BO4: 1G

This series adds debug page-size allocation control for user BO in xe

This series includes:
 - debug control state in xe_device
 - a debugfs knob to select allocation mode
 - 1G BO alignment flag handling
 - debug policy application at user BO create time
 - PT bind support for selecting leaf level (4K/64K, 2M, 1G paths)
 - add live Kunit coverage for BO page size allocation

The default path is unchanged when the debug control is not enabled.

v2
-- addressed v1 comments at 
   https://patchwork.freedesktop.org/series/169640/

v3
- refactor the design
- update patches based on review feedback
- due to space missing after drm/xe: it created a new series
  https://patchwork.freedesktop.org/series/170246/

v4
- initialize page-size control state before userspace-visible registration
- add Kconfig support before CONFIG_DRM_XE_DEBUG_PAGE_SIZE users
- limit debugfs and BO policy handling to supported dGFX VRAM paths
- add fast-path mode checks and ALIGN() overflow handling
- preserve existing BO NEEDS_* flags
- defer mixed-mode index advancement until successful
  BO create ioctl completion
- replace 2M/1G vma_flags propagation with stable target_leaf_level state
- propagate target_leaf_level from bind op to VMA and into PT bind
- allow smaller huge-page fallback and fix clear_pt handling in PT walk
- skip VRAM-only live KUnit tests on non-dGFX
  and restore state on all exits

v5:
- Guard debug page-size control support with CONFIG_DRM_XE_DEBUG_PAGE_SIZE
- Fix kernel-doc warnings in xe_device_types.h for page_size_alloc_ctrl
- Keep the normal BO creation path unchanged when no debug mode is selected
- Reword commit messages for clarity and to match the implementation

v6:
- Add Gaurd to kunit tests

v7:
- CI build failure

v8:
- use drmm_mutext_init instead mutex_init
- Ensure calling xe_debug_page_size_alloc_ctrl_init
  unconditionally
- refactor helper routine names xe_debug_page_size_mode_not_none()
  xe_debug_page_size_mode_is_mixed()
- use READ_ONCE for lockless wherever needed for readers and also
  match WRITE_ONCE to align READ_ONCE for protected writers
- Make debugfs mode options more readable for that use string fromat like,
  "none", "only_2m", "only_1g" and "mixed" mode
- simplify repeatative loop of mixed mode flag and align check on
  get_flag_from_cur_index_in_mixed_mode()
- drop https://patchwork.freedesktop.org/patch/740059/?series=168905&rev=5
  as this can be managed to get from bo flags on PT layer
- populate xe_walk.target_leaf_level from bo flags through
  xe_pt_target_leaf_level_from_bo()

v9:
- Make sure probe fail upon drmm_mutex_init failure of pagesize alloc
  init
- Add an OOB guard for mode in page_size_alloc_mode_show().
  This check makes the function display "unknown" if mode has been
  maliciously altered by KMD, preventing out-of-bounds access.
  Under normal operation, values set through debugfs are validated,
  so OOB values should not occur.
- simplify mode-to-string lookup using page_size_alloc_mode_names[]
- use sysfs_match_string() to parse page_size_alloc_mode writes

v10:
- use xe_bo_is_vram() instead of raw VRAM flag checks
  so huge-page selection is based on BO VRAM placement.
- resend with rebase

Nareshkumar Gollakoti (6):
  drm/xe: add page size allocation control state to xe_device
  drm/xe/debugfs: add page-size allocation mode knob
  drm/xe: add XE_BO_FLAG_NEEDS_1G for minimum page-size sizing
  drm/xe: apply debug page-size allocation policy to user BOs
  drm/xe/pt: allow selecting the bind leaf PTE level
  drm/xe/tests: add live KUnit coverage for BO page-size allocation
    modes

 drivers/gpu/drm/xe/Kconfig.debug            |  16 ++
 drivers/gpu/drm/xe/tests/xe_bo.c            | 242 ++++++++++++++++++++
 drivers/gpu/drm/xe/tests/xe_live_test_mod.c |   6 +
 drivers/gpu/drm/xe/xe_bo.c                  | 160 ++++++++++++-
 drivers/gpu/drm/xe/xe_bo.h                  |   1 +
 drivers/gpu/drm/xe/xe_debugfs.c             |  78 +++++++
 drivers/gpu/drm/xe/xe_device.c              |  25 ++
 drivers/gpu/drm/xe/xe_device.h              |  48 ++++
 drivers/gpu/drm/xe/xe_device_types.h        |  31 +++
 drivers/gpu/drm/xe/xe_pt.c                  |  76 +++++-
 10 files changed, 679 insertions(+), 4 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-29 12:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29  8:40 [PATCH v10 0/6] drm/xe: add page size allocation mode control and coverage Nareshkumar Gollakoti
2026-07-29  8:40 ` [PATCH v10 1/6] drm/xe: add page size allocation control state to xe_device Nareshkumar Gollakoti
2026-07-29  8:40 ` [PATCH v10 2/6] drm/xe/debugfs: add page-size allocation mode knob Nareshkumar Gollakoti
2026-07-29  8:40 ` [PATCH v10 3/6] drm/xe: add XE_BO_FLAG_NEEDS_1G for minimum page-size sizing Nareshkumar Gollakoti
2026-07-29  8:40 ` [PATCH v10 4/6] drm/xe: apply debug page-size allocation policy to user BOs Nareshkumar Gollakoti
2026-07-29  8:40 ` [PATCH v10 5/6] drm/xe/pt: allow selecting the bind leaf PTE level Nareshkumar Gollakoti
2026-07-29  8:40 ` [PATCH v10 6/6] drm/xe/tests: add live KUnit coverage for BO page-size allocation modes Nareshkumar Gollakoti
  -- strict thread matches above, loose matches on Subject: below --
2026-07-29 12:18 [PATCH v10 0/6] drm/xe: add page size allocation mode control and coverage Nareshkumar Gollakoti
2026-07-29 12:18 ` [PATCH v10 2/6] drm/xe/debugfs: add page-size allocation mode knob Nareshkumar Gollakoti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox