History

drm/xe/uapi: Hide the madvise autoreset behind a VM_BIND flag

The madvise implementation currently resets the SVM madvise if the underlying CPU map is unmapped. This is in an attempt to mimic the CPU madvise behaviour. However, it's not clear that this is a desired behaviour since if the end app user relies on it for malloc()ed objects or stack objects, it may not work as intended. Instead of having the autoreset functionality being a direct application-facing implicit UAPI, make the UMD explicitly choose this behaviour if it wants to expose it by introducing DRM_XE_VM_BIND_FLAG_MADVISE_AUTORESET, and add a semantics description. v2: - Kerneldoc fixes. Fix a commit log message.

Thomas Hellström committed 1 year ago

Commit 59a2d3f1 parent b3af8654 files · +30 −3Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/drm/xe_drm.h+15−0
@@ -1017,6 +1017,20 @@ struct drm_xe_vm_destroy { · 1016 unmodified lines
1017 * valid on VMs with DRM_XE_VM_CREATE_FLAG_FAULT_MODE set. The CPU address1017 * valid on VMs with DRM_XE_VM_CREATE_FLAG_FAULT_MODE set. The CPU address
1018 * mirror flag are only valid for DRM_XE_VM_BIND_OP_MAP operations, the BO1018 * mirror flag are only valid for DRM_XE_VM_BIND_OP_MAP operations, the BO
1019 * handle MBZ, and the BO offset MBZ.1019 * handle MBZ, and the BO offset MBZ.
1020 * - %DRM_XE_VM_BIND_FLAG_MADVISE_AUTORESET - Can be used in combination with
1021 * %DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR to reset madvises when the underlying
1022 * CPU address space range is unmapped (typically with munmap(2) or brk(2)).
1023 * The madvise values set with &DRM_IOCTL_XE_MADVISE are reset to the values
1024 * that were present immediately after the &DRM_IOCTL_XE_VM_BIND.
1025 * The reset GPU virtual address range is the intersection of the range bound
1026 * using &DRM_IOCTL_XE_VM_BIND and the virtual CPU address space range
1027 * unmapped.
1028 * This functionality is present to mimic the behaviour of CPU address space
1029 * madvises set using madvise(2), which are typically reset on unmap.
1030 * Note: free(3) may or may not call munmap(2) and/or brk(2), and may thus
1031 * not invoke autoreset. Neither will stack variables going out of scope.
1032 * Therefore it's recommended to always explicitly reset the madvises when
1033 * freeing the memory backing a region used in a &DRM_IOCTL_XE_MADVISE call.
1020 *1034 *
1021 * The @prefetch_mem_region_instance for %DRM_XE_VM_BIND_OP_PREFETCH can also be:1035 * The @prefetch_mem_region_instance for %DRM_XE_VM_BIND_OP_PREFETCH can also be:
1022 * - %DRM_XE_CONSULT_MEM_ADVISE_PREF_LOC, which ensures prefetching occurs in1036 * - %DRM_XE_CONSULT_MEM_ADVISE_PREF_LOC, which ensures prefetching occurs in
@@ -1123,6 +1137,7 @@ struct drm_xe_vm_bind_op { · 100 unmodified lines
1123#define DRM_XE_VM_BIND_FLAG_DUMPABLE (1 << 3)1137#define DRM_XE_VM_BIND_FLAG_DUMPABLE (1 << 3)
1124#define DRM_XE_VM_BIND_FLAG_CHECK_PXP (1 << 4)1138#define DRM_XE_VM_BIND_FLAG_CHECK_PXP (1 << 4)
1125#define DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR (1 << 5)1139#define DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR (1 << 5)
1140#define DRM_XE_VM_BIND_FLAG_MADVISE_AUTORESET (1 << 6)
1126 /** @flags: Bind flags */1141 /** @flags: Bind flags */
1127 __u32 flags;1142 __u32 flags;
1128 1143

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t