Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1232625ybg; Tue, 2 Jun 2020 04:55:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNzLD/jtCZAgZyGYb2NAcOVcmkDJtya5ataDaZO4gTYrsNvs+u22oxpbKWlWlOa/5SIRHJ X-Received: by 2002:a17:906:490f:: with SMTP id b15mr22617012ejq.180.1591098903698; Tue, 02 Jun 2020 04:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591098903; cv=none; d=google.com; s=arc-20160816; b=s/QTHHljyPfTgEkmB2T0d+IVnilF6gwO0Q9528WBoayjJ8PQq8UvNKKYBgz+ZUUImJ rIhLueW0TUvY1UR6Xi386vhuApwJrIc+Qld2TCznlMg+qYIg8DgY+dbE9Gs6shiLJFSi dA6jcs3hCvKzuCZy0lqDGamdsSqt2HCOICubl2rGUTpZn0sPYMqG5dsvdaUwcDLbAVHY 9PVHouBWrW7ZAW0S5SABNXNoLYAEdgkWdrTMhzrTCVcCYI9i0cq7Iwvx1op5DYmkH8Rf yDGMSFW6g0tAQf/iaV4Y9c6jUQpXfVAhy5jXIbGpvYeN+6tRhGB2/FzjwS3u9OQywJYF R1zA== 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=+e7JcAqvNsF50BieyZdtO2pM9LlmJmgMniNabUyI9+w=; b=HGAG7FR1IBeMxdmHbCQV66VbudgAz/4cp2OsTI8UC8LfI5iEVXCydocR4mqsIqXPCk DSNJZl5hblcmpr0yoKUn0OZJEy4bBRVQNuXWpJn+EwlaQclsMYdaytk1aIRBFPa0Svau BoOsp3DGm7KwY3wx0pxLZA19S+7S85ndddH5x2fgMFcfqTk+k+PICWOnfzcWIjQYKNU3 aL9e7VDCeEF15qxC8WGGReRr61hffG/ys0/8g5cbjstfWu7pj0sXTIRXEQtSjIN9aNSm MLc2jriWDbLP+qmJJKifL/5HaaG/VUmfT221fReImXfOMPLsRqUXNyviqOCGs1XfrTzN ktOw== 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 94si1390921edm.445.2020.06.02.04.54.40; Tue, 02 Jun 2020 04:55:03 -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 S1728327AbgFBLvt convert rfc822-to-8bit (ORCPT + 99 others); Tue, 2 Jun 2020 07:51:49 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:49002 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728170AbgFBLvc (ORCPT ); Tue, 2 Jun 2020 07:51:32 -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-220-AzP_FFAjPiWdXO7c3OwAMg-1; Tue, 02 Jun 2020 07:51:27 -0400 X-MC-Unique: AzP_FFAjPiWdXO7c3OwAMg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D59281030980; Tue, 2 Jun 2020 11:51:25 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.195.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 911A210013D7; Tue, 2 Jun 2020 11:51:23 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Ian Rogers , Stephane Eranian , Andi Kleen Subject: [PATCH 10/13] perf tools: Release metric_events rblist Date: Tue, 2 Jun 2020 13:50:52 +0200 Message-Id: <20200602115055.1168446-11-jolsa@kernel.org> In-Reply-To: <20200602115055.1168446-1-jolsa@kernel.org> References: <20200602115055.1168446-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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. 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 8a0c470dd92b..6d45b9783b73 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2252,6 +2252,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