lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aGN6tPDP50RrNTnq@google.com>
Date: Mon, 30 Jun 2025 23:05:40 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Kan Liang <kan.liang@...ux.intel.com>,
	John Garry <john.g.garry@...cle.com>, Will Deacon <will@...nel.org>,
	James Clark <james.clark@...aro.org>,
	Mike Leach <mike.leach@...aro.org>, Leo Yan <leo.yan@...ux.dev>,
	"Masami Hiramatsu (Google)" <mhiramat@...nel.org>,
	Ravi Bangoria <ravi.bangoria@....com>,
	Charlie Jenkins <charlie@...osinc.com>,
	Colin Ian King <colin.i.king@...il.com>,
	Andi Kleen <ak@...ux.intel.com>, Dmitry Vyukov <dvyukov@...gle.com>,
	Graham Woodward <graham.woodward@....com>,
	Ilkka Koskinen <ilkka@...amperecomputing.com>,
	Zhongqiu Han <quic_zhonhan@...cinc.com>,
	Yicong Yang <yangyicong@...ilicon.com>,
	Athira Rajeev <atrajeev@...ux.ibm.com>,
	Kajol Jain <kjain@...ux.ibm.com>, Li Huafei <lihuafei1@...wei.com>,
	"Steinar H. Gunderson" <sesse@...gle.com>,
	Stephen Brennan <stephen.s.brennan@...cle.com>,
	Chun-Tse Shao <ctshao@...gle.com>, Yujie Liu <yujie.liu@...el.com>,
	"Dr. David Alan Gilbert" <linux@...blig.org>,
	Levi Yun <yeoreum.yun@....com>, Howard Chu <howardchu95@...il.com>,
	Weilin Wang <weilin.wang@...el.com>,
	Thomas Falcon <thomas.falcon@...el.com>,
	Matt Fleming <matt@...dmodwrite.com>,
	Veronika Molnarova <vmolnaro@...hat.com>,
	Krzysztof Łopatowski <krzysztof.m.lopatowski@...il.com>,
	Zixian Cai <fzczx123@...il.com>,
	Steve Clevenger <scclevenger@...amperecomputing.com>,
	Ben Gainey <ben.gainey@....com>,
	Chaitanya S Prakash <chaitanyas.prakash@....com>,
	Martin Liska <martin.liska@....com>,
	Martin Liška <m.liska@...link.cz>,
	Song Liu <song@...nel.org>, linux-kernel@...r.kernel.org,
	linux-perf-users@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v5 16/23] perf bench synthesize: Avoid use of global
 perf_env

On Fri, Jun 27, 2025 at 09:50:10PM -0700, Ian Rogers wrote:
> The benchmark doesn't use a data file and so the header perf_env isn't
> used. Stack allocate a host perf_env for use to avoid the use of the
> global perf_env.
> 
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
>  tools/perf/bench/synthesize.c | 30 +++++++++++++++++++-----------
>  1 file changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/tools/perf/bench/synthesize.c b/tools/perf/bench/synthesize.c
> index 9b333276cbdb..79d99ba50284 100644
> --- a/tools/perf/bench/synthesize.c
> +++ b/tools/perf/bench/synthesize.c
> @@ -114,10 +114,13 @@ static int run_single_threaded(void)
>  		.pid = "self",
>  	};
>  	struct perf_thread_map *threads;
> +	struct perf_env host_env;
>  	int err;
>  
>  	perf_set_singlethreaded();
> -	session = perf_session__new(NULL, NULL);
> +	perf_env__init(&host_env);
> +	session = __perf_session__new(/*data=*/NULL, /*tool=*/NULL,
> +				      /*trace_event_repipe=*/false, &host_env);
>  	if (IS_ERR(session)) {
>  		pr_err("Session creation failed.\n");
>  		return PTR_ERR(session);

Missing perf_env__exit() ?


> @@ -144,6 +147,7 @@ static int run_single_threaded(void)
>  		perf_thread_map__put(threads);
>  
>  	perf_session__delete(session);
> +	perf_env__exit(&host_env);
>  	return err;
>  }
>  
> @@ -154,17 +158,21 @@ static int do_run_multi_threaded(struct target *target,
>  	u64 runtime_us;
>  	unsigned int i;
>  	double time_average, time_stddev, event_average, event_stddev;
> -	int err;
> +	int err = 0;
>  	struct stats time_stats, event_stats;
>  	struct perf_session *session;
> +	struct perf_env host_env;
>  
> +	perf_env__init(&host_env);
>  	init_stats(&time_stats);
>  	init_stats(&event_stats);
>  	for (i = 0; i < multi_iterations; i++) {
> -		session = perf_session__new(NULL, NULL);
> -		if (IS_ERR(session))
> -			return PTR_ERR(session);
> -
> +		session = __perf_session__new(/*data=*/NULL, /*tool=*/NULL,
> +					      /*trace_event_repipe=*/false, &host_env);
> +		if (IS_ERR(session)) {
> +			err = PTR_ERR(session);
> +			goto err_out;
> +		}
>  		atomic_set(&event_count, 0);
>  		gettimeofday(&start, NULL);
>  		err = __machine__synthesize_threads(&session->machines.host,
> @@ -173,10 +181,8 @@ static int do_run_multi_threaded(struct target *target,
>  						process_synthesized_event,
>  						true, false,
>  						nr_threads_synthesize);
> -		if (err) {
> -			perf_session__delete(session);
> -			return err;
> -		}
> +		if (err)
> +			goto err_out;

Missing perf_session__delete() ?


>  
>  		gettimeofday(&end, NULL);
>  		timersub(&end, &start, &diff);
> @@ -198,7 +204,9 @@ static int do_run_multi_threaded(struct target *target,
>  
>  	printf("    Average time per event %.3f usec\n",
>  		time_average / event_average);
> -	return 0;
> +err_out:
> +	perf_env__exit(&host_env);
> +	return err;
>  }
>  
>  static int run_multi_threaded(void)
> -- 
> 2.50.0.727.gbf7dc18ff4-goog
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ