From: Matthew Brost <matthew.brost@intel.com>
To: <intel-xe@lists.freedesktop.org>
Subject: [Intel-xe] [PATCH v5 8/8] drm/xe: Optimize size of xe_vma allocation
Date: Mon, 3 Apr 2023 18:42:28 -0700 [thread overview]
Message-ID: <20230404014228.3738347-9-matthew.brost@intel.com> (raw)
In-Reply-To: <20230404014228.3738347-1-matthew.brost@intel.com>
Reduce gt_mask to a u8 from a u64, only allocate userptr state if VMA is
a userptr, and union of destroy callback and worker.
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
drivers/gpu/drm/xe/xe_vm.c | 14 +++--
drivers/gpu/drm/xe/xe_vm_types.h | 88 +++++++++++++++++---------------
2 files changed, 57 insertions(+), 45 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index bacad720e7ba..a3ab257614ef 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -814,7 +814,7 @@ static struct xe_vma *xe_vma_create(struct xe_vm *vm,
u64 bo_offset_or_userptr,
u64 start, u64 end,
bool read_only, bool null,
- u64 gt_mask)
+ u8 gt_mask)
{
struct xe_vma *vma;
struct xe_gt *gt;
@@ -823,7 +823,11 @@ static struct xe_vma *xe_vma_create(struct xe_vm *vm,
XE_BUG_ON(start >= end);
XE_BUG_ON(end >= vm->size);
- vma = kzalloc(sizeof(*vma), GFP_KERNEL);
+ if (!bo && !null) /* userptr */
+ vma = kzalloc(sizeof(*vma), GFP_KERNEL);
+ else
+ vma = kzalloc(sizeof(*vma) - sizeof(struct xe_userptr),
+ GFP_KERNEL);
if (!vma) {
vma = ERR_PTR(-ENOMEM);
return vma;
@@ -2148,7 +2152,7 @@ static void print_op(struct xe_device *xe, struct drm_gpuva_op *op)
static struct drm_gpuva_ops *
vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
u64 bo_offset_or_userptr, u64 addr, u64 range,
- u32 operation, u64 gt_mask, u32 region)
+ u32 operation, u8 gt_mask, u32 region)
{
struct drm_gem_object *obj = bo ? &bo->ttm.base : NULL;
struct ww_acquire_ctx ww;
@@ -2233,7 +2237,7 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
}
static struct xe_vma *new_vma(struct xe_vm *vm, struct drm_gpuva_op_map *op,
- u64 gt_mask, bool read_only, bool null)
+ u8 gt_mask, bool read_only, bool null)
{
struct xe_bo *bo = op->gem.obj ? gem_to_xe_bo(op->gem.obj) : NULL;
struct xe_vma *vma;
@@ -3177,8 +3181,8 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
u64 addr = bind_ops[i].addr;
u32 op = bind_ops[i].op;
u64 obj_offset = bind_ops[i].obj_offset;
- u64 gt_mask = bind_ops[i].gt_mask;
u32 region = bind_ops[i].region;
+ u8 gt_mask = bind_ops[i].gt_mask;
ops[i] = vm_bind_ioctl_ops_create(vm, bos[i], obj_offset,
addr, range, op, gt_mask,
diff --git a/drivers/gpu/drm/xe/xe_vm_types.h b/drivers/gpu/drm/xe/xe_vm_types.h
index a049dfa9450a..d52f02a457c2 100644
--- a/drivers/gpu/drm/xe/xe_vm_types.h
+++ b/drivers/gpu/drm/xe/xe_vm_types.h
@@ -34,22 +34,34 @@ struct xe_vm;
#define XE_VMA_PTE_2M (DRM_GPUVA_USERBITS << 7)
#define XE_VMA_PTE_1G (DRM_GPUVA_USERBITS << 8)
+/** struct xe_userptr - User pointer */
+struct xe_userptr {
+ /**
+ * @notifier: MMU notifier for user pointer (invalidation call back)
+ */
+ struct mmu_interval_notifier notifier;
+ /** @sgt: storage for a scatter gather table */
+ struct sg_table sgt;
+ /** @sg: allocated scatter gather table */
+ struct sg_table *sg;
+ /** @notifier_seq: notifier sequence number */
+ unsigned long notifier_seq;
+ /**
+ * @initial_bind: user pointer has been bound at least once.
+ * write: vm->userptr.notifier_lock in read mode and vm->resv held.
+ * read: vm->userptr.notifier_lock in write mode or vm->resv held.
+ */
+ bool initial_bind;
+#if IS_ENABLED(CONFIG_DRM_XE_USERPTR_INVAL_INJECT)
+ u32 divisor;
+#endif
+};
+
+/** xe_vma - Virtual memory address */
struct xe_vma {
/** @gpuva: Base GPUVA object */
struct drm_gpuva gpuva;
- /** @gt_mask: GT mask of where to create binding for this VMA */
- u64 gt_mask;
-
- /**
- * @gt_present: GT mask of binding are present for this VMA.
- * protected by vm->lock, vm->resv and for userptrs,
- * vm->userptr.notifier_lock for writing. Needs either for reading,
- * but if reading is done under the vm->lock only, it needs to be held
- * in write mode.
- */
- u64 gt_present;
-
union {
/** @userptr_link: link into VM repin list if userptr */
struct list_head userptr_link;
@@ -77,16 +89,29 @@ struct xe_vma {
} notifier;
};
- /** @destroy_cb: callback to destroy VMA when unbind job is done */
- struct dma_fence_cb destroy_cb;
+ union {
+ /** @destroy_cb: callback to destroy VMA when unbind job is done */
+ struct dma_fence_cb destroy_cb;
+ /** @destroy_work: worker to destroy this BO */
+ struct work_struct destroy_work;
+ };
- /** @destroy_work: worker to destroy this BO */
- struct work_struct destroy_work;
+ /** @gt_mask: GT mask of where to create binding for this VMA */
+ u8 gt_mask;
+
+ /**
+ * @gt_present: GT mask of binding are present for this VMA.
+ * protected by vm->lock, vm->resv and for userptrs,
+ * vm->userptr.notifier_lock for writing. Needs either for reading,
+ * but if reading is done under the vm->lock only, it needs to be held
+ * in write mode.
+ */
+ u8 gt_present;
/** @usm: unified shared memory state */
struct {
/** @gt_invalidated: VMA has been invalidated */
- u64 gt_invalidated;
+ u8 gt_invalidated;
} usm;
struct {
@@ -97,28 +122,11 @@ struct xe_vma {
struct list_head link;
} extobj;
- /** @userptr: user pointer state */
- struct {
- /**
- * @notifier: MMU notifier for user pointer (invalidation call back)
- */
- struct mmu_interval_notifier notifier;
- /** @sgt: storage for a scatter gather table */
- struct sg_table sgt;
- /** @sg: allocated scatter gather table */
- struct sg_table *sg;
- /** @notifier_seq: notifier sequence number */
- unsigned long notifier_seq;
- /**
- * @initial_bind: user pointer has been bound at least once.
- * write: vm->userptr.notifier_lock in read mode and vm->resv held.
- * read: vm->userptr.notifier_lock in write mode or vm->resv held.
- */
- bool initial_bind;
-#if IS_ENABLED(CONFIG_DRM_XE_USERPTR_INVAL_INJECT)
- u32 divisor;
-#endif
- } userptr;
+ /**
+ * @userptr: user pointer state, only allocated for VMAs that are
+ * user pointers
+ */
+ struct xe_userptr userptr;
};
struct xe_device;
@@ -382,7 +390,7 @@ struct xe_vma_op {
*/
struct async_op_fence *fence;
/** @gt_mask: gt mask for this operation */
- u64 gt_mask;
+ u8 gt_mask;
/** @flags: operation flags */
enum xe_vma_op_flags flags;
--
2.34.1
next prev parent reply other threads:[~2023-04-04 1:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 1:42 [Intel-xe] [PATCH v5 0/8] Port Xe to use GPUVA and implement NULL VM binds Matthew Brost
2023-04-04 1:42 ` [Intel-xe] [PATCH v5 1/8] maple_tree: split up MA_STATE() macro Matthew Brost
2023-04-04 1:42 ` [Intel-xe] [PATCH v5 2/8] maple_tree: Export mas_preallocate Matthew Brost
2023-04-04 1:42 ` [Intel-xe] [PATCH v5 3/8] drm: manager to keep track of GPUs VA mappings Matthew Brost
2023-04-04 1:42 ` [Intel-xe] [PATCH v5 4/8] drm/xe: Port Xe to GPUVA Matthew Brost
2023-04-21 12:52 ` Thomas Hellström
2023-04-21 12:56 ` Thomas Hellström
2023-04-21 14:54 ` Thomas Hellström
2023-04-25 11:41 ` Thomas Hellström
2023-04-04 1:42 ` [Intel-xe] [PATCH v5 5/8] drm/xe: NULL binding implementation Matthew Brost
2023-04-04 1:42 ` [Intel-xe] [PATCH v5 6/8] drm/xe: Avoid doing rebinds Matthew Brost
2023-04-04 1:42 ` [Intel-xe] [PATCH v5 7/8] drm/xe: Reduce the number list links in xe_vma Matthew Brost
2023-04-04 1:42 ` Matthew Brost [this message]
2023-04-04 1:44 ` [Intel-xe] ✓ CI.Patch_applied: success for Port Xe to use GPUVA and implement NULL VM binds (rev5) Patchwork
2023-04-04 1:45 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-04-04 1:49 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-04-04 2:09 ` [Intel-xe] ○ CI.BAT: info " Patchwork
2023-04-04 13:20 ` [Intel-xe] [PATCH v5 0/8] Port Xe to use GPUVA and implement NULL VM binds Thomas Hellström
2023-04-04 14:56 ` Matthew Brost
2023-04-05 15:31 ` Thomas Hellström
2023-04-06 1:20 ` 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=20230404014228.3738347-9-matthew.brost@intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/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