Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1201513rdh; Mon, 25 Sep 2023 06:17:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqok9VVoHsEbtvNLpTc3gb3/Ful6D9MTdSR80s+USeEEaSzL6UP02HrP/3Wz2Pg66TjKWJ X-Received: by 2002:a05:6a20:4406:b0:154:bfaf:a710 with SMTP id ce6-20020a056a20440600b00154bfafa710mr6182877pzb.41.1695647838719; Mon, 25 Sep 2023 06:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695647838; cv=none; d=google.com; s=arc-20160816; b=pqtRm0V7kITJH+o7R+QK3TkCtWCaTYpe5vggDjRctyQa9/xRHFoRSEI/5BpR8wmEtO tfDaeAoAiK5A2kkI2elWRRYVBjnj7TOgdZ1WCFCx8J2i9bbvkxAk3ygdeaf5N83W37H1 O4NzVbd/jZaOEEoxEQgJq8PvEw1Kpd2XpZyPjKvpv7r7HxEFeF8TJ+GKXFaYViQSZy5C 2k5rQuuf3RAPd0nvxEB3Bl60Xv3qdnV2s1qcWM6QOoubYfNI/n+F7TW91sPljPc3o9+c ilxHyryk33D3VigPoJ4jYemL3SLcElpzkgYpJatd+nWKABes5bkqyBFZprlOtDXk5gVu BThQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+6/jqq/7UnaGVA0UjlFCIGzyop29RxbuSGwJT6cKM1A=; fh=aicQXd2sVDKynU70/92qv+8AnsPgYK5pq7fTzS41MP4=; b=SpKf5HZMwOEJaQ0vXnJ7Ly5Kx69W5QG0CeKGkCflXLy7hgiUzjFgRAYG3X1wbhDXes ktCNmHStVUHszVuWfWmsm2BaHt1OqYBl8UGQqPOUEz9wLkxrvgwQH5lnowy0JJAv/QmK m3J/waVO9Tptvtvc2lPdBkEXNceffQc9vKhZ/gOhw0ZMp4b2SttVRNlTkR5zXsPLvV8x R1p4P35e9tYt3I/vK0iHtf+6Ze5l6bf5JQg1vdkjYvIHCPH4o6Z7CjXHy/mFHXeLvLWH aXiVEywQVxWLJbP2GBG5RTraKQpLJcTbtR2SJCpVQQrTdo3YDtiklg9QGivqsNX/VgTV fckQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GuXUXsnl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ms9-20020a17090b234900b00274a5edad0csi9758054pjb.139.2023.09.25.06.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:17:18 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=GuXUXsnl; 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=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 lipwig.vger.email (Postfix) with ESMTP id BFFAC807D986; Sun, 24 Sep 2023 23:20:49 -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 S232233AbjIYGUl (ORCPT + 99 others); Mon, 25 Sep 2023 02:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232036AbjIYGUK (ORCPT ); Mon, 25 Sep 2023 02:20:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0007D120; Sun, 24 Sep 2023 23:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695622786; x=1727158786; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7e9wQj2WA71mq/iJI8NeRrmr4krAfSIj4xsh0x+V4bc=; b=GuXUXsnlh/nKXn41JfOYpeIf06g5NbF4OkMR9UHhiFJK5457eFDQQRAx S29NlTgTxoHZRFhtXg0KSt2cEnkFreKT5A6ocanv8B8NXkbhi2YhLYchy sV8j2JMPJintIZBRDpnTQgtx7KnJvGv8+b/beAT7rhdYau8xqeVVAC8wv F5ANs8OOuexnnTIQp7IMTHd3bQJRZCQcBZKoAH4CwpFd9sNL1NBw9r7+R QXJIgBA9bFHjDE36dEpZq5BVyXlaCUwrgDMpxMhTmfW8b42lNSXfcyPy/ BOmLeoR/YSLwiRkPwbxj6IpZ1i2YiDtb+djJXvy1hofwv7rxIaxVm5/pz A==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="445279440" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="445279440" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 23:19:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="818494353" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="818494353" Received: from b49691a75598.jf.intel.com ([10.54.34.22]) by fmsmga004.fm.intel.com with ESMTP; 24 Sep 2023 23:19:15 -0700 From: weilin.wang@intel.com To: weilin.wang@intel.com, Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers , Mark Rutland Subject: [RFC PATCH 09/25] perf stat: Add helper functions for hardware-grouping method Date: Sun, 24 Sep 2023 23:18:08 -0700 Message-Id: <20230925061824.3818631-10-weilin.wang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230925061824.3818631-1-weilin.wang@intel.com> References: <20230925061824.3818631-1-weilin.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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]); Sun, 24 Sep 2023 23:20:50 -0700 (PDT) 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); + 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; +err_out: + metricgroup__free_event_info(&event_info_list); + metricgroup__free_pmu_info(&pmu_info_list); return ret; #undef RETURN_IF_NON_ZERO } -- 2.39.3