Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2139483rdh; Tue, 26 Sep 2023 13:51:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNyee/lVDYwnwXQ1yTSdMtsWh3qI4lOsfWGPPey/Kok9NRHvP3qIGOYfXY8nfBbR/TAipX X-Received: by 2002:a05:6a20:1612:b0:149:9b2f:a79d with SMTP id l18-20020a056a20161200b001499b2fa79dmr41882pzj.6.1695761510956; Tue, 26 Sep 2023 13:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695761510; cv=none; d=google.com; s=arc-20160816; b=L3VAEZJ+XjQlyrxef2WlIHO26GepCTSSuQOEDnn6a4kiSb7jM2ktd7aHTkaZhEZCTn vYq5azsOQCMP0+KMI4O4YxRfNkn94XDbHMw1TW0f+AjCmF0rByYWJ5TQSIbpOK2+xar2 99DaG0s9qPWA5mGbtpKQpOiVptTnRDJcJDUaP3cllvFNt9wojH+WYy8KoBix6HZVS8vl fzQTq+37D3O4dGFR7mVfwXljCTGdDdCmj26nMO5IMTzbgubya9a7gRy6yn0kAJF5mipv ygu0nj08zD5xAAhRhU9IgE2Qven5i+d7U/uBIia3PaypAsUckebVQ9O5gs7ltOQHyEGO iCcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=rFiZeLxroQGXEag094lq5PMeTdiwIyGkghcUsCx6eCY=; fh=R1OkhriIwip1F03SPBPuQjbmUJVFiHc78tVoBI9xOtw=; b=S+J2sanVZjVgVdwrfKsfUJblXzBOTclwu32VV4UsIprlNzYXIbbVjfXQw7K1k1N2/I 0aMc3s79XsIC3kQmyhVXUBMxAHUevASs/hfd89GgFrMqFVdMLqv1YZwMsb2Rzwbud/B9 o6BJCtQ3G79GpJ97ZXzPl/XQpWusNjvoInCCCvKpAKqI0yHoUAaFTbQZ2hZ13MHlNfFv yAE/m7kOMDozLq6YNyTxnZWhJCF5HWjjre+vbITs/SMUW/DQEZ8RU6ArESKjU0akHbmm AnBlRvp3PirjEQLpTaqBkhCfdI3K0n0ZM3HjyjPdybAkOvGWLAi+pYBKTbNEPxw1zigt ECvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gGObSqN7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id y129-20020a62ce87000000b0068fea8a6169si12595676pfg.404.2023.09.26.13.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 13:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gGObSqN7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 5FCA281DF264; Tue, 26 Sep 2023 09:18:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235206AbjIZQS2 (ORCPT + 99 others); Tue, 26 Sep 2023 12:18:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233309AbjIZQS1 (ORCPT ); Tue, 26 Sep 2023 12:18:27 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22174AF; Tue, 26 Sep 2023 09:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695745101; x=1727281101; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=A9jrx3tFlJDnW5UDsrNm7zRxi6LjPePTrAxC7omemIg=; b=gGObSqN7r/mLLDF3ID/Onac+rAOwPLjIUQuwJjyhdE2s8T3AJcc6ZJ9z JJneD/L7dxddSxBkqrCZDnmdbsEE1CclVXvgugubuKCn9TPwcFcC6zb/x xig+fsN80rFBe6CjZW769DSRR0X6IAZue9A2hqCkWiLg/dqm47w3pTISP K02IKsO2LyuCOYplY8IAoeEoZrJiSvO3WlKcxkiyyaltTDWc6SIXQT1o+ N1W3BJU5QZj/rJvCYCbCnxE4+U5RetCTK7XZGFUmqbgRNE/wozduuibb9 KQm81OhnHNvjy62t3WvDoevBmxLwzUlIixQZ70xSkpU0EdqRc3jUS2W5i g==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="381505902" X-IronPort-AV: E=Sophos;i="6.03,178,1694761200"; d="scan'208";a="381505902" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 09:18:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,178,1694761200"; d="scan'208";a="203932" Received: from linux.intel.com ([10.54.29.200]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 09:17:50 -0700 Received: from [10.209.130.196] (kliang2-mobl1.ccr.corp.intel.com [10.209.130.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id C7571580BBE; Tue, 26 Sep 2023 09:18:17 -0700 (PDT) Message-ID: <81539684-f673-8af5-ff94-fe90a81a06e9@linux.intel.com> Date: Tue, 26 Sep 2023 12:18:16 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RFC PATCH 13/25] perf stat: Add functions to hardware-grouping method Content-Language: en-US To: weilin.wang@intel.com, Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers , Mark Rutland References: <20230925061824.3818631-1-weilin.wang@intel.com> <20230925061824.3818631-14-weilin.wang@intel.com> From: "Liang, Kan" In-Reply-To: <20230925061824.3818631-14-weilin.wang@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 26 Sep 2023 09:18:26 -0700 (PDT) On 2023-09-25 2:18 a.m., weilin.wang@intel.com wrote: > From: Weilin Wang > > Add functions to free all the group lists before exit metric grouping > > Signed-off-by: Weilin Wang > --- > 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; > }; >