Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4262368ybp; Mon, 7 Oct 2019 05:58:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEOhMhe8/FJyCcAdsQaIzVH8GQwWh3FR1YXIYAtATcje5M+8HXePsH/oTUcwCyLs+ni2YE X-Received: by 2002:a05:6402:7c1:: with SMTP id u1mr28985691edy.198.1570453133693; Mon, 07 Oct 2019 05:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570453133; cv=none; d=google.com; s=arc-20160816; b=ZYoaS2ffPugRuxqbAe0Zo83Z7Uaxuv8F4EaXBinKJxfo/MOagilD1yCIi2Ki0iDd2j IoktizOnEpjfUNfWfdfVaNx6jV/1iU4Sa6t5xuzrOYiYdPWeWOydXWrOF8Ct5XeihJ4c DrBRqhM5b0y2+kMN+JsvK6RN95ttDxD6s/HZh1HIe7gYOGlqD0U+eJks47sWP6sBk4nb iE8UHWRwdh1m+ivvNPhyQW1Y+Q7s3uEVDviS5h3PKPFQeOfDfLpqKro24HNNtK5WAnJ4 uHyEIGPgV4ZezQgE8ml6k3ievQVRd8lWhPZh5WKreWBbhY6vHaakNQnf7Xet1h0SkUeI g60g== 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=uFyJq+p27yZBEM9LlZLAfLyqo5gRjtKqbxAiBipGCIY=; b=jiRosZdu5qAs/WlM1M23zhUdBRGq9Bppx9c3ebTPQ36jRaXTSFbZqbQUPfgZw1bKCN zHbE3nLwVwe6SW0BZCiJelvBl/4EM1LOIe3y4AXTaCSPipZGTLS5wOT6S3JFqYr5Q4hA K5SEkGPCf6oQn2FYZkwBiTXIAq0+grT0wfRuyWgIr1QFEoaEWpBfOFlo0kJeos8i7wuz q/xH9U+EnqzTVqzO78gaRQrAzUTaAT0ugBJUKCYJLFbztA5JixPxjavkYUSLhpR3bzwF /a6RvgV2qWVgccwkgod6MMzgIUBsdpu+/+gSqubQgvmCnkE/2UE3VGh/Ci7mCCsaRt8b gyOw== 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 w10si7997820edv.21.2019.10.07.05.58.30; Mon, 07 Oct 2019 05:58:53 -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 S1728625AbfJGMzg (ORCPT + 99 others); Mon, 7 Oct 2019 08:55:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60882 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728382AbfJGMyn (ORCPT ); Mon, 7 Oct 2019 08:54:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 738C4A44AF8; Mon, 7 Oct 2019 12:54:43 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AC145D9CC; Mon, 7 Oct 2019 12:54:41 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 24/36] libperf: Add perf_evlist__exit function Date: Mon, 7 Oct 2019 14:53:32 +0200 Message-Id: <20191007125344.14268-25-jolsa@kernel.org> In-Reply-To: <20191007125344.14268-1-jolsa@kernel.org> References: <20191007125344.14268-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 07 Oct 2019 12:54:43 +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 | 12 +++++++++++- tools/perf/lib/include/internal/evlist.h | 2 ++ tools/perf/util/evlist.c | 6 +----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index 5ae1da97d2e6..7ba98f0e6365 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -109,13 +109,23 @@ perf_evlist__next(struct perf_evlist *evlist, struct perf_evsel *prev) return next; } +void perf_evlist__exit(struct perf_evlist *evlist) +{ + perf_cpu_map__put(evlist->cpus); + perf_thread_map__put(evlist->threads); + evlist->cpus = NULL; + evlist->threads = NULL; + fdarray__exit(&evlist->pollfd); +} + void perf_evlist__delete(struct perf_evlist *evlist) { if (evlist == NULL) return; perf_evlist__munmap(evlist); - fdarray__exit(&evlist->pollfd); + perf_evlist__close(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 b2019700cdc0..0721512ffb19 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 71679cce7257..3669ca767340 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -138,7 +138,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) @@ -148,10 +148,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