From patchwork Tue Jun 24 22:47:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexis Berlemont X-Patchwork-Id: 4414771 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C8059F1D6 for ; Tue, 24 Jun 2014 22:54:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B34A20320 for ; Tue, 24 Jun 2014 22:54:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 242C82035C for ; Tue, 24 Jun 2014 22:54:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754177AbaFXWxp (ORCPT ); Tue, 24 Jun 2014 18:53:45 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:36540 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751222AbaFXWuM (ORCPT ); Tue, 24 Jun 2014 18:50:12 -0400 Received: by mail-wi0-f175.google.com with SMTP id r20so6896401wiv.2 for ; Tue, 24 Jun 2014 15:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=yMBVwv5Esh6JU82VX8gwhPna1mB5YQk3XgOCXMRVQ5w=; b=V/g/tkuTMzHt1n5RIOh105ja4lISGk+tDZ7gyMZFvLLrb6KmfXtIUc1FdAmBOXZahp 8gwusP4xDCAdLMGjKV9bf3CYsFVj91INxCuupsSQgACtvZ8dLIOScEHP98LYIv9EMR4B hmVrntCtajMGzoC7kIQTqt2ejzyOuFDqA3QhHB/CYX9FiUl+Y9fX7lG4aHv8HDReewIv miciJ4v9NyweDlHn7DdoqtRREmdpXmr3kMTPGPJrmT7m4o+tZH4kNhff135wo5mYEyWk CmT/bHtokaWvZYCT/q1hLTn7vv8Zbqw26FAjwmtQnGSL5c7F1nulm+ZArh69/VlYT3VA KYeA== X-Received: by 10.180.82.199 with SMTP id k7mr5943900wiy.34.1403650210407; Tue, 24 Jun 2014 15:50:10 -0700 (PDT) Received: from localhost.localdomain (APuteaux-554-1-46-194.w90-35.abo.wanadoo.fr. [90.35.125.194]) by mx.google.com with ESMTPSA id gp15sm3387067wjc.10.2014.06.24.15.50.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jun 2014 15:50:09 -0700 (PDT) From: Alexis Berlemont To: linux-kernel@vger.kernel.org Cc: Jiri Olsa , dsahern@gmail.com, mingo@kernel.org, sam@ravnborg.org, mmarek@suse.cz, namhyung@kernel.org, Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Paul Mackerras , Corey Ashford , Frederic Weisbecker , Borislav Petkov , linux-kbuild@vger.kernel.org, Stephane Eranian Subject: [PATCH 02/13] perf tools: Kbuild builtin source related fixies Date: Wed, 25 Jun 2014 00:47:49 +0200 Message-Id: <1403650080-3130-3-git-send-email-alexis.berlemont@gmail.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403650080-3130-1-git-send-email-alexis.berlemont@gmail.com> References: <1403650080-3130-1-git-send-email-alexis.berlemont@gmail.com> In-Reply-To: References: Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiri Olsa Adding CONFIG_BUILTIN_* defines to govern builtin commands. This will be usefull for kbuild process switch. Signed-off-by: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Paul Mackerras Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Namhyung Kim Cc: Borislav Petkov Cc: Michal Marek Cc: linux-kbuild@vger.kernel.org Cc: Stephane Eranian --- tools/perf/builtin-annotate.c | 8 ++++++- tools/perf/builtin-cmds.h | 27 ++++++++++++++++++++++ tools/perf/builtin-help.c | 1 + tools/perf/builtin-kvm.c | 19 ++++++++++------ tools/perf/builtin-report.c | 3 +++ tools/perf/builtin-top.c | 19 ++++++++++++---- tools/perf/perf.c | 45 +++++++++++++++++++++++++++++++++++-- tools/perf/ui/setup.c | 6 +++-- tools/perf/util/generate-cmdlist.sh | 10 +++++++++ 9 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 tools/perf/builtin-cmds.h diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 1ec429f..d40070f 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -5,6 +5,7 @@ * look up and read DSOs and symbol information and display * a histogram of results, along various sorting keys. */ +#include "generated/autoconf.h" #include "builtin.h" #include "util/util.h" @@ -114,7 +115,7 @@ static void hists__find_annotations(struct hists *hists, struct perf_evsel *evsel, struct perf_annotate *ann) { - struct rb_node *nd = rb_first(&hists->entries), *next; + struct rb_node *nd = rb_first(&hists->entries); int key = K_RIGHT; while (nd) { @@ -153,7 +154,9 @@ find_next: /* skip missing symbols */ nd = rb_next(nd); +#ifdef CONFIG_TUI } else if (use_browser == 1) { + struct rb_node *next = NULL; key = hist_entry__tui_annotate(he, evsel, NULL); switch (key) { case -1: @@ -172,6 +175,7 @@ find_next: if (next != NULL) nd = next; +#endif /* CONFIG_TUI */ } else { hist_entry__tty_annotate(he, evsel, ann); nd = rb_next(nd); @@ -314,7 +318,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"), +#ifdef CONFIG_TUI OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), +#endif /* CONFIG_TUI */ OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"), OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, "file", "vmlinux pathname"), diff --git a/tools/perf/builtin-cmds.h b/tools/perf/builtin-cmds.h new file mode 100644 index 0000000..fec342a --- /dev/null +++ b/tools/perf/builtin-cmds.h @@ -0,0 +1,27 @@ +#ifndef BUILTIN_CMDS_H +#define BUILTIN_CMDS_H + +#define CONFIG_BUILTIN_REPORT 1 +#define CONFIG_BUILTIN_SCRIPT 1 +#define CONFIG_BUILTIN_BENCH 1 +#define CONFIG_BUILTIN_SCHED 1 +#define CONFIG_BUILTIN_TRACE 1 +#define CONFIG_BUILTIN_TOP 1 +#define CONFIG_BUILTIN_RECORD 1 +#define CONFIG_BUILTIN_BUILDID_LIST 1 +#define CONFIG_BUILTIN_INJECT 1 +#define CONFIG_BUILTIN_LOCK 1 +#define CONFIG_BUILTIN_KVM 1 +#define CONFIG_BUILTIN_BUILDID_CACHE 1 +#define CONFIG_BUILTIN_EVLIST 1 +#define CONFIG_BUILTIN_KMEM 1 +#define CONFIG_BUILTIN_STAT 1 +#define CONFIG_BUILTIN_DIFF 1 +#define CONFIG_BUILTIN_ANNOTATE 1 +#define CONFIG_BUILTIN_TIMECHART 1 +#define CONFIG_BUILTIN_LIST 1 +#define CONFIG_BUILTIN_HELP 1 +#define CONFIG_BUILTIN_PROBE 1 +#define CONFIG_BUILTIN_MEM 1 + +#endif /* BUILTIN_CMDS_H */ diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 178b88a..b6c78a6 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -7,6 +7,7 @@ #include "util/cache.h" #include "builtin.h" #include "util/exec_cmd.h" +#include "builtin-cmds.h" #include "common-cmds.h" #include "util/parse-options.h" #include "util/run-command.h" diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 0f1e5a2..0d0d9c7 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1718,20 +1718,25 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused) if (!strncmp(argv[0], "rec", 3)) return __cmd_record(file_name, argc, argv); - else if (!strncmp(argv[0], "rep", 3)) + + if (!strncmp(argv[0], "rep", 3)) return __cmd_report(file_name, argc, argv); - else if (!strncmp(argv[0], "diff", 4)) + + if (!strncmp(argv[0], "diff", 4)) return cmd_diff(argc, argv, NULL); - else if (!strncmp(argv[0], "top", 3)) + + if (!strncmp(argv[0], "top", 3)) return cmd_top(argc, argv, NULL); - else if (!strncmp(argv[0], "buildid-list", 12)) + + if (!strncmp(argv[0], "buildid-list", 12)) return __cmd_buildid_list(file_name, argc, argv); + #if defined(__i386__) || defined(__x86_64__) - else if (!strncmp(argv[0], "stat", 4)) + if (!strncmp(argv[0], "stat", 4)) return kvm_cmd_stat(file_name, argc, argv); #endif - else - usage_with_options(kvm_usage, kvm_options); + + usage_with_options(kvm_usage, kvm_options); return 0; } diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 21d830b..c97410a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -5,6 +5,7 @@ * look up and read DSOs and symbol information and display * a histogram of results, along various sorting keys. */ +#include "generated/autoconf.h" #include "builtin.h" #include "util/util.h" @@ -391,6 +392,7 @@ static int report__browse_hists(struct report *rep) const char *help = "For a higher level overview, try: perf report --sort comm,dso"; switch (use_browser) { +#ifdef CONFIG_TUI case 1: ret = perf_evlist__tui_browse_hists(evlist, help, NULL, rep->min_percent, @@ -402,6 +404,7 @@ static int report__browse_hists(struct report *rep) if (ret != K_SWITCH_INPUT_DATA) ret = 0; break; +#endif /* CONFIG_TUI */ case 2: ret = report__gtk_browse_hists(rep, help); break; diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 377971d..c668b0a 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -17,6 +17,7 @@ * * Released under the GPL v2. (and only v2, not any later version) */ +#include "generated/autoconf.h" #include "builtin.h" #include "perf.h" @@ -534,6 +535,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c) return ret; } +#ifdef CONFIG_TUI static void perf_top__sort_new_samples(void *arg) { struct perf_top *t = arg; @@ -576,6 +578,7 @@ static void *display_thread_tui(void *arg) done = 1; return NULL; } +#endif /* CONFIG_TUI */ static void *display_thread(void *arg) { @@ -903,9 +906,12 @@ static int perf_top__setup_sample_type(struct perf_top *top __maybe_unused) return 0; } +typedef void* (*display_fn_t)(void *); + static int __cmd_top(struct perf_top *top) { struct record_opts *opts = &top->record_opts; + display_fn_t display_fn = display_thread; pthread_t thread; int ret; @@ -942,8 +948,8 @@ static int __cmd_top(struct perf_top *top) * XXX 'top' still doesn't start workloads like record, trace, but should, * so leave the check here. */ - if (!target__none(&opts->target)) - perf_evlist__enable(top->evlist); + if (!target__none(&opts->target)) + perf_evlist__enable(top->evlist); /* Wait for a minimal set of events before starting the snapshot */ poll(top->evlist->pollfd, top->evlist->nr_fds, 100); @@ -951,8 +957,13 @@ static int __cmd_top(struct perf_top *top) perf_top__mmap_read(top); ret = -1; - if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui : - display_thread), top)) { + +#ifdef CONFIG_TUI + if (use_browser > 0) + display_fn = display_thread_tui; +#endif + + if (pthread_create(&thread, NULL, display_fn, top)) { ui__error("Could not create display thread.\n"); goto out_delete; } diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 95c58fc..8dd6f6f 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -7,6 +7,7 @@ * perf top, perf record, perf report, etc.) are started. */ #include "builtin.h" +#include "builtin-cmds.h" #include "util/exec_cmd.h" #include "util/cache.h" @@ -33,34 +34,74 @@ struct cmd_struct { }; static struct cmd_struct commands[] = { +#ifdef CONFIG_BUILTIN_BUILDID_CACHE { "buildid-cache", cmd_buildid_cache, 0 }, +#endif +#ifdef CONFIG_BUILTIN_BUILDID_LIST { "buildid-list", cmd_buildid_list, 0 }, +#endif +#ifdef CONFIG_BUILTIN_DIFF { "diff", cmd_diff, 0 }, +#endif +#ifdef CONFIG_BUILTIN_EVLIST { "evlist", cmd_evlist, 0 }, +#endif +#ifdef CONFIG_BUILTIN_HELP { "help", cmd_help, 0 }, +#endif +#ifdef CONFIG_BUILTIN_LIST { "list", cmd_list, 0 }, +#endif +#ifdef CONFIG_BUILTIN_RECORD { "record", cmd_record, 0 }, +#endif +#ifdef CONFIG_BUILTIN_REPORT { "report", cmd_report, 0 }, +#endif +#ifdef CONFIG_BUILTIN_BENCH { "bench", cmd_bench, 0 }, +#endif +#ifdef CONFIG_BUILTIN_STAT { "stat", cmd_stat, 0 }, +#endif +#ifdef CONFIG_BUILTIN_TIMECHART { "timechart", cmd_timechart, 0 }, +#endif +#ifdef CONFIG_BUILTIN_TOP { "top", cmd_top, 0 }, +#endif +#ifdef CONFIG_BUILTIN_ANNOTATE { "annotate", cmd_annotate, 0 }, +#endif { "version", cmd_version, 0 }, +#ifdef CONFIG_BUILTIN_SCRIPT { "script", cmd_script, 0 }, +#endif +#ifdef CONFIG_BUILTIN_SCHED { "sched", cmd_sched, 0 }, -#ifdef HAVE_LIBELF_SUPPORT +#endif +#if defined HAVE_LIBELF_SUPPORT && defined CONFIG_BUILTIN_PROBE { "probe", cmd_probe, 0 }, #endif +#ifdef CONFIG_BUILTIN_KMEM { "kmem", cmd_kmem, 0 }, +#endif +#ifdef CONFIG_BUILTIN_LOCK { "lock", cmd_lock, 0 }, +#endif +#ifdef CONFIG_BUILTIN_KVM { "kvm", cmd_kvm, 0 }, +#endif { "test", cmd_test, 0 }, -#ifdef HAVE_LIBAUDIT_SUPPORT +#if defined HAVE_LIBAUDIT_SUPPORT && defined CONFIG_BUILTIN_TRACE { "trace", cmd_trace, 0 }, #endif +#ifdef CONFIG_BUILTIN_INJECT { "inject", cmd_inject, 0 }, +#endif +#ifdef CONFIG_BUILTIN_MEM { "mem", cmd_mem, 0 }, +#endif }; struct pager_config { diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c index ba51fa8..ec7fd36 100644 --- a/tools/perf/ui/setup.c +++ b/tools/perf/ui/setup.c @@ -77,11 +77,13 @@ void setup_browser(bool fallback_to_pager) PERF_GTK_DSO); sleep(1); /* fall through */ +#ifdef CONFIG_TUI case 1: use_browser = 1; if (ui__init() == 0) break; /* fall through */ +#endif default: use_browser = 0; if (fallback_to_pager) @@ -96,11 +98,11 @@ void exit_browser(bool wait_for_ok) case 2: exit_gtk_browser(wait_for_ok); break; - +#ifdef CONFIG_TUI case 1: ui__exit(wait_for_ok); break; - +#endif default: break; } diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh index 36a885d..05ee30f 100755 --- a/tools/perf/util/generate-cmdlist.sh +++ b/tools/perf/util/generate-cmdlist.sh @@ -1,5 +1,11 @@ #!/bin/sh +function cfg() +{ + cfg=`echo $1 | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'` + echo "$cfg" +} + echo "/* Automatically generated by $0 */ struct cmdname_help { @@ -13,6 +19,7 @@ sed -n -e 's/^perf-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt | sort | while read cmd do + echo "#ifdef CONFIG_BUILTIN_$(cfg $cmd)" sed -n ' /^NAME/,/perf-'"$cmd"'/H ${ @@ -20,6 +27,7 @@ do s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/ p }' "Documentation/perf-$cmd.txt" + echo "#endif" done echo "#ifdef HAVE_LIBELF_SUPPORT" @@ -27,6 +35,7 @@ sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt | sort | while read cmd do + echo "#ifdef CONFIG_BUILTIN_$(cfg $cmd)" sed -n ' /^NAME/,/perf-'"$cmd"'/H ${ @@ -34,6 +43,7 @@ do s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/ p }' "Documentation/perf-$cmd.txt" + echo "#endif" done echo "#endif /* HAVE_LIBELF_SUPPORT */" echo "};"