Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5002285ybi; Tue, 30 Jul 2019 11:59:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqySymfxraDlLD/6H4dlQW82Q9pN068R+LKoW0vdp0f5cTuUtZgyYHN66VD5Egpzciu9DRqL X-Received: by 2002:a63:2cd5:: with SMTP id s204mr92992590pgs.95.1564513157846; Tue, 30 Jul 2019 11:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564513157; cv=none; d=google.com; s=arc-20160816; b=JGq6cperC1/dMD+SmisghwebtlWPuU1uS2ZiIlVqmy2X1ebJ6d48ZEW2ekpYBfWe+F 5A/wMcLfaYPkMdt0OklfjuzWrOcOYVfDduuEnXQjsrUXGcp09wpzyHIhJm1Is2XHJAw0 2ILt450nD7qW2+YeiHqHT83t1Se14jWmeTA0RF2UrPUgvBMfjCHpXcCDk1ALiKdk9JQG qbVowOHAYg0uFomhnWn/jt1aTt2zV2Fxhnke5X87Eqge6dNazgvpGh82T1us5cUvvUu8 R3RwJRnrSOAujrLKiKaM86RITxjqjJB74w7RcQ3oCbehHsEAdwmTNNJ60lSxUMMr42Tg uyHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=hcy/n/CSc3ozRpkImB7HVWhYZIzXYJwwEsfzFzqCYxc=; b=z5HOwS8PO63OR7RVoVQ1g3mWN9dGDDkSYdQhFGVFhc2phcgIxC0OhbDgEzc8N/HB0o JwsaFPWQVPXj9eq5QqBjkSQrvZpQMedLNgMcNnvTCoHpHCqlUsnfpYftEQRf4MhlOxZe kyuVLxK2t3twb6fCJgTYun4rMXCl7sE4fjMQJ2m4t9qaCez2XzKoNblbiwM7m/WzeoVX R0l7XWVBBS6ZXNIlvNZUc5pkqKcRL5D2wfhThRQqMOkyfOzuvCgeZIbpZXUEtdhcE2cX adbwwFi8ohki6/UarcpOzGQJkowDASNpsK7JgtF2rUA1uVSgHbKYWWv8aUWB9D9p/d64 75fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019071901 header.b=cfCmfk7j; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si30259399pla.80.2019.07.30.11.59.02; Tue, 30 Jul 2019 11:59:17 -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; dkim=pass header.i=@zytor.com header.s=2019071901 header.b=cfCmfk7j; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388512AbfG3S4b (ORCPT + 99 others); Tue, 30 Jul 2019 14:56:31 -0400 Received: from terminus.zytor.com ([198.137.202.136]:59311 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388140AbfG3S4a (ORCPT ); Tue, 30 Jul 2019 14:56:30 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6UIuIKj3336762 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 30 Jul 2019 11:56:18 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6UIuIKj3336762 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019071901; t=1564512979; bh=hcy/n/CSc3ozRpkImB7HVWhYZIzXYJwwEsfzFzqCYxc=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=cfCmfk7jB4Ztzh5h7ymazr8MnbK9GRnnWWa15UH6P+gGMAnHCmT0twwWMrj6O1DlD cn3ijWJ5PojMgqNBDfmXBJHvTynqEDsOxYJKhbdDiFc4VSSkcI9kUh4z0fbD3hwVDN g1gWb3VxTWKPdVCMD4K0iNfmcRK1vfbbLhse6hUbdGA3CAFMlf/FL6Xk4x9PkEVWCU CnhB3TaSZUvToXJS7CdN5ACCa8wH/e2X+OEwmVzuUwGgJcr+JdeU8vZYrRmvWP4MwI LmewvOKTcHUTMFhHbMyBAVyJzsv85kvqQfaziND7wNHnCAHJJUFV92enams90tZFxK 6PuHZwBK/5PdQ== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6UIuHbq3336759; Tue, 30 Jul 2019 11:56:17 -0700 Date: Tue, 30 Jul 2019 11:56:17 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jiri Olsa Message-ID: Cc: ak@linux.intel.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, mpetlan@redhat.com, jolsa@kernel.org, hpa@zytor.com, tglx@linutronix.de, acme@redhat.com, alexey.budankov@linux.intel.com, mingo@kernel.org Reply-To: namhyung@kernel.org, ak@linux.intel.com, mpetlan@redhat.com, alexander.shishkin@linux.intel.com, peterz@infradead.org, linux-kernel@vger.kernel.org, mingo@kernel.org, alexey.budankov@linux.intel.com, acme@redhat.com, jolsa@kernel.org, hpa@zytor.com, tglx@linutronix.de In-Reply-To: <20190721112506.12306-66-jolsa@kernel.org> References: <20190721112506.12306-66-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] libperf: Adopt perf_evsel__enable()/disable()/apply_filter() functions Git-Commit-ID: a00571fda6091b5268d05e87d0797efe2db1920a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a00571fda6091b5268d05e87d0797efe2db1920a Gitweb: https://git.kernel.org/tip/a00571fda6091b5268d05e87d0797efe2db1920a Author: Jiri Olsa AuthorDate: Sun, 21 Jul 2019 13:24:52 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 29 Jul 2019 18:34:46 -0300 libperf: Adopt perf_evsel__enable()/disable()/apply_filter() functions Move the following functions: evsel__enable() evsel__disable() evsel__apply_filter() to libperf with the following names: perf_evsel__enable() perf_evsel__disable() perf_evsel__apply_filter() Export only perf_evsel__enable()/disable(), keeping the perf_evsel__apply_filter() one private for the moment. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Andi Kleen Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190721112506.12306-66-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/evsel.c | 36 +++++++++++++++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/lib/include/perf/evsel.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ tools/perf/util/evlist.c | 2 +- tools/perf/util/evsel.c | 29 ++------------------------ tools/perf/util/evsel.h | 1 - 7 files changed, 44 insertions(+), 29 deletions(-) diff --git a/tools/perf/lib/evsel.c b/tools/perf/lib/evsel.c index 390fcf9107c1..c3f3722e9f91 100644 --- a/tools/perf/lib/evsel.c +++ b/tools/perf/lib/evsel.c @@ -14,6 +14,7 @@ #include #include #include +#include void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr) { @@ -179,3 +180,38 @@ int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, return 0; } + +static int perf_evsel__run_ioctl(struct perf_evsel *evsel, + int ioc, void *arg) +{ + int cpu, thread; + + for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { + for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { + int fd = FD(evsel, cpu, thread), + err = ioctl(fd, ioc, arg); + + if (err) + return err; + } + } + + return 0; +} + +int perf_evsel__enable(struct perf_evsel *evsel) +{ + return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, 0); +} + +int perf_evsel__disable(struct perf_evsel *evsel) +{ + return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, 0); +} + +int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter) +{ + return perf_evsel__run_ioctl(evsel, + PERF_EVENT_IOC_SET_FILTER, + (void *)filter); +} diff --git a/tools/perf/lib/include/internal/evsel.h b/tools/perf/lib/include/internal/evsel.h index 89bae3720d67..8b854d1c9b45 100644 --- a/tools/perf/lib/include/internal/evsel.h +++ b/tools/perf/lib/include/internal/evsel.h @@ -24,5 +24,6 @@ int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); void perf_evsel__close_fd(struct perf_evsel *evsel); void perf_evsel__free_fd(struct perf_evsel *evsel); int perf_evsel__read_size(struct perf_evsel *evsel); +int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter); #endif /* __LIBPERF_INTERNAL_EVSEL_H */ diff --git a/tools/perf/lib/include/perf/evsel.h b/tools/perf/lib/include/perf/evsel.h index 16ae3f873280..0db18dfabdb8 100644 --- a/tools/perf/lib/include/perf/evsel.h +++ b/tools/perf/lib/include/perf/evsel.h @@ -30,5 +30,7 @@ LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map * LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, struct perf_counts_values *count); +LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); +LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel); #endif /* __LIBPERF_EVSEL_H */ diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map index 2e23cf420cce..5bd491ac1762 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map @@ -13,6 +13,8 @@ LIBPERF_0.0.1 { perf_thread_map__put; perf_evsel__new; perf_evsel__delete; + perf_evsel__enable; + perf_evsel__disable; perf_evsel__init; perf_evsel__open; perf_evsel__close; diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index c6b4883b2d49..c4489a1ad6bc 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1109,7 +1109,7 @@ int perf_evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel) * filters only work for tracepoint event, which doesn't have cpu limit. * So evlist and evsel should always be same. */ - err = evsel__apply_filter(evsel, evsel->filter); + err = perf_evsel__apply_filter(&evsel->core, evsel->filter); if (err) { *err_evsel = evsel; break; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 0957ec24f518..64bc32ed6dfa 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1153,31 +1153,6 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts, perf_evsel__reset_sample_bit(evsel, BRANCH_STACK); } -static int perf_evsel__run_ioctl(struct evsel *evsel, - int ioc, void *arg) -{ - int cpu, thread; - - for (cpu = 0; cpu < xyarray__max_x(evsel->core.fd); cpu++) { - for (thread = 0; thread < xyarray__max_y(evsel->core.fd); thread++) { - int fd = FD(evsel, cpu, thread), - err = ioctl(fd, ioc, arg); - - if (err) - return err; - } - } - - return 0; -} - -int evsel__apply_filter(struct evsel *evsel, const char *filter) -{ - return perf_evsel__run_ioctl(evsel, - PERF_EVENT_IOC_SET_FILTER, - (void *)filter); -} - int perf_evsel__set_filter(struct evsel *evsel, const char *filter) { char *new_filter = strdup(filter); @@ -1220,7 +1195,7 @@ int perf_evsel__append_addr_filter(struct evsel *evsel, const char *filter) int evsel__enable(struct evsel *evsel) { - int err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, 0); + int err = perf_evsel__enable(&evsel->core); if (!err) evsel->disabled = false; @@ -1230,7 +1205,7 @@ int evsel__enable(struct evsel *evsel) int evsel__disable(struct evsel *evsel) { - int err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, 0); + int err = perf_evsel__disable(&evsel->core); /* * We mark it disabled here so that tools that disable a event can * ignore events after they disable it. I.e. the ring buffer may have diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 57e315d8158e..0989fb2eb1ec 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -287,7 +287,6 @@ int perf_evsel__set_filter(struct evsel *evsel, const char *filter); int perf_evsel__append_tp_filter(struct evsel *evsel, const char *filter); int perf_evsel__append_addr_filter(struct evsel *evsel, const char *filter); -int evsel__apply_filter(struct evsel *evsel, const char *filter); int evsel__enable(struct evsel *evsel); int evsel__disable(struct evsel *evsel);