diff mbox series

[i-g-t,4/9] lib/igt_drm_fdinfo: Copy over region map name on match

Message ID 20231012081547.852052-5-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Client memory fdinfo test and intel_gpu_top support | expand

Commit Message

Tvrtko Ursulin Oct. 12, 2023, 8:15 a.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

I will need some record of which regions were found for intel_gpu_top so
lets just copy over the region name from the map on the first match.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_drm_fdinfo.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kamil Konieczny Nov. 3, 2023, 6:56 p.m. UTC | #1
Hi Tvrtko,
On 2023-10-12 at 09:15:42 +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> I will need some record of which regions were found for intel_gpu_top so
> lets just copy over the region name from the map on the first match.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>

> ---
>  lib/igt_drm_fdinfo.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
> index b72822894782..222ccbfb1fd6 100644
> --- a/lib/igt_drm_fdinfo.c
> +++ b/lib/igt_drm_fdinfo.c
> @@ -148,6 +148,10 @@ static int parse_region(char *line, struct drm_client_fdinfo *info,
>  		for (i = 0; i < region_entries; i++) {
>  			if (!strncmp(name, region_map[i], name_len)) {
>  				found = i;
> +				if (!info->region_names[info->num_regions][0]) {
> +					assert(name_len < sizeof(info->region_names[i]));
> +					strncpy(info->region_names[i], name, name_len);
> +				}
>  				break;
>  			}
>  		}
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
index b72822894782..222ccbfb1fd6 100644
--- a/lib/igt_drm_fdinfo.c
+++ b/lib/igt_drm_fdinfo.c
@@ -148,6 +148,10 @@  static int parse_region(char *line, struct drm_client_fdinfo *info,
 		for (i = 0; i < region_entries; i++) {
 			if (!strncmp(name, region_map[i], name_len)) {
 				found = i;
+				if (!info->region_names[info->num_regions][0]) {
+					assert(name_len < sizeof(info->region_names[i]));
+					strncpy(info->region_names[i], name, name_len);
+				}
 				break;
 			}
 		}