|
XenevaOS
|
#include <xe_drm.h>
Public Attributes | ||
| __u64 | extensions | |
| __u64 | start | |
| __u64 | range | |
| __u32 | vm_id | |
| __u32 | type | |
| union { | ||
| struct { | ||
| __u32 devmem_fd | ||
| __u16 migration_policy | ||
| __u16 region_instance | ||
| __u64 reserved | ||
| } preferred_mem_loc | ||
| struct { | ||
| __u32 val | ||
| __u32 pad | ||
| __u64 reserved | ||
| } atomic | ||
| struct { | ||
| __u32 val | ||
| __u32 pad | ||
| __u64 reserved | ||
| } pat_index | ||
| struct { | ||
| __u32 val | ||
| __u32 pad | ||
| __u64 retained_ptr | ||
| } purge_state_val | ||
| }; | ||
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:
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, };
| union { ... } drm_xe_madvise |
| struct { ... } drm_xe_madvise::atomic |
@atomic: Atomic access policy
Used when @type == DRM_XE_MEM_RANGE_ATTR_ATOMIC.
Supported values for @atomic.val:
| __u32 drm_xe_madvise::devmem_fd |
@preferred_mem_loc.devmem_fd: Device file-descriptor of the device where the preferred memory is located, or one of the above special values. Please also see @preferred_mem_loc.region_instance below.
| __u64 drm_xe_madvise::extensions |
@extensions: Pointer to the first extension struct, if any
| __u16 drm_xe_madvise::migration_policy |
@preferred_mem_loc.migration_policy: Page migration policy
| __u32 drm_xe_madvise::pad |
@atomic.pad: MBZ
@pat_index.pad: MBZ
@purge_state_val.pad: MBZ
| struct { ... } drm_xe_madvise::pat_index |
@pat_index: Page attribute table index
Used when @type == DRM_XE_MEM_RANGE_ATTR_PAT.
| struct { ... } drm_xe_madvise::preferred_mem_loc |
@preferred_mem_loc: preferred memory location
Used when @type == DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC
Supported values for @preferred_mem_loc.devmem_fd:
Supported values for @preferred_mem_loc.migration_policy:
| struct { ... } drm_xe_madvise::purge_state_val |
@purge_state_val: Purgeable state configuration
Used when @type == DRM_XE_VMA_ATTR_PURGEABLE_STATE.
Configures the purgeable state of buffer objects in the specified virtual address range. This allows applications to hint to the kernel about bo's usage patterns for better memory management.
By default all VMAs are in WILLNEED state.
Supported values for @purge_state_val.val:
DRM_XE_VMA_PURGEABLE_STATE_DONTNEED (1): Marks BO as not currently needed. Kernel may purge it under memory pressure to reclaim memory. Only applies to non-shared BOs. The kernel sets the __u32 at @retained_ptr to 1 if the backing store still exists (not yet purged), or 0 if it was already purged.
Important: Once marked as DONTNEED, touching the BO's memory is undefined behavior. It may succeed temporarily (before the kernel purges the backing store) but will suddenly fail once the BO transitions to PURGED state.
To transition back: use WILLNEED and check @retained_ptr — if 0, backing store was lost and the BO must be recreated.
The following operations are blocked in DONTNEED state to prevent the BO from being re-mapped after madvise:
| __u64 drm_xe_madvise::range |
@range: size of the virtual address range
| __u16 drm_xe_madvise::region_instance |
@preferred_mem_loc.region_instance : Region instance. MBZ if @devmem_fd <= DRM_XE_PREFERRED_LOC_DEFAULT_DEVICE. Otherwise should point to the desired device VRAM instance of the device indicated by @preferred_mem_loc.devmem_fd.
| __u64 drm_xe_madvise::reserved |
@preferred_mem_loc.reserved : Reserved
@atomic.reserved: Reserved
@pat_index.reserved: Reserved
@reserved: Reserved
| __u64 drm_xe_madvise::retained_ptr |
@purge_state_val.retained_ptr: Pointer to a __u32 output field for backing store status.
Userspace must initialize the __u32 value at this address to 0 before the ioctl. Kernel writes a __u32 after the operation:
If userspace fails to initialize to 0, ioctl returns -EINVAL. This ensures a safe default (0 = assume purged) if kernel cannot write the result.
Similar to i915's drm_i915_gem_madvise.retained field.
| __u64 drm_xe_madvise::start |
@start: start of the virtual address range
| __u32 drm_xe_madvise::type |
@type: type of attribute
| __u32 drm_xe_madvise::val |
@atomic.val: value of atomic operation
@pat_index.val: PAT index value
@purge_state_val.val: value for DRM_XE_VMA_ATTR_PURGEABLE_STATE
| __u32 drm_xe_madvise::vm_id |
@vm_id: vm_id of the virtual range