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: <81539684-f673-8af5-ff94-fe90a81a06e9@linux.intel.com>
Date:   Tue, 26 Sep 2023 12:18:16 -0400
From:   "Liang, Kan" <kan.liang@...ux.intel.com>
To:     weilin.wang@...el.com, Ian Rogers <irogers@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>
Cc:     linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
        Perry Taylor <perry.taylor@...el.com>,
        Samantha Alt <samantha.alt@...el.com>,
        Caleb Biggers <caleb.biggers@...el.com>,
        Mark Rutland <mark.rutland@....com>
Subject: Re: [RFC PATCH 13/25] perf stat: Add functions to hardware-grouping
 method



On 2023-09-25 2:18 a.m., weilin.wang@...el.com wrote:
> From: Weilin Wang <weilin.wang@...el.com>
> 
> Add functions to free all the group lists before exit metric grouping
> 
> Signed-off-by: Weilin Wang <weilin.wang@...el.com>
> ---
>  tools/perf/util/metricgroup.c | 39 ++++++++++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 8d54e71bf..4b1b0470d 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -1528,6 +1528,38 @@ static int parse_counter(const char *counter,
>  	return 0;
>  }
>  
> +static void group_event_list_free(struct metricgroup__group *groups)
> +{
> +	struct metricgroup__group_events *e, *tmp;
> +
> +	list_for_each_entry_safe (e, tmp, &groups->event_head, nd) {
> +		list_del_init(&e->nd);
> +		free(e);
> +	}
> +}
> +
> +static void group_list_free(struct metricgroup__pmu_group_list *groups)
> +{
> +	struct metricgroup__group *g, *tmp;
> +
> +	list_for_each_entry_safe (g, tmp, &groups->group_head, nd) {
> +		list_del_init(&g->nd);
> +		group_event_list_free(g);
> +		free(g);
> +	}
> +}
> +
> +static void metricgroup__free_group_list(struct list_head *groups)
> +{
> +	struct metricgroup__pmu_group_list *g, *tmp;
> +
> +	list_for_each_entry_safe (g, tmp, groups, nd) {
> +		list_del_init(&g->nd);
> +		group_list_free(g);
> +		free(g);
> +	}
> +}
> +
>  static void metricgroup__free_event_info(struct list_head
>  					*event_info_list)
>  {
> @@ -1845,6 +1877,8 @@ static int assign_event_grouping(struct metricgroup__event_info *e,
>  		struct metricgroup__pmu_counters *p;
>  
>  		pmu_group_head = malloc(sizeof(struct metricgroup__pmu_group_list));
> +		if (!pmu_group_head)
> +			return -ENOMEM;

I think it's better to combine the free and init/alloc into a single patch.

Thanks,
Kan

>  		INIT_LIST_HEAD(&pmu_group_head->group_head);
>  		pr_debug("create new group for event %s in pmu %s\n", e->name, e->pmu_name);
>  		pmu_group_head->pmu_name = e->pmu_name;
> @@ -1886,8 +1920,11 @@ static int create_grouping(struct list_head *pmu_info_list,
>  		pr_debug("Event name %s, [pmu]=%s, [counters]=%s\n", e->name,
>  			e->pmu_name, bit_buf);
>  		ret = assign_event_grouping(e, pmu_info_list, &groups);
> +		if (ret)
> +			goto out;
>  	}
> -
> +out:
> +	metricgroup__free_group_list(&groups);
>  	return ret;
>  };
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ