Skip to contentSkip to conversation

drm/i915: Interface to get GFX shmem usage stats per process

RFC In review Praveen Paneri 4 participants 11 messages Mar 22, 2018 – Mar 26, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover drm/i915: Interface to get GFX shmem usage stats per process

This series introduces a new gfx driver interface for tracking graphics memory usage at per process level. This interface is currently needed by android memtracker HAL and it can also be used with driver's shrinker interface (see patch 5).

This feature was last floated to ML by Sourab and the discussion can be viewed here-
https://lists.freedesktop.org/archives/intel-gfx/2014-September/051687.html
Two major comments that I could see here are
1) Handling of cases where drm fd is shared across processes.
2) Sysfs is probably not a right place for this. Debugfs would be more appropriate?

I have tried to address (1) by moving away from "per drm fd based object accounting" to "per process based object accounting". With that, gfx memory consumed by child process created by fork() gets accounted separately from the parent process even though they share the same fd.

WIP on-
- filesystem switch as mentioned in (2) above
- some IGT failures observed with the series

I would like to get early reviews and feedback on this while I work on above points.

Credits:
Sourab and Akash (Authors)
Nidhi (Rebased to latest drm-tip)
Praveen (Worked on review comments and other fixes)

Sourab Gupta (5):
drm/i915: Sysfs interface to get GFX shmem usage stats per process drm/i915: Calculate total shmem GFX memory consumed drm/i915: Sysfs interface to get detailed GFX buffer info per process drm/i915: Output the user virtual addresses for GFX buffers drm/i915: Update process mm stats for Gen GFX memory

 drivers/gpu/drm/i915/i915_debugfs.c      |   15 -
 drivers/gpu/drm/i915/i915_drv.c          |    1 +
 drivers/gpu/drm/i915/i915_drv.h          |   25 +
 drivers/gpu/drm/i915/i915_gem.c          | 1009 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_gem_object.h   |    2 +
 drivers/gpu/drm/i915/i915_gem_shrinker.c |   18 +
 drivers/gpu/drm/i915/i915_gpu_error.c    |   23 +-
 drivers/gpu/drm/i915/i915_gpu_error.h    |    6 +
 drivers/gpu/drm/i915/i915_params.c       |    2 +
 drivers/gpu/drm/i915/i915_params.h       |    3 +-
 drivers/gpu/drm/i915/i915_sysfs.c        |  272 ++++++++
 11 files changed, 1356 insertions(+), 20 deletions(-)
Signature · 6 lines
1.9.1

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

RFC 1/5 drm/i915: Sysfs interface to get GFX shmem usage stats per process

From: Sourab Gupta <[email protected]>

There's a need for an interface which provide information about GFX memory usage per process, at any instantaneous point of time. Such information is useful to analyze GFX memory usage of the processes, on the lines of other system memory usage tools (e.g. procrank). This is especially useful for the GFX intensive processes, since the tools such as procrank may not be able to provide a precise view of GFX memory consumption, with its specific intricacies (such as differentiation between private, shared and purgeable buffers).

The patch provides a sysfs interface to list GFX memory usage for each client process. The interface also provides GFX buffers/memory usage information categorized into various buckets according to buffer type such as purgeable, private, shared.

v2:
-Move from per drm file accounting to per process accounting to
address shared drm fd cases (Daniel)
-Use div64_u64 for 64 bit divisions (Sagar)

---
 drivers/gpu/drm/i915/i915_drv.c        |   1 +
 drivers/gpu/drm/i915/i915_drv.h        |   4 +
 drivers/gpu/drm/i915/i915_gem.c        | 548 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_gem_object.h |   1 +
 drivers/gpu/drm/i915/i915_gpu_error.c  |   9 +-
 drivers/gpu/drm/i915/i915_gpu_error.h  |   4 +
 drivers/gpu/drm/i915/i915_params.c     |   2 +
 drivers/gpu/drm/i915/i915_params.h     |   3 +-
 drivers/gpu/drm/i915/i915_sysfs.c      |  78 +++++
 9 files changed, 647 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index a7d3275..06c0901 100644
@@ -2847,6 +2847,7 @@ static int intel_runtime_resume(struct device *kdev)
 	.lastclose = i915_driver_lastclose,
 	.postclose = i915_driver_postclose,
 
+	.gem_open_object = i915_gem_open_object,
 	.gem_close_object = i915_gem_close_object,
 	.gem_free_object_unlocked = i915_gem_free_object,
 	.gem_vm_ops = &i915_gem_vm_ops,
drivers/gpu/drm/i915/i915_drv.h +4 -0
index c9c3b2b..c23ba28 100644
@@ -1660,6 +1660,7 @@ struct drm_i915_private {
 
 	bool preserve_bios_swizzle;
 
+	struct kobject memtrack_kobj;
 	/* overlay */
 	struct intel_overlay *overlay;
 
@@ -2884,6 +2885,7 @@ struct drm_i915_gem_object *
 struct drm_i915_gem_object *
 i915_gem_object_create_from_data(struct drm_i915_private *dev_priv,
 				 const void *data, size_t size);
+int i915_gem_open_object(struct drm_gem_object *gem, struct drm_file *file);
 void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file);
 void i915_gem_free_object(struct drm_gem_object *obj);
 
@@ -3352,6 +3354,8 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 /* i915_sysfs.c */
 void i915_setup_sysfs(struct drm_i915_private *dev_priv);
 void i915_teardown_sysfs(struct drm_i915_private *dev_priv);
+int i915_get_drm_clients_info(struct drm_i915_error_state_buf *m,
+			      struct drm_device *dev);
 
 /* intel_lpe_audio.c */
 int  intel_lpe_audio_init(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_gem.c +548 -0

583 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem_object.h +1 -0
index 54f00b3..8176d7d 100644
@@ -279,6 +279,7 @@ struct drm_i915_gem_object {
 
 		void *gvt_info;
 	};
+	struct list_head pid_info;
 
 	/** for phys allocated objects */
 	struct drm_dma_handle *phys_handle;
drivers/gpu/drm/i915/i915_gpu_error.c +7 -2
index effaf98..3e8fc79 100644
@@ -90,6 +90,11 @@ static bool __i915_error_ok(struct drm_i915_error_state_buf *e)
 	return true;
 }
 
+bool i915_error_ok(struct drm_i915_error_state_buf *e)
+{
+	return __i915_error_ok(e);
+}
+
 static bool __i915_error_seek(struct drm_i915_error_state_buf *e,
 			      unsigned len)
 {
@@ -161,8 +166,8 @@ static void i915_error_vprintf(struct drm_i915_error_state_buf *e,
 	__i915_error_advance(e, len);
 }
 
-static void i915_error_puts(struct drm_i915_error_state_buf *e,
-			    const char *str)
+void i915_error_puts(struct drm_i915_error_state_buf *e,
+		     const char *str)
 {
 	unsigned len;
 
drivers/gpu/drm/i915/i915_gpu_error.h +4 -0
index ac57606..dac2a35 100644
@@ -308,6 +308,10 @@ int i915_error_state_buf_init(struct drm_i915_error_state_buf *eb,
 			      struct drm_i915_private *i915,
 			      size_t count, loff_t pos);
 
+void i915_error_puts(struct drm_i915_error_state_buf *e,
+		     const char *str);
+bool i915_error_ok(struct drm_i915_error_state_buf *e);
+
 static inline void
 i915_error_state_buf_release(struct drm_i915_error_state_buf *eb)
 {
drivers/gpu/drm/i915/i915_params.c +2 -0
index 08108ce..746d45c 100644
@@ -178,6 +178,8 @@ struct i915_params i915_modparams __read_mostly = {
 i915_param_named(enable_gvt, bool, 0400,
 	"Enable support for Intel GVT-g graphics virtualization host support(default:false)");
 
+i915_param_named(memtrack_debug, bool, 0600, "use memtrack capability (default:true)");
+
 static __always_inline void _print_param(struct drm_printer *p,
 					 const char *name,
 					 const char *type,
drivers/gpu/drm/i915/i915_params.h +2 -1
index c963603..40cd3ab 100644
@@ -69,7 +69,8 @@
 	param(bool, nuclear_pageflip, false) \
 	param(bool, enable_dp_mst, true) \
 	param(bool, enable_dpcd_backlight, false) \
-	param(bool, enable_gvt, false)
+	param(bool, enable_gvt, false) \
+	param(bool, memtrack_debug, true)
 
 #define MEMBER(T, member, ...) T member;
 struct i915_params {
drivers/gpu/drm/i915/i915_sysfs.c +78 -0

99 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

Re: [RFC 1/5] drm/i915: Sysfs interface to get GFX shmem usage stats per process

Quoting Praveen Paneri (2018-03-22 14:14:54)

Quoted 4 lines

From: Sourab Gupta <[email protected]>

There's a need for an interface which provide information about GFX memory usage per process, at any instantaneous point of time.

You meant per context surely. So why not solve userspace's problem in userspace, you are missing a whole lot of rationale here to justify so much *invasive* code.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

RFC 2/5 drm/i915: Calculate total shmem GFX memory consumed

In reply to Praveen Paneri

From: Sourab Gupta <[email protected]>

There are some GFX buffers e.g. ringbuffers, ctx buffers, etc. which are not associated with any drm fd. Thus, the sum of the shmem memory consumed by processes would be less than the total memory actually consumed in the system.

This patch keeps track of all shmem memory consumptions in the system which is given out by the sysfs interface introduced earlier.

---
 drivers/gpu/drm/i915/i915_drv.h        |  2 ++
 drivers/gpu/drm/i915/i915_gem.c        | 38 +++++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/i915_gem_object.h |  1 +
 3 files changed, 38 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index c23ba28..b760133 100644
@@ -980,6 +980,8 @@ struct i915_gem_mm {
 	spinlock_t object_stat_lock;
 	u64 object_memory;
 	u32 object_count;
+
+	size_t phys_mem_total;
 };
 
 #define I915_IDLE_ENGINES_TIMEOUT (200) /* in ms */
drivers/gpu/drm/i915/i915_gem.c +35 -3
index 49555ea..6116e37 100644
@@ -2313,6 +2313,17 @@ static void i915_gem_object_free_mmap_offset(struct drm_i915_gem_object *obj)
 	 */
 	shmem_truncate_range(file_inode(obj->base.filp), 0, (loff_t)-1);
 	obj->mm.madv = __I915_MADV_PURGED;
+
+	/*
+	 * Mark the object as not having backing pages, as physical space
+	 * returned back to kernel
+	 */
+	if (obj->has_backing_pages == 1) {
+		struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
+
+		dev_priv->mm.phys_mem_total -= obj->base.size;
+		obj->has_backing_pages = 0;
+	}
 	obj->mm.pages = ERR_PTR(-EFAULT);
 }
 
@@ -2600,6 +2611,13 @@ static int i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
 
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 
+	if (obj->has_backing_pages == 0) {
+		struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
+
+		dev_priv->mm.phys_mem_total += obj->base.size;
+		obj->has_backing_pages = 1;
+	}
+
 	return 0;
 
 err_sg:
@@ -4667,6 +4685,11 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
 	init_request_active(&obj->frontbuffer_write, frontbuffer_retire);
 
 	obj->mm.madv = I915_MADV_WILLNEED;
+	/*
+	 * Mark the object as not having backing pages, as no allocation
+	 * for it yet
+	 */
+	obj->has_backing_pages = 0;
 	INIT_LIST_HEAD(&obj->pid_info);
 	INIT_RADIX_TREE(&obj->mm.get_page.radix, GFP_KERNEL | __GFP_NOWARN);
 	mutex_init(&obj->mm.get_page.lock);
@@ -4858,6 +4881,13 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 
 		if (obj->base.import_attach)
 			drm_prime_gem_destroy(&obj->base, NULL);
+		if (!obj->stolen && (obj->has_backing_pages == 1)) {
+			struct drm_i915_private *dev_priv =
+					obj->base.dev->dev_private;
+
+			dev_priv->mm.phys_mem_total -= obj->base.size;
+			obj->has_backing_pages = 0;
+		}
 
 		reservation_object_fini(&obj->__builtin_resv);
 		drm_gem_object_release(&obj->base);
@@ -6318,6 +6348,8 @@ static int i915_obj_shared_count(struct drm_i915_gem_object *obj,
 		u64 nr_bytes =
 			i915_obj_get_shmem_pages_alloced(obj)*PAGE_SIZE;
 
+		if (obj->has_backing_pages)
+			stats->num_obj_allocated++;
 		if (obj->mm.madv == I915_MADV_DONTNEED) {
 			stats->num_obj_purgeable++;
 			if (nr_bytes != 0)
@@ -6325,7 +6357,6 @@ static int i915_obj_shared_count(struct drm_i915_gem_object *obj,
 		}
 
 		if (nr_bytes != 0) {
-			stats->num_obj_allocated++;
 			if (obj_shared_count > 1) {
 				stats->phys_space_allocated_shared += nr_bytes;
 				stats->phys_space_shared_proportion +=
@@ -6416,7 +6447,7 @@ static int i915_gem_object_pid_order(int id, void *ptr, void *data)
 			    struct drm_device *dev)
 {
 	struct drm_file *file;
-
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct name_entry *entry, *next;
 	struct pid_stat_entry *pid_entry, *temp_entry;
 	struct pid_stat_entry *new_pid_entry, *new_temp_entry;
@@ -6519,7 +6550,8 @@ static int i915_gem_object_pid_order(int id, void *ptr, void *data)
 	err_printf(m,
 		"\t\t\t\t\t\t\t\t%13zdK\t%12zdK\tTotal\n",
 			total_shared_prop_space, total_priv_space);
-
+	err_printf(m, "\nTotal used GFX Shmem Physical space %8zdK\n",
+		  dev_priv->mm.phys_mem_total/1024);
 	if (ret)
 		return ret;
 	if (m->bytes == 0 && m->err)
drivers/gpu/drm/i915/i915_gem_object.h +1 -0
index 8176d7d..8eb0288 100644
@@ -147,6 +147,7 @@ struct drm_i915_gem_object {
 #define I915_BO_CACHE_COHERENT_FOR_READ BIT(0)
 #define I915_BO_CACHE_COHERENT_FOR_WRITE BIT(1)
 	unsigned int cache_dirty:1;
+	unsigned int has_backing_pages:1;
 
 	/**
 	 * @read_domains: Read memory domains.
Signature · 6 lines
1.9.1

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

RFC 3/5 drm/i915: Sysfs interface to get detailed GFX buffer info per process

In reply to Praveen Paneri

From: Sourab Gupta <[email protected]>

Sometimes, in order to debug the mem usage scenarios, the summarized view of GFX memory consumption per process is not sufficient, as it doesn't provide buffer level details. Therefore, there's a need for an interface, which can provide such detailed information.

This patch provides a sysfs interface to retrieve such detailed information about GFX buffers used per process. Each process has a sysfs file associated in the 'gfx_memtrack' directory, named by the process' tgid. Reading the file will provide list of all GFX buffers open by the process, along with their attributes such as size, pinneed, tiling, shared, allocstate, gtt offset, etc.

v2:
-Use div64_u64 for 64 bit divisions (Sagar)

---
 drivers/gpu/drm/i915/i915_debugfs.c   |  15 --
 drivers/gpu/drm/i915/i915_drv.h       |  11 ++
 drivers/gpu/drm/i915/i915_gem.c       | 302 +++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_gpu_error.c |  14 ++
 drivers/gpu/drm/i915/i915_gpu_error.h |   2 +
 drivers/gpu/drm/i915/i915_sysfs.c     | 184 +++++++++++++++++++++
 6 files changed, 507 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -15
index 7816cd5..94e7987 100644
@@ -63,21 +63,6 @@ static char get_active_flag(struct drm_i915_gem_object *obj)
 	return i915_gem_object_is_active(obj) ? '*' : ' ';
 }
 
-static char get_pin_flag(struct drm_i915_gem_object *obj)
-{
-	return obj->pin_global ? 'p' : ' ';
-}
-
-static char get_tiling_flag(struct drm_i915_gem_object *obj)
-{
-	switch (i915_gem_object_get_tiling(obj)) {
-	default:
-	case I915_TILING_NONE: return ' ';
-	case I915_TILING_X: return 'X';
-	case I915_TILING_Y: return 'Y';
-	}
-}
-
 static char get_global_flag(struct drm_i915_gem_object *obj)
 {
 	return obj->userfault_count ? 'g' : ' ';
drivers/gpu/drm/i915/i915_drv.h +11 -0
index b760133..85a3dd9 100644
@@ -337,6 +337,7 @@ struct drm_i915_file_private {
 	} rps_client;
 
 	unsigned int bsd_engine;
+	struct bin_attribute *obj_attr;
 
 /* Client can have a maximum of 3 contexts banned before
  * it is denied of creating new contexts. As one context
@@ -982,6 +983,8 @@ struct i915_gem_mm {
 	u32 object_count;
 
 	size_t phys_mem_total;
+	/* accounting all gem clients */
+	struct list_head gem_client_pids;
 };
 
 #define I915_IDLE_ENGINES_TIMEOUT (200) /* in ms */
@@ -2890,6 +2893,8 @@ struct drm_i915_gem_object *
 int i915_gem_open_object(struct drm_gem_object *gem, struct drm_file *file);
 void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file);
 void i915_gem_free_object(struct drm_gem_object *obj);
+char get_pin_flag(struct drm_i915_gem_object *obj);
+char get_tiling_flag(struct drm_i915_gem_object *obj);
 
 static inline void i915_gem_drain_freed_objects(struct drm_i915_private *i915)
 {
@@ -3358,6 +3363,12 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 void i915_teardown_sysfs(struct drm_i915_private *dev_priv);
 int i915_get_drm_clients_info(struct drm_i915_error_state_buf *m,
 			      struct drm_device *dev);
+int i915_gem_get_obj_info(struct drm_i915_error_state_buf *m,
+			  struct drm_device *dev, struct pid *tgid);
+int i915_gem_create_sysfs_file_entry(struct drm_device *dev,
+				     struct bin_attribute *obj_attr);
+void i915_gem_remove_sysfs_file_entry(struct drm_device *dev,
+				      struct bin_attribute *obj_attr);
 
 /* intel_lpe_audio.c */
 int  intel_lpe_audio_init(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_gem.c +296 -6

390 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gpu_error.c +14 -0
index 3e8fc79..7638459 100644
@@ -859,6 +859,20 @@ int i915_error_state_buf_init(struct drm_i915_error_state_buf *ebuf,
 	return 0;
 }
 
+int i915_obj_state_buf_init(struct drm_i915_error_state_buf *ebuf,
+				size_t count)
+{
+	memset(ebuf, 0, sizeof(*ebuf));
+
+	ebuf->buf = kmalloc(count, GFP_KERNEL);
+
+	if (ebuf->buf == NULL)
+		return -ENOMEM;
+
+	ebuf->size = count;
+	return 0;
+}
+
 static void i915_error_object_free(struct drm_i915_error_object *obj)
 {
 	int page;
drivers/gpu/drm/i915/i915_gpu_error.h +2 -0
index dac2a35..0db5829 100644
@@ -307,6 +307,8 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *estr,
 int i915_error_state_buf_init(struct drm_i915_error_state_buf *eb,
 			      struct drm_i915_private *i915,
 			      size_t count, loff_t pos);
+int i915_obj_state_buf_init(struct drm_i915_error_state_buf *eb,
+			    size_t count);
 
 void i915_error_puts(struct drm_i915_error_state_buf *e,
 		     const char *str);
drivers/gpu/drm/i915/i915_sysfs.c +184 -0

190 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

RFC 4/5 drm/i915: Output the user virtual addresses for GFX buffers

In reply to Praveen Paneri

From: Sourab Gupta <[email protected]>

This patch adds the functionality to output the virtual addresses of each GFX buffer, mapped into process address space (via interfaces such as mmap and mmap_gtt).

---
 drivers/gpu/drm/i915/i915_gem.c | 112 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 107 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +107 -5
index 2cb6c98..25845652 100644
@@ -85,10 +85,16 @@ struct pid_stat_entry {
 	int pid_num;
 };
 
+struct drm_i915_obj_virt_addr {
+	struct list_head head;
+	unsigned long user_virt_addr;
+};
+
 struct drm_i915_obj_pid_info {
 	struct list_head head;
 	pid_t tgid;
 	int open_handle_count;
+	struct list_head virt_addr_head;
 };
 
 struct drm_i915_gem_client_pid {
@@ -145,6 +151,9 @@ static void async_mmput(struct mm_struct *mm)
 static void i915_gem_obj_remove_all_pids(struct drm_i915_private *i915,
 					 struct drm_i915_gem_object *obj);
 static void i915_gem_obj_remove_pid(struct drm_i915_gem_object *obj);
+static int i915_obj_insert_virt_addr(struct drm_i915_gem_object *obj,
+				     unsigned long addr, bool is_map_gtt,
+				     bool is_mutex_locked);
 
 static bool cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
 {
@@ -1839,6 +1848,7 @@ static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
 	struct drm_i915_gem_mmap *args = data;
 	struct drm_i915_gem_object *obj;
 	unsigned long addr;
+	int ret;
 
 	if (args->flags & ~(I915_MMAP_WC))
 		return -EINVAL;
@@ -1884,6 +1894,10 @@ static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
 	if (IS_ERR((void *)addr))
 		return addr;
 
+	ret = i915_obj_insert_virt_addr(obj, addr, false, false);
+	if (ret)
+		return ret;
+
 	args->addr_ptr = (uint64_t) addr;
 
 	return 0;
@@ -2085,6 +2099,10 @@ int i915_gem_fault(struct vm_fault *vmf)
 		list_add(&obj->userfault_link, &dev_priv->mm.userfault_list);
 	GEM_BUG_ON(!obj->userfault_count);
 
+	ret = i915_obj_insert_virt_addr(obj,
+					(unsigned long)area->vm_start,
+					true, true);
+
 	i915_vma_set_ggtt_write(vma);
 
 err_fence:
@@ -6298,6 +6316,7 @@ static int i915_gem_obj_insert_pid(struct drm_i915_gem_object *obj)
 		}
 		entry->tgid = current_tgid;
 		entry->open_handle_count = 1;
+		INIT_LIST_HEAD(&entry->virt_addr_head);
 		list_add_tail(&entry->head, &obj->pid_info);
 	}
 
@@ -6309,6 +6328,7 @@ static void i915_gem_obj_remove_pid(struct drm_i915_gem_object *obj)
 {
 	pid_t current_tgid = task_tgid_nr(current);
 	struct drm_i915_obj_pid_info *pid_entry, *pid_next;
+	struct drm_i915_obj_virt_addr *virt_entry, *virt_next;
 	int found = 0;
 
 	if (!i915_modparams.memtrack_debug)
@@ -6321,6 +6341,13 @@ static void i915_gem_obj_remove_pid(struct drm_i915_gem_object *obj)
 			pid_entry->open_handle_count--;
 			found = 1;
 			if (pid_entry->open_handle_count == 0) {
+				list_for_each_entry_safe(virt_entry,
+						virt_next,
+						&pid_entry->virt_addr_head,
+						head) {
+					list_del(&virt_entry->head);
+					kfree(virt_entry);
+				}
 				list_del(&pid_entry->head);
 				kfree(pid_entry);
 			}
@@ -6338,9 +6365,18 @@ static void i915_gem_obj_remove_all_pids(struct drm_i915_private *i915,
 					 struct drm_i915_gem_object *obj)
 {
 	struct drm_i915_obj_pid_info *pid_entry, *pid_next;
+	struct drm_i915_obj_virt_addr *virt_entry, *virt_next;
 
 	mutex_lock(&i915->drm.struct_mutex);
 	list_for_each_entry_safe(pid_entry, pid_next, &obj->pid_info, head) {
+		list_for_each_entry_safe(virt_entry,
+					 virt_next,
+					 &pid_entry->virt_addr_head,
+					 head) {
+			list_del(&virt_entry->head);
+			kfree(virt_entry);
+		}
+
 		/* Remove object from that pid's client list */
 		while (pid_entry->open_handle_count--)
 			i915_gem_client_remove(i915, pid_entry->tgid, true);
@@ -6351,6 +6387,61 @@ static void i915_gem_obj_remove_all_pids(struct drm_i915_private *i915,
 	mutex_unlock(&i915->drm.struct_mutex);
 }
 
+static int i915_obj_insert_virt_addr(struct drm_i915_gem_object *obj,
+				     unsigned long addr,
+				     bool is_map_gtt,
+				     bool is_mutex_locked)
+{
+	struct drm_i915_obj_pid_info *pid_entry;
+	pid_t current_tgid = task_tgid_nr(current);
+	int ret = 0, found = 0;
+
+	if (!i915_modparams.memtrack_debug)
+		return 0;
+
+	if (is_map_gtt)
+		addr |= 1;
+
+	if (!is_mutex_locked) {
+		ret = i915_mutex_lock_interruptible(obj->base.dev);
+		if (ret)
+			return ret;
+	}
+
+	list_for_each_entry(pid_entry, &obj->pid_info, head) {
+		if (pid_entry->tgid == current_tgid) {
+			struct drm_i915_obj_virt_addr *virt_entry, *new_entry;
+
+			list_for_each_entry(virt_entry,
+					    &pid_entry->virt_addr_head,
+					    head) {
+				if (virt_entry->user_virt_addr == addr) {
+					found = 1;
+					break;
+				}
+			}
+			if (found)
+				break;
+			new_entry = kzalloc(sizeof(*new_entry), GFP_KERNEL);
+			if (new_entry == NULL) {
+				DRM_ERROR("alloc failed\n");
+				ret = -ENOMEM;
+				goto out;
+			}
+			new_entry->user_virt_addr = addr;
+			list_add_tail(&new_entry->head,
+				&pid_entry->virt_addr_head);
+			break;
+		}
+	}
+
+out:
+	if (!is_mutex_locked)
+		mutex_unlock(&obj->base.dev->struct_mutex);
+
+	return ret;
+}
+
 static int i915_obj_find_insert_in_hash(struct drm_i915_gem_object *obj,
 				struct pid_stat_entry *pid_entry,
 				bool *found)
@@ -6421,6 +6512,7 @@ static int i915_obj_shared_count(struct drm_i915_gem_object *obj,
 {
 	struct i915_vma *vma;
 	struct drm_i915_obj_pid_info *pid_info_entry;
+	struct drm_i915_obj_virt_addr *virt_entry;
 	struct drm_i915_error_state_buf *m = obj_stat_buf->m;
 	struct pid_stat_entry *pid_entry = obj_stat_buf->entry;
 	struct per_file_obj_mem_info *stats = &pid_entry->stats;
@@ -6475,12 +6567,22 @@ static int i915_obj_shared_count(struct drm_i915_gem_object *obj,
 		i915_error_printf(m, "  %08llx ", vma->node.start);
 	}
 	if (list_empty(&obj->vma_list))
-		err_puts(m, "                  ");
-
-	list_for_each_entry(pid_info_entry, &obj->pid_info, head)
-		i915_error_printf(m, " (%d: %d)",
+		err_puts(m, "                                    ");
+	list_for_each_entry(pid_info_entry, &obj->pid_info, head) {
+		err_printf(m, " (%d: %d:",
 			   pid_info_entry->tgid,
 			   pid_info_entry->open_handle_count);
+		list_for_each_entry(virt_entry,
+				    &pid_info_entry->virt_addr_head, head) {
+			if (virt_entry->user_virt_addr & 1)
+				err_printf(m, " %p",
+				(void *)(virt_entry->user_virt_addr & ~1));
+			else
+				err_printf(m, " %p*",
+				(void *)virt_entry->user_virt_addr);
+		}
+		err_puts(m, ") ");
+	}
 
 	err_puts(m, "\n");
 
@@ -6792,7 +6894,7 @@ static int i915_gem_object_pid_order(int id, void *ptr, void *data)
 	i915_error_printf(m, "%"SPACES_STR(NUM_SPACES)"s\n", " ");
 
 	err_puts(m,
-		"\n Obj Identifier   Obj-Size Resident-Size Pin Tiling Dirty Shared Vmap Stolen Mappable  AllocState Global/PP  GttOffset (PID: handle count)\n");
+		"\n Obj Identifier   Obj-Size Resident-Size Pin Tiling Dirty Shared Vmap Stolen Mappable  AllocState Global/PP  GttOffset (PID: handle count: user virt addrs)\n");
 
 	list_for_each_entry(file, &dev->filelist, lhead) {
 		struct get_obj_stats_buf obj_stat_buf;
Signature · 6 lines
1.9.1

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

RFC 5/5 drm/i915: Update process mm stats for Gen GFX memory

In reply to Praveen Paneri

From: Sourab Gupta <[email protected]>

The GFX memory consumed by a process is not accounted by kernel. This leads to a scenario wherein the low memory killer is not able to correctly identify the best process to be killed during OOM scenarios. This case particularly manifests when an application has a large GFX memory footprint but has a significantly smaller system mem consumption. Low mem killer in such a case will not be able to identify this culprit process, and lot of innocent process will be killed without freeing much memory.

This patch utilizes the memtracker functions to add the accounting for the processes' GFX memory consumption.
The internal kernel counters updated thus don't affect the output of procrank, meminfo or smaps.
The kernel counters updated though would lead to better approximation of process' memory consumption, leading to better low mem killer behavior.

The memtracker functions are called at asynchronous points during shrinker invocation.
Thus, in times of memory stress, we ensure to update the processes' GFX mem statistics, therefore leading to better low mem killer behavior

---
 drivers/gpu/drm/i915/i915_drv.h          |  8 ++++++
 drivers/gpu/drm/i915/i915_gem.c          | 47 +++++++++++++++++++++++++++-----
 drivers/gpu/drm/i915/i915_gem_shrinker.c | 18 ++++++++++++
 drivers/gpu/drm/i915/i915_sysfs.c        | 22 +++++++++++----
 4 files changed, 82 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -0
index 85a3dd9..0646175 100644
@@ -316,6 +316,14 @@ struct i915_hotplug {
 struct i915_mm_struct;
 struct i915_mmu_object;
 
+struct i915_gem_file_attr_priv {
+	char tgid_str[16];
+	struct pid *tgid;
+	size_t rss_size;
+	struct mm_struct *mm;
+	struct drm_i915_error_state_buf buf;
+};
+
 struct drm_i915_file_private {
 	struct drm_i915_private *dev_priv;
 	struct drm_file *file;
drivers/gpu/drm/i915/i915_gem.c +40 -7

95 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem_shrinker.c +18 -0
index 5757fb7..09fe3bf 100644
@@ -304,6 +304,22 @@ unsigned long i915_gem_shrink_all(struct drm_i915_private *i915)
 	return freed;
 }
 
+static void i915_gem_update_gfx_stats(struct drm_device *dev)
+{
+	struct drm_i915_private *i915 = to_i915(dev);
+	struct drm_i915_error_state_buf error_str;
+	bool unlock;
+
+	if (!shrinker_lock(i915, &unlock))
+		return;
+
+	error_str.bytes = 0;
+	error_str.size = 0;
+	error_str.err = -ENOSPC;
+	i915_get_drm_clients_info(&error_str, dev);
+	shrinker_unlock(i915, unlock);
+}
+
 static unsigned long
 i915_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc)
 {
@@ -341,6 +357,8 @@ unsigned long i915_gem_shrink_all(struct drm_i915_private *i915)
 			    128ul /* default SHRINK_BATCH */);
 	}
 
+	i915_gem_update_gfx_stats(&i915->drm);
+
 	return count;
 }
 
drivers/gpu/drm/i915/i915_sysfs.c +16 -6
index 7f7d74a..5829aec 100644
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/stat.h>
 #include <linux/sysfs.h>
+#include <linux/sched/mm.h>
 #include "intel_drv.h"
 #include "i915_drv.h"
 
@@ -570,7 +571,13 @@ static ssize_t i915_gem_clients_state_read(struct file *filp,
 	if (ret)
 		return ret;
 
+	ret = i915_mutex_lock_interruptible(dev);
+	if (ret)
+		goto out;
+
 	ret = i915_get_drm_clients_info(&error_str, dev);
+
+	mutex_unlock(&dev->struct_mutex);
 	if (ret)
 		goto out;
 
@@ -585,12 +592,6 @@ static ssize_t i915_gem_clients_state_read(struct file *filp,
 #define GEM_OBJ_STAT_BUF_SIZE (4*1024) /* 4KB */
 #define GEM_OBJ_STAT_BUF_SIZE_MAX (1024*1024) /* 1MB */
 
-struct i915_gem_file_attr_priv {
-	char tgid_str[16];
-	struct pid *tgid;
-	struct drm_i915_error_state_buf buf;
-};
-
 static ssize_t i915_gem_read_objects(struct file *filp,
 				struct kobject *memtrack_kobj,
 				struct bin_attribute *attr,
@@ -727,6 +728,9 @@ int i915_gem_create_sysfs_file_entry(struct drm_device *dev,
 	obj_attr->size = 0;
 	obj_attr->read = i915_gem_read_objects;
 
+	attr_priv->rss_size = 0;
+	attr_priv->mm = current->mm;
+	atomic_inc(&current->mm->mm_count);
 	attr_priv->tgid = tgid;
 	obj_attr->private = attr_priv;
 
@@ -761,6 +765,12 @@ void i915_gem_remove_sysfs_file_entry(struct drm_device *dev,
 
 	attr_priv = obj_attr->private;
 
+	if (attr_priv->mm) {
+		add_mm_counter(attr_priv->mm, MM_FILEPAGES,
+				-attr_priv->rss_size);
+		mmdrop(attr_priv->mm);
+	}
+
 	sysfs_remove_bin_file(&dev_priv->memtrack_kobj, obj_attr);
 
 	i915_error_state_buf_release(&attr_priv->buf);
Signature · 6 lines
1.9.1

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

✗ Fi.CI.CHECKPATCH: warning for drm/i915: Interface to get GFX shmem usage stats per process

In reply to Praveen Paneri
== Series Details ==

== Series Details ==

Series: drm/i915: Interface to get GFX shmem usage stats per process
URL : https://patchwork.freedesktop.org/series/40464/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
a2507d62bb4c drm/i915: Sysfs interface to get GFX shmem usage stats per process
-:228: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV)
#228: FILE: drivers/gpu/drm/i915/i915_gem.c:6118:
+	if (res > 0 && buffer[res-1] != '\0' && len < PAGE_SIZE)
 	                         ^

-:229: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV) #229: FILE: drivers/gpu/drm/i915/i915_gem.c:6119:
+ buffer[res-1] = '\0';
^

-:275: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!entry" #275: FILE: drivers/gpu/drm/i915/i915_gem.c:6165:
+ if (entry == NULL) {

-:315: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #315: FILE: drivers/gpu/drm/i915/i915_gem.c:6205:
+ DRM_DEBUG("Couldn't find matching tgid %d for obj %p\n",
+ current_tgid, obj);

-:329: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #329: FILE: drivers/gpu/drm/i915/i915_gem.c:6219:
+static int i915_obj_find_insert_in_hash(struct drm_i915_gem_object *obj,
+ struct pid_stat_entry *pid_entry,

-:336: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #336: FILE: drivers/gpu/drm/i915/i915_gem.c:6226:
+ ret = drm_ht_find_item(&pid_entry->namelist,
+ (unsigned long)&obj->base, &hash_item);

-:338: CHECK:BRACES: braces {} should be used on all arms of this statement #338: FILE: drivers/gpu/drm/i915/i915_gem.c:6228:
+ if (ret) {
[...]
+ } else
[...]

-:341: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!entry" #341: FILE: drivers/gpu/drm/i915/i915_gem.c:6231:
+ if (entry == NULL) {

-:350: CHECK:BRACES: Unbalanced braces around else statement #350: FILE: drivers/gpu/drm/i915/i915_gem.c:6240:
+ } else

-:357: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #357: FILE: drivers/gpu/drm/i915/i915_gem.c:6247:
+static int i915_obj_shared_count(struct drm_i915_gem_object *obj,
+ struct pid_stat_entry *pid_entry,

-:371: CHECK:BRACES: braces {} should be used on all arms of this statement #371: FILE: drivers/gpu/drm/i915/i915_gem.c:6261:
+ if (!obj->base.name && !obj->base.dma_buf)
[...]
+ else if (obj->base.import_attach) {
[...]

-:429: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #429: FILE: drivers/gpu/drm/i915/i915_gem.c:6319:
+ i915_obj_get_shmem_pages_alloced(obj)*PAGE_SIZE;
^

-:439: CHECK:BRACES: braces {} should be used on all arms of this statement #439: FILE: drivers/gpu/drm/i915/i915_gem.c:6329:
+ if (obj_shared_count > 1) {
[...]
+ } else
[...]

-:443: CHECK:BRACES: Unbalanced braces around else statement #443: FILE: drivers/gpu/drm/i915/i915_gem.c:6333:
+ } else

-:480: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!new_entry" #480: FILE: drivers/gpu/drm/i915/i915_gem.c:6370:
+ if (new_entry == NULL) {

-:490: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #490: FILE: drivers/gpu/drm/i915/i915_gem.c:6380:
+ ret = drm_ht_create(&new_entry->namelist,
+ DRM_DEBUG_MAGIC_HASH_ORDER);

-:519: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #519: FILE: drivers/gpu/drm/i915/i915_gem.c:6409:
+
+ }

-:541: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #541: FILE: drivers/gpu/drm/i915/i915_gem.c:6431:
+ err_puts(m,
+ "\n\n pid Total Shared Priv Purgeable Alloced SharedPHYsize SharedPHYprop PrivPHYsize PurgeablePHYsize process\n");

-:561: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #561: FILE: drivers/gpu/drm/i915/i915_gem.c:6451:
+ list_for_each_entry_safe(new_pid_entry, new_temp_entry,
+ &sorted_pid_stats, head) {

-:567: WARNING:MULTILINE_DEREFERENCE: Avoid multiple line dereference - prefer 'new_pid_entry->stats.phys_space_shared_proportion' #567: FILE: drivers/gpu/drm/i915/i915_gem.c:6457:
+ new_pid_entry->
+ stats.phys_space_shared_proportion +

-:572: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #572: FILE: drivers/gpu/drm/i915/i915_gem.c:6462:
+ list_add_tail(&pid_entry->head,
+ &new_pid_entry->head);

-:576: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #576: FILE: drivers/gpu/drm/i915/i915_gem.c:6466:
+ if (list_is_last(&new_pid_entry->head,
+ &sorted_pid_stats)) {

-:579: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #579: FILE: drivers/gpu/drm/i915/i915_gem.c:6469:
+ list_add_tail(&pid_entry->head,
+ &sorted_pid_stats);

-:585: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #585: FILE: drivers/gpu/drm/i915/i915_gem.c:6475:
+ list_for_each_entry_safe(pid_entry, temp_entry,
+ &sorted_pid_stats, head) {

-:589: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #589: FILE: drivers/gpu/drm/i915/i915_gem.c:6479:
+ err_printf(m,
+ "%5d %6d %6d %6d %9d %8d %14zdK %14zdK %14zdK %14zdK %s",

-:596: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #596: FILE: drivers/gpu/drm/i915/i915_gem.c:6486:
+ pid_entry->stats.phys_space_allocated_shared/1024,
^

-:597: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #597: FILE: drivers/gpu/drm/i915/i915_gem.c:6487:
+ pid_entry->stats.phys_space_shared_proportion/1024,
^

-:598: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #598: FILE: drivers/gpu/drm/i915/i915_gem.c:6488:
+ pid_entry->stats.phys_space_allocated_priv/1024,
^

-:599: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #599: FILE: drivers/gpu/drm/i915/i915_gem.c:6489:
+ pid_entry->stats.phys_space_purgeable/1024,
^

-:602: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!task" #602: FILE: drivers/gpu/drm/i915/i915_gem.c:6492:
+ if (task == NULL)

-:608: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #608: FILE: drivers/gpu/drm/i915/i915_gem.c:6498:
+ pid_entry->stats.phys_space_shared_proportion/1024;
^

-:610: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #610: FILE: drivers/gpu/drm/i915/i915_gem.c:6500:
+ pid_entry->stats.phys_space_allocated_priv/1024;
^

-:614: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #614: FILE: drivers/gpu/drm/i915/i915_gem.c:6504:
+ list_for_each_entry_safe(entry, next,
+ &pid_entry->namefree, head) {

-:617: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #617: FILE: drivers/gpu/drm/i915/i915_gem.c:6507:
+ drm_ht_remove_item(&pid_entry->namelist,
+ &entry->hash_item);

-:628: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #628: FILE: drivers/gpu/drm/i915/i915_gem.c:6518:
+ err_puts(m,
+ "\t\t\t\t\t\t\t\t--------------\t-------------\t--------\n");

-:630: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #630: FILE: drivers/gpu/drm/i915/i915_gem.c:6520:
+ err_printf(m,
+ "\t\t\t\t\t\t\t\t%13zdK\t%12zdK\tTotal\n",

-:754: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #754: FILE: drivers/gpu/drm/i915/i915_sysfs.c:555:
}
+static ssize_t i915_gem_clients_state_read(struct file *filp,

-:755: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #755: FILE: drivers/gpu/drm/i915/i915_sysfs.c:556:
+static ssize_t i915_gem_clients_state_read(struct file *filp,
+ struct kobject *memtrack_kobj,

-:791: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #791: FILE: drivers/gpu/drm/i915/i915_sysfs.c:593:
};
+static struct bin_attribute i915_gem_client_state_attr = {

-:793: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH' are not preferred. Consider using octal permissions '0644'. #793: FILE: drivers/gpu/drm/i915/i915_sysfs.c:595:
+ .attr.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,

-:819: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #819: FILE: drivers/gpu/drm/i915/i915_sysfs.c:621:
+ ret = kobject_init_and_add(

-:823: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #823: FILE: drivers/gpu/drm/i915/i915_sysfs.c:625:
+ DRM_ERROR(

-:829: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #829: FILE: drivers/gpu/drm/i915/i915_sysfs.c:631:
+ ret = sysfs_create_bin_file(&dev_priv->memtrack_kobj,
+ &i915_gem_client_state_attr);

-:831: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #831: FILE: drivers/gpu/drm/i915/i915_sysfs.c:633:
+ DRM_ERROR(

-:847: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #847: FILE: drivers/gpu/drm/i915/i915_sysfs.c:718:
+ sysfs_remove_bin_file(&dev_priv->memtrack_kobj,
+ &i915_gem_client_state_attr);

total: 0 errors, 2 warnings, 43 checks, 766 lines checked
27bfa55dd165 drm/i915: Calculate total shmem GFX memory consumed
-:84: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'obj->has_backing_pages == 1' #84: FILE: drivers/gpu/drm/i915/i915_gem.c:4884:
+ if (!obj->stolen && (obj->has_backing_pages == 1)) {

-:126: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #126: FILE: drivers/gpu/drm/i915/i915_gem.c:6554:
+ err_printf(m, "\nTotal used GFX Shmem Physical space %8zdK\n",
+ dev_priv->mm.phys_mem_total/1024);

-:126: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #126: FILE: drivers/gpu/drm/i915/i915_gem.c:6554:
+ dev_priv->mm.phys_mem_total/1024);
^

total: 0 errors, 0 warnings, 3 checks, 101 lines checked
0d8d278defab drm/i915: Sysfs interface to get detailed GFX buffer info per process -:167: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!client_pid" #167: FILE: drivers/gpu/drm/i915/i915_gem.c:3689:
+ if (client_pid == NULL) {

-:175: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #175: FILE: drivers/gpu/drm/i915/i915_gem.c:3697:
+ ret = i915_gem_create_sysfs_file_entry(&i915->drm,
+ &client_pid->obj_attr);

-:187: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #187: FILE: drivers/gpu/drm/i915/i915_gem.c:3709:
+
+ }

-:201: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'client_pid->tgid == tgid' #201: FILE: drivers/gpu/drm/i915/i915_gem.c:3723:
+ if ((client_pid->tgid == tgid) &&
+ (--client_pid->open_obj_count == 0)) {

-:249: CHECK:LINE_SPACING: Please don't use multiple blank lines #249: FILE: drivers/gpu/drm/i915/i915_gem.c:3790:

+

-:322: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #322: FILE: drivers/gpu/drm/i915/i915_gem.c:6436:
+ nr_bytes = i915_obj_get_shmem_pages_alloced(obj)*PAGE_SIZE;
^

-:324: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'obj->mm.madv != __I915_MADV_PURGED' #324: FILE: drivers/gpu/drm/i915/i915_gem.c:6438:
+ if (!discard && !obj->stolen &&
+ (obj->mm.madv != __I915_MADV_PURGED) &&
+ (nr_bytes != 0)) {

-:324: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'nr_bytes != 0' #324: FILE: drivers/gpu/drm/i915/i915_gem.c:6438:
+ if (!discard && !obj->stolen &&
+ (obj->mm.madv != __I915_MADV_PURGED) &&
+ (nr_bytes != 0)) {

-:325: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #325: FILE: drivers/gpu/drm/i915/i915_gem.c:6439:
+ if (!discard && !obj->stolen &&
+ (obj->mm.madv != __I915_MADV_PURGED) &&

-:335: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #335: FILE: drivers/gpu/drm/i915/i915_gem.c:6449:
+ i915_error_printf(m,
+ "%p: %7zdK %10zdK %c %c %s %s %s %s %s",

-:368: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #368: FILE: drivers/gpu/drm/i915/i915_gem.c:6482:
+ i915_error_printf(m, " (%d: %d)",
+ pid_info_entry->tgid,

-:389: CHECK:BRACES: Blank lines aren't necessary after an open brace '{' #389: FILE: drivers/gpu/drm/i915/i915_gem.c:6503:
+ list_for_each_entry(pid_info, &obj->pid_info, head) {
+

-:435: CHECK:CONCATENATED_STRING: Concatenated strings should use spaces between elements #435: FILE: drivers/gpu/drm/i915/i915_gem.c:6792:
+ i915_error_printf(m, "%"SPACES_STR(NUM_SPACES)"s\n", " ");

-:438: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #438: FILE: drivers/gpu/drm/i915/i915_gem.c:6795:
+ err_puts(m,
+ "\n Obj Identifier Obj-Size Resident-Size Pin Tiling Dirty Shared Vmap Stolen Mappable AllocState Global/PP GttOffset (PID: handle count)\n");

-:448: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #448: FILE: drivers/gpu/drm/i915/i915_gem.c:6805:
+ ret = idr_for_each(&file->object_idr,
+ &i915_drm_gem_obj_info, &obj_stat_buf);

-:460: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #460: FILE: drivers/gpu/drm/i915/i915_gem.c:6817:
+ i915_error_printf(m, "%5d %8zdK ", pid_nr(tgid),
+ (pid_entry.stats.phys_space_shared_proportion +

-:461: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #461: FILE: drivers/gpu/drm/i915/i915_gem.c:6818:
+ pid_entry.stats.phys_space_allocated_priv)/1024);
^

-:468: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #468: FILE: drivers/gpu/drm/i915/i915_gem.c:6825:
+ drm_ht_remove_item(&pid_entry.namelist,
+ &entry->hash_item);

-:489: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #489: FILE: drivers/gpu/drm/i915/i915_gem.c:6863:
+int i915_gem_get_obj_info(struct drm_i915_error_state_buf *m,
+ struct drm_device *dev, struct pid *tgid)

-:512: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #512: FILE: drivers/gpu/drm/i915/i915_gpu_error.c:863:
+int i915_obj_state_buf_init(struct drm_i915_error_state_buf *ebuf,
+ size_t count)

-:518: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!ebuf->buf" #518: FILE: drivers/gpu/drm/i915/i915_gpu_error.c:869:
+ if (ebuf->buf == NULL)

-:549: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #549: FILE: drivers/gpu/drm/i915/i915_sysfs.c:585:
}
+#define GEM_OBJ_STAT_BUF_SIZE (4*1024) /* 4KB */

-:549: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #549: FILE: drivers/gpu/drm/i915/i915_sysfs.c:585:
+#define GEM_OBJ_STAT_BUF_SIZE (4*1024) /* 4KB */

                                 ^

-:550: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #550: FILE: drivers/gpu/drm/i915/i915_sysfs.c:586:
+#define GEM_OBJ_STAT_BUF_SIZE_MAX (1024*1024) /* 1MB */

                                        ^

-:559: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #559: FILE: drivers/gpu/drm/i915/i915_sysfs.c:595:
+static ssize_t i915_gem_read_objects(struct file *filp,
+ struct kobject *memtrack_kobj,

-:601: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #601: FILE: drivers/gpu/drm/i915/i915_sysfs.c:637:
+ DRM_ERROR(

-:610: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #610: FILE: drivers/gpu/drm/i915/i915_sysfs.c:646:
+ ret = i915_obj_state_buf_init(&attr_priv->buf,
+ buf_size);

-:612: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #612: FILE: drivers/gpu/drm/i915/i915_sysfs.c:648:
+ DRM_ERROR(

-:643: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #643: FILE: drivers/gpu/drm/i915/i915_sysfs.c:679:
+ ret = i915_obj_state_buf_init(&attr_priv->buf,
+ buf_size);

-:645: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #645: FILE: drivers/gpu/drm/i915/i915_sysfs.c:681:
+ DRM_ERROR(

-:657: CHECK:BRACES: braces {} should be used on all arms of this statement #657: FILE: drivers/gpu/drm/i915/i915_sysfs.c:693:
+ if (bytes_available > 0) {
[...]
+ } else
[...]

-:660: CHECK:BRACES: Unbalanced braces around else statement #660: FILE: drivers/gpu/drm/i915/i915_sysfs.c:696:
+ } else

-:690: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH' are not preferred. Consider using octal permissions '0644'. #690: FILE: drivers/gpu/drm/i915/i915_sysfs.c:726:
+ obj_attr->attr.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;

-:700: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #700: FILE: drivers/gpu/drm/i915/i915_sysfs.c:736:
+ DRM_ERROR(

-:723: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!obj_attr" #723: FILE: drivers/gpu/drm/i915/i915_sysfs.c:759:
+ if (WARN_ON(obj_attr == NULL))

total: 0 errors, 1 warnings, 34 checks, 664 lines checked 486204b0dac9 drm/i915: Output the user virtual addresses for GFX buffers -:97: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #97: FILE: drivers/gpu/drm/i915/i915_gem.c:6345:
+ list_for_each_entry_safe(virt_entry,
+ virt_next,

-:165: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!new_entry" #165: FILE: drivers/gpu/drm/i915/i915_gem.c:6426:
+ if (new_entry == NULL) {

-:172: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #172: FILE: drivers/gpu/drm/i915/i915_gem.c:6433:
+ list_add_tail(&new_entry->head,
+ &pid_entry->virt_addr_head);

-:212: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #212: FILE: drivers/gpu/drm/i915/i915_gem.c:6579:
+ err_printf(m, " %p",
+ (void *)(virt_entry->user_virt_addr & ~1));

-:215: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #215: FILE: drivers/gpu/drm/i915/i915_gem.c:6582:
+ err_printf(m, " %p*",
+ (void *)virt_entry->user_virt_addr);

total: 0 errors, 0 warnings, 5 checks, 199 lines checked 05a4782cc77f drm/i915: Update process mm stats for Gen GFX memory -:80: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #80: FILE: drivers/gpu/drm/i915/i915_gem.c:6306:
+ add_mm_counter(pid_entry->attr_priv->mm, MM_FILEPAGES,
+ new_size - old_size);

-:248: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #248: FILE: drivers/gpu/drm/i915/i915_sysfs.c:770:
+ add_mm_counter(attr_priv->mm, MM_FILEPAGES,
+ -attr_priv->rss_size);

total: 0 errors, 0 warnings, 2 checks, 192 lines checked

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

maintainer
#8 lore raw

Re: ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Interface to get GFX shmem usage stats per process

Quoted 9 lines · Patchwork

== Series Details ==

Series: drm/i915: Interface to get GFX shmem usage stats per process
URL : https://patchwork.freedesktop.org/series/40464/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip

I don't mind the foo == NULL comparisons leading to warnings CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!foo"

But everything else here is valid, and should be fixed before submitting this for real.

BR,
Jani.

Quoted 453 lines

a2507d62bb4c drm/i915: Sysfs interface to get GFX shmem usage stats per process -:228: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV) #228: FILE: drivers/gpu/drm/i915/i915_gem.c:6118:

(quoted diff) +1 -1
+	if (res > 0 && buffer[res-1] != '\0' && len < PAGE_SIZE)
 	                         ^
 
-:229: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV)

#229: FILE: drivers/gpu/drm/i915/i915_gem.c:6119:

(quoted diff) +1 -1
+		buffer[res-1] = '\0';
 		          ^
 
-:275: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!entry"

#275: FILE: drivers/gpu/drm/i915/i915_gem.c:6165:

(quoted diff) +1 -1
+		if (entry == NULL) {
 
-:315: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#315: FILE: drivers/gpu/drm/i915/i915_gem.c:6205:

(quoted diff) +2 -1
+		DRM_DEBUG("Couldn't find matching tgid %d for obj %p\n",
+				current_tgid, obj);
 
-:329: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#329: FILE: drivers/gpu/drm/i915/i915_gem.c:6219:

(quoted diff) +2 -1
+static int i915_obj_find_insert_in_hash(struct drm_i915_gem_object *obj,
+				struct pid_stat_entry *pid_entry,
 
-:336: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#336: FILE: drivers/gpu/drm/i915/i915_gem.c:6226:

(quoted diff) +2 -1
+	ret = drm_ht_find_item(&pid_entry->namelist,
+				(unsigned long)&obj->base, &hash_item);
 
-:338: CHECK:BRACES: braces {} should be used on all arms of this statement

#338: FILE: drivers/gpu/drm/i915/i915_gem.c:6228:

(quoted diff) +2 -1
+	if (ret) {
[...]
+	} else
[...]
 
-:341: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!entry"

#341: FILE: drivers/gpu/drm/i915/i915_gem.c:6231:

(quoted diff) +1 -1
+		if (entry == NULL) {
 
-:350: CHECK:BRACES: Unbalanced braces around else statement

#350: FILE: drivers/gpu/drm/i915/i915_gem.c:6240:

(quoted diff) +1 -1
+	} else
 
-:357: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#357: FILE: drivers/gpu/drm/i915/i915_gem.c:6247:

(quoted diff) +2 -1
+static int i915_obj_shared_count(struct drm_i915_gem_object *obj,
+				struct pid_stat_entry *pid_entry,
 
-:371: CHECK:BRACES: braces {} should be used on all arms of this statement

#371: FILE: drivers/gpu/drm/i915/i915_gem.c:6261:

(quoted diff) +2 -1
+	if (!obj->base.name && !obj->base.dma_buf)
[...]
+	else if (obj->base.import_attach) {
[...]
 
-:429: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV)

#429: FILE: drivers/gpu/drm/i915/i915_gem.c:6319:

(quoted diff) +1 -1
+			i915_obj_get_shmem_pages_alloced(obj)*PAGE_SIZE;
 			                                     ^
 
-:439: CHECK:BRACES: braces {} should be used on all arms of this statement

#439: FILE: drivers/gpu/drm/i915/i915_gem.c:6329:

(quoted diff) +2 -1
+			if (obj_shared_count > 1) {
[...]
+			} else
[...]
 
-:443: CHECK:BRACES: Unbalanced braces around else statement

#443: FILE: drivers/gpu/drm/i915/i915_gem.c:6333:

(quoted diff) +1 -1
+			} else
 
-:480: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!new_entry"

#480: FILE: drivers/gpu/drm/i915/i915_gem.c:6370:

(quoted diff) +1 -1
+			if (new_entry == NULL) {
 
-:490: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#490: FILE: drivers/gpu/drm/i915/i915_gem.c:6380:

(quoted diff) +2 -1
+			ret = drm_ht_create(&new_entry->namelist,
+					DRM_DEBUG_MAGIC_HASH_ORDER);
 
-:519: CHECK:BRACES: Blank lines aren't necessary before a close brace '}'

#519: FILE: drivers/gpu/drm/i915/i915_gem.c:6409:

(quoted diff) +2 -1
+
+	}
 
-:541: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#541: FILE: drivers/gpu/drm/i915/i915_gem.c:6431:

(quoted diff) +2 -1
+	err_puts(m,
+		"\n\n  pid   Total  Shared  Priv   Purgeable  Alloced  SharedPHYsize   SharedPHYprop    PrivPHYsize   PurgeablePHYsize   process\n");
 
-:561: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#561: FILE: drivers/gpu/drm/i915/i915_gem.c:6451:

(quoted diff) +2 -1
+		list_for_each_entry_safe(new_pid_entry, new_temp_entry,
+			&sorted_pid_stats, head) {
 
-:567: WARNING:MULTILINE_DEREFERENCE: Avoid multiple line dereference - prefer 'new_pid_entry->stats.phys_space_shared_proportion'

#567: FILE: drivers/gpu/drm/i915/i915_gem.c:6457:

(quoted diff) +2 -1
+				new_pid_entry->
+				stats.phys_space_shared_proportion +
 
-:572: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#572: FILE: drivers/gpu/drm/i915/i915_gem.c:6462:

(quoted diff) +2 -1
+				list_add_tail(&pid_entry->head,
+					&new_pid_entry->head);
 
-:576: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#576: FILE: drivers/gpu/drm/i915/i915_gem.c:6466:

(quoted diff) +2 -1
+			if (list_is_last(&new_pid_entry->head,
+				&sorted_pid_stats)) {
 
-:579: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#579: FILE: drivers/gpu/drm/i915/i915_gem.c:6469:

(quoted diff) +2 -1
+				list_add_tail(&pid_entry->head,
+						&sorted_pid_stats);
 
-:585: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#585: FILE: drivers/gpu/drm/i915/i915_gem.c:6475:

(quoted diff) +2 -1
+	list_for_each_entry_safe(pid_entry, temp_entry,
+				&sorted_pid_stats, head) {
 
-:589: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#589: FILE: drivers/gpu/drm/i915/i915_gem.c:6479:

(quoted diff) +2 -1
+		err_printf(m,
+			"%5d %6d %6d %6d %9d %8d %14zdK %14zdK %14zdK  %14zdK     %s",
 
-:596: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)

#596: FILE: drivers/gpu/drm/i915/i915_gem.c:6486:

(quoted diff) +1 -1
+			   pid_entry->stats.phys_space_allocated_shared/1024,
 			                                               ^
 
-:597: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)

#597: FILE: drivers/gpu/drm/i915/i915_gem.c:6487:

(quoted diff) +1 -1
+			   pid_entry->stats.phys_space_shared_proportion/1024,
 			                                                ^
 
-:598: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)

#598: FILE: drivers/gpu/drm/i915/i915_gem.c:6488:

(quoted diff) +1 -1
+			   pid_entry->stats.phys_space_allocated_priv/1024,
 			                                             ^
 
-:599: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)

#599: FILE: drivers/gpu/drm/i915/i915_gem.c:6489:

(quoted diff) +1 -1
+			   pid_entry->stats.phys_space_purgeable/1024,
 			                                        ^
 
-:602: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!task"

#602: FILE: drivers/gpu/drm/i915/i915_gem.c:6492:

(quoted diff) +1 -1
+		if (task == NULL)
 
-:608: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)

#608: FILE: drivers/gpu/drm/i915/i915_gem.c:6498:

(quoted diff) +1 -1
+			pid_entry->stats.phys_space_shared_proportion/1024;
 			                                             ^
 
-:610: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)

#610: FILE: drivers/gpu/drm/i915/i915_gem.c:6500:

(quoted diff) +1 -1
+			pid_entry->stats.phys_space_allocated_priv/1024;
 			                                          ^
 
-:614: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#614: FILE: drivers/gpu/drm/i915/i915_gem.c:6504:

(quoted diff) +2 -1
+		list_for_each_entry_safe(entry, next,
+					&pid_entry->namefree, head) {
 
-:617: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#617: FILE: drivers/gpu/drm/i915/i915_gem.c:6507:

(quoted diff) +2 -1
+			drm_ht_remove_item(&pid_entry->namelist,
+					&entry->hash_item);
 
-:628: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#628: FILE: drivers/gpu/drm/i915/i915_gem.c:6518:

(quoted diff) +2 -1
+	err_puts(m,
+		"\t\t\t\t\t\t\t\t--------------\t-------------\t--------\n");
 
-:630: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#630: FILE: drivers/gpu/drm/i915/i915_gem.c:6520:

(quoted diff) +2 -1
+	err_printf(m,
+		"\t\t\t\t\t\t\t\t%13zdK\t%12zdK\tTotal\n",
 
-:754: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations

#754: FILE: drivers/gpu/drm/i915/i915_sysfs.c:555:
}
+static ssize_t i915_gem_clients_state_read(struct file *filp,

-:755: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #755: FILE: drivers/gpu/drm/i915/i915_sysfs.c:556:

(quoted diff) +2 -1
+static ssize_t i915_gem_clients_state_read(struct file *filp,
+				struct kobject *memtrack_kobj,
 
-:791: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations

#791: FILE: drivers/gpu/drm/i915/i915_sysfs.c:593:
};
+static struct bin_attribute i915_gem_client_state_attr = {

-:793: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH' are not preferred. Consider using octal permissions '0644'. #793: FILE: drivers/gpu/drm/i915/i915_sysfs.c:595:

(quoted diff) +1 -1
+	.attr.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
 
-:819: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('

#819: FILE: drivers/gpu/drm/i915/i915_sysfs.c:621:

(quoted diff) +1 -1
+		ret = kobject_init_and_add(
 
-:823: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('

#823: FILE: drivers/gpu/drm/i915/i915_sysfs.c:625:

(quoted diff) +1 -1
+			DRM_ERROR(
 
-:829: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#829: FILE: drivers/gpu/drm/i915/i915_sysfs.c:631:

(quoted diff) +2 -1
+			ret = sysfs_create_bin_file(&dev_priv->memtrack_kobj,
+					    &i915_gem_client_state_attr);
 
-:831: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('

#831: FILE: drivers/gpu/drm/i915/i915_sysfs.c:633:

(quoted diff) +1 -1
+				DRM_ERROR(
 
-:847: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#847: FILE: drivers/gpu/drm/i915/i915_sysfs.c:718:

(quoted diff) +2 -0
+		sysfs_remove_bin_file(&dev_priv->memtrack_kobj,
+					&i915_gem_client_state_attr);

total: 0 errors, 2 warnings, 43 checks, 766 lines checked
27bfa55dd165 drm/i915: Calculate total shmem GFX memory consumed
-:84: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'obj->has_backing_pages == 1' #84: FILE: drivers/gpu/drm/i915/i915_gem.c:4884:

(quoted diff) +1 -1
+		if (!obj->stolen && (obj->has_backing_pages == 1)) {
 
-:126: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#126: FILE: drivers/gpu/drm/i915/i915_gem.c:6554:

(quoted diff) +2 -1
+	err_printf(m, "\nTotal used GFX Shmem Physical space %8zdK\n",
+		  dev_priv->mm.phys_mem_total/1024);
 
-:126: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)

#126: FILE: drivers/gpu/drm/i915/i915_gem.c:6554:

(quoted diff) +1 -0
+		  dev_priv->mm.phys_mem_total/1024);
 		                             ^

total: 0 errors, 0 warnings, 3 checks, 101 lines checked
0d8d278defab drm/i915: Sysfs interface to get detailed GFX buffer info per process -:167: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!client_pid" #167: FILE: drivers/gpu/drm/i915/i915_gem.c:3689:

(quoted diff) +1 -1
+		if (client_pid == NULL) {
 
-:175: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#175: FILE: drivers/gpu/drm/i915/i915_gem.c:3697:

(quoted diff) +2 -1
+		ret = i915_gem_create_sysfs_file_entry(&i915->drm,
+						 &client_pid->obj_attr);
 
-:187: CHECK:BRACES: Blank lines aren't necessary before a close brace '}'

#187: FILE: drivers/gpu/drm/i915/i915_gem.c:3709:

(quoted diff) +2 -1
+
+	}
 
-:201: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'client_pid->tgid == tgid'

#201: FILE: drivers/gpu/drm/i915/i915_gem.c:3723:

(quoted diff) +2 -1
+		if ((client_pid->tgid == tgid) &&
+		    (--client_pid->open_obj_count == 0)) {
 
-:249: CHECK:LINE_SPACING: Please don't use multiple blank lines

#249: FILE: drivers/gpu/drm/i915/i915_gem.c:3790:

+

-:322: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #322: FILE: drivers/gpu/drm/i915/i915_gem.c:6436:

(quoted diff) +1 -1
+		nr_bytes = i915_obj_get_shmem_pages_alloced(obj)*PAGE_SIZE;
 		                                                ^
 
-:324: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'obj->mm.madv != __I915_MADV_PURGED'

#324: FILE: drivers/gpu/drm/i915/i915_gem.c:6438:

(quoted diff) +3 -1
+	if (!discard && !obj->stolen &&
+			(obj->mm.madv != __I915_MADV_PURGED) &&
+			(nr_bytes != 0)) {
 
-:324: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'nr_bytes != 0'

#324: FILE: drivers/gpu/drm/i915/i915_gem.c:6438:

(quoted diff) +3 -1
+	if (!discard && !obj->stolen &&
+			(obj->mm.madv != __I915_MADV_PURGED) &&
+			(nr_bytes != 0)) {
 
-:325: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#325: FILE: drivers/gpu/drm/i915/i915_gem.c:6439:

(quoted diff) +2 -1
+	if (!discard && !obj->stolen &&
+			(obj->mm.madv != __I915_MADV_PURGED) &&
 
-:335: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#335: FILE: drivers/gpu/drm/i915/i915_gem.c:6449:

(quoted diff) +2 -1
+	i915_error_printf(m,
+		"%p: %7zdK  %10zdK     %c      %c     %s      %s      %s     %s     %s",
 
-:368: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#368: FILE: drivers/gpu/drm/i915/i915_gem.c:6482:

(quoted diff) +2 -1
+		i915_error_printf(m, " (%d: %d)",
+			   pid_info_entry->tgid,
 
-:389: CHECK:BRACES: Blank lines aren't necessary after an open brace '{'

#389: FILE: drivers/gpu/drm/i915/i915_gem.c:6503:

(quoted diff) +2 -1
+	list_for_each_entry(pid_info, &obj->pid_info, head) {
+
 
-:435: CHECK:CONCATENATED_STRING: Concatenated strings should use spaces between elements

#435: FILE: drivers/gpu/drm/i915/i915_gem.c:6792:

(quoted diff) +1 -1
+	i915_error_printf(m, "%"SPACES_STR(NUM_SPACES)"s\n", " ");
 
-:438: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#438: FILE: drivers/gpu/drm/i915/i915_gem.c:6795:

(quoted diff) +2 -1
+	err_puts(m,
+		"\n Obj Identifier   Obj-Size Resident-Size Pin Tiling Dirty Shared Vmap Stolen Mappable  AllocState Global/PP  GttOffset (PID: handle count)\n");
 
-:448: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#448: FILE: drivers/gpu/drm/i915/i915_gem.c:6805:

(quoted diff) +2 -1
+		ret = idr_for_each(&file->object_idr,
+				&i915_drm_gem_obj_info, &obj_stat_buf);
 
-:460: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#460: FILE: drivers/gpu/drm/i915/i915_gem.c:6817:

(quoted diff) +2 -1
+	i915_error_printf(m, "%5d %8zdK ", pid_nr(tgid),
+			(pid_entry.stats.phys_space_shared_proportion +
 
-:461: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)

#461: FILE: drivers/gpu/drm/i915/i915_gem.c:6818:

(quoted diff) +1 -1
+			 pid_entry.stats.phys_space_allocated_priv)/1024);
 			                                           ^
 
-:468: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#468: FILE: drivers/gpu/drm/i915/i915_gem.c:6825:

(quoted diff) +2 -1
+		drm_ht_remove_item(&pid_entry.namelist,
+				&entry->hash_item);
 
-:489: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#489: FILE: drivers/gpu/drm/i915/i915_gem.c:6863:

(quoted diff) +2 -1
+int i915_gem_get_obj_info(struct drm_i915_error_state_buf *m,
+			struct drm_device *dev, struct pid *tgid)
 
-:512: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#512: FILE: drivers/gpu/drm/i915/i915_gpu_error.c:863:

(quoted diff) +2 -1
+int i915_obj_state_buf_init(struct drm_i915_error_state_buf *ebuf,
+				size_t count)
 
-:518: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!ebuf->buf"

#518: FILE: drivers/gpu/drm/i915/i915_gpu_error.c:869:

(quoted diff) +1 -1
+	if (ebuf->buf == NULL)
 
-:549: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations

#549: FILE: drivers/gpu/drm/i915/i915_sysfs.c:585:
}
+#define GEM_OBJ_STAT_BUF_SIZE (4*1024) /* 4KB */

-:549: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #549: FILE: drivers/gpu/drm/i915/i915_sysfs.c:585:
+#define GEM_OBJ_STAT_BUF_SIZE (4*1024) /* 4KB */

                                 ^

-:550: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #550: FILE: drivers/gpu/drm/i915/i915_sysfs.c:586:
+#define GEM_OBJ_STAT_BUF_SIZE_MAX (1024*1024) /* 1MB */

                                        ^

-:559: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #559: FILE: drivers/gpu/drm/i915/i915_sysfs.c:595:

(quoted diff) +2 -1
+static ssize_t i915_gem_read_objects(struct file *filp,
+				struct kobject *memtrack_kobj,
 
-:601: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('

#601: FILE: drivers/gpu/drm/i915/i915_sysfs.c:637:

(quoted diff) +1 -1
+		DRM_ERROR(
 
-:610: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#610: FILE: drivers/gpu/drm/i915/i915_sysfs.c:646:

(quoted diff) +2 -1
+			ret = i915_obj_state_buf_init(&attr_priv->buf,
+				buf_size);
 
-:612: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('

#612: FILE: drivers/gpu/drm/i915/i915_sysfs.c:648:

(quoted diff) +1 -1
+				DRM_ERROR(
 
-:643: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#643: FILE: drivers/gpu/drm/i915/i915_sysfs.c:679:

(quoted diff) +2 -1
+			ret = i915_obj_state_buf_init(&attr_priv->buf,
+						buf_size);
 
-:645: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('

#645: FILE: drivers/gpu/drm/i915/i915_sysfs.c:681:

(quoted diff) +1 -1
+				DRM_ERROR(
 
-:657: CHECK:BRACES: braces {} should be used on all arms of this statement

#657: FILE: drivers/gpu/drm/i915/i915_sysfs.c:693:

(quoted diff) +2 -1
+	if (bytes_available > 0) {
[...]
+	} else
[...]
 
-:660: CHECK:BRACES: Unbalanced braces around else statement

#660: FILE: drivers/gpu/drm/i915/i915_sysfs.c:696:

(quoted diff) +1 -1
+	} else
 
-:690: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH' are not preferred. Consider using octal permissions '0644'.

#690: FILE: drivers/gpu/drm/i915/i915_sysfs.c:726:

(quoted diff) +1 -1
+	obj_attr->attr.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
 
-:700: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('

#700: FILE: drivers/gpu/drm/i915/i915_sysfs.c:736:

(quoted diff) +1 -1
+		DRM_ERROR(
 
-:723: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!obj_attr"

#723: FILE: drivers/gpu/drm/i915/i915_sysfs.c:759:

(quoted diff) +1 -0
+	if (WARN_ON(obj_attr == NULL))

total: 0 errors, 1 warnings, 34 checks, 664 lines checked 486204b0dac9 drm/i915: Output the user virtual addresses for GFX buffers -:97: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #97: FILE: drivers/gpu/drm/i915/i915_gem.c:6345:

(quoted diff) +2 -1
+				list_for_each_entry_safe(virt_entry,
+						virt_next,
 
-:165: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!new_entry"

#165: FILE: drivers/gpu/drm/i915/i915_gem.c:6426:

(quoted diff) +1 -1
+			if (new_entry == NULL) {
 
-:172: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#172: FILE: drivers/gpu/drm/i915/i915_gem.c:6433:

(quoted diff) +2 -1
+			list_add_tail(&new_entry->head,
+				&pid_entry->virt_addr_head);
 
-:212: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#212: FILE: drivers/gpu/drm/i915/i915_gem.c:6579:

(quoted diff) +2 -1
+				err_printf(m, " %p",
+				(void *)(virt_entry->user_virt_addr & ~1));
 
-:215: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#215: FILE: drivers/gpu/drm/i915/i915_gem.c:6582:

(quoted diff) +2 -0
+				err_printf(m, " %p*",
+				(void *)virt_entry->user_virt_addr);

total: 0 errors, 0 warnings, 5 checks, 199 lines checked 05a4782cc77f drm/i915: Update process mm stats for Gen GFX memory -:80: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #80: FILE: drivers/gpu/drm/i915/i915_gem.c:6306:

(quoted diff) +2 -1
+		add_mm_counter(pid_entry->attr_priv->mm, MM_FILEPAGES,
+				new_size - old_size);
 
-:248: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

#248: FILE: drivers/gpu/drm/i915/i915_sysfs.c:770:

(quoted diff) +2 -0
+		add_mm_counter(attr_priv->mm, MM_FILEPAGES,
+				-attr_priv->rss_size);

total: 0 errors, 0 warnings, 2 checks, 192 lines checked

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

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

✗ Fi.CI.SPARSE: warning for drm/i915: Interface to get GFX shmem usage stats per process

In reply to Praveen Paneri
== Series Details ==

== Series Details ==

Series: drm/i915: Interface to get GFX shmem usage stats per process
URL : https://patchwork.freedesktop.org/series/40464/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Commit: drm/i915: Sysfs interface to get GFX shmem usage stats per process
Okay!

Commit: drm/i915: Calculate total shmem GFX memory consumed Okay!

Commit: drm/i915: Sysfs interface to get detailed GFX buffer info per process +drivers/gpu/drm/i915/i915_gem.c:3672:5: warning: symbol 'i915_gem_client_add' was not declared. Should it be static? +drivers/gpu/drm/i915/i915_gem.c:3713:6: warning: symbol 'i915_gem_client_remove' was not declared. Should it be static? +drivers/gpu/drm/i915/i915_gem.c:6457:40: warning: Using plain integer as NULL pointer

Commit: drm/i915: Output the user virtual addresses for GFX buffers Okay!

Commit: drm/i915: Update process mm stats for Gen GFX memory Okay!

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

#10 lore raw

✗ Fi.CI.BAT: failure for drm/i915: Interface to get GFX shmem usage stats per process

In reply to Praveen Paneri
== Series Details ==

== Series Details ==

Series: drm/i915: Interface to get GFX shmem usage stats per process
URL : https://patchwork.freedesktop.org/series/40464/
State : failure

== Summary ==

Series 40464v1 drm/i915: Interface to get GFX shmem usage stats per process
https://patchwork.freedesktop.org/api/1.0/series/40464/revisions/1/mbox/

---- Possible new issues:

Test debugfs_test:

        Subgroup read_all_entries:
                pass       -> INCOMPLETE (fi-pnv-d510)

---- Known issues:

Test kms_pipe_crc_basic:

        Subgroup suspend-read-crc-pipe-b:
                incomplete -> PASS       (fi-snb-2520m) fdo#103713

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713

fi-bdw-5557u     total:285  pass:264  dwarn:0   dfail:0   fail:0   skip:21  time:433s
fi-bdw-gvtdvm    total:285  pass:261  dwarn:0   dfail:0   fail:0   skip:24  time:441s
fi-blb-e6850     total:285  pass:220  dwarn:1   dfail:0   fail:0   skip:64  time:380s
fi-bsw-n3050     total:285  pass:239  dwarn:0   dfail:0   fail:0   skip:46  time:537s
fi-bwr-2160      total:285  pass:180  dwarn:0   dfail:0   fail:0   skip:105 time:300s
fi-bxt-dsi       total:285  pass:255  dwarn:0   dfail:0   fail:0   skip:30  time:512s
fi-bxt-j4205     total:285  pass:256  dwarn:0   dfail:0   fail:0   skip:29  time:516s
fi-byt-j1900     total:285  pass:250  dwarn:0   dfail:0   fail:0   skip:35  time:520s
fi-byt-n2820     total:285  pass:246  dwarn:0   dfail:0   fail:0   skip:39  time:511s
fi-cfl-8700k     total:285  pass:257  dwarn:0   dfail:0   fail:0   skip:28  time:408s
fi-cfl-u         total:285  pass:259  dwarn:0   dfail:0   fail:0   skip:26  time:512s
fi-cnl-drrs      total:285  pass:254  dwarn:3   dfail:0   fail:0   skip:28  time:520s
fi-cnl-y3        total:285  pass:259  dwarn:0   dfail:0   fail:0   skip:26  time:589s
fi-elk-e7500     total:285  pass:225  dwarn:1   dfail:0   fail:0   skip:59  time:424s
fi-gdg-551       total:285  pass:176  dwarn:0   dfail:0   fail:1   skip:108 time:313s
fi-glk-1         total:285  pass:257  dwarn:0   dfail:0   fail:0   skip:28  time:535s
fi-hsw-4770      total:285  pass:258  dwarn:0   dfail:0   fail:0   skip:27  time:403s
fi-ilk-650       total:285  pass:225  dwarn:0   dfail:0   fail:0   skip:60  time:425s
fi-ivb-3520m     total:285  pass:256  dwarn:0   dfail:0   fail:0   skip:29  time:473s
fi-ivb-3770      total:285  pass:252  dwarn:0   dfail:0   fail:0   skip:33  time:432s
fi-kbl-7500u     total:285  pass:260  dwarn:1   dfail:0   fail:0   skip:24  time:475s
fi-kbl-7567u     total:285  pass:265  dwarn:0   dfail:0   fail:0   skip:20  time:465s
fi-kbl-r         total:285  pass:258  dwarn:0   dfail:0   fail:0   skip:27  time:514s
fi-pnv-d510      total:3    pass:2    dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6260u     total:285  pass:265  dwarn:0   dfail:0   fail:0   skip:20  time:441s
fi-skl-6600u     total:285  pass:258  dwarn:0   dfail:0   fail:0   skip:27  time:539s
fi-skl-6700k2    total:285  pass:261  dwarn:0   dfail:0   fail:0   skip:24  time:502s
fi-skl-6770hq    total:285  pass:265  dwarn:0   dfail:0   fail:0   skip:20  time:492s
fi-skl-guc       total:285  pass:257  dwarn:0   dfail:0   fail:0   skip:28  time:428s
fi-skl-gvtdvm    total:285  pass:262  dwarn:0   dfail:0   fail:0   skip:23  time:445s
fi-snb-2520m     total:285  pass:245  dwarn:0   dfail:0   fail:0   skip:40  time:565s
fi-snb-2600      total:285  pass:245  dwarn:0   dfail:0   fail:0   skip:40  time:402s

fi-cfl-s3 failed to connect after reboot

7ae13170ff7a3e55b3f10149db1b34571d5bbd7b drm-tip: 2018y-03m-22d-14h-02m-32s UTC integration manifest 05a4782cc77f drm/i915: Update process mm stats for Gen GFX memory
486204b0dac9 drm/i915: Output the user virtual addresses for GFX buffers 0d8d278defab drm/i915: Sysfs interface to get detailed GFX buffer info per process 27bfa55dd165 drm/i915: Calculate total shmem GFX memory consumed
a2507d62bb4c drm/i915: Sysfs interface to get GFX shmem usage stats per process

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8449/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx