Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5482356ybp; Mon, 14 Oct 2019 23:39:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLklEjsKQi+otiRpMBzfOOG0QWKLLQIcIxiBykrm8/vpE/XoepqESRp8D3AqzPikfoHfFr X-Received: by 2002:a17:906:4d95:: with SMTP id s21mr32262754eju.175.1571121547010; Mon, 14 Oct 2019 23:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571121547; cv=none; d=google.com; s=arc-20160816; b=G016+0zqHfNncgTi5sufzeaPYwm1d8ivN8lkz3D8T6RMtfkRoF4eM1VmjNeYMyPf+W pPePzAIpsRna9r7ceRiaNQemUrHEd2OzKtiyu/C3z19ooACa+ZbMS/CGMh7RFy/zu/I6 dBgr0rP+4TtWc9pnKb+QoaLDkkv7tCpnhDqkFb6RfEV3sCTxpvbRRytd4X4kRsD6wZgb Wft/2XFbEvXA4cuEnbkfWcz3xv1i+PHmD737ui/kbgpU7Cj7OFRtnZ5jIYVEueL10noR vD7y/PNc0DY8c7DEqeeSAUekL0yLRUfIjgPXIc35RqICIuS0XOjPHIMXn0wPKWtZglkg LSrw== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=GhyJmAKVH2rdlymYWwYmF+AZWzW/HLI8o0XYUoI3m00=; b=aojl/M2WD+cSkYqgP66+4emXxjQrYFyq+7nm/42bnRHNb91IRtumClbxUtaNaia6wO iVCCukkl/JQ8v7921stOnP9utd3wVzsmiAqWUkaeE+1nOuB1sO9lHW/CGqN7lZfcF994 yuJJRF9ot7IBF/i1jZy/NSKc79tnDeA28fXpBrZLP4LKheWGJj0wNdNFeyQjPr6SBPu8 KGpw719Tz3AjfJ/9YS8ZE6RhQFHCFo9rL5PtCJnxkffWsIdjSManKKfPgMr99PB8vhGF D5Sm41MgxjlAXW1yHeTL126BJjarp059ePBi15oNAB0+S4wbTWf0MK7/7lKKXgqpAyqI pnKA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11si12483104eje.365.2019.10.14.23.38.42; Mon, 14 Oct 2019 23:39:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728426AbfJOFbz (ORCPT + 99 others); Tue, 15 Oct 2019 01:31:55 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:41929 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728389AbfJOFbw (ORCPT ); Tue, 15 Oct 2019 01:31:52 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iKFQm-0008S5-1r; Tue, 15 Oct 2019 07:31:36 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id A7D4C1C0482; Tue, 15 Oct 2019 07:31:35 +0200 (CEST) Date: Tue, 15 Oct 2019 05:31:35 -0000 From: "tip-bot2 for Jiri Olsa" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] libperf: Introduce perf_evlist__purge() Cc: Jiri Olsa , Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191007125344.14268-26-jolsa@kernel.org> References: <20191007125344.14268-26-jolsa@kernel.org> MIME-Version: 1.0 Message-ID: <157111749561.12254.7991223629195181264.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 696f27c994ed056fd176ce9dc51c7988e148e4b0 Gitweb: https://git.kernel.org/tip/696f27c994ed056fd176ce9dc51c7988e148e4b0 Author: Jiri Olsa AuthorDate: Mon, 07 Oct 2019 14:53:33 +02:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Thu, 10 Oct 2019 12:57:22 -03:00 libperf: Introduce perf_evlist__purge() Add a static perf_evlist__purge() function to purge evsels from a evlist. Add also perf_evlist__for_each_entry_safe() which is used by perf_evlist__purge(). Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20191007125344.14268-26-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/evlist.c | 13 +++++++++++++ tools/perf/lib/include/internal/evlist.h | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index 7ba98f0..9534ad9 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -109,6 +109,18 @@ perf_evlist__next(struct perf_evlist *evlist, struct perf_evsel *prev) return next; } +static void perf_evlist__purge(struct perf_evlist *evlist) +{ + struct perf_evsel *pos, *n; + + perf_evlist__for_each_entry_safe(evlist, n, pos) { + list_del_init(&pos->node); + perf_evsel__delete(pos); + } + + evlist->nr_entries = 0; +} + void perf_evlist__exit(struct perf_evlist *evlist) { perf_cpu_map__put(evlist->cpus); @@ -125,6 +137,7 @@ void perf_evlist__delete(struct perf_evlist *evlist) perf_evlist__munmap(evlist); perf_evlist__close(evlist); + perf_evlist__purge(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 0721512..be0b25a 100644 --- a/tools/perf/lib/include/internal/evlist.h +++ b/tools/perf/lib/include/internal/evlist.h @@ -82,6 +82,24 @@ void perf_evlist__exit(struct perf_evlist *evlist); #define perf_evlist__for_each_entry_reverse(evlist, evsel) \ __perf_evlist__for_each_entry_reverse(&(evlist)->entries, evsel) +/** + * __perf_evlist__for_each_entry_safe - safely iterate thru all the evsels + * @list: list_head instance to iterate + * @tmp: struct evsel temp iterator + * @evsel: struct evsel iterator + */ +#define __perf_evlist__for_each_entry_safe(list, tmp, evsel) \ + list_for_each_entry_safe(evsel, tmp, list, node) + +/** + * perf_evlist__for_each_entry_safe - safely iterate thru all the evsels + * @evlist: evlist instance to iterate + * @evsel: struct evsel iterator + * @tmp: struct evsel temp iterator + */ +#define perf_evlist__for_each_entry_safe(evlist, tmp, evsel) \ + __perf_evlist__for_each_entry_safe(&(evlist)->entries, tmp, evsel) + static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist) { return list_entry(evlist->entries.next, struct perf_evsel, node);