Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1628379rdh; Mon, 25 Sep 2023 20:48:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHujJzQi1Se/fwsAgm0f4Vnmn1Ykv2AbxTcSes0d0bEv+52GHlTyo0cmfY69c/1XLIvZA70 X-Received: by 2002:a05:6358:15ca:b0:145:63b5:8e91 with SMTP id t10-20020a05635815ca00b0014563b58e91mr8001951rwh.10.1695700100984; Mon, 25 Sep 2023 20:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695700100; cv=none; d=google.com; s=arc-20160816; b=Q59t5rqcyhem73V1wIb+k9MxxvDvyF+DUUrAtB6dHkO7rnwD+uR4QdXSN1q8d2C3MK UNBQZqZ8Omcieh81sxujBVTDKjWafKBGd+eSa36giuFXs6bnnYZ+tk27pnoJ6dzqmL0S JYLHlXCfvdXeQQD1W9KNJLuk3dNuo1p0fqJomtXS6CfWGKgBhJasVZCJTjfCgU3sF2UU DljJNoC7lYGd2Od8asKauscuN0zLoCrzzvY6lFrQ+kC0T3ZSQTpgaYzrYLYxxwkoMr6H 3jYRE4NNe2/tw1vnh1pPYVryY2TdjH/n4Ar5AJdubh+cv9gvXBelNkBobLkXkholLWnW kN/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=8NAhk0my4sjabOG8Ws1L8xu97cV8XbqIqO6U/K11+SM=; fh=txG0yjwlB5lWwS0lNDJ4GbL1kaW6w8REh6nOQZMyd4g=; b=j2nm/qmLw4swWXEwQXl8C/px7PAUqiGGznfkLag0VA9RcM5Y3oOVbQITFQEUaS8GSB 26dJ2v2rlxY5SLsWIJfA42wfCzcFGHYcwYFEFd4r4Dch0YhlqDIF6YbcuvK/1+wefl+x ZWh1ybgdTJ9mjho26vsdkjbDKWofndcVzV5E9OfecdAjimkJTqQ4XjnaxSEWGKlwbG65 vDajkf0r47x5f3z/QbaB6AN19xdFMV0KZXb/dmy0qA/E4AyGMtp/yddrMdqkqWRhJI3H RZ2zVcMJvuZlBnMTQ/JsPb7o98YFYZxvOJZNzX8pdwDxjQap/tsbKF/ySLivbiGtrVaw tGYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l24-20020a637018000000b0057e21f51ab3si8015007pgc.665.2023.09.25.20.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 20:48:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CFBD9809E213; Mon, 25 Sep 2023 20:37:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbjIZDhs (ORCPT + 99 others); Mon, 25 Sep 2023 23:37:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjIZDhq (ORCPT ); Mon, 25 Sep 2023 23:37:46 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E805C9; Mon, 25 Sep 2023 20:37:35 -0700 (PDT) Received: from kwepemm000003.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RvlhN3yXnzNnqX; Tue, 26 Sep 2023 11:33:40 +0800 (CST) Received: from [10.67.111.205] (10.67.111.205) by kwepemm000003.china.huawei.com (7.193.23.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 26 Sep 2023 11:37:29 +0800 Subject: Re: [RFC PATCH 09/25] perf stat: Add helper functions for hardware-grouping method To: , Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang CC: , , Perry Taylor , Samantha Alt , Caleb Biggers , Mark Rutland References: <20230925061824.3818631-1-weilin.wang@intel.com> <20230925061824.3818631-10-weilin.wang@intel.com> From: Yang Jihong Message-ID: Date: Tue, 26 Sep 2023 11:37:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20230925061824.3818631-10-weilin.wang@intel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.111.205] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm000003.china.huawei.com (7.193.23.66) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 25 Sep 2023 20:37:57 -0700 (PDT) Hello, On 2023/9/25 14:18, weilin.wang@intel.com wrote: > From: Weilin Wang > > Add functions to free pmu_info_list and event_info_list before exit > grouping > > Signed-off-by: Weilin Wang > --- > tools/perf/util/metricgroup.c | 32 ++++++++++++++++++++++++++++---- > 1 file changed, 28 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > index feb5dab26..0ca885a42 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -1507,6 +1507,27 @@ static int parse_counter(const char *counter, > return 0; > } > > +static void metricgroup__free_event_info(struct list_head > + *event_info_list) > +{ > + struct metricgroup__event_info *e, *tmp; > + > + list_for_each_entry_safe(e, tmp, event_info_list, nd) { > + list_del_init(&e->nd); > + free(e); > + } > +} > + > +static void metricgroup__free_pmu_info(struct list_head *pmu_info_list) > +{ > + struct metricgroup__pmu_counters *p, *tmp; > + > + list_for_each_entry_safe(p, tmp, pmu_info_list, nd) { > + list_del_init(&p->nd); > + free(p); > + } > +} > + > static struct metricgroup__event_info *event_info__new(const char *name, > const char *pmu_name, > const char *counter, > @@ -1524,7 +1545,8 @@ static struct metricgroup__event_info *event_info__new(const char *name, > } > e->name = name; > e->free_counter = free_counter; > - e->pmu_name = strdup(pmu_name); > + //e->pmu_name = strdup(pmu_name); Can the commented-out code be deleted? > + e->pmu_name = pmu_name; > if (free_counter) { > ret = set_counter_bitmap(0, e->counters); > if (ret) > @@ -1687,13 +1709,15 @@ static int hw_aware_build_grouping(struct expr_parse_ctx *ctx __maybe_unused, > > ret = get_metricgroup_events(id, etable, &event_info_list); > if (ret) > - return ret; > + goto err_out; > } > ret = get_pmu_counter_layouts(&pmu_info_list, ltable); > if (ret) > - return ret; > - > + goto err_out; There seems to be no need for "goto err_out" here. > > +err_out: > + metricgroup__free_event_info(&event_info_list); > + metricgroup__free_pmu_info(&pmu_info_list); > return ret; > #undef RETURN_IF_NON_ZERO > } > Thanks, Yang