From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755739AbdGKIwM (ORCPT ); Tue, 11 Jul 2017 04:52:12 -0400 Received: from terminus.zytor.com ([65.50.211.136]:55141 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755530AbdGKIwK (ORCPT ); Tue, 11 Jul 2017 04:52:10 -0400 Date: Tue, 11 Jul 2017 01:49:46 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: dsahern@gmail.com, mingo@kernel.org, jolsa@kernel.org, wangnan0@huawei.com, tglx@linutronix.de, hpa@zytor.com, namhyung@kernel.org, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, acme@redhat.com Reply-To: hpa@zytor.com, tglx@linutronix.de, wangnan0@huawei.com, dsahern@gmail.com, mingo@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, acme@redhat.com, linux-kernel@vger.kernel.org, namhyung@kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf evsel: State in the default event name if attr.exclude_kernel is set Git-Commit-ID: ede5626d303b721dd02246a3850380943c24e380 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ede5626d303b721dd02246a3850380943c24e380 Gitweb: http://git.kernel.org/tip/ede5626d303b721dd02246a3850380943c24e380 Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 10 Jul 2017 16:19:25 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 10 Jul 2017 16:19:25 -0300 perf evsel: State in the default event name if attr.exclude_kernel is set When no event is specified perf will use the "cycles" hardware event with the highest precision available in the processor, and excluding kernel events for non-root users, so make that clear in the event name by setting the "u" event modifier, i.e. "cycles:upp". E.g.: The default for root: # perf record usleep 1 # perf evlist -v cycles:ppp: ..., precise_ip: 3, exclude_kernel: 0, ... # And for !root: $ perf record usleep 1 $ perf evlist -v cycles:uppp: ... , precise_ip: 3, exclude_kernel: 1, ... $ Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-lf29zcdl422i9knrgde0uwy3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index f2a1876..413f74d 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -298,8 +298,10 @@ struct perf_evsel *perf_evsel__new_cycles(void) goto out; /* use asprintf() because free(evsel) assumes name is allocated */ - if (asprintf(&evsel->name, "cycles%.*s", - attr.precise_ip ? attr.precise_ip + 1 : 0, ":ppp") < 0) + if (asprintf(&evsel->name, "cycles%s%s%.*s", + (attr.precise_ip || attr.exclude_kernel) ? ":" : "", + attr.exclude_kernel ? "u" : "", + attr.precise_ip ? attr.precise_ip + 1 : 0, "ppp") < 0) goto error_free; out: return evsel;