diff mbox series

[2/5] drm/i915: Record which clients own a VM

Message ID 20230608145133.1059554-3-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series fdinfo memory stats | expand

Commit Message

Tvrtko Ursulin June 8, 2023, 2:51 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

To enable accounting of indirect client memory usage (such as page tables)
in the following patch, lets start recording the creator of each PPGTT.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c       | 11 ++++++++---
 drivers/gpu/drm/i915/gem/i915_gem_context_types.h |  3 +++
 drivers/gpu/drm/i915/gt/intel_gtt.h               |  1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

Comments

kernel test robot June 8, 2023, 5:48 p.m. UTC | #1
Hi Tvrtko,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Tvrtko-Ursulin/drm-i915-Track-buffer-objects-belonging-to-clients/20230608-225344
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230608145133.1059554-3-tvrtko.ursulin%40linux.intel.com
patch subject: [PATCH 2/5] drm/i915: Record which clients own a VM
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20230609/202306090149.5gHC8re3-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build):
        git remote add drm-tip git://anongit.freedesktop.org/drm/drm-tip
        git fetch drm-tip drm-tip
        git checkout drm-tip/drm-tip
        b4 shazam https://lore.kernel.org/r/20230608145133.1059554-3-tvrtko.ursulin@linux.intel.com
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 olddefconfig
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/gpu/drm/i915/

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306090149.5gHC8re3-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/gpu/drm/i915/gem/i915_gem_context.c:2587:
   drivers/gpu/drm/i915/gem/selftests/mock_context.c: In function 'live_context':
>> drivers/gpu/drm/i915/gem/selftests/mock_context.c:86:35: error: passing argument 1 of 'proto_context_create' from incompatible pointer type [-Werror=incompatible-pointer-types]
      86 |         pc = proto_context_create(i915, 0);
         |                                   ^~~~
         |                                   |
         |                                   struct drm_i915_private *
   drivers/gpu/drm/i915/gem/i915_gem_context.c:282:52: note: expected 'struct drm_i915_file_private *' but argument is of type 'struct drm_i915_private *'
     282 | proto_context_create(struct drm_i915_file_private *fpriv,
         |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
>> drivers/gpu/drm/i915/gem/selftests/mock_context.c:86:14: error: too few arguments to function 'proto_context_create'
      86 |         pc = proto_context_create(i915, 0);
         |              ^~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/gem/i915_gem_context.c:282:1: note: declared here
     282 | proto_context_create(struct drm_i915_file_private *fpriv,
         | ^~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/gem/selftests/mock_context.c: In function 'kernel_context':
   drivers/gpu/drm/i915/gem/selftests/mock_context.c:155:35: error: passing argument 1 of 'proto_context_create' from incompatible pointer type [-Werror=incompatible-pointer-types]
     155 |         pc = proto_context_create(i915, 0);
         |                                   ^~~~
         |                                   |
         |                                   struct drm_i915_private *
   drivers/gpu/drm/i915/gem/i915_gem_context.c:282:52: note: expected 'struct drm_i915_file_private *' but argument is of type 'struct drm_i915_private *'
     282 | proto_context_create(struct drm_i915_file_private *fpriv,
         |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   drivers/gpu/drm/i915/gem/selftests/mock_context.c:155:14: error: too few arguments to function 'proto_context_create'
     155 |         pc = proto_context_create(i915, 0);
         |              ^~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/gem/i915_gem_context.c:282:1: note: declared here
     282 | proto_context_create(struct drm_i915_file_private *fpriv,
         | ^~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors


vim +/proto_context_create +86 drivers/gpu/drm/i915/gem/selftests/mock_context.c

79f0f4724d9c50 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2017-07-21   76  
79f0f4724d9c50 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2017-07-21   77  struct i915_gem_context *
a8c9a7f52ec5a4 drivers/gpu/drm/i915/gem/selftests/mock_context.c Chris Wilson           2019-11-07   78  live_context(struct drm_i915_private *i915, struct file *file)
79f0f4724d9c50 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2017-07-21   79  {
a4c1cdd34e2cda drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08   80  	struct drm_i915_file_private *fpriv = to_drm_file(file)->driver_priv;
a34857dc92475a drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08   81  	struct i915_gem_proto_context *pc;
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21   82  	struct i915_gem_context *ctx;
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21   83  	int err;
c100777cc00ce9 drivers/gpu/drm/i915/gem/selftests/mock_context.c Tvrtko Ursulin         2019-12-24   84  	u32 id;
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21   85  
a34857dc92475a drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08  @86  	pc = proto_context_create(i915, 0);
a34857dc92475a drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08   87  	if (IS_ERR(pc))
a34857dc92475a drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08   88  		return ERR_CAST(pc);
a34857dc92475a drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08   89  
a34857dc92475a drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08   90  	ctx = i915_gem_create_context(i915, pc);
d3ac8d42168a9b drivers/gpu/drm/i915/gem/selftests/mock_context.c Daniele Ceraolo Spurio 2021-09-24   91  	proto_context_close(i915, pc);
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21   92  	if (IS_ERR(ctx))
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21   93  		return ctx;
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21   94  
03d0ed8a8e9300 drivers/gpu/drm/i915/gem/selftests/mock_context.c Chris Wilson           2020-01-28   95  	i915_gem_context_set_no_error_capture(ctx);
03d0ed8a8e9300 drivers/gpu/drm/i915/gem/selftests/mock_context.c Chris Wilson           2020-01-28   96  
a4c1cdd34e2cda drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08   97  	err = xa_alloc(&fpriv->context_xa, &id, NULL, xa_limit_32b, GFP_KERNEL);
3e05531243d032 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21   98  	if (err < 0)
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21   99  		goto err_ctx;
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21  100  
a4c1cdd34e2cda drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08  101  	gem_context_register(ctx, fpriv, id);
a4c1cdd34e2cda drivers/gpu/drm/i915/gem/selftests/mock_context.c Faith Ekstrand         2021-07-08  102  
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21  103  	return ctx;
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21  104  
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21  105  err_ctx:
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21  106  	context_close(ctx);
3aa9945a528e76 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2019-03-21  107  	return ERR_PTR(err);
79f0f4724d9c50 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2017-07-21  108  }
8ec21a7c4b5216 drivers/gpu/drm/i915/selftests/mock_context.c     Chris Wilson           2018-02-05  109
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 9a9ff84c90d7..35cf6608180e 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -279,7 +279,8 @@  static int proto_context_set_protected(struct drm_i915_private *i915,
 }
 
 static struct i915_gem_proto_context *
-proto_context_create(struct drm_i915_private *i915, unsigned int flags)
+proto_context_create(struct drm_i915_file_private *fpriv,
+		     struct drm_i915_private *i915, unsigned int flags)
 {
 	struct i915_gem_proto_context *pc, *err;
 
@@ -287,6 +288,7 @@  proto_context_create(struct drm_i915_private *i915, unsigned int flags)
 	if (!pc)
 		return ERR_PTR(-ENOMEM);
 
+	pc->fpriv = fpriv;
 	pc->num_user_engines = -1;
 	pc->user_engines = NULL;
 	pc->user_flags = BIT(UCONTEXT_BANNABLE) |
@@ -1621,6 +1623,7 @@  i915_gem_create_context(struct drm_i915_private *i915,
 			err = PTR_ERR(ppgtt);
 			goto err_ctx;
 		}
+		ppgtt->vm.fpriv = pc->fpriv;
 		vm = &ppgtt->vm;
 	}
 	if (vm)
@@ -1740,7 +1743,7 @@  int i915_gem_context_open(struct drm_i915_private *i915,
 	/* 0 reserved for invalid/unassigned ppgtt */
 	xa_init_flags(&file_priv->vm_xa, XA_FLAGS_ALLOC1);
 
-	pc = proto_context_create(i915, 0);
+	pc = proto_context_create(file_priv, i915, 0);
 	if (IS_ERR(pc)) {
 		err = PTR_ERR(pc);
 		goto err;
@@ -1822,6 +1825,7 @@  int i915_gem_vm_create_ioctl(struct drm_device *dev, void *data,
 
 	GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
 	args->vm_id = id;
+	ppgtt->vm.fpriv = file_priv;
 	return 0;
 
 err_put:
@@ -2284,7 +2288,8 @@  int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 		return -EIO;
 	}
 
-	ext_data.pc = proto_context_create(i915, args->flags);
+	ext_data.pc = proto_context_create(file->driver_priv, i915,
+					   args->flags);
 	if (IS_ERR(ext_data.pc))
 		return PTR_ERR(ext_data.pc);
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
index cb78214a7dcd..c573c067779f 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
@@ -188,6 +188,9 @@  struct i915_gem_proto_engine {
  * CONTEXT_CREATE_SET_PARAM during GEM_CONTEXT_CREATE.
  */
 struct i915_gem_proto_context {
+	/** @fpriv: Client which creates the context */
+	struct drm_i915_file_private *fpriv;
+
 	/** @vm: See &i915_gem_context.vm */
 	struct i915_address_space *vm;
 
diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h b/drivers/gpu/drm/i915/gt/intel_gtt.h
index 4d6296cdbcfd..7192a534a654 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
@@ -248,6 +248,7 @@  struct i915_address_space {
 	struct drm_mm mm;
 	struct intel_gt *gt;
 	struct drm_i915_private *i915;
+	struct drm_i915_file_private *fpriv;
 	struct device *dma;
 	u64 total;		/* size addr space maps (ex. 2GB for ggtt) */
 	u64 reserved;		/* size addr space reserved */