All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, Nirmoy Das <nirmoy.das@intel.com>
Subject: Re: [Intel-gfx] [PATCH i-g-t 5/6] intel_gpu_top: Fix cleanup on old kernels / unsupported GPU
Date: Fri, 27 Jan 2023 17:10:52 +0100	[thread overview]
Message-ID: <20230127161052.thz5q2sqxtge2cwn@kamilkon-desk1> (raw)
In-Reply-To: <20230127111241.3624629-6-tvrtko.ursulin@linux.intel.com>

Hi Tvrtko,

On 2023-01-27 at 11:12:40 +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Avoid trying to dereference null engines on exit when there are either
> none which are supported, or kernel does not have i915 PMU support.
> 
> Also fix a memory leak on the same failure path just so Valgrind runs are
> quite.
> 
> v2:
>  * Fix a memory leak in the same failure mode too.

Please rebase, patch do not apply.

> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Acked-by: Nirmoy Das <nirmoy.das@intel.com> # v1
-------------------------------------------- ^^^^^
Delete this.

Rest looks good,

Regards,
Kamil

> ---
>  tools/intel_gpu_top.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 7aa233570463..0a1de41b3374 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -340,7 +340,7 @@ static struct engines *discover_engines(char *device)
>  
>  	d = opendir(sysfs_root);
>  	if (!d)
> -		return NULL;
> +		goto err;
>  
>  	while ((dent = readdir(d)) != NULL) {
>  		const char *endswith = "-busy";
> @@ -423,10 +423,8 @@ static struct engines *discover_engines(char *device)
>  	}
>  
>  	if (ret) {
> -		free(engines);
>  		errno = ret;
> -
> -		return NULL;
> +		goto err;
>  	}
>  
>  	qsort(engine_ptr(engines, 0), engines->num_engines,
> @@ -435,6 +433,11 @@ static struct engines *discover_engines(char *device)
>  	engines->root = d;
>  
>  	return engines;
> +
> +err:
> +	free(engines);
> +
> +	return NULL;
>  }
>  
>  static void free_engines(struct engines *engines)
> @@ -448,6 +451,9 @@ static void free_engines(struct engines *engines)
>  	};
>  	unsigned int i;
>  
> +	if (!engines)
> +		return;
> +
>  	for (pmu = &free_list[0]; *pmu; pmu++) {
>  		if ((*pmu)->present)
>  			free((char *)(*pmu)->units);
> @@ -2568,7 +2574,7 @@ int main(int argc, char **argv)
>  			"Failed to detect engines! (%s)\n(Kernel 4.16 or newer is required for i915 PMU support.)\n",
>  			strerror(errno));
>  		ret = EXIT_FAILURE;
> -		goto err;
> +		goto err_engines;
>  	}
>  
>  	ret = pmu_init(engines);
> @@ -2585,7 +2591,7 @@ int main(int argc, char **argv)
>  "More information can be found at 'Perf events and tool security' document:\n"
>  "https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html\n");
>  		ret = EXIT_FAILURE;
> -		goto err;
> +		goto err_pmu;
>  	}
>  
>  	ret = EXIT_SUCCESS;
> @@ -2699,8 +2705,9 @@ int main(int argc, char **argv)
>  		free_clients(clients);
>  
>  	free(codename);
> -err:
> +err_pmu:
>  	free_engines(engines);
> +err_engines:
>  	free(pmu_device);
>  exit:
>  	igt_devices_free();
> -- 
> 2.34.1
> 

WARNING: multiple messages have this Message-ID (diff)
From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org,
	Nirmoy Das <nirmoy.das@intel.com>,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: Re: [igt-dev] [Intel-gfx] [PATCH i-g-t 5/6] intel_gpu_top: Fix cleanup on old kernels / unsupported GPU
Date: Fri, 27 Jan 2023 17:10:52 +0100	[thread overview]
Message-ID: <20230127161052.thz5q2sqxtge2cwn@kamilkon-desk1> (raw)
In-Reply-To: <20230127111241.3624629-6-tvrtko.ursulin@linux.intel.com>

Hi Tvrtko,

On 2023-01-27 at 11:12:40 +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Avoid trying to dereference null engines on exit when there are either
> none which are supported, or kernel does not have i915 PMU support.
> 
> Also fix a memory leak on the same failure path just so Valgrind runs are
> quite.
> 
> v2:
>  * Fix a memory leak in the same failure mode too.

Please rebase, patch do not apply.

> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Acked-by: Nirmoy Das <nirmoy.das@intel.com> # v1
-------------------------------------------- ^^^^^
Delete this.

Rest looks good,

Regards,
Kamil

> ---
>  tools/intel_gpu_top.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 7aa233570463..0a1de41b3374 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -340,7 +340,7 @@ static struct engines *discover_engines(char *device)
>  
>  	d = opendir(sysfs_root);
>  	if (!d)
> -		return NULL;
> +		goto err;
>  
>  	while ((dent = readdir(d)) != NULL) {
>  		const char *endswith = "-busy";
> @@ -423,10 +423,8 @@ static struct engines *discover_engines(char *device)
>  	}
>  
>  	if (ret) {
> -		free(engines);
>  		errno = ret;
> -
> -		return NULL;
> +		goto err;
>  	}
>  
>  	qsort(engine_ptr(engines, 0), engines->num_engines,
> @@ -435,6 +433,11 @@ static struct engines *discover_engines(char *device)
>  	engines->root = d;
>  
>  	return engines;
> +
> +err:
> +	free(engines);
> +
> +	return NULL;
>  }
>  
>  static void free_engines(struct engines *engines)
> @@ -448,6 +451,9 @@ static void free_engines(struct engines *engines)
>  	};
>  	unsigned int i;
>  
> +	if (!engines)
> +		return;
> +
>  	for (pmu = &free_list[0]; *pmu; pmu++) {
>  		if ((*pmu)->present)
>  			free((char *)(*pmu)->units);
> @@ -2568,7 +2574,7 @@ int main(int argc, char **argv)
>  			"Failed to detect engines! (%s)\n(Kernel 4.16 or newer is required for i915 PMU support.)\n",
>  			strerror(errno));
>  		ret = EXIT_FAILURE;
> -		goto err;
> +		goto err_engines;
>  	}
>  
>  	ret = pmu_init(engines);
> @@ -2585,7 +2591,7 @@ int main(int argc, char **argv)
>  "More information can be found at 'Perf events and tool security' document:\n"
>  "https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html\n");
>  		ret = EXIT_FAILURE;
> -		goto err;
> +		goto err_pmu;
>  	}
>  
>  	ret = EXIT_SUCCESS;
> @@ -2699,8 +2705,9 @@ int main(int argc, char **argv)
>  		free_clients(clients);
>  
>  	free(codename);
> -err:
> +err_pmu:
>  	free_engines(engines);
> +err_engines:
>  	free(pmu_device);
>  exit:
>  	igt_devices_free();
> -- 
> 2.34.1
> 

  reply	other threads:[~2023-01-27 16:10 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27 11:12 [Intel-gfx] [PATCH i-g-t 0/6] Assorted intel_gpu_top improvements Tvrtko Ursulin
2023-01-27 11:12 ` [igt-dev] " Tvrtko Ursulin
2023-01-27 11:12 ` [Intel-gfx] [PATCH i-g-t 1/6] intel_gpu_top: Fix man page formatting Tvrtko Ursulin
2023-01-27 11:12   ` [igt-dev] " Tvrtko Ursulin
2023-01-27 17:18   ` [Intel-gfx] " Kamil Konieczny
2023-01-27 17:18     ` [igt-dev] " Kamil Konieczny
2023-01-27 11:12 ` [Intel-gfx] [PATCH i-g-t 2/6] intel_gpu_top: Automatically enclose JSON output into brackets Tvrtko Ursulin
2023-01-27 11:12   ` [igt-dev] " Tvrtko Ursulin
2023-01-27 11:12 ` [Intel-gfx] [PATCH i-g-t 3/6] intel_gpu_top: Add command line switch to start in physical engine mode Tvrtko Ursulin
2023-01-27 11:12   ` [igt-dev] " Tvrtko Ursulin
2023-01-27 11:12 ` [Intel-gfx] [PATCH i-g-t 4/6] intel_gpu_top: Aggregate engine classes in all output modes Tvrtko Ursulin
2023-01-27 11:12   ` [igt-dev] " Tvrtko Ursulin
2023-01-27 11:12 ` [Intel-gfx] [PATCH i-g-t 5/6] intel_gpu_top: Fix cleanup on old kernels / unsupported GPU Tvrtko Ursulin
2023-01-27 11:12   ` [igt-dev] " Tvrtko Ursulin
2023-01-27 16:10   ` Kamil Konieczny [this message]
2023-01-27 16:10     ` [igt-dev] [Intel-gfx] " Kamil Konieczny
2023-01-30 10:55     ` [Intel-gfx] [igt-dev] " Tvrtko Ursulin
2023-01-30 10:55       ` [igt-dev] [Intel-gfx] " Tvrtko Ursulin
2023-01-30 10:58       ` [Intel-gfx] [igt-dev] " Das, Nirmoy
2023-01-30 10:58         ` [igt-dev] [Intel-gfx] " Das, Nirmoy
2023-01-30 16:54       ` [Intel-gfx] [igt-dev] " Kamil Konieczny
2023-01-30 16:54         ` [igt-dev] [Intel-gfx] " Kamil Konieczny
2023-01-27 11:12 ` [Intel-gfx] [PATCH i-g-t 6/6] lib/igt_device_scan: Improve Intel discrete GPU selection Tvrtko Ursulin
2023-01-27 11:12   ` [igt-dev] " Tvrtko Ursulin
2023-01-27 11:39   ` [Intel-gfx] " Petri Latvala
2023-01-27 11:39     ` Petri Latvala
2023-01-27 11:53     ` [Intel-gfx] " Tvrtko Ursulin
2023-01-27 11:53       ` Tvrtko Ursulin
2023-01-27 13:41       ` [Intel-gfx] " Petri Latvala
2023-01-27 13:41         ` Petri Latvala
2023-01-27 16:17   ` [Intel-gfx] " Kamil Konieczny
2023-01-27 16:17     ` [igt-dev] " Kamil Konieczny
2023-01-30 11:04     ` [Intel-gfx] " Tvrtko Ursulin
2023-01-30 11:04       ` Tvrtko Ursulin
2023-01-30 16:51       ` [Intel-gfx] " Kamil Konieczny
2023-01-30 16:51         ` Kamil Konieczny
2023-01-30  6:30   ` [Intel-gfx] " Zbigniew Kempczyński
2023-01-30  6:30     ` [igt-dev] " Zbigniew Kempczyński
2023-01-27 12:16 ` [igt-dev] ✓ Fi.CI.BAT: success for Assorted intel_gpu_top improvements Patchwork
2023-01-27 14:33 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-01-30 12:28   ` Kamil Konieczny
2023-01-30 15:02     ` Yedireswarapu, SaiX Nandan
2023-01-30 13:51 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230127161052.thz5q2sqxtge2cwn@kamilkon-desk1 \
    --to=kamil.konieczny@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=nirmoy.das@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.