[Intel-xe] [PATCH 5/7] drm/xe: Track page table memory usage for client

Upadhyay, Tejas tejas.upadhyay at intel.com
Thu Sep 7 08:40:27 UTC 2023



> -----Original Message-----
> From: Ghimiray, Himal Prasad <himal.prasad.ghimiray at intel.com>
> Sent: Wednesday, September 6, 2023 3:25 PM
> To: Upadhyay, Tejas <tejas.upadhyay at intel.com>; intel-
> xe at lists.freedesktop.org
> Cc: Iddamsetty, Aravind <aravind.iddamsetty at intel.com>
> Subject: Re: [PATCH 5/7] drm/xe: Track page table memory usage for client
> 
> 
> On 31-08-2023 14:35, Tejas Upadhyay wrote:
> > Account page table memory usage in the owning client memory usage
> > stats.
> >
> > Signed-off-by: Tejas Upadhyay <tejas.upadhyay at intel.com>
> > ---
> >   drivers/gpu/drm/xe/xe_pt.c | 4 +++-
> >   drivers/gpu/drm/xe/xe_vm.c | 9 ++++++++-
> >   2 files changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
> > index 5709518e314b..8df83241c5fe 100644
> > --- a/drivers/gpu/drm/xe/xe_pt.c
> > +++ b/drivers/gpu/drm/xe/xe_pt.c
> > @@ -7,6 +7,7 @@
> >
> >   #include "xe_bo.h"
> >   #include "xe_device.h"
> > +#include "xe_drm_client.h"
> >   #include "xe_gt.h"
> >   #include "xe_gt_tlb_invalidation.h"
> >   #include "xe_migrate.h"
> > @@ -195,7 +196,8 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct
> xe_tile *tile,
> >   	pt->bo = bo;
> >   	pt->level = level;
> >   	pt->base.dir = level ? &as_xe_pt_dir(pt)->dir : NULL;
> > -
> > +	if (vm->xef)
> > +		xe_drm_client_add_bo(vm->xef->client, pt->bo);
> >   	XE_WARN_ON(level > XE_VM_MAX_LEVEL);
> >
> >   	return pt;
> > diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> > index f5f832c8ed42..84fb1069fdbb 100644
> > --- a/drivers/gpu/drm/xe/xe_vm.c
> > +++ b/drivers/gpu/drm/xe/xe_vm.c
> > @@ -18,6 +18,7 @@
> >
> >   #include "xe_bo.h"
> >   #include "xe_device.h"
> > +#include "xe_drm_client.h"
> >   #include "xe_exec_queue.h"
> >   #include "xe_gt.h"
> >   #include "xe_gt_pagefault.h"
> > @@ -1980,6 +1981,7 @@ int xe_vm_create_ioctl(struct drm_device *dev,
> void *data,
> >   	struct xe_device *xe = to_xe_device(dev);
> >   	struct xe_file *xef = to_xe_file(file);
> >   	struct drm_xe_vm_create *args = data;
> > +	struct xe_tile *tile;
> >   	struct xe_vm *vm;
> >   	u32 id, asid;
> >   	int err;
> > @@ -2058,7 +2060,12 @@ int xe_vm_create_ioctl(struct drm_device *dev,
> > void *data,
> >
> >   	args->vm_id = id;
> >   	vm->xef = xef;
> > -
> > +	/* Record BO memory for VM pagetable create aginst client */
> > +	for_each_tile(tile, xe, id) {
> > +		if (!vm->pt_root[id])
> > +			continue;
> > +		xe_drm_client_add_bo(vm->xef->client, vm->pt_root[id]-
> >bo);
> 
> can be changed to
> 
> if (vm->pt_root[id])
> 	xe_drm_client_add_bo(vm->xef->client, vm->pt_root[id]->bo);
> 

Sure.

> BR
> Himal
> 
> > +	}
> >   #if IS_ENABLED(CONFIG_DRM_XE_DEBUG_MEM)
> >   	/* Warning: Security issue - never enable by default */
> >   	args->reserved[0] = xe_bo_main_addr(vm->pt_root[0]->bo,
> > XE_PAGE_SIZE);


More information about the Intel-xe mailing list