Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp793888ybe; Fri, 13 Sep 2019 06:29:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXZ4GmkVMgFWeXqewLLRciE6HCUrCaVvBzB+FwUlGZ5cTDhjiFqJTvhozsredW2uMdqo03 X-Received: by 2002:a17:906:d926:: with SMTP id rn6mr3455579ejb.175.1568381381344; Fri, 13 Sep 2019 06:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381381; cv=none; d=google.com; s=arc-20160816; b=EL+yVsk1yorSYYYg7xDI2kF8zID/YHG+nJdqcqnM1+ErEPeo4LGOioY3smsT1WjSBx qA0snQKWoa31WdC5aquMgk8Y9JsMnRuPKHjUAJx389V/o2QmRPH5e1xzmXQsMFGQ//ad vH/wsjiz4UTdeg2EQ0HCE2B4SwsokcUEji7H2TZNJwkwSRnI7vQDR/vn9W+pXYesHssO yC5AOssOQmPsDglhxMkTk/bMz5V4PmMdjqMWJ+AmjpvdrDJyoP1/ekRlzYZvnX2GgTvB iaT/HmBa2UelfUayXR+u8+OZ14EnJO3xw3cPXxfDCuHoILh8NcV0wVbHfftGYi5j6+zP 1HKA== 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=1ylkEekm+elMg+v6Z+cQBP92ZWR6/Adk7ErzB4MrggE=; b=LSnOV65XdaO6XPNwahF3hOLEQDVSs8pwFgCborkW3kKo/vIk70OFDjnZ4TXw3iJ4gm XTNqZD9vJTPX42pXFKmif0Wgh/jqpsr4PqMnasbxUCnfh/jVpcwBrA6aGnCAO14c0VJg H+gglYUgg2sRz3070pT845K/umAM6gTfnOmIqDu4+1GsW1jkW1rv3VcCDANywakTPlck Z7R8ObIwqe2TpQC0I6OGdZbEa3Kzt3myYR3UJd54WrpH00W4jYAM1RpU0BuDy96urvH1 SrTPCu5BuURfjRMYW0YgLn3JlyRf1Xr9JOJhIqB+eq4t7Nt4VDbaaniaAZBwY7vpGnhr ES+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p39si16655395eda.416.2019.09.13.06.29.13; Fri, 13 Sep 2019 06:29:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403819AbfIMN0c (ORCPT + 99 others); Fri, 13 Sep 2019 09:26:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59738 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403815AbfIMN0a (ORCPT ); Fri, 13 Sep 2019 09:26:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90D9D18C427D; Fri, 13 Sep 2019 13:26:29 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB3AB5C1D4; Fri, 13 Sep 2019 13:26:27 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 62/73] libperf: Add perf_evlist__exit function Date: Fri, 13 Sep 2019 15:23:44 +0200 Message-Id: <20190913132355.21634-63-jolsa@kernel.org> In-Reply-To: <20190913132355.21634-1-jolsa@kernel.org> References: <20190913132355.21634-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Fri, 13 Sep 2019 13:26:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding perf_evlist__exit function, so far it's not exported and added only for internal use for perf and libperf. Using it to release cpus/threads and pollfd array. Link: http://lkml.kernel.org/n/tip-1n61vkdnvfqaeb7k4mwlvs1h@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/evlist.c | 15 ++++++++++++--- tools/perf/lib/include/internal/evlist.h | 2 ++ tools/perf/util/evlist.c | 6 +----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index e27fe1fcef3d..b9dd040a6162 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -107,11 +107,20 @@ perf_evlist__next(struct perf_evlist *evlist, struct perf_evsel *prev) return next; } -void perf_evlist__delete(struct perf_evlist *evlist) +void perf_evlist__exit(struct perf_evlist *evlist) { - free(evlist->mmap); - free(evlist->mmap_ovw); + perf_cpu_map__put(evlist->cpus); + perf_thread_map__put(evlist->threads); + evlist->cpus = NULL; + evlist->threads = NULL; + zfree(&evlist->mmap); + zfree(&evlist->mmap_ovw); fdarray__exit(&evlist->pollfd); +} + +void perf_evlist__delete(struct perf_evlist *evlist) +{ + perf_evlist__exit(evlist); free(evlist); } diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h index 851837ce4ff8..1ca822eeab1d 100644 --- a/tools/perf/lib/include/internal/evlist.h +++ b/tools/perf/lib/include/internal/evlist.h @@ -48,6 +48,8 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops, struct perf_mmap_param *mp); +void perf_evlist__exit(struct perf_evlist *evlist); + /** * __perf_evlist__for_each_entry - iterate thru all the evsels * @list: list_head instance to iterate diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 728a15cddda7..0c69621e2b2e 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -137,7 +137,7 @@ void evlist__exit(struct evlist *evlist) { zfree(&evlist->mmap); zfree(&evlist->overwrite_mmap); - fdarray__exit(&evlist->core.pollfd); + perf_evlist__exit(&evlist->core); } void evlist__delete(struct evlist *evlist) @@ -147,10 +147,6 @@ void evlist__delete(struct evlist *evlist) evlist__munmap(evlist); evlist__close(evlist); - perf_cpu_map__put(evlist->core.cpus); - perf_thread_map__put(evlist->core.threads); - evlist->core.cpus = NULL; - evlist->core.threads = NULL; evlist__purge(evlist); evlist__exit(evlist); free(evlist); -- 2.21.0