Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030270AbbEFDUA (ORCPT ); Tue, 5 May 2015 23:20:00 -0400 Received: from terminus.zytor.com ([198.137.202.10]:36632 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030250AbbEFDT4 (ORCPT ); Tue, 5 May 2015 23:19:56 -0400 Date: Tue, 5 May 2015 20:19:39 -0700 From: tip-bot for Namhyung Kim Message-ID: Cc: linux-kernel@vger.kernel.org, acme@redhat.com, tglx@linutronix.de, mingo@kernel.org, js1304@gmail.com, a.p.zijlstra@chello.nl, minchan@kernel.org, jolsa@redhat.com, namhyung@kernel.org, hpa@zytor.com, penberg@kernel.org, dsahern@gmail.com Reply-To: linux-kernel@vger.kernel.org, acme@redhat.com, tglx@linutronix.de, mingo@kernel.org, minchan@kernel.org, a.p.zijlstra@chello.nl, jolsa@redhat.com, dsahern@gmail.com, penberg@kernel.org, hpa@zytor.com, namhyung@kernel.org, js1304@gmail.com In-Reply-To: <1430837572-31395-1-git-send-email-namhyung@kernel.org> References: <1430837572-31395-1-git-send-email-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf kmem: Show warning when trying to run stat without record Git-Commit-ID: a923e2c4b14f99f70692f82ee7bd63717604b738 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 Content-Length: 2741 Lines: 73 Commit-ID: a923e2c4b14f99f70692f82ee7bd63717604b738 Gitweb: http://git.kernel.org/tip/a923e2c4b14f99f70692f82ee7bd63717604b738 Author: Namhyung Kim AuthorDate: Tue, 5 May 2015 23:52:52 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 5 May 2015 18:13:08 -0300 perf kmem: Show warning when trying to run stat without record Sometimes one can mistakenly run 'perf kmem stat' without running 'perf kmem record' before or with a different configuration like recording --slab and stat --page. Show a warning message like the one below to inform the user: # perf kmem stat --page --caller No page allocation events found. Have you run 'perf kmem record --page'? Signed-off-by: Namhyung Kim Acked-by: Pekka Enberg Cc: David Ahern Cc: Jiri Olsa Cc: Joonsoo Kim Cc: Minchan Kim Cc: Peter Zijlstra Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/1430837572-31395-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-kmem.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 828b728..e628bf1 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -1882,6 +1882,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused) }; struct perf_session *session; int ret = -1; + const char errmsg[] = "No %s allocation events found. Have you run 'perf kmem record --%s'?\n"; perf_config(kmem_config, NULL); argc = parse_options_subcommand(argc, argv, kmem_options, @@ -1908,11 +1909,21 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused) if (session == NULL) return -1; + if (kmem_slab) { + if (!perf_evlist__find_tracepoint_by_name(session->evlist, + "kmem:kmalloc")) { + pr_err(errmsg, "slab", "slab"); + return -1; + } + } + if (kmem_page) { - struct perf_evsel *evsel = perf_evlist__first(session->evlist); + struct perf_evsel *evsel; - if (evsel == NULL || evsel->tp_format == NULL) { - pr_err("invalid event found.. aborting\n"); + evsel = perf_evlist__find_tracepoint_by_name(session->evlist, + "kmem:mm_page_alloc"); + if (evsel == NULL) { + pr_err(errmsg, "page", "page"); return -1; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/