From: Matthew Brost <matthew.brost@intel.com>
To: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: intel-xe@lists.freedesktop.org,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v5 02/23] drm/xe/uapi: Add madvise interface
Date: Mon, 28 Jul 2025 20:29:17 -0700 [thread overview]
Message-ID: <aIhADaWMFfId3v3O@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250722133526.3550547-3-himal.prasad.ghimiray@intel.com>
On Tue, Jul 22, 2025 at 07:05:05PM +0530, Himal Prasad Ghimiray wrote:
> This commit introduces a new madvise interface to support
> driver-specific ioctl operations. The madvise interface allows for more
> efficient memory management by providing hints to the driver about the
> expected memory usage and pte update policy for gpuvma.
>
> v2 (Matthew/Thomas)
> - Drop num_ops support
> - Drop purgeable support
> - Add kernel-docs
> - IOWR/IOW
>
> v3 (Matthew/Thomas)
> - Reorder attributes
> - use __u16 for migration_policy
> - use __u64 for reserved in unions
> - Avoid usage of vma
>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
> include/uapi/drm/xe_drm.h | 131 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 131 insertions(+)
>
> diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
> index e2426413488f..51dcf63684b0 100644
> --- a/include/uapi/drm/xe_drm.h
> +++ b/include/uapi/drm/xe_drm.h
> @@ -81,6 +81,7 @@ extern "C" {
> * - &DRM_IOCTL_XE_EXEC
> * - &DRM_IOCTL_XE_WAIT_USER_FENCE
> * - &DRM_IOCTL_XE_OBSERVATION
> + * - &DRM_IOCTL_XE_MADVISE
> */
>
> /*
> @@ -102,6 +103,7 @@ extern "C" {
> #define DRM_XE_EXEC 0x09
> #define DRM_XE_WAIT_USER_FENCE 0x0a
> #define DRM_XE_OBSERVATION 0x0b
> +#define DRM_XE_MADVISE 0x0c
>
> /* Must be kept compact -- no holes */
>
> @@ -117,6 +119,7 @@ extern "C" {
> #define DRM_IOCTL_XE_EXEC DRM_IOW(DRM_COMMAND_BASE + DRM_XE_EXEC, struct drm_xe_exec)
> #define DRM_IOCTL_XE_WAIT_USER_FENCE DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_WAIT_USER_FENCE, struct drm_xe_wait_user_fence)
> #define DRM_IOCTL_XE_OBSERVATION DRM_IOW(DRM_COMMAND_BASE + DRM_XE_OBSERVATION, struct drm_xe_observation_param)
> +#define DRM_IOCTL_XE_MADVISE DRM_IOW(DRM_COMMAND_BASE + DRM_XE_MADVISE, struct drm_xe_madvise)
>
> /**
> * DOC: Xe IOCTL Extensions
> @@ -1974,6 +1977,134 @@ struct drm_xe_query_eu_stall {
> __u64 sampling_rates[];
> };
>
> +/**
> + * struct drm_xe_madvise - Input of &DRM_IOCTL_XE_MADVISE
> + *
> + * This structure is used to set memory attributes for a virtual address range
> + * in a VM. The type of attribute is specified by @type, and the corresponding
> + * union member is used to provide additional parameters for @type.
> + *
> + * Supported attribute types:
> + * - DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC: Set preferred memory location.
> + * - DRM_XE_MEM_RANGE_ATTR_ATOMIC: Set atomic access policy.
> + * - DRM_XE_MEM_RANGE_ATTR_PAT: Set page attribute table index.
> + *
> + * Example:
> + *
> + * .. code-block:: C
> + *
> + * struct drm_xe_madvise madvise = {
> + * .vm_id = vm_id,
> + * .start = 0x100000,
> + * .range = 0x2000,
> + * .type = DRM_XE_MEM_RANGE_ATTR_ATOMIC,
> + * .atomic_val = DRM_XE_ATOMIC_DEVICE,
> + * .pad = 0,
Nit, you don't need to show init of zero fields.
Nit aside, uAPI looks good to me.
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> + * };
> + *
> + * ioctl(fd, DRM_IOCTL_XE_MADVISE, &madvise);
> + *
> + */
> +struct drm_xe_madvise {
> + /** @extensions: Pointer to the first extension struct, if any */
> + __u64 extensions;
> +
> + /** @start: start of the virtual address range */
> + __u64 start;
> +
> + /** @range: size of the virtual address range */
> + __u64 range;
> +
> + /** @vm_id: vm_id of the virtual range */
> + __u32 vm_id;
> +
> +#define DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC 0
> +#define DRM_XE_MEM_RANGE_ATTR_ATOMIC 1
> +#define DRM_XE_MEM_RANGE_ATTR_PAT 2
> + /** @type: type of attribute */
> + __u32 type;
> +
> + union {
> + /**
> + * @preferred_mem_loc: preferred memory location
> + *
> + * Used when @type == DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC
> + *
> + * Supported values for @preferred_mem_loc.devmem_fd:
> + * - DRM_XE_PREFERRED_LOC_DEFAULT_DEVICE: set vram of faulting tile as preferred loc
> + * - DRM_XE_PREFERRED_LOC_DEFAULT_SYSTEM: set smem as preferred loc
> + *
> + * Supported values for @preferred_mem_loc.migration_policy:
> + * - DRM_XE_MIGRATE_ALL_PAGES
> + * - DRM_XE_MIGRATE_ONLY_SYSTEM_PAGES
> + */
> + struct {
> +#define DRM_XE_PREFERRED_LOC_DEFAULT_DEVICE 0
> +#define DRM_XE_PREFERRED_LOC_DEFAULT_SYSTEM -1
> + /** @preferred_mem_loc.devmem_fd: fd for preferred loc */
> + __u32 devmem_fd;
> +
> +#define DRM_XE_MIGRATE_ALL_PAGES 0
> +#define DRM_XE_MIGRATE_ONLY_SYSTEM_PAGES 1
> + /** @preferred_mem_loc.migration_policy: Page migration policy */
> + __u16 migration_policy;
> +
> + /** @preferred_mem_loc.pad : MBZ */
> + __u16 pad;
> +
> + /** @preferred_mem_loc.reserved : Reserved */
> + __u64 reserved;
> + } preferred_mem_loc;
> +
> + /**
> + * @atomic: Atomic access policy
> + *
> + * Used when @type == DRM_XE_MEM_RANGE_ATTR_ATOMIC.
> + *
> + * Supported values for @atomic.val:
> + * - DRM_XE_ATOMIC_UNDEFINED: Undefined or default behaviour
> + * Support both GPU and CPU atomic operations for system allocator
> + * Support GPU atomic operations for normal(bo) allocator
> + * - DRM_XE_ATOMIC_DEVICE: Support GPU atomic operations
> + * - DRM_XE_ATOMIC_GLOBAL: Support both GPU and CPU atomic operations
> + * - DRM_XE_ATOMIC_CPU: Support CPU atomic
> + */
> + struct {
> +#define DRM_XE_ATOMIC_UNDEFINED 0
> +#define DRM_XE_ATOMIC_DEVICE 1
> +#define DRM_XE_ATOMIC_GLOBAL 2
> +#define DRM_XE_ATOMIC_CPU 3
> + /** @atomic.val: value of atomic operation */
> + __u32 val;
> +
> + /** @atomic.pad: MBZ */
> + __u32 pad;
> +
> + /** @atomic.reserved: Reserved */
> + __u64 reserved;
> + } atomic;
> +
> + /**
> + * @pat_index: Page attribute table index
> + *
> + * Used when @type == DRM_XE_MEM_RANGE_ATTR_PAT.
> + */
> + struct {
> + /** @pat_index.val: PAT index value */
> + __u32 val;
> +
> + /** @pat_index.pad: MBZ */
> + __u32 pad;
> +
> + /** @pat_index.reserved: Reserved */
> + __u64 reserved;
> + } pat_index;
> + };
> +
> + /** @reserved: Reserved */
> + __u64 reserved[2];
> +};
> +
> #if defined(__cplusplus)
> }
> #endif
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-07-29 3:29 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 13:35 [PATCH v5 00/23] MADVISE FOR XE Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 01/23] Introduce drm_gpuvm_sm_map_ops_flags enums for sm_map_ops Himal Prasad Ghimiray
2025-07-22 13:38 ` Danilo Krummrich
2025-07-24 0:43 ` Matthew Brost
2025-07-24 10:05 ` Ghimiray, Himal Prasad
2025-07-24 10:32 ` Caterina Shablia
2025-07-28 10:20 ` Ghimiray, Himal Prasad
2025-07-24 10:02 ` Ghimiray, Himal Prasad
2025-07-27 21:18 ` Matthew Brost
2025-07-28 6:16 ` Ghimiray, Himal Prasad
2025-07-22 13:35 ` [PATCH v5 02/23] drm/xe/uapi: Add madvise interface Himal Prasad Ghimiray
2025-07-29 3:29 ` Matthew Brost [this message]
2025-07-22 13:35 ` [PATCH v5 03/23] drm/xe/vm: Add attributes struct as member of vma Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 04/23] drm/xe/vma: Move pat_index to vma attributes Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 05/23] drm/xe/vma: Modify new_vma to accept struct xe_vma_mem_attr as parameter Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 06/23] drm/gpusvm: Make drm_gpusvm_for_each_* macros public Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 07/23] drm/xe/svm: Split system allocator vma incase of madvise call Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 08/23] drm/xe: Allow CPU address mirror VMA unbind with gpu bindings for madvise Himal Prasad Ghimiray
2025-07-29 3:40 ` Matthew Brost
2025-07-29 7:42 ` Ghimiray, Himal Prasad
2025-07-22 13:35 ` [PATCH v5 09/23] drm/xe/svm: Add xe_svm_ranges_zap_ptes_in_range() for PTE zapping Himal Prasad Ghimiray
2025-07-29 3:42 ` Matthew Brost
2025-07-22 13:35 ` [PATCH v5 10/23] drm/xe: Implement madvise ioctl for xe Himal Prasad Ghimiray
2025-07-29 3:52 ` Matthew Brost
2025-07-29 4:23 ` Matthew Brost
2025-07-29 9:43 ` Ghimiray, Himal Prasad
2025-07-22 13:35 ` [PATCH v5 11/23] drm/xe/svm : Add svm ranges migration policy on atomic access Himal Prasad Ghimiray
2025-07-29 4:04 ` Matthew Brost
2025-07-30 4:59 ` Ghimiray, Himal Prasad
2025-07-22 13:35 ` [PATCH v5 12/23] drm/xe/madvise: Update migration policy based on preferred location Himal Prasad Ghimiray
2025-07-29 4:07 ` Matthew Brost
2025-07-22 13:35 ` [PATCH v5 13/23] drm/xe/svm: Support DRM_XE_SVM_ATTR_PAT memory attribute Himal Prasad Ghimiray
2025-07-23 16:55 ` Ghimiray, Himal Prasad
2025-07-22 13:35 ` [PATCH v5 14/23] drm/xe/uapi: Add flag for consulting madvise hints on svm prefetch Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 15/23] drm/xe/svm: Consult madvise preferred location in prefetch Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 16/23] drm/xe/bo: Add attributes field to xe_bo Himal Prasad Ghimiray
2025-07-22 13:35 ` [PATCH v5 17/23] drm/xe/bo: Update atomic_access attribute on madvise Himal Prasad Ghimiray
2025-07-29 4:18 ` Matthew Brost
2025-07-22 13:35 ` [PATCH v5 18/23] drm/xe/madvise: Skip vma invalidation if mem attr are unchanged Himal Prasad Ghimiray
2025-07-29 4:19 ` Matthew Brost
2025-07-22 13:35 ` [PATCH v5 19/23] drm/xe/vm: Add helper to check for default VMA memory attributes Himal Prasad Ghimiray
2025-07-29 4:33 ` Matthew Brost
2025-07-22 13:35 ` [PATCH v5 20/23] drm/xe: Reset VMA attributes to default in SVM garbage collector Himal Prasad Ghimiray
2025-07-24 21:50 ` Matthew Brost
2025-07-29 5:27 ` Matthew Brost
2025-07-30 6:09 ` Ghimiray, Himal Prasad
2025-07-29 5:41 ` Matthew Brost
2025-07-30 6:06 ` Ghimiray, Himal Prasad
2025-07-22 13:35 ` [PATCH v5 21/23] drm/xe/vm: Add a delayed worker to merge fragmented vmas Himal Prasad Ghimiray
2025-07-29 4:39 ` Matthew Brost
2025-07-30 11:08 ` Ghimiray, Himal Prasad
2025-07-22 13:35 ` [PATCH v5 22/23] drm/xe: Enable madvise ioctl for xe Himal Prasad Ghimiray
2025-07-29 4:34 ` Matthew Brost
2025-07-22 13:35 ` [PATCH v5 23/23] drm/xe/uapi: Add UAPI for querying VMA count and memory attributes Himal Prasad Ghimiray
2025-07-29 5:37 ` Matthew Brost
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=aIhADaWMFfId3v3O@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--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 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.