Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp11157ybg; Tue, 2 Jun 2020 14:51:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXHELH8Tv8KM6o2rmloq0JOs89dWQfvW2x1KNCuzHVY1+lzEPvXHDoatv/RYLB/Qsmravc X-Received: by 2002:a17:906:1149:: with SMTP id i9mr12056519eja.100.1591134696350; Tue, 02 Jun 2020 14:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591134696; cv=none; d=google.com; s=arc-20160816; b=siTxylu+theb5b1mPQq0myatsZMQcuQ2oXJVRtlj7gHtfWJByFHNvG6skOb2Z28ZdK /W7XGg0WJ0MMaSoSLJ33mjjIkcc4BXZ2sx/MHJC5tCXxpnhJiNv/cOWiaxek1A6QrmV0 gWIOhvCe02o2sa90ZSNHEh/GRRFfdLeZxHtBACbCL0YGp4YVDX+x0bwipIyr02qu+sXn 6Gxpo9CkUE0g5HAYckDhND5eUjqK9tmZe+8BQMGXxH+OW9Sq/vqFKoZuY2y5/wOCSdq6 TWbo8vM4OZd63PvLeLdzN8yPdyXgHp+PPDI3TBdiNS+0LlTq2AfOkpkNFtHgHmANLPPM 5ZYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=310bFaQwbnBwCHDUEBPg0+q4u2w5iujQYChSEp+ZxFs=; b=ap905NnJxOTVfWbs44ChM2Mmc/k/x8ourFGaeS5V7Lne6cG/syWj6+ik1Ba/4AAj/9 TrBsZzgWtJepuR2apWDRpouV9PxNbuk+zMqPiYYRc9VT0VXlQFV2bC3yEo5n2rbbnZ81 mHxLuy7GLcS64PFHevnfi6sbsbc1HZxqXw6hzQrCZOo5eXJb9tJGyijyC1vFbBiuSIdo aSOTdPV3limSFn5KRHD9AbGj0DCa0mrUnxox54wHn3EFNvhARxQDVbNb2vQXsB2bFNR2 R+g7dvfJR4IyNUFOFx17RoLvhf3KveQnulQyL394OrNXIk1CJrI1RKAt1UWz+3ZMcjWT zjMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si91226ejr.212.2020.06.02.14.51.13; Tue, 02 Jun 2020 14:51:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728498AbgFBVsf convert rfc822-to-8bit (ORCPT + 99 others); Tue, 2 Jun 2020 17:48:35 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:23842 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728440AbgFBVsb (ORCPT ); Tue, 2 Jun 2020 17:48:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-57HBCWq8Ms-KhOhTFRkbgQ-1; Tue, 02 Jun 2020 17:48:26 -0400 X-MC-Unique: 57HBCWq8Ms-KhOhTFRkbgQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F38EEA0BD7; Tue, 2 Jun 2020 21:48:24 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5374F78921; Tue, 2 Jun 2020 21:48:22 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Ian Rogers , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Stephane Eranian , Andi Kleen Subject: [PATCH 10/13] perf tools: Release metric_events rblist Date: Tue, 2 Jun 2020 23:47:38 +0200 Message-Id: <20200602214741.1218986-11-jolsa@kernel.org> In-Reply-To: <20200602214741.1218986-1-jolsa@kernel.org> References: <20200602214741.1218986-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We don't release metric_events rblist, add the missing delete hook and call the release before leaving cmd_stat. Acked-by: Ian Rogers Signed-off-by: Jiri Olsa --- tools/perf/builtin-stat.c | 1 + tools/perf/util/metricgroup.c | 19 +++++++++++++++++++ tools/perf/util/metricgroup.h | 1 + 3 files changed, 21 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 01f8aed735be..8a01595a3f4c 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2307,6 +2307,7 @@ int cmd_stat(int argc, const char **argv) evlist__delete(evsel_list); + metricgroup__rblist_exit(&stat_config.metric_events); runtime_stat_delete(&stat_config); return status; diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index fe33fee7f6ad..1b80a7901388 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -76,11 +76,30 @@ static struct rb_node *metric_event_new(struct rblist *rblist __maybe_unused, return &me->nd; } +static void metric_event_delete(struct rblist *rblist __maybe_unused, + struct rb_node *rb_node) +{ + struct metric_event *me = container_of(rb_node, struct metric_event, nd); + struct metric_expr *expr, *tmp; + + list_for_each_entry_safe(expr, tmp, &me->head, nd) { + free(expr); + } + + free(me); +} + static void metricgroup__rblist_init(struct rblist *metric_events) { rblist__init(metric_events); metric_events->node_cmp = metric_event_cmp; metric_events->node_new = metric_event_new; + metric_events->node_delete = metric_event_delete; +} + +void metricgroup__rblist_exit(struct rblist *metric_events) +{ + rblist__exit(metric_events); } struct egroup { diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index 426c824e20bf..8315bd1a7da4 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -47,4 +47,5 @@ void metricgroup__print(bool metrics, bool groups, char *filter, bool raw, bool details); bool metricgroup__has_metric(const char *metric); int arch_get_runtimeparam(void); +void metricgroup__rblist_exit(struct rblist *metric_events); #endif -- 2.25.4