Skip to contentSkip to conversation

drm/i915/lmem: debugfs for LMEM details

PATCH Superseded Ramalingam C 3 participants 4 messages Dec 20, 2019 – Dec 24, 2019

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/i915/lmem: debugfs for LMEM details

From: Lukasz Fiedorowicz <[email protected]>

Debugfs i915_gem_object is extended to enable the IGTs to detect the LMEM's availability and the total size of LMEM.

v2: READ_ONCE is used [Chris]

---
 drivers/gpu/drm/i915/i915_debugfs.c        | 6 +++++-
 drivers/gpu/drm/i915/intel_memory_region.c | 5 ++++-
 drivers/gpu/drm/i915/intel_memory_region.h | 2 ++
 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +5 -1
index d28468eaed57..7e8e5112da25 100644
@@ -373,7 +373,11 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
 		   atomic_read(&i915->mm.free_count),
 		   i915->mm.shrink_memory);
 
-	seq_putc(m, '\n');
+	if (HAS_LMEM(i915)) {
+		seq_printf(m, "LMEM total: %llu bytes, available %llu bytes\n",
+			   READ_ONCE(i915->mm.regions[INTEL_REGION_LMEM]->total),
+			   READ_ONCE(i915->mm.regions[INTEL_REGION_LMEM]->avail));
+	}
 
 	print_context_stats(m, i915);
 
drivers/gpu/drm/i915/intel_memory_region.c +4 -1
index e24c280e5930..15e539de0a82 100644
@@ -37,7 +37,7 @@ __intel_memory_region_put_pages_buddy(struct intel_memory_region *mem,
 				      struct list_head *blocks)
 {
 	mutex_lock(&mem->mm_lock);
-	intel_memory_region_free_pages(mem, blocks);
+	mem->avail += intel_memory_region_free_pages(mem, blocks);
 	mutex_unlock(&mem->mm_lock);
 }
 
@@ -106,6 +106,7 @@ __intel_memory_region_get_pages_buddy(struct intel_memory_region *mem,
 			break;
 	} while (1);
 
+	mem->avail -= size;
 	mutex_unlock(&mem->mm_lock);
 	return 0;
 
@@ -164,6 +165,8 @@ intel_memory_region_create(struct drm_i915_private *i915,
 	mem->io_start = io_start;
 	mem->min_page_size = min_page_size;
 	mem->ops = ops;
+	mem->total = size;
+	mem->avail = mem->total;
 
 	mutex_init(&mem->objects.lock);
 	INIT_LIST_HEAD(&mem->objects.list);
drivers/gpu/drm/i915/intel_memory_region.h +2 -0
index 238722009677..644ca73d7905 100644
@@ -82,6 +82,8 @@ struct intel_memory_region {
 
 	resource_size_t io_start;
 	resource_size_t min_page_size;
+	resource_size_t total;
+	resource_size_t avail;
 
 	unsigned int type;
 	unsigned int instance;
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

Quoting Ramalingam C (2019-12-20 15:11:57)

Quoted 24 lines

From: Lukasz Fiedorowicz <[email protected]>

Debugfs i915_gem_object is extended to enable the IGTs to detect the LMEM's availability and the total size of LMEM.

v2: READ_ONCE is used [Chris]

---
 drivers/gpu/drm/i915/i915_debugfs.c        | 6 +++++-
 drivers/gpu/drm/i915/intel_memory_region.c | 5 ++++-
 drivers/gpu/drm/i915/intel_memory_region.h | 2 ++
 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index d28468eaed57..7e8e5112da25 100644

drivers/gpu/drm/i915/i915_debugfs.c static int i915_gem_object_info(struct seq_file *m, void *data) · line 379

Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c +4 -1
@@ -373,7 +373,11 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
                   atomic_read(&i915->mm.free_count),
                   i915->mm.shrink_memory);
 
-       seq_putc(m, '\n');
+       if (HAS_LMEM(i915)) {
+               seq_printf(m, "LMEM total: %llu bytes, available %llu bytes\n",
+                          READ_ONCE(i915->mm.regions[INTEL_REGION_LMEM]->total),
+                          READ_ONCE(i915->mm.regions[INTEL_REGION_LMEM]->avail));

It has to be %pa &total, &avail. That removes the READ_ONE() :( -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Ramalingam C
Thank you for the patch! Yet something to improve:

Hi Ramalingam,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[cannot apply to drm-tip/drm-tip v5.5-rc3 next-20191220]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Ramalingam-C/drm-i915-lmem-debugfs-for-LMEM-details/20191223-230416
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-g003-20191223 (attached as .config)
compiler: gcc-7 (Debian 7.5.0-3) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

drivers/gpu/drm/i915/i915_debugfs.c: In function 'i915_gem_object_info':

>> drivers/gpu/drm/i915/i915_debugfs.c:377:33: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'resource_size_t {aka unsigned int}' [-Werror=format=]
      seq_printf(m, "LMEM total: %llu bytes, available %llu bytes\n",
                                 ~~~^
                                 %u
   drivers/gpu/drm/i915/i915_debugfs.c:377:55: error: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'resource_size_t {aka unsigned int}' [-Werror=format=]
      seq_printf(m, "LMEM total: %llu bytes, available %llu bytes\n",
                                                       ~~~^
                                                       %u

cc1: all warnings being treated as errors

vim +377 drivers/gpu/drm/i915/i915_debugfs.c

366
367 static int i915_gem_object_info(struct seq_file *m, void *data)
368 {
369 struct drm_i915_private *i915 = node_to_i915(m->private);
370
371 seq_printf(m, "%u shrinkable [%u free] objects, %llu bytes\n",

   372			   i915->mm.shrink_count,
   373			   atomic_read(&i915->mm.free_count),
   374			   i915->mm.shrink_memory);
   375	
   376		if (HAS_LMEM(i915)) {
 > 377			seq_printf(m, "LMEM total: %llu bytes, available %llu bytes\n",

378 READ_ONCE(i915->mm.regions[INTEL_REGION_LMEM]->total),
379 READ_ONCE(i915->mm.regions[INTEL_REGION_LMEM]->avail));
380 }
381
382 print_context_stats(m, i915);
383
384 return 0;
385 }
386

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

#3 lore raw
In reply to Ramalingam C
Thank you for the patch! Perhaps something to improve:

Hi Ramalingam,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip v5.5-rc3 next-20191220] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Ramalingam-C/drm-i915-lmem-debugfs-for-LMEM-details/20191223-230416
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-defconfig (attached as .config)
compiler: gcc-7 (Debian 7.5.0-3) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

drivers/gpu/drm/i915/i915_debugfs.c: In function 'i915_gem_object_info':

>> drivers/gpu/drm/i915/i915_debugfs.c:377:33: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'resource_size_t {aka unsigned int}' [-Wformat=]
      seq_printf(m, "LMEM total: %llu bytes, available %llu bytes\n",
                                 ~~~^
                                 %u
   drivers/gpu/drm/i915/i915_debugfs.c:377:55: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'resource_size_t {aka unsigned int}' [-Wformat=]
      seq_printf(m, "LMEM total: %llu bytes, available %llu bytes\n",
                                                       ~~~^
                                                       %u

vim +377 drivers/gpu/drm/i915/i915_debugfs.c

366
367 static int i915_gem_object_info(struct seq_file *m, void *data)
368 {
369 struct drm_i915_private *i915 = node_to_i915(m->private);
370
371 seq_printf(m, "%u shrinkable [%u free] objects, %llu bytes\n",

   372			   i915->mm.shrink_count,
   373			   atomic_read(&i915->mm.free_count),
   374			   i915->mm.shrink_memory);
   375	
   376		if (HAS_LMEM(i915)) {
 > 377			seq_printf(m, "LMEM total: %llu bytes, available %llu bytes\n",

378 READ_ONCE(i915->mm.regions[INTEL_REGION_LMEM]->total),
379 READ_ONCE(i915->mm.regions[INTEL_REGION_LMEM]->avail));
380 }
381
382 print_context_stats(m, i915);
383
384 return 0;
385 }
386

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation