[PATCH 2/3] perf hists browser: add callchain-specific annotation
By pressing 'a' in the hists browser, the user gets an annotated view of the code of the selected symbols. This patch adds the case 'A'; if this key is pressed (and if the call-graph option was enabled at record time), perf will build the callchain from the top frame until the selected symbol and select the corresponding annotation histogram. Thus, the user will get an annotated view of the symbol code specific to the callchain displayed in the hists browser. Signed-off-by: Alexis Berlemont --- tools/perf/ui/browsers/hists.c | 188 - 1 file changed, 185 insertions(+), 3 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index da24072bb76e..9ed7fdc4dc51 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -2543,17 +2543,157 @@ struct popup_action { struct thread *thread; struct map_symbol ms; int socket; + boolcontext_annotate; int (*fn)(struct hist_browser *browser, struct popup_action *act); }; +static int copy_call_list_entry(struct list_head *callchain, + struct callchain_list *call) +{ + struct call_list_entry *entry = zalloc(sizeof(*entry)); + + if (!entry) { + perror("not enough memory to scan callchains"); + return -1; + } + + entry->ip = entry->sym_start = call->ip; + if (call->ms.sym != NULL) + entry->sym_start = call->ms.sym->start; + + list_add_tail(&entry->list, callchain); + + return 0; +} + +static int __hist_browser_build_callchain(struct list_head *callchain, + struct rb_root *root, + struct callchain_list *target) +{ + struct callchain_node *tmp_node; + struct rb_node *node; + struct callchain_list *call; + struct call_list_entry *new_call, *tmp; + + node = rb_first(root); + + while (node) { + char folded_sign = ' '; + size_t added_count = 0; + + tmp_node = rb_entry(node, struct callchain_node, rb_node); + + /* +* If the callchain display mode is "flat", the list +* "parent_val" may contain the entries in common. +*/ + + list_for_each_entry(call, &tmp_node->parent_val, list) { + + /* +* If we have not found the highlighted callchain +* entry... +*/ + + if (target == call) + return 0; + + /* +* ...we need to keep the current element: the next +* one could be the right one and we need to build a +* callchain. +*/ + + if (copy_call_list_entry(callchain, call) < 0) + return -1; + + added_count++; + } + + /* +* If the callchain display mode is "graph", "fractal" or even +* "flat", the callchain entries (the last one for "flat" are in +* the list "val". +*/ + + list_for_each_entry(call, &tmp_node->val, list) { + + /* +* If we have not found the highlighted callchain +* entry... +*/ + + if (target == call) + return 0; + + /* +* ...we need to keep the current element: the next +* one could be the right one and we need to build a +* callchain. +*/ + + if (copy_call_list_entry(callchain, call) < 0) + return -1; + + added_count++; + + /* +* If we meet the folded sign '+' (and if the current +* element does not match), there is no need to go +* further, the callchain elements below cannot be the +* ones we are looking for. +*/ + + folded_sign = callchain_list__folded(call); + if (folded_sign == '+') + break; + } + + /* +* If the last scanned entry is unfolded, the callchain element +* we are looking for may be behing; so, let
[PATCH 3/3] perf report: fill per-callchain symbol annotation histograms
The per-callchain histograms must be fed at some points with the profiling samples. A solution is to fill them right after having filled the per-symbol ones: in the callback hist_iter__report_callback. Signed-off-by: Alexis Berlemont --- tools/perf/builtin-report.c | 8 1 file changed, 8 insertions(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c18158b83eb1..d825a599d4b4 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -136,6 +136,14 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter, if (single) err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); + if (err == 0) { + struct callchain_cursor *cursor = &callchain_cursor; + + err = hist_entry_cxt__inc_addr_samples(he, + evsel->idx, + al->addr, + cursor); + } } else { err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); } -- 2.12.2
[PATCH 1/3] perf annotate: implement per-callchain annotation histogram
A symbol can be called from various points and according to its calling context, it can provide different results. This patch creates one histogram for every different callchain recorded and accumulates profiling samples into the appropriate one. Samples recorded with the same callchain are not mixed with other ones, The noise should be reduced. Signed-off-by: Alexis Berlemont --- tools/perf/util/annotate.c | 308 - tools/perf/util/annotate.h | 19 +++ 2 files changed, 324 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 30498a2d4a6f..fa7691a0f205 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -18,6 +18,7 @@ #include "annotate.h" #include "evsel.h" #include "block-range.h" +#include "callchain.h" #include "arch/common.h" #include #include @@ -554,7 +555,7 @@ int symbol__alloc_hist(struct symbol *sym) { struct annotation *notes = symbol__annotation(sym); const size_t size = symbol__size(sym); - size_t sizeof_sym_hist; + size_t sizeof_sym_hist, nr_sym_hist; /* Check for overflow when calculating sizeof_sym_hist */ if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(u64)) @@ -567,12 +568,17 @@ int symbol__alloc_hist(struct symbol *sym) / symbol_conf.nr_events) return -1; - notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist); + /* Allocate 1 histogram per event and 1 more for context annotation */ + nr_sym_hist = symbol_conf.nr_events + 1; + + notes->src = zalloc(sizeof(*notes->src) + + nr_sym_hist * sizeof_sym_hist); if (notes->src == NULL) return -1; notes->src->sizeof_sym_hist = sizeof_sym_hist; - notes->src->nr_histograms = symbol_conf.nr_events; + notes->src->nr_histograms = nr_sym_hist; INIT_LIST_HEAD(¬es->src->source); + INIT_LIST_HEAD(¬es->src->context_hists); return 0; } @@ -591,11 +597,18 @@ static int symbol__alloc_hist_cycles(struct symbol *sym) void symbol__annotate_zero_histograms(struct symbol *sym) { struct annotation *notes = symbol__annotation(sym); + struct cxt_hist_entry *hist_entry; pthread_mutex_lock(¬es->lock); if (notes->src != NULL) { memset(notes->src->histograms, 0, notes->src->nr_histograms * notes->src->sizeof_sym_hist); + + list_for_each_entry(hist_entry, + ¬es->src->context_hists, list) { + list_del(&hist_entry->list); + free(hist_entry); + } if (notes->src->cycles_hist) memset(notes->src->cycles_hist, 0, symbol__size(sym) * sizeof(struct cyc_hist)); @@ -681,6 +694,7 @@ static struct annotation *symbol__get_annotation(struct symbol *sym, bool cycles if (symbol__alloc_hist_cycles(sym) < 0) return NULL; } + return notes; } @@ -697,6 +711,281 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, return __symbol__inc_addr_samples(sym, map, notes, evidx, addr); } +static bool __symbol_cxt__cmp_call_cursor(struct cxt_hist_entry *hist_entry, + struct callchain_cursor *cursor) +{ + struct callchain_cursor_node *node; + struct call_list_entry *entry; + u64 match_count = 0; + + callchain_cursor_commit(cursor); + + /* +* One element of the callchain cursor cannot be matched: the last +* element (or first according to the order) which corresponds to the +* real sampled address; so, let's skip it (if need be) and... +*/ + if (callchain_param.order == ORDER_CALLEE) + callchain_cursor_advance(cursor); + + /* ...consider it has matched */ + match_count++; + + list_for_each_entry(entry, &hist_entry->callchain, list) { + + node = callchain_cursor_current(cursor); + if (node == NULL) + break; + + if (entry->ip == node->ip) + match_count++; + + callchain_cursor_advance(cursor); + } + + return match_count == cursor->nr; +} + +static int __symbol_cxt__copy_call_cursor(struct cxt_hist_entry *hist_entry, + struct callchain_cursor *cursor) +{ + struct callchain_cursor_node *node; + struct call_list_entry *entry, *n; + + callchain_cursor_commit(cursor); + node = callchain_cursor_current(curs
[PATCH 0/3] perf: callchain-specific annotation
Hi, These patches are a proposal to fulfill the following point of perf's TODO list (https://perf.wiki.kernel.org/index.php/Todo): * What I want is that if I am on bar*(), it annotates bar*(), no samples just the call site (obtained from the callchain) dissassembly. This is useful because in many cases there maybe multiple call sites within a function and there maybe inlines in between. Hard to track down if you cannot figure out the surrounding addresses of the call site. (Request made by Stephane Eranian). These patches are still at an early stage: * Per-callchain annotation is only available in perf-report; * Tests were not performed on real-world applications but on small basic ones. Alexis. Alexis Berlemont (3): perf annotate: implement per-callchain annotation histogram perf hists browser: add callchain-specific annotation perf report: fill per-callchain symbol annotation histograms tools/perf/builtin-report.c| 8 ++ tools/perf/ui/browsers/hists.c | 188 - tools/perf/util/annotate.c | 308 - tools/perf/util/annotate.h | 19 +++ 4 files changed, 517 insertions(+), 6 deletions(-) -- 2.12.2
[tip:perf/core] perf probe: Add sdt probes arguments into the uprobe cmd string
Commit-ID: 3b1f8311f6963cd11a7d1efbcd2fd900d472ba5c Gitweb: http://git.kernel.org/tip/3b1f8311f6963cd11a7d1efbcd2fd900d472ba5c Author: Alexis Berlemont AuthorDate: Wed, 14 Dec 2016 01:07:32 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 21 Mar 2017 10:59:01 -0300 perf probe: Add sdt probes arguments into the uprobe cmd string An sdt probe can be associated with arguments but they were not passed to the user probe tracing interface (uprobe_events); this patch adapts the sdt argument descriptors according to the uprobe input format. As the uprobe parser does not support scaled address mode, perf will skip arguments which cannot be adapted to the uprobe format. Here are the results: $ perf buildid-cache -v --add test_sdt $ perf probe -x test_sdt sdt_libfoo:table_frob $ perf probe -x test_sdt sdt_libfoo:table_diddle $ perf record -e sdt_libfoo:table_frob -e sdt_libfoo:table_diddle test_sdt $ perf script test_sdt ... 666.255678: sdt_libfoo:table_frob: (4004d7) arg0=0 arg1=0 test_sdt ... 666.255683: sdt_libfoo:table_diddle: (40051a) arg0=0 arg1=0 test_sdt ... 666.255686: sdt_libfoo:table_frob: (4004d7) arg0=1 arg1=2 test_sdt ... 666.255689: sdt_libfoo:table_diddle: (40051a) arg0=3 arg1=4 test_sdt ... 666.255692: sdt_libfoo:table_frob: (4004d7) arg0=2 arg1=4 test_sdt ... 666.255694: sdt_libfoo:table_diddle: (40051a) arg0=6 arg1=8 Signed-off-by: Alexis Berlemont Acked-by: Masami Hiramatsu Cc: Alexander Shishkin Cc: Hemant Kumar Cc: Peter Zijlstra Cc: Ravi Bangoria Link: http://lkml.kernel.org/r/20161214000732.1710-3-alexis.berlem...@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/util/perf_regs.c | 83 + tools/perf/util/perf_regs.c | 6 ++ tools/perf/util/perf_regs.h | 6 ++ tools/perf/util/probe-file.c | 170 ++- 4 files changed, 261 insertions(+), 4 deletions(-) diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index c5db14f..09a7f55 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -1,4 +1,7 @@ +#include + #include "../../perf.h" +#include "../../util/util.h" #include "../../util/perf_regs.h" const struct sample_reg sample_reg_masks[] = { @@ -26,3 +29,83 @@ const struct sample_reg sample_reg_masks[] = { #endif SMPL_REG_END }; + +struct sdt_name_reg { + const char *sdt_name; + const char *uprobe_name; +}; +#define SDT_NAME_REG(n, m) {.sdt_name = "%" #n, .uprobe_name = "%" #m} +#define SDT_NAME_REG_END {.sdt_name = NULL, .uprobe_name = NULL} + +static const struct sdt_name_reg sdt_reg_renamings[] = { + SDT_NAME_REG(eax, ax), + SDT_NAME_REG(rax, ax), + SDT_NAME_REG(ebx, bx), + SDT_NAME_REG(rbx, bx), + SDT_NAME_REG(ecx, cx), + SDT_NAME_REG(rcx, cx), + SDT_NAME_REG(edx, dx), + SDT_NAME_REG(rdx, dx), + SDT_NAME_REG(esi, si), + SDT_NAME_REG(rsi, si), + SDT_NAME_REG(edi, di), + SDT_NAME_REG(rdi, di), + SDT_NAME_REG(ebp, bp), + SDT_NAME_REG(rbp, bp), + SDT_NAME_REG_END, +}; + +int sdt_rename_register(char **pdesc, char *old_name) +{ + const struct sdt_name_reg *rnames = sdt_reg_renamings; + char *new_desc, *old_desc = *pdesc; + size_t prefix_len, sdt_len, uprobe_len, old_desc_len, offset; + int ret = -1; + + while (ret != 0 && rnames->sdt_name != NULL) { + sdt_len = strlen(rnames->sdt_name); + ret = strncmp(old_name, rnames->sdt_name, sdt_len); + rnames += !!ret; + } + + if (rnames->sdt_name == NULL) + return 0; + + sdt_len = strlen(rnames->sdt_name); + uprobe_len = strlen(rnames->uprobe_name); + old_desc_len = strlen(old_desc) + 1; + + new_desc = zalloc(old_desc_len + uprobe_len - sdt_len); + if (new_desc == NULL) + return -1; + + /* Copy the chars before the register name (at least '%') */ + prefix_len = old_name - old_desc; + memcpy(new_desc, old_desc, prefix_len); + + /* Copy the new register name */ + memcpy(new_desc + prefix_len, rnames->uprobe_name, uprobe_len); + + /* Copy the chars after the register name (if need be) */ + offset = prefix_len + sdt_len; + if (offset < old_desc_len) { + /* +* The orginal register name can be suffixed by 'b', +* 'w' or 'd' to indicate its size; so, we need to +* skip this char if we met one. +*/ + char sfx = old_desc[offset]; + + if (sfx == 'b' || sfx == 'w' || sfx == 'd') + offset++; + } + + if (offset < old_desc
[tip:perf/core] perf sdt: Add scanning of sdt probes arguments
Commit-ID: be88184b1c7054719296387c6063748fb48fa645 Gitweb: http://git.kernel.org/tip/be88184b1c7054719296387c6063748fb48fa645 Author: Alexis Berlemont AuthorDate: Wed, 14 Dec 2016 01:07:31 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 21 Mar 2017 10:56:28 -0300 perf sdt: Add scanning of sdt probes arguments During a "perf buildid-cache --add" command, the section ".note.stapsdt" of the "added" binary is scanned in order to list the available SDT markers available in a binary. The parts containing the probes arguments were left unscanned. The whole section is now parsed; the probe arguments are extracted for later use. Signed-off-by: Alexis Berlemont Acked-by: Masami Hiramatsu Cc: Alexander Shishkin Cc: Hemant Kumar Cc: Peter Zijlstra Cc: Ravi Bangoria Link: http://lkml.kernel.org/r/20161214000732.1710-2-alexis.berlem...@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol-elf.c | 25 +++-- tools/perf/util/symbol.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 4e59dde..0e660db 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1828,7 +1828,7 @@ void kcore_extract__delete(struct kcore_extract *kce) static int populate_sdt_note(Elf **elf, const char *data, size_t len, struct list_head *sdt_notes) { - const char *provider, *name; + const char *provider, *name, *args; struct sdt_note *tmp = NULL; GElf_Ehdr ehdr; GElf_Addr base_off = 0; @@ -1887,6 +1887,25 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, goto out_free_prov; } + args = memchr(name, '\0', data + len - name); + + /* +* There is no argument if: +* - We reached the end of the note; +* - There is not enough room to hold a potential string; +* - The argument string is empty or just contains ':'. +*/ + if (args == NULL || data + len - args < 2 || + args[1] == ':' || args[1] == '\0') + tmp->args = NULL; + else { + tmp->args = strdup(++args); + if (!tmp->args) { + ret = -ENOMEM; + goto out_free_name; + } + } + if (gelf_getclass(*elf) == ELFCLASS32) { memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr)); tmp->bit32 = true; @@ -1898,7 +1917,7 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, if (!gelf_getehdr(*elf, &ehdr)) { pr_debug("%s : cannot get elf header.\n", __func__); ret = -EBADF; - goto out_free_name; + goto out_free_args; } /* Adjust the prelink effect : @@ -1923,6 +1942,8 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, list_add_tail(&tmp->note_list, sdt_notes); return 0; +out_free_args: + free(tmp->args); out_free_name: free(tmp->name); out_free_prov: diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 6c358b7..9222c7e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -351,6 +351,7 @@ int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); struct sdt_note { char *name; /* name of the note*/ char *provider; /* provider name */ + char *args; bool bit32; /* whether the location is 32 bits? */ union { /* location, base and semaphore addrs */ Elf64_Addr a64[3];
Re: [PATCH v5 0/2] perf probe: add sdt probes arguments into the uprobe cmd string
Ravi Bangoria wrote: > > > On Wednesday 14 December 2016 01:06 PM, Ingo Molnar wrote: > > * Alexis Berlemont wrote: > > > >> Hi Masami, > >> > >> Many thanks for your mail. > >> > >> Here is another patch set which tries to fix the points you mentioned: > >> > >> * Skip the arguments containing a constant ($123); > >> * Review the code in charge of the register renaming (search for '%' > >> and parse it); > >> * Minor changes (print the argument in case of error, skipping, check > >> the sdt arg type index); > >> > >> Many thanks, > >> > >> Alexis. > >> > >> Alexis Berlemont (2): > >> perf sdt: add scanning of sdt probles arguments > >> perf probe: add sdt probes arguments into the uprobe cmd string > > I'd like to hijack this thread to report an SDT oddity - one of my boxen > > reports > > lots of SDT tracepoints in 'perf list': > > > > mem:[/len][:access] [Hardware breakpoint] > > > > sdt_libc:lll_lock_wait_private [SDT event] > > sdt_libc:longjmp [SDT event] > > sdt_libc:longjmp_target[SDT event] > > sdt_libc:memory_arena_new [SDT event] > > sdt_libc:memory_arena_retry[SDT event] > > sdt_libc:memory_arena_reuse[SDT event] > > sdt_libc:memory_arena_reuse_free_list [SDT event] > > sdt_libc:memory_arena_reuse_wait [SDT event] > > sdt_libc:memory_calloc_retry [SDT event] > > sdt_libc:memory_heap_free [SDT event] > > ... > > > > But none of them work: > > > > Error: No permissions to read > > /sys/kernel/debug/tracing/events/sdt_libc/longjmp > > Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing' > > > > ... > > > > Error: File /sys/kernel/debug/tracing/events/sdt_libc/longjmp not found. > > Hint: Perhaps this kernel misses some CONFIG_ setting to enable this > > feature?. > > > > What kind of patches are required for SDT probes to work? > > Hi Ingo, > > Works for me on my x86 Fedora 25 box. May be some permission issue? > > @Alexis, Planning to progress on it :) ? I would like to prepare patch for > powerpc. Hi, Just a quick mail to apologize. After a few weeks without answer, I forgot to regularly poll this thread during my free time. I've just noticed the patches you sent meanwhile... Once more sorry, Alexis. > > Thanks, > Ravi > > > Thanks, > > > > Ingo > > >
[PATCH v2 0/1] perf: check that objdump correctly works
Hi Arnaldo, Here is a patch which checks that objdump works without calling it first with the "-v" option. Thanks to the shell pipefail option (which returns the rightmost error status in the shell pipe) and the grep subshell which prevents "no-match" errors, we are able the use waitpid on the whole pipeline and get the appropriate return code. This is the most simple and straightforward solution I found. The downside might be that it relies on the availability of "pipefail" shell option. However, I checked that even busybox's shell implemented it. Alexis. Alexis Berlemont (1): perf annotate: check that objdump correctly works tools/perf/util/annotate.c | 69 +++--- tools/perf/util/annotate.h | 3 ++ 2 files changed, 68 insertions(+), 4 deletions(-) -- 2.11.0
[PATCH v2 1/1] perf annotate: check that objdump correctly works
Before disassembling, the tool objdump is called just to be sure: * objdump is available in the path; * objdump is an executable binary; * objdump has no dependency issue or anything else. This objdump "pre-"command is only necessary because the real objdump command is followed by some " | grep ..."; this prevents the shell from returning the exit code of objdump execution. Signed-off-by: Alexis Berlemont --- tools/perf/util/annotate.c | 69 +++--- tools/perf/util/annotate.h | 3 ++ 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index ea7e0de4b9c1..6fbaabbc9d2a 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -20,9 +20,12 @@ #include "block-range.h" #include "arch/common.h" #include +#include #include #include #include +#include +#include const char *disassembler_style; const char *objdump_path; @@ -1286,6 +1289,21 @@ int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map * " --vmlinux vmlinux\n", build_id_msg ?: ""); } break; + + case SYMBOL_ANNOTATE_ERRNO__NO_OBJDUMP: + scnprintf(buf, buflen, "No objdump tool available in $PATH\n"); + break; + + case SYMBOL_ANNOTATE_ERRNO__NO_EXEC_OBJDUMP: + scnprintf(buf, buflen, + "The objdump tool found in $PATH cannot be executed\n"); + break; + + case SYMBOL_ANNOTATE_ERRNO__NO_OUTPUT: + scnprintf(buf, buflen, + "The objdump tool returned no disassembled code\n"); + break; + default: scnprintf(buf, buflen, "Internal error: Invalid %d error code\n", errnum); break; @@ -1329,6 +1347,44 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil return 0; } +static int annotate__check_exec(int pid, const char *command) +{ + int wstatus, err; + + err = waitpid(pid, &wstatus, 0); + if (err < 0) { + pr_err("Failure calling waitpid: %s: (%s)\n", + strerror(errno), command); + return -1; + } + + pr_debug("%s: %d %d\n", command, pid, WEXITSTATUS(wstatus)); + + switch (WEXITSTATUS(wstatus)) { + case 0: + /* Success */ + err = 0; + break; + case 127: + /* The shell did not find objdump in the path */ + err = SYMBOL_ANNOTATE_ERRNO__NO_OBJDUMP; + break; + default: + /* +* In the default case, we consider that objdump +* cannot be executed; so it gathers many fault +* scenarii: +* - objdump is not an executable (126); +* - objdump has some dependency issue; +* - ... +*/ + err = SYMBOL_ANNOTATE_ERRNO__NO_EXEC_OBJDUMP; + break; + } + + return err; +} + static const char *annotate__norm_arch(const char *arch_name) { struct utsname uts; @@ -1426,7 +1482,8 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na snprintf(command, sizeof(command), "%s %s%s --start-address=0x%016" PRIx64 " --stop-address=0x%016" PRIx64 -" -l -d %s %s -C %s 2>/dev/null|grep -v %s|expand", +" -l -d %s %s -C %s 2>/dev/null | " +"{ grep -v %s || true; } | expand", objdump_path ? objdump_path : "objdump", disassembler_style ? "-M " : "", disassembler_style ? disassembler_style : "", @@ -1454,7 +1511,7 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na close(stdout_fd[0]); dup2(stdout_fd[1], 1); close(stdout_fd[1]); - execl("/bin/sh", "sh", "-c", command, NULL); + execl("/bin/sh", "sh", "-o", "pipefail", "-c", command, NULL); perror(command); exit(-1); } @@ -1479,8 +1536,12 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na nline++; } - if (nline == 0) + err = annotate__check_exec(pid, command); + + if (err == 0 && nline == 0) { pr_err("No output from %s\n", command); + err = SYMBOL_ANNOTATE_ERRNO__NO_OUTPUT; + } /* * kallsym
[PATCH v5 1/2] perf sdt: add scanning of sdt probles arguments
During a "perf buildid-cache --add" command, the section ".note.stapsdt" of the "added" binary is scanned in order to list the available SDT markers available in a binary. The parts containing the probes arguments were left unscanned. The whole section is now parsed; the probe arguments are extracted for later use. Signed-off-by: Alexis Berlemont --- tools/perf/util/symbol-elf.c | 25 +++-- tools/perf/util/symbol.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 99400b0..7725c3f 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1822,7 +1822,7 @@ void kcore_extract__delete(struct kcore_extract *kce) static int populate_sdt_note(Elf **elf, const char *data, size_t len, struct list_head *sdt_notes) { - const char *provider, *name; + const char *provider, *name, *args; struct sdt_note *tmp = NULL; GElf_Ehdr ehdr; GElf_Addr base_off = 0; @@ -1881,6 +1881,25 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, goto out_free_prov; } + args = memchr(name, '\0', data + len - name); + + /* +* There is no argument if: +* - We reached the end of the note; +* - There is not enough room to hold a potential string; +* - The argument string is empty or just contains ':'. +*/ + if (args == NULL || data + len - args < 2 || + args[1] == ':' || args[1] == '\0') + tmp->args = NULL; + else { + tmp->args = strdup(++args); + if (!tmp->args) { + ret = -ENOMEM; + goto out_free_name; + } + } + if (gelf_getclass(*elf) == ELFCLASS32) { memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr)); tmp->bit32 = true; @@ -1892,7 +1911,7 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, if (!gelf_getehdr(*elf, &ehdr)) { pr_debug("%s : cannot get elf header.\n", __func__); ret = -EBADF; - goto out_free_name; + goto out_free_args; } /* Adjust the prelink effect : @@ -1917,6 +1936,8 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, list_add_tail(&tmp->note_list, sdt_notes); return 0; +out_free_args: + free(tmp->args); out_free_name: free(tmp->name); out_free_prov: diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 6c358b7..9222c7e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -351,6 +351,7 @@ int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); struct sdt_note { char *name; /* name of the note*/ char *provider; /* provider name */ + char *args; bool bit32; /* whether the location is 32 bits? */ union { /* location, base and semaphore addrs */ Elf64_Addr a64[3]; -- 2.10.2
[PATCH v5 2/2] perf probe: add sdt probes arguments into the uprobe cmd string
An sdt probe can be associated with arguments but they were not passed to the user probe tracing interface (uprobe_events); this patch adapts the sdt argument descriptors according to the uprobe input format. As the uprobe parser does not support scaled address mode, perf will skip arguments which cannot be adapted to the uprobe format. Here are the results: $ perf buildid-cache -v --add test_sdt $ perf probe -x test_sdt sdt_libfoo:table_frob $ perf probe -x test_sdt sdt_libfoo:table_diddle $ perf record -e sdt_libfoo:table_frob -e sdt_libfoo:table_diddle test_sdt $ perf script test_sdt ... 666.255678: sdt_libfoo:table_frob: (4004d7) arg0=0 arg1=0 test_sdt ... 666.255683: sdt_libfoo:table_diddle: (40051a) arg0=0 arg1=0 test_sdt ... 666.255686: sdt_libfoo:table_frob: (4004d7) arg0=1 arg1=2 test_sdt ... 666.255689: sdt_libfoo:table_diddle: (40051a) arg0=3 arg1=4 test_sdt ... 666.255692: sdt_libfoo:table_frob: (4004d7) arg0=2 arg1=4 test_sdt ... 666.255694: sdt_libfoo:table_diddle: (40051a) arg0=6 arg1=8 Signed-off-by: Alexis Berlemont --- tools/perf/arch/x86/util/perf_regs.c | 83 + tools/perf/util/perf_regs.c | 6 ++ tools/perf/util/perf_regs.h | 6 ++ tools/perf/util/probe-file.c | 170 ++- 4 files changed, 261 insertions(+), 4 deletions(-) diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index c5db14f..09a7f55 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -1,4 +1,7 @@ +#include + #include "../../perf.h" +#include "../../util/util.h" #include "../../util/perf_regs.h" const struct sample_reg sample_reg_masks[] = { @@ -26,3 +29,83 @@ const struct sample_reg sample_reg_masks[] = { #endif SMPL_REG_END }; + +struct sdt_name_reg { + const char *sdt_name; + const char *uprobe_name; +}; +#define SDT_NAME_REG(n, m) {.sdt_name = "%" #n, .uprobe_name = "%" #m} +#define SDT_NAME_REG_END {.sdt_name = NULL, .uprobe_name = NULL} + +static const struct sdt_name_reg sdt_reg_renamings[] = { + SDT_NAME_REG(eax, ax), + SDT_NAME_REG(rax, ax), + SDT_NAME_REG(ebx, bx), + SDT_NAME_REG(rbx, bx), + SDT_NAME_REG(ecx, cx), + SDT_NAME_REG(rcx, cx), + SDT_NAME_REG(edx, dx), + SDT_NAME_REG(rdx, dx), + SDT_NAME_REG(esi, si), + SDT_NAME_REG(rsi, si), + SDT_NAME_REG(edi, di), + SDT_NAME_REG(rdi, di), + SDT_NAME_REG(ebp, bp), + SDT_NAME_REG(rbp, bp), + SDT_NAME_REG_END, +}; + +int sdt_rename_register(char **pdesc, char *old_name) +{ + const struct sdt_name_reg *rnames = sdt_reg_renamings; + char *new_desc, *old_desc = *pdesc; + size_t prefix_len, sdt_len, uprobe_len, old_desc_len, offset; + int ret = -1; + + while (ret != 0 && rnames->sdt_name != NULL) { + sdt_len = strlen(rnames->sdt_name); + ret = strncmp(old_name, rnames->sdt_name, sdt_len); + rnames += !!ret; + } + + if (rnames->sdt_name == NULL) + return 0; + + sdt_len = strlen(rnames->sdt_name); + uprobe_len = strlen(rnames->uprobe_name); + old_desc_len = strlen(old_desc) + 1; + + new_desc = zalloc(old_desc_len + uprobe_len - sdt_len); + if (new_desc == NULL) + return -1; + + /* Copy the chars before the register name (at least '%') */ + prefix_len = old_name - old_desc; + memcpy(new_desc, old_desc, prefix_len); + + /* Copy the new register name */ + memcpy(new_desc + prefix_len, rnames->uprobe_name, uprobe_len); + + /* Copy the chars after the register name (if need be) */ + offset = prefix_len + sdt_len; + if (offset < old_desc_len) { + /* +* The orginal register name can be suffixed by 'b', +* 'w' or 'd' to indicate its size; so, we need to +* skip this char if we met one. +*/ + char sfx = old_desc[offset]; + + if (sfx == 'b' || sfx == 'w' || sfx == 'd') + offset++; + } + + if (offset < old_desc_len) + memcpy(new_desc + prefix_len + uprobe_len, + old_desc + offset, old_desc_len - offset); + + free(old_desc); + *pdesc = new_desc; + + return 0; +} diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index c4023f2..a37e593 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -6,6 +6,12 @@ const struct sample_reg __weak sample_reg_masks[] = { SMPL_REG_END }; +int __weak sdt_rename_register(char **pdesc __maybe_unused, + char *old_name __maybe_unused) +{ + retur
[PATCH v5 0/2] perf probe: add sdt probes arguments into the uprobe cmd string
Hi Masami, Many thanks for your mail. Here is another patch set which tries to fix the points you mentioned: * Skip the arguments containing a constant ($123); * Review the code in charge of the register renaming (search for '%' and parse it); * Minor changes (print the argument in case of error, skipping, check the sdt arg type index); Many thanks, Alexis. Alexis Berlemont (2): perf sdt: add scanning of sdt probles arguments perf probe: add sdt probes arguments into the uprobe cmd string tools/perf/arch/x86/util/perf_regs.c | 83 + tools/perf/util/perf_regs.c | 6 ++ tools/perf/util/perf_regs.h | 6 ++ tools/perf/util/probe-file.c | 170 ++- tools/perf/util/symbol-elf.c | 25 +- tools/perf/util/symbol.h | 1 + 6 files changed, 285 insertions(+), 6 deletions(-) -- 2.10.2
Re: [PATCH] perf annotate: check that objdump correctly works
Arnaldo Carvalho de Melo wrote: > Em Thu, Dec 01, 2016 at 01:04:36AM +0100, Alexis Berlemont escreveu: > > Before disassembling, the tool objdump is called just to be sure: > > * objdump is available in the path; > > * objdump is an executable binary; > > * objdump has no dependency issue or anything else. > > > > This objdump "pre-"command is only necessary because the real objdump > > command is followed by some " | grep ..."; this prevents the shell > > from returning the exit code of objdump execution. > > > > Signed-off-by: Alexis Berlemont > > --- > > tools/perf/util/annotate.c | 79 > > +- > > tools/perf/util/annotate.h | 3 ++ > > 2 files changed, 81 insertions(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c > > index 3e34ee0..9d6c3a0 100644 > > --- a/tools/perf/util/annotate.c > > > +static int annotate__check_objdump(void) > > +{ > > + char command[PATH_MAX * 2]; > > + int wstatus, err; > > + pid_t pid; > > + > > + snprintf(command, sizeof(command), > > + "%s -v > /dev/null 2>&1", > > + objdump_path ? objdump_path : "objdump"); > > + > > + pid = fork(); > > + if (pid < 0) { > > + pr_err("Failure forking to run %s\n", command); > > + return -1; > > + } > > + > > + if (pid == 0) { > > + execl("/bin/sh", "sh", "-c", command, NULL); > > + exit(-1); > > + } > > + > > + err = waitpid(pid, &wstatus, 0); > > + if (err < 0) { > > + pr_err("Failure calling waitpid: %s: (%s)\n", > > + strerror(errno), command); > > + return -1; > > + } > > + > > + pr_err("%s: %d %d\n", command, pid, WEXITSTATUS(wstatus)); > > So this will appear in all cases, no need for that, i.e. in the success > case we don't need to get that flashing on the screen, on the last line. > Many thanks for your answer and your time. Sorry for the late anwser and such an obvious error. > > + switch (WEXITSTATUS(wstatus)) { > > + case 0: > > + /* Success */ > > + err = 0; > > + break; > > So probably you want to return 0; here instead and then at the error > case, i.e. when you set err to !0 you do that pr_err() call above, but I > think it would be better to use pr_debug(), the warning on the popup box > is what by default is more polished to tell the user, the details are > for developers or people wanting to dig in. > > But while doing this I thought that you could instead call this only > after objdump fails, i.e. if all is right, no need for checking what > went wrong. > > I.e. you would do the grep step separately, after checking objdump's > error. > > If you think that is too much work, then please just do the > pr_err->pr_debug conversion, which would remove the flashing for the > success case. I will do the grep separately; no problem. Alexis. > > I tested it, btw, using: > > perf annotate --objdump /dev/null page_fault > > Which produced a better output than what we have now (nothing): > > > ??Error: >???Couldn't annotate page_fault: ??? >???The objdump tool found in $PATH cannot be executed??? >??? ??? >??? ??? >???Press any key... ??? > > > > > > /dev/null -v > /dev/null 2>&1: 10336 126 > > > --- > > summary: make that last line appear only when -v is used (pr_debug) and > consider covering the case where --objdump was used, where talking about $PATH > is misleading. > > > > + case 127: > > + /* The shell did not find objdump in the path */ > > + err = SYMBOL_ANNOTATE_ERRNO__NO_OBJDUMP; > > + break; > > + default: > > + /* > > +* In the default case, we consider that objdump > > +* cannot be executed; so it gathers many fault &
Re: [PATCH v4 0/2] perf probe: add sdt probes arguments into the uprobe cmd string
Alexis Berlemont wrote: > Hi Arnaldo, > > Here is another patch set which fixes the issues you noticed. > Could you indicate me a way to improve these patches so as to move forward ? Regards, Alexis. > Thank you. > > Alexis. > > Alexis Berlemont (2): > perf sdt: add scanning of sdt probles arguments > perf probe: add sdt probes arguments into the uprobe cmd string > > tools/perf/arch/x86/util/perf_regs.c | 18 > tools/perf/util/perf_regs.c | 4 + > tools/perf/util/perf_regs.h | 13 +++ > tools/perf/util/probe-file.c | 169 > ++- > tools/perf/util/symbol-elf.c | 25 +- > tools/perf/util/symbol.h | 1 + > 6 files changed, 224 insertions(+), 6 deletions(-) > > -- > 2.10.2 >
Re: [PATCH v3 0/2] perf: measure page fault duration in perf trace
Alexis Berlemont wrote: > Hi, > > Here is another attempt to make the perf-trace subcommand print the > page fault durations. > > This solution is based on static tracepoints and it was necessary to > add 2 more tracepoints. I understood that adding tracepoints is a > questionable solution; I can try something else if someone has another > idea. > Could you indicate me a way to improve these patches so as to move forward ? Regards, Alexis. > Alexis. > > Alexis Berlemont (2): > perf, x86-mm: declare page-faults tracepoints like irq-vectors ones > perf: add page fault duration measures in perf trace > > arch/x86/include/asm/trace/exceptions.h | 17 ++- > arch/x86/mm/fault.c | 17 ++- > tools/perf/Documentation/perf-trace.txt | 4 +- > tools/perf/builtin-trace.c | 231 > > 4 files changed, 238 insertions(+), 31 deletions(-) > > -- > 2.10.2 >
[PATCH] perf annotate: check that objdump correctly works
Before disassembling, the tool objdump is called just to be sure: * objdump is available in the path; * objdump is an executable binary; * objdump has no dependency issue or anything else. This objdump "pre-"command is only necessary because the real objdump command is followed by some " | grep ..."; this prevents the shell from returning the exit code of objdump execution. Signed-off-by: Alexis Berlemont --- tools/perf/util/annotate.c | 79 +- tools/perf/util/annotate.h | 3 ++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 3e34ee0..9d6c3a0 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -20,9 +20,12 @@ #include "block-range.h" #include "arch/common.h" #include +#include #include #include #include +#include +#include const char *disassembler_style; const char *objdump_path; @@ -1278,6 +1281,21 @@ int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map * " --vmlinux vmlinux\n", build_id_msg ?: ""); } break; + + case SYMBOL_ANNOTATE_ERRNO__NO_OBJDUMP: + scnprintf(buf, buflen, "No objdump tool available in $PATH\n"); + break; + + case SYMBOL_ANNOTATE_ERRNO__NO_EXEC_OBJDUMP: + scnprintf(buf, buflen, + "The objdump tool found in $PATH cannot be executed\n"); + break; + + case SYMBOL_ANNOTATE_ERRNO__NO_OUTPUT: + scnprintf(buf, buflen, + "The objdump tool returned no disassembled code\n"); + break; + default: scnprintf(buf, buflen, "Internal error: Invalid %d error code\n", errnum); break; @@ -1321,6 +1339,61 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil return 0; } +static int annotate__check_objdump(void) +{ + char command[PATH_MAX * 2]; + int wstatus, err; + pid_t pid; + + snprintf(command, sizeof(command), + "%s -v > /dev/null 2>&1", + objdump_path ? objdump_path : "objdump"); + + pid = fork(); + if (pid < 0) { + pr_err("Failure forking to run %s\n", command); + return -1; + } + + if (pid == 0) { + execl("/bin/sh", "sh", "-c", command, NULL); + exit(-1); + } + + err = waitpid(pid, &wstatus, 0); + if (err < 0) { + pr_err("Failure calling waitpid: %s: (%s)\n", + strerror(errno), command); + return -1; + } + + pr_err("%s: %d %d\n", command, pid, WEXITSTATUS(wstatus)); + + switch (WEXITSTATUS(wstatus)) { + case 0: + /* Success */ + err = 0; + break; + case 127: + /* The shell did not find objdump in the path */ + err = SYMBOL_ANNOTATE_ERRNO__NO_OBJDUMP; + break; + default: + /* +* In the default case, we consider that objdump +* cannot be executed; so it gathers many fault +* scenarii: +* - objdump is not an executable (126); +* - objdump has some dependency issue; +* - ... +*/ + err = SYMBOL_ANNOTATE_ERRNO__NO_EXEC_OBJDUMP; + break; + } + + return err; +} + static const char *annotate__norm_arch(const char *arch_name) { struct utsname uts; @@ -1351,6 +1424,10 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na if (err) return err; + err = annotate__check_objdump(); + if (err) + return err; + arch_name = annotate__norm_arch(arch_name); if (!arch_name) return -1; @@ -1482,7 +1559,7 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na delete_last_nop(sym); fclose(file); - err = 0; + err = nline == 0 ? SYMBOL_ANNOTATE_ERRNO__NO_OUTPUT : 0; out_remove_tmp: close(stdout_fd[0]); diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 87e4cad..123f60c 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -172,6 +172,9 @@ enum symbol_disassemble_errno { __SYMBOL_ANNOTATE_ERRNO__START = -1, SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX = __SYMBOL_ANNOTATE_ERRNO__START, + SYMBOL_ANNOTATE_ERRNO__NO_EXEC_OBJDUMP, + SYMBOL_ANNOTATE_ERRNO__NO_OBJDUMP, + SYMBOL_ANNOTATE_ERRNO__NO_OUTPUT, __SYMBOL_ANNOTATE_ERRNO__END, }; -- 2.10.2
[PATCH] perf: check that objdump correctly works
Hi, In perf todo list, there was an entry regarding objdump: * Check if the objdump call in annotate worked or not, providing a popup window telling it didn't work, to test, just uninstall binutils or otherwise remove objdump from the path. The patch below tries to fulfill that point. Alexis. Alexis Berlemont (1): perf annotate: check that objdump correctly works tools/perf/util/annotate.c | 79 +- tools/perf/util/annotate.h | 3 ++ 2 files changed, 81 insertions(+), 1 deletion(-) -- 2.10.2
[PATCH v4 1/2] perf sdt: add scanning of sdt probles arguments
During a "perf buildid-cache --add" command, the section ".note.stapsdt" of the "added" binary is scanned in order to list the available SDT markers available in a binary. The parts containing the probes arguments were left unscanned. The whole section is now parsed; the probe arguments are extracted for later use. Signed-off-by: Alexis Berlemont --- tools/perf/util/symbol-elf.c | 25 +++-- tools/perf/util/symbol.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 99400b0..7725c3f 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1822,7 +1822,7 @@ void kcore_extract__delete(struct kcore_extract *kce) static int populate_sdt_note(Elf **elf, const char *data, size_t len, struct list_head *sdt_notes) { - const char *provider, *name; + const char *provider, *name, *args; struct sdt_note *tmp = NULL; GElf_Ehdr ehdr; GElf_Addr base_off = 0; @@ -1881,6 +1881,25 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, goto out_free_prov; } + args = memchr(name, '\0', data + len - name); + + /* +* There is no argument if: +* - We reached the end of the note; +* - There is not enough room to hold a potential string; +* - The argument string is empty or just contains ':'. +*/ + if (args == NULL || data + len - args < 2 || + args[1] == ':' || args[1] == '\0') + tmp->args = NULL; + else { + tmp->args = strdup(++args); + if (!tmp->args) { + ret = -ENOMEM; + goto out_free_name; + } + } + if (gelf_getclass(*elf) == ELFCLASS32) { memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr)); tmp->bit32 = true; @@ -1892,7 +1911,7 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, if (!gelf_getehdr(*elf, &ehdr)) { pr_debug("%s : cannot get elf header.\n", __func__); ret = -EBADF; - goto out_free_name; + goto out_free_args; } /* Adjust the prelink effect : @@ -1917,6 +1936,8 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, list_add_tail(&tmp->note_list, sdt_notes); return 0; +out_free_args: + free(tmp->args); out_free_name: free(tmp->name); out_free_prov: diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index dec7e2d4..db1953e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -348,6 +348,7 @@ int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); struct sdt_note { char *name; /* name of the note*/ char *provider; /* provider name */ + char *args; bool bit32; /* whether the location is 32 bits? */ union { /* location, base and semaphore addrs */ Elf64_Addr a64[3]; -- 2.10.2
[PATCH v4 2/2] perf probe: add sdt probes arguments into the uprobe cmd string
An sdt probe can be associated with arguments but they were not passed to the user probe tracing interface (uprobe_events); this patch adapts the sdt argument descriptors according to the uprobe input format. As the uprobe parser does not support scaled address mode, perf will skip arguments which cannot be adapted to the uprobe format. Here are the results: $ perf buildid-cache -v --add test_sdt $ perf probe -x test_sdt sdt_libfoo:table_frob $ perf probe -x test_sdt sdt_libfoo:table_diddle $ perf record -e sdt_libfoo:table_frob -e sdt_libfoo:table_diddle test_sdt $ perf script test_sdt ... 666.255678: sdt_libfoo:table_frob: (4004d7) arg0=0 arg1=0 test_sdt ... 666.255683: sdt_libfoo:table_diddle: (40051a) arg0=0 arg1=0 test_sdt ... 666.255686: sdt_libfoo:table_frob: (4004d7) arg0=1 arg1=2 test_sdt ... 666.255689: sdt_libfoo:table_diddle: (40051a) arg0=3 arg1=4 test_sdt ... 666.255692: sdt_libfoo:table_frob: (4004d7) arg0=2 arg1=4 test_sdt ... 666.255694: sdt_libfoo:table_diddle: (40051a) arg0=6 arg1=8 Signed-off-by: Alexis Berlemont --- tools/perf/arch/x86/util/perf_regs.c | 18 tools/perf/util/perf_regs.c | 4 + tools/perf/util/perf_regs.h | 13 +++ tools/perf/util/probe-file.c | 169 ++- 4 files changed, 200 insertions(+), 4 deletions(-) diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index c5db14f..52a1e65 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -26,3 +26,21 @@ const struct sample_reg sample_reg_masks[] = { #endif SMPL_REG_END }; + +const struct sdt_name_reg sdt_reg_renamings[] = { + SDT_NAME_REG(eax, ax), + SDT_NAME_REG(rax, ax), + SDT_NAME_REG(ebx, bx), + SDT_NAME_REG(rbx, bx), + SDT_NAME_REG(ecx, cx), + SDT_NAME_REG(rcx, cx), + SDT_NAME_REG(edx, dx), + SDT_NAME_REG(rdx, dx), + SDT_NAME_REG(esi, si), + SDT_NAME_REG(rsi, si), + SDT_NAME_REG(edi, di), + SDT_NAME_REG(rdi, di), + SDT_NAME_REG(ebp, bp), + SDT_NAME_REG(rbp, bp), + SDT_NAME_REG_END, +}; diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index c4023f2..1c21150 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -6,6 +6,10 @@ const struct sample_reg __weak sample_reg_masks[] = { SMPL_REG_END }; +const struct sdt_name_reg __weak sdt_reg_renamings[] = { + SDT_NAME_REG_END, +}; + #ifdef HAVE_PERF_REGS_SUPPORT int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) { diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h index 679d6e4..41815ca 100644 --- a/tools/perf/util/perf_regs.h +++ b/tools/perf/util/perf_regs.h @@ -15,6 +15,19 @@ struct sample_reg { extern const struct sample_reg sample_reg_masks[]; +struct sdt_name_reg { + const char *sdt_name; + const char *uprobe_name; +}; +#define SDT_NAME_REG(n, m) {.sdt_name = "%" #n, .uprobe_name = "%" #m} +#define SDT_NAME_REG_END {.sdt_name = NULL, .uprobe_name = NULL} + +/* + * The table sdt_reg_renamings is used for adjusting gcc/gas-generated + * registers before filling the uprobe tracer interface. + */ +extern const struct sdt_name_reg sdt_reg_renamings[]; + #ifdef HAVE_PERF_REGS_SUPPORT #include diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 436b647..75033c7 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -27,6 +27,7 @@ #include "probe-event.h" #include "probe-file.h" #include "session.h" +#include "perf_regs.h" #define MAX_CMDLEN 256 @@ -687,6 +688,165 @@ static unsigned long long sdt_note__get_addr(struct sdt_note *note) : (unsigned long long)note->addr.a64[0]; } +static const char * const type_to_suffix[] = { + ":s64", "", "", "", ":s32", "", ":s16", ":s8", + "", ":u8", ":u16", "", ":u32", "", "", "", ":u64" +}; + +static int synthesize_sdt_probe_arg(struct strbuf *buf, int i, const char *arg) +{ + const struct sdt_name_reg *rnames; + char *tmp, *desc = strdup(arg); + const char *prefix = "", *suffix = ""; + int ret = -1; + + if (desc == NULL) { + pr_debug4("Allocation error\n"); + return ret; + } + + tmp = strchr(desc, '@'); + if (tmp) { + long type_idx; + /* +* Isolate the string number and convert it into a +* binary value; this will be an index to get suffix +* of the uprobe name (defining the type) +*/ + tmp[0] = '\0';
[PATCH v4 0/2] perf probe: add sdt probes arguments into the uprobe cmd string
Hi Arnaldo, Here is another patch set which fixes the issues you noticed. Thank you. Alexis. Alexis Berlemont (2): perf sdt: add scanning of sdt probles arguments perf probe: add sdt probes arguments into the uprobe cmd string tools/perf/arch/x86/util/perf_regs.c | 18 tools/perf/util/perf_regs.c | 4 + tools/perf/util/perf_regs.h | 13 +++ tools/perf/util/probe-file.c | 169 ++- tools/perf/util/symbol-elf.c | 25 +- tools/perf/util/symbol.h | 1 + 6 files changed, 224 insertions(+), 6 deletions(-) -- 2.10.2
[PATCH v3 0/2] perf probe: add sdt probes arguments into the uprobe cmd string
Hi Hemant, Once more thank you for your answer. Sorry for this bug: I tested the patches only on small sample binaries. Now it is tested against the systemtap-enabled libraries libc and libpthread. There were 2 problems: * The one you disclosed: in indirect addressing mode, positive offsets not prefixed with a '+' character; * Another one still in indirect addressing mode: offsets which were not constants but symbols; The following patches solves them both. # cat /sys/kernel/tracing/uprobe_events p:sdt_libpthread/pthread_start /lib/libpthread-2.23.so:0x7448 arg0=%ax:u64 arg1=+1600(%ax):u64 arg2=+1608(%ax):u64 p:sdt_libpthread/pthread_create /lib/libpthread-2.23.so:0x7be9 arg0=%ax:u64 arg1=-184(%bp):u64 arg2=-160(%bp):u64 arg3=-168(%bp):u64 p:sdt_libpthread/pthread_join /lib/libpthread-2.23.so:0x864d arg0=%di:u64 p:sdt_libpthread/pthread_join_ret /lib/libpthread-2.23.so:0x86fe arg0=%bx:u64 arg1=%ax:s32 arg2=+1584(%bx):u64 p:sdt_libpthread/mutex_init /lib/libpthread-2.23.so:0x938b arg0=%di:u64 p:sdt_libpthread/mutex_destroy /lib/libpthread-2.23.so:0x9410 arg0=%di:u64 p:sdt_libpthread/mutex_acquired /lib/libpthread-2.23.so:0x9685 arg0=%bx:u64 p:sdt_libpthread/mutex_acquired_1 /lib/libpthread-2.23.so:0x9b31 arg0=%r8:u64 ... # cat /sys/kernel/tracing/uprobe_events p:sdt_libc/setjmp /lib/libc-2.23.so:0x00033181 arg0=%di:u64 arg1=%si:s32 arg2=%ax:u64 p:sdt_libc/longjmp /lib/libc-2.23.so:0x00033263 arg0=%di:u64 arg1=%si:s32 arg2=%dx:u64 p:sdt_libc/longjmp_1 /lib/libc-2.23.so:0x000f7fc3 arg0=%di:u64 arg1=%si:s32 arg2=%dx:u64 p:sdt_libc/longjmp_target /lib/libc-2.23.so:0x0003327f arg0=%di:u64 arg1=%ax:s32 arg2=%dx:u64 p:sdt_libc/longjmp_target_1 /lib/libc-2.23.so:0x000f7fdf arg0=%di:u64 arg1=%ax:s32 arg2=%dx:u64 ... Thanks, Alexis. Alexis Berlemont (2): perf sdt: add scanning of sdt probles arguments perf probe: add sdt probes arguments into the uprobe cmd string tools/perf/arch/x86/util/perf_regs.c | 18 tools/perf/util/perf_regs.c | 4 + tools/perf/util/perf_regs.h | 13 +++ tools/perf/util/probe-file.c | 169 ++- tools/perf/util/symbol-elf.c | 16 +++- tools/perf/util/symbol.h | 1 + 6 files changed, 216 insertions(+), 5 deletions(-) -- 2.10.2
[PATCH v3 2/2] perf probe: add sdt probes arguments into the uprobe cmd string
An sdt probe can be associated with arguments but they were not passed to the user probe tracing interface (uprobe_events); this patch adapts the sdt argument descriptors according to the uprobe input format. As the uprobe parser does not support scaled address mode, perf will skip arguments which cannot be adapted to the uprobe format. Here are the results: $ perf buildid-cache -v --add test_sdt $ perf probe -x test_sdt sdt_libfoo:table_frob $ perf probe -x test_sdt sdt_libfoo:table_diddle $ perf record -e sdt_libfoo:table_frob -e sdt_libfoo:table_diddle test_sdt $ perf script test_sdt ... 666.255678: sdt_libfoo:table_frob: (4004d7) arg0=0 arg1=0 test_sdt ... 666.255683: sdt_libfoo:table_diddle: (40051a) arg0=0 arg1=0 test_sdt ... 666.255686: sdt_libfoo:table_frob: (4004d7) arg0=1 arg1=2 test_sdt ... 666.255689: sdt_libfoo:table_diddle: (40051a) arg0=3 arg1=4 test_sdt ... 666.255692: sdt_libfoo:table_frob: (4004d7) arg0=2 arg1=4 test_sdt ... 666.255694: sdt_libfoo:table_diddle: (40051a) arg0=6 arg1=8 Signed-off-by: Alexis Berlemont --- tools/perf/arch/x86/util/perf_regs.c | 18 tools/perf/util/perf_regs.c | 4 + tools/perf/util/perf_regs.h | 13 +++ tools/perf/util/probe-file.c | 169 ++- 4 files changed, 200 insertions(+), 4 deletions(-) diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index c5db14f..52a1e65 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -26,3 +26,21 @@ const struct sample_reg sample_reg_masks[] = { #endif SMPL_REG_END }; + +const struct sdt_name_reg sdt_reg_renamings[] = { + SDT_NAME_REG(eax, ax), + SDT_NAME_REG(rax, ax), + SDT_NAME_REG(ebx, bx), + SDT_NAME_REG(rbx, bx), + SDT_NAME_REG(ecx, cx), + SDT_NAME_REG(rcx, cx), + SDT_NAME_REG(edx, dx), + SDT_NAME_REG(rdx, dx), + SDT_NAME_REG(esi, si), + SDT_NAME_REG(rsi, si), + SDT_NAME_REG(edi, di), + SDT_NAME_REG(rdi, di), + SDT_NAME_REG(ebp, bp), + SDT_NAME_REG(rbp, bp), + SDT_NAME_REG_END, +}; diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index c4023f2..1c21150 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -6,6 +6,10 @@ const struct sample_reg __weak sample_reg_masks[] = { SMPL_REG_END }; +const struct sdt_name_reg __weak sdt_reg_renamings[] = { + SDT_NAME_REG_END, +}; + #ifdef HAVE_PERF_REGS_SUPPORT int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) { diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h index 679d6e4..41815ca 100644 --- a/tools/perf/util/perf_regs.h +++ b/tools/perf/util/perf_regs.h @@ -15,6 +15,19 @@ struct sample_reg { extern const struct sample_reg sample_reg_masks[]; +struct sdt_name_reg { + const char *sdt_name; + const char *uprobe_name; +}; +#define SDT_NAME_REG(n, m) {.sdt_name = "%" #n, .uprobe_name = "%" #m} +#define SDT_NAME_REG_END {.sdt_name = NULL, .uprobe_name = NULL} + +/* + * The table sdt_reg_renamings is used for adjusting gcc/gas-generated + * registers before filling the uprobe tracer interface. + */ +extern const struct sdt_name_reg sdt_reg_renamings[]; + #ifdef HAVE_PERF_REGS_SUPPORT #include diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 436b647..75033c7 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -27,6 +27,7 @@ #include "probe-event.h" #include "probe-file.h" #include "session.h" +#include "perf_regs.h" #define MAX_CMDLEN 256 @@ -687,6 +688,165 @@ static unsigned long long sdt_note__get_addr(struct sdt_note *note) : (unsigned long long)note->addr.a64[0]; } +static const char * const type_to_suffix[] = { + ":s64", "", "", "", ":s32", "", ":s16", ":s8", + "", ":u8", ":u16", "", ":u32", "", "", "", ":u64" +}; + +static int synthesize_sdt_probe_arg(struct strbuf *buf, int i, const char *arg) +{ + const struct sdt_name_reg *rnames; + char *tmp, *desc = strdup(arg); + const char *prefix = "", *suffix = ""; + int ret = -1; + + if (desc == NULL) { + pr_debug4("Allocation error\n"); + return ret; + } + + tmp = strchr(desc, '@'); + if (tmp) { + long type_idx; + /* +* Isolate the string number and convert it into a +* binary value; this will be an index to get suffix +* of the uprobe name (defining the type) +*/ + tmp[0] = '\0';
[PATCH v3 1/2] perf sdt: add scanning of sdt probles arguments
During a "perf buildid-cache --add" command, the section ".note.stapsdt" of the "added" binary is scanned in order to list the available SDT markers available in a binary. The parts containing the probes arguments were left unscanned. The whole section is now parsed; the probe arguments are extracted for later use. Signed-off-by: Alexis Berlemont --- tools/perf/util/symbol-elf.c | 16 +++- tools/perf/util/symbol.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 99400b0..0fbe0b2 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1822,7 +1822,7 @@ void kcore_extract__delete(struct kcore_extract *kce) static int populate_sdt_note(Elf **elf, const char *data, size_t len, struct list_head *sdt_notes) { - const char *provider, *name; + const char *provider, *name, *args; struct sdt_note *tmp = NULL; GElf_Ehdr ehdr; GElf_Addr base_off = 0; @@ -1881,6 +1881,20 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, goto out_free_prov; } + args = (const char *)memchr(name, '\0', data + len - name); + + /* +* There is no argument if: +* - We reached the end of the note; +* - There is not enough room to hold a potential string; +* - The argument string is empty or just contains ':'. +*/ + if (args == NULL || data + len - args < 2 || + args[1] == ':' || args[1] == '\0') + tmp->args = NULL; + else + tmp->args = strdup(++args); + if (gelf_getclass(*elf) == ELFCLASS32) { memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr)); tmp->bit32 = true; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 2d0a905..913be07 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -347,6 +347,7 @@ int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); struct sdt_note { char *name; /* name of the note*/ char *provider; /* provider name */ + char *args; bool bit32; /* whether the location is 32 bits? */ union { /* location, base and semaphore addrs */ Elf64_Addr a64[3]; -- 2.10.2
[PATCH v2 2/2] perf probe: add sdt probes arguments into the uprobe cmd string
An sdt probe can be associated with arguments but they were not passed to the user probe tracing interface (uprobe_events); this patch adapts the sdt argument descriptors according to the uprobe input format. As the uprobe parser does not support scaled address mode, perf will skip arguments which cannot be adapted to the uprobe format. Here are the results: $ perf buildid-cache -v --add test_sdt $ perf probe -x test_sdt sdt_libfoo:table_frob $ perf probe -x test_sdt sdt_libfoo:table_diddle $ perf record -e sdt_libfoo:table_frob -e sdt_libfoo:table_diddle test_sdt $ perf script test_sdt ... 666.255678: sdt_libfoo:table_frob: (4004d7) arg0=0 arg1=0 test_sdt ... 666.255683: sdt_libfoo:table_diddle: (40051a) arg0=0 arg1=0 test_sdt ... 666.255686: sdt_libfoo:table_frob: (4004d7) arg0=1 arg1=2 test_sdt ... 666.255689: sdt_libfoo:table_diddle: (40051a) arg0=3 arg1=4 test_sdt ... 666.255692: sdt_libfoo:table_frob: (4004d7) arg0=2 arg1=4 test_sdt ... 666.255694: sdt_libfoo:table_diddle: (40051a) arg0=6 arg1=8 Signed-off-by: Alexis Berlemont --- tools/perf/arch/x86/util/perf_regs.c | 18 + tools/perf/util/perf_regs.c | 4 + tools/perf/util/perf_regs.h | 13 tools/perf/util/probe-file.c | 141 ++- 4 files changed, 172 insertions(+), 4 deletions(-) diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index c5db14f..52a1e65 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -26,3 +26,21 @@ const struct sample_reg sample_reg_masks[] = { #endif SMPL_REG_END }; + +const struct sdt_name_reg sdt_reg_renamings[] = { + SDT_NAME_REG(eax, ax), + SDT_NAME_REG(rax, ax), + SDT_NAME_REG(ebx, bx), + SDT_NAME_REG(rbx, bx), + SDT_NAME_REG(ecx, cx), + SDT_NAME_REG(rcx, cx), + SDT_NAME_REG(edx, dx), + SDT_NAME_REG(rdx, dx), + SDT_NAME_REG(esi, si), + SDT_NAME_REG(rsi, si), + SDT_NAME_REG(edi, di), + SDT_NAME_REG(rdi, di), + SDT_NAME_REG(ebp, bp), + SDT_NAME_REG(rbp, bp), + SDT_NAME_REG_END, +}; diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index c4023f2..1c21150 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -6,6 +6,10 @@ const struct sample_reg __weak sample_reg_masks[] = { SMPL_REG_END }; +const struct sdt_name_reg __weak sdt_reg_renamings[] = { + SDT_NAME_REG_END, +}; + #ifdef HAVE_PERF_REGS_SUPPORT int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) { diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h index 679d6e4..41815ca 100644 --- a/tools/perf/util/perf_regs.h +++ b/tools/perf/util/perf_regs.h @@ -15,6 +15,19 @@ struct sample_reg { extern const struct sample_reg sample_reg_masks[]; +struct sdt_name_reg { + const char *sdt_name; + const char *uprobe_name; +}; +#define SDT_NAME_REG(n, m) {.sdt_name = "%" #n, .uprobe_name = "%" #m} +#define SDT_NAME_REG_END {.sdt_name = NULL, .uprobe_name = NULL} + +/* + * The table sdt_reg_renamings is used for adjusting gcc/gas-generated + * registers before filling the uprobe tracer interface. + */ +extern const struct sdt_name_reg sdt_reg_renamings[]; + #ifdef HAVE_PERF_REGS_SUPPORT #include diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 436b647..587763d 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -27,6 +27,7 @@ #include "probe-event.h" #include "probe-file.h" #include "session.h" +#include "perf_regs.h" #define MAX_CMDLEN 256 @@ -687,6 +688,137 @@ static unsigned long long sdt_note__get_addr(struct sdt_note *note) : (unsigned long long)note->addr.a64[0]; } +static const char * const type_to_suffix[] = { + ":s64", "", "", "", ":s32", "", ":s16", ":s8", + "", ":u8", ":u16", "", ":u32", "", "", "", ":u64" +}; + +static int synthesize_sdt_probe_arg(struct strbuf *buf, int i, const char *arg) +{ + const struct sdt_name_reg *rnames; + char *tmp, *desc = strdup(arg); + const char *suffix = ""; + int ret = -1; + + if (desc == NULL) { + pr_debug4("Allocation error\n"); + return ret; + } + + /* +* The uprobe tracer format does not support all the +* addressing modes (notably: in x86 the scaled mode); so, we +* detect ',' characters, if there is just one, there is no +* use converting the sdt arg into a uprobe one. +*/ + if (strchr(desc, ',')) { + pr_debug4("SDT argument format not suppo
[PATCH v2 0/2] perf probe: add sdt probes arguments into the uprobe cmd string
Hi Hemant, Many thanks for your answer. Here is another proposal in which the x86 register renaming table has been moved into the x86-specific part. Thanks, Alexis. Alexis Berlemont (2): perf sdt: add scanning of sdt probles arguments perf probe: add sdt probes arguments into the uprobe cmd string tools/perf/arch/x86/util/perf_regs.c | 18 + tools/perf/util/perf_regs.c | 4 + tools/perf/util/perf_regs.h | 13 tools/perf/util/probe-file.c | 141 ++- tools/perf/util/symbol-elf.c | 16 +++- tools/perf/util/symbol.h | 1 + 6 files changed, 188 insertions(+), 5 deletions(-) -- 2.10.2
[PATCH v2 1/2] perf sdt: add scanning of sdt probles arguments
During a "perf buildid-cache --add" command, the section ".note.stapsdt" of the "added" binary is scanned in order to list the available SDT markers available in a binary. The parts containing the probes arguments were left unscanned. The whole section is now parsed; the probe arguments are extracted for later use. Signed-off-by: Alexis Berlemont --- tools/perf/util/symbol-elf.c | 16 +++- tools/perf/util/symbol.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 99400b0..0fbe0b2 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1822,7 +1822,7 @@ void kcore_extract__delete(struct kcore_extract *kce) static int populate_sdt_note(Elf **elf, const char *data, size_t len, struct list_head *sdt_notes) { - const char *provider, *name; + const char *provider, *name, *args; struct sdt_note *tmp = NULL; GElf_Ehdr ehdr; GElf_Addr base_off = 0; @@ -1881,6 +1881,20 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, goto out_free_prov; } + args = (const char *)memchr(name, '\0', data + len - name); + + /* +* There is no argument if: +* - We reached the end of the note; +* - There is not enough room to hold a potential string; +* - The argument string is empty or just contains ':'. +*/ + if (args == NULL || data + len - args < 2 || + args[1] == ':' || args[1] == '\0') + tmp->args = NULL; + else + tmp->args = strdup(++args); + if (gelf_getclass(*elf) == ELFCLASS32) { memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr)); tmp->bit32 = true; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 2d0a905..913be07 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -347,6 +347,7 @@ int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); struct sdt_note { char *name; /* name of the note*/ char *provider; /* provider name */ + char *args; bool bit32; /* whether the location is 32 bits? */ union { /* location, base and semaphore addrs */ Elf64_Addr a64[3]; -- 2.10.2
[PATCH v3 1/2] perf, x86-mm: declare page-faults tracepoints like irq-vectors ones
The tracepoints "exceptions:page_fault_(user|kernel)" were renamed "exceptions:page_fault_(user|kernel)_entry". Two more tracepoints were added: "exceptions:page_fault_(user|kernel)_exit". These events are called right before and after __do_page_fault(). Signed-off-by: Alexis Berlemont --- arch/x86/include/asm/trace/exceptions.h | 17 - arch/x86/mm/fault.c | 17 ++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/trace/exceptions.h b/arch/x86/include/asm/trace/exceptions.h index 2fbc66c..ecbe64e 100644 --- a/arch/x86/include/asm/trace/exceptions.h +++ b/arch/x86/include/asm/trace/exceptions.h @@ -33,14 +33,29 @@ DECLARE_EVENT_CLASS(x86_exceptions, __entry->error_code) ); #define DEFINE_PAGE_FAULT_EVENT(name) \ -DEFINE_EVENT_FN(x86_exceptions, name, \ +DEFINE_EVENT_FN(x86_exceptions, name##_entry, \ + TP_PROTO(unsigned long address, struct pt_regs *regs, \ +unsigned long error_code), \ + TP_ARGS(address, regs, error_code), \ + trace_irq_vector_regfunc, \ + trace_irq_vector_unregfunc);\ +DEFINE_EVENT_FN(x86_exceptions, name##_exit, \ TP_PROTO(unsigned long address, struct pt_regs *regs, \ unsigned long error_code), \ TP_ARGS(address, regs, error_code), \ trace_irq_vector_regfunc, \ trace_irq_vector_unregfunc); +/* + * page_fault_user - called when entering/exiting a page fault in + * user-space + */ DEFINE_PAGE_FAULT_EVENT(page_fault_user); + +/* + * page_fault_kernel - called when entering/exiting a page fault in + * kernel-space + */ DEFINE_PAGE_FAULT_EVENT(page_fault_kernel); #undef TRACE_INCLUDE_PATH diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9f72ca3..2ed2716 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1465,12 +1465,22 @@ NOKPROBE_SYMBOL(do_page_fault); #ifdef CONFIG_TRACING static nokprobe_inline void trace_page_fault_entries(unsigned long address, struct pt_regs *regs, -unsigned long error_code) + unsigned long error_code) { if (user_mode(regs)) - trace_page_fault_user(address, regs, error_code); + trace_page_fault_user_entry(address, regs, error_code); else - trace_page_fault_kernel(address, regs, error_code); + trace_page_fault_kernel_entry(address, regs, error_code); +} + +static nokprobe_inline void +trace_page_fault_exits(unsigned long address, struct pt_regs *regs, + unsigned long error_code) +{ + if (user_mode(regs)) + trace_page_fault_user_exit(address, regs, error_code); + else + trace_page_fault_kernel_exit(address, regs, error_code); } dotraplinkage void notrace @@ -1488,6 +1498,7 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code) prev_state = exception_enter(); trace_page_fault_entries(address, regs, error_code); __do_page_fault(regs, error_code, address); + trace_page_fault_exits(address, regs, error_code); exception_exit(prev_state); } NOKPROBE_SYMBOL(trace_do_page_fault); -- 2.10.2
[PATCH v3 0/2] perf: measure page fault duration in perf trace
Hi, Here is another attempt to make the perf-trace subcommand print the page fault durations. This solution is based on static tracepoints and it was necessary to add 2 more tracepoints. I understood that adding tracepoints is a questionable solution; I can try something else if someone has another idea. Alexis. Alexis Berlemont (2): perf, x86-mm: declare page-faults tracepoints like irq-vectors ones perf: add page fault duration measures in perf trace arch/x86/include/asm/trace/exceptions.h | 17 ++- arch/x86/mm/fault.c | 17 ++- tools/perf/Documentation/perf-trace.txt | 4 +- tools/perf/builtin-trace.c | 231 4 files changed, 238 insertions(+), 31 deletions(-) -- 2.10.2
[PATCH v3 2/2] perf: add page fault duration measures in perf trace
Thanks to the tracepoints exceptions:page_fault_kernel_exit and exceptions:page_fault_user_exit, the subcommand perf-trace can now print the duration of page-fault exception handling just like it is done for syscalls. Here is the result; the page fault durations are indicated in parenthesis (like syscalls): Here is an example; the durations are indicated in parenthesis just like with syscalls: 0.053 ( 0.053 ms): ls/152 minfault [__clear_user+0x25] => 0x694e7e (?k) 0.114 ( 0.027 ms): ls/152 minfault [__clear_user+0x25] => 0x7fb912eaafc0 (?k) 0.201 ( 0.030 ms): ls/152 minfault [_start+0x0] => /lib/ld-2.23.so@0xc70 (x.) ... Signed-off-by: Alexis Berlemont --- tools/perf/Documentation/perf-trace.txt | 4 +- tools/perf/builtin-trace.c | 231 2 files changed, 208 insertions(+), 27 deletions(-) diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt index 781b019..53c103c 100644 --- a/tools/perf/Documentation/perf-trace.txt +++ b/tools/perf/Documentation/perf-trace.txt @@ -117,7 +117,9 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs. -F=[all|min|maj]:: --pf=[all|min|maj]:: Trace pagefaults. Optionally, you can specify whether you want minor, - major or all pagefaults. Default value is maj. + major or all pagefaults. Default value is maj. Durations of + page-fault handling will be printed if possible (need for some + architecture-dependent tracepoints). --syscalls:: Trace system calls. This options is enabled by default. diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 5f45166..f0957a8 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -861,6 +861,8 @@ struct thread_trace { } paths; struct intlist *syscall_stats; + u64pgfault_entry_time; + char *pgfault_entry_str; }; static struct thread_trace *thread_trace__new(void) @@ -1797,21 +1799,56 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, return 0; } -static void print_location(FILE *f, struct perf_sample *sample, - struct addr_location *al, - bool print_dso, bool print_sym) +static int trace__pgfault_enter(struct trace *trace, + struct perf_evsel *evsel __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample) { + struct thread *thread; + struct thread_trace *ttrace; + int err = -1; + + thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + if (!thread) + goto out; + + ttrace = thread__trace(thread, trace->output); + if (ttrace == NULL) + goto out_put; + + ttrace->pgfault_entry_time = sample->time; + +out: + err = 0; +out_put: + thread__put(thread); + return err; +} + +static size_t scnprintf_location(char *bf, size_t size, + struct perf_sample *sample, + struct addr_location *al, + bool print_dso, bool print_sym) +{ + size_t printed = 0; if ((verbose || print_dso) && al->map) - fprintf(f, "%s@", al->map->dso->long_name); + printed += scnprintf(bf + printed, + size - printed, "%s@", al->map->dso->long_name); if ((verbose || print_sym) && al->sym) - fprintf(f, "%s+0x%" PRIx64, al->sym->name, - al->addr - al->sym->start); + printed += scnprintf(bf + printed, + size - printed, + "%s+0x%" PRIx64, al->sym->name, + al->addr - al->sym->start); else if (al->map) - fprintf(f, "0x%" PRIx64, al->addr); + printed += scnprintf(bf + printed, + size - printed, "0x%" PRIx64, al->addr); else - fprintf(f, "0x%" PRIx64, sample->addr); + printed += scnprintf(bf + printed, + size - printed, "0x%" PRIx64, sample->addr); + + return printed; } static int trace__pgfault(struct trace *trace, @@ -1823,13 +1860,22 @@ static int trace__pgfault(struct trace *trace, struct addr_location al; char map_type = 'd'; struct thread_trace *ttrace; + size_t printed = 0; int err = -1; int callchain_ret = 0; thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + if (!th
[PATCH 1/2] perf sdt: add scanning of sdt probles arguments
During a "perf buildid-cache --add" command, the section ".note.stapsdt" of the "added" binary is scanned in order to list the available SDT markers available in a binary. The parts containing the probes arguments were left unscanned. The whole section is now parsed; the probe arguments are extracted for later use. Signed-off-by: Alexis Berlemont --- tools/perf/util/symbol-elf.c | 16 +++- tools/perf/util/symbol.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 99400b0..0fbe0b2 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1822,7 +1822,7 @@ void kcore_extract__delete(struct kcore_extract *kce) static int populate_sdt_note(Elf **elf, const char *data, size_t len, struct list_head *sdt_notes) { - const char *provider, *name; + const char *provider, *name, *args; struct sdt_note *tmp = NULL; GElf_Ehdr ehdr; GElf_Addr base_off = 0; @@ -1881,6 +1881,20 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len, goto out_free_prov; } + args = (const char *)memchr(name, '\0', data + len - name); + + /* +* There is no argument if: +* - We reached the end of the note; +* - There is not enough room to hold a potential string; +* - The argument string is empty or just contains ':'. +*/ + if (args == NULL || data + len - args < 2 || + args[1] == ':' || args[1] == '\0') + tmp->args = NULL; + else + tmp->args = strdup(++args); + if (gelf_getclass(*elf) == ELFCLASS32) { memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr)); tmp->bit32 = true; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 2d0a905..913be07 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -347,6 +347,7 @@ int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); struct sdt_note { char *name; /* name of the note*/ char *provider; /* provider name */ + char *args; bool bit32; /* whether the location is 32 bits? */ union { /* location, base and semaphore addrs */ Elf64_Addr a64[3]; -- 2.10.2
[PATCH 2/2] perf probe: add sdt probes arguments into the uprobe cmd string
An sdt probe can be associated with arguments but they were not passed to the user probe tracing interface (uprobe_events); this patch adapts the sdt argument descriptors according to the uprobe input format. As the uprobe parser does not support scaled address mode, perf will skip arguments which cannot be adapted to the uprobe format. Here are the results: $ perf buildid-cache -v --add test_sdt $ perf probe -x test_sdt sdt_libfoo:table_frob $ perf probe -x test_sdt sdt_libfoo:table_diddle $ perf record -e sdt_libfoo:table_frob -e sdt_libfoo:table_diddle test_sdt $ perf script test_sdt ... 666.255678: sdt_libfoo:table_frob: (4004d7) arg0=0 arg1=0 test_sdt ... 666.255683: sdt_libfoo:table_diddle: (40051a) arg0=0 arg1=0 test_sdt ... 666.255686: sdt_libfoo:table_frob: (4004d7) arg0=1 arg1=2 test_sdt ... 666.255689: sdt_libfoo:table_diddle: (40051a) arg0=3 arg1=4 test_sdt ... 666.255692: sdt_libfoo:table_frob: (4004d7) arg0=2 arg1=4 test_sdt ... 666.255694: sdt_libfoo:table_diddle: (40051a) arg0=6 arg1=8 Signed-off-by: Alexis Berlemont --- tools/perf/util/probe-file.c | 176 ++- 1 file changed, 172 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 436b647..a97a170 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -28,6 +28,46 @@ #include "probe-file.h" #include "session.h" +#ifdef HAVE_GELF_GETNOTE_SUPPORT + +/* + * Local declarations needed for adjusting gcc/gas-generated registers + * before filling the uprobe tracer interface. + */ + +struct sdt_reg_renaming { + const char *sdt_name; + const char *uprobe_name; +}; + +#define REG_RENAMING(n, m) {.sdt_name = "%" #n, .uprobe_name = "%" #m} +#define REG_RENAMING_END {.sdt_name = NULL, .uprobe_name = NULL} + +static const struct sdt_reg_renaming sdt_reg_renaming_table[] = { + REG_RENAMING(eax, ax), + REG_RENAMING(rax, ax), + REG_RENAMING(ebx, bx), + REG_RENAMING(rbx, bx), + REG_RENAMING(ecx, cx), + REG_RENAMING(rcx, cx), + REG_RENAMING(edx, dx), + REG_RENAMING(rdx, dx), + REG_RENAMING(esi, si), + REG_RENAMING(rsi, si), + REG_RENAMING(edi, di), + REG_RENAMING(rdi, di), + REG_RENAMING(ebp, bp), + REG_RENAMING(rbp, bp), + REG_RENAMING_END, +}; + +static const char * const type_to_suffix[] = { + ":s64", "", "", "", ":s32", "", ":s16", ":s8", + "", ":u8", ":u16", "", ":u32", "", "", "", ":u64" +}; + +#endif /* HAVE_GELF_GETNOTE_SUPPORT */ + #define MAX_CMDLEN 256 static void print_open_warning(int err, bool uprobe) @@ -687,6 +727,133 @@ static unsigned long long sdt_note__get_addr(struct sdt_note *note) : (unsigned long long)note->addr.a64[0]; } +static int synthesize_sdt_probe_arg(struct strbuf *buf, int i, const char *arg) +{ + const struct sdt_reg_renaming *rnames; + char *tmp, *desc = strdup(arg); + const char *suffix = ""; + int ret = -1; + + if (desc == NULL) { + pr_debug4("Allocation error\n"); + return ret; + } + + /* +* The uprobe tracer format does not support all the +* addressing modes (notably: in x86 the scaled mode); so, we +* detect ',' characters, if there is just one, there is no +* use converting the sdt arg into a uprobe one. +*/ + if (strchr(desc, ',')) { + pr_debug4("SDT argument format not supported\n"); + goto out; + } + + tmp = strchr(desc, '@'); + if (tmp) { + long type_idx; + /* +* Isolate the string number and convert it into a +* binary value; this will be an index to get suffix +* of the uprobe name (defining the type) +*/ + tmp[0] = '\0'; + type_idx = strtol(desc, NULL, 10); + if (type_idx == LONG_MIN || + type_idx == LONG_MAX) { + pr_debug4("Failed to get sdt type\n"); + goto error; + } + suffix = type_to_suffix[type_idx + 8]; + /* Get rid of the sdt prefix which is now useless */ + tmp++; + memmove(desc, tmp, strlen(tmp) + 1); + } + + /* +* The uprobe parser does not support all gas register names; +* so, we have to replace them (ex. for x86_64: %rax -> %ax); +* the loop below performs all the needed renamings if needed. +*/ + + for (rnames = sdt_reg_renaming_ta
[PATCH 0/2] perf: add support of SDT probes arguments
Hi, In the perf todo list (https://perf.wiki.kernel.org/index.php/Todo), there is an entry related with SDT markers support; SDT tracepoints were already supported by perf but, so far, the probes arguments are skipped. Here are 2 small patches which adds support of SDT probes arguments: $ perf record -e sdt_libfoo:table_frob -e sdt_libfoo:table_diddle test_sdt $ perf script test_sdt ... 666.255678: sdt_libfoo:table_frob: (4004d7) arg0=0 arg1=0 test_sdt ... 666.255683: sdt_libfoo:table_diddle: (40051a) arg0=0 arg1=0 test_sdt ... 666.255686: sdt_libfoo:table_frob: (4004d7) arg0=1 arg1=2 test_sdt ... 666.255689: sdt_libfoo:table_diddle: (40051a) arg0=3 arg1=4 test_sdt ... 666.255692: sdt_libfoo:table_frob: (4004d7) arg0=2 arg1=4 test_sdt ... 666.255694: sdt_libfoo:table_diddle: (40051a) arg0=6 arg1=8 The patches were generated against tip/perf/core. Alexis. Alexis Berlemont (2): perf sdt: add scanning of sdt probles arguments perf probe: add sdt probes arguments into the uprobe cmd string tools/perf/util/probe-file.c | 176 ++- tools/perf/util/symbol-elf.c | 16 +++- tools/perf/util/symbol.h | 1 + 3 files changed, 188 insertions(+), 5 deletions(-) -- 2.10.2
[PATCH v2] perf, x86-mm: declare page-faults tracepoints like irq-vectors ones
The tracepoints "exceptions:page_fault_(user|kernel)" were renamed "exceptions:page_fault_(user|kernel)_entry". Two more tracepoints were added: "exceptions:page_fault_(user|kernel)_exit". These events are called right before and after __do_page_fault(). Signed-off-by: Alexis Berlemont --- arch/x86/include/asm/trace/exceptions.h | 17 - arch/x86/mm/fault.c | 17 ++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/trace/exceptions.h b/arch/x86/include/asm/trace/exceptions.h index 2fbc66c..ecbe64e 100644 --- a/arch/x86/include/asm/trace/exceptions.h +++ b/arch/x86/include/asm/trace/exceptions.h @@ -33,14 +33,29 @@ DECLARE_EVENT_CLASS(x86_exceptions, __entry->error_code) ); #define DEFINE_PAGE_FAULT_EVENT(name) \ -DEFINE_EVENT_FN(x86_exceptions, name, \ +DEFINE_EVENT_FN(x86_exceptions, name##_entry, \ + TP_PROTO(unsigned long address, struct pt_regs *regs, \ +unsigned long error_code), \ + TP_ARGS(address, regs, error_code), \ + trace_irq_vector_regfunc, \ + trace_irq_vector_unregfunc);\ +DEFINE_EVENT_FN(x86_exceptions, name##_exit, \ TP_PROTO(unsigned long address, struct pt_regs *regs, \ unsigned long error_code), \ TP_ARGS(address, regs, error_code), \ trace_irq_vector_regfunc, \ trace_irq_vector_unregfunc); +/* + * page_fault_user - called when entering/exiting a page fault in + * user-space + */ DEFINE_PAGE_FAULT_EVENT(page_fault_user); + +/* + * page_fault_kernel - called when entering/exiting a page fault in + * kernel-space + */ DEFINE_PAGE_FAULT_EVENT(page_fault_kernel); #undef TRACE_INCLUDE_PATH diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9f72ca3..2ed2716 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1465,12 +1465,22 @@ NOKPROBE_SYMBOL(do_page_fault); #ifdef CONFIG_TRACING static nokprobe_inline void trace_page_fault_entries(unsigned long address, struct pt_regs *regs, -unsigned long error_code) + unsigned long error_code) { if (user_mode(regs)) - trace_page_fault_user(address, regs, error_code); + trace_page_fault_user_entry(address, regs, error_code); else - trace_page_fault_kernel(address, regs, error_code); + trace_page_fault_kernel_entry(address, regs, error_code); +} + +static nokprobe_inline void +trace_page_fault_exits(unsigned long address, struct pt_regs *regs, + unsigned long error_code) +{ + if (user_mode(regs)) + trace_page_fault_user_exit(address, regs, error_code); + else + trace_page_fault_kernel_exit(address, regs, error_code); } dotraplinkage void notrace @@ -1488,6 +1498,7 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code) prev_state = exception_enter(); trace_page_fault_entries(address, regs, error_code); __do_page_fault(regs, error_code, address); + trace_page_fault_exits(address, regs, error_code); exception_exit(prev_state); } NOKPROBE_SYMBOL(trace_do_page_fault); -- 2.10.1
[PATCH v2] perf, x86-mm: declare page-faults tracepoints like irq-vectors ones
So, would you be OK with the following patch ? There is a symmetry just like irq_vectors tracepoints: # perf list | grep -E "exception|irq_vectors" exceptions:page_fault_kernel_entry [Tracepoint event] exceptions:page_fault_kernel_exit [Tracepoint event] exceptions:page_fault_user_entry [Tracepoint event] exceptions:page_fault_user_exit[Tracepoint event] irq_vectors:call_function_entry[Tracepoint event] irq_vectors:call_function_exit [Tracepoint event] ... Maybe 2 tracepoints (instead of 4) should have been enough; however, there were already 1 tracepoint per mode before. Alexis. Alexis Berlemont (1): perf, x86-mm: declare page-faults tracepoints like irq-vectors ones arch/x86/include/asm/trace/exceptions.h | 17 - arch/x86/mm/fault.c | 17 ++--- 2 files changed, 30 insertions(+), 4 deletions(-) -- 2.10.1
[PATCH 1/2] perf, x86-mm: Add exit-fault tracing
Signed-off-by: Alexis Berlemont --- arch/x86/include/asm/trace/exceptions.h | 21 + arch/x86/mm/fault.c | 1 + 2 files changed, 22 insertions(+) diff --git a/arch/x86/include/asm/trace/exceptions.h b/arch/x86/include/asm/trace/exceptions.h index 2fbc66c..39f78bb 100644 --- a/arch/x86/include/asm/trace/exceptions.h +++ b/arch/x86/include/asm/trace/exceptions.h @@ -43,6 +43,27 @@ DEFINE_EVENT_FN(x86_exceptions, name, \ DEFINE_PAGE_FAULT_EVENT(page_fault_user); DEFINE_PAGE_FAULT_EVENT(page_fault_kernel); +TRACE_EVENT_FN(page_fault_exit, + + TP_PROTO(unsigned long address), + + TP_ARGS(address), + + TP_STRUCT__entry( + __field(unsigned long, address) + ), + + TP_fast_assign( + __entry->address = address; + ), + + TP_printk("address=%lx", __entry->address), + + trace_irq_vector_regfunc, + + trace_irq_vector_unregfunc +); + #undef TRACE_INCLUDE_PATH #define TRACE_INCLUDE_PATH . #define TRACE_INCLUDE_FILE exceptions diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9f72ca3..e31e8ef 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1488,6 +1488,7 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code) prev_state = exception_enter(); trace_page_fault_entries(address, regs, error_code); __do_page_fault(regs, error_code, address); + trace_page_fault_exit(address); exception_exit(prev_state); } NOKPROBE_SYMBOL(trace_do_page_fault); -- 2.10.1
[PATCH 2/2] perf: add page fault duration measures in perf trace
Signed-off-by: Alexis Berlemont --- tools/perf/Documentation/perf-trace.txt | 4 +- tools/perf/builtin-trace.c | 225 2 files changed, 202 insertions(+), 27 deletions(-) diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt index 781b019..53c103c 100644 --- a/tools/perf/Documentation/perf-trace.txt +++ b/tools/perf/Documentation/perf-trace.txt @@ -117,7 +117,9 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs. -F=[all|min|maj]:: --pf=[all|min|maj]:: Trace pagefaults. Optionally, you can specify whether you want minor, - major or all pagefaults. Default value is maj. + major or all pagefaults. Default value is maj. Durations of + page-fault handling will be printed if possible (need for some + architecture-dependent tracepoints). --syscalls:: Trace system calls. This options is enabled by default. diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 5f45166..100c28a 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -861,6 +861,8 @@ struct thread_trace { } paths; struct intlist *syscall_stats; + u64pgfault_entry_time; + char *pgfault_entry_str; }; static struct thread_trace *thread_trace__new(void) @@ -1797,21 +1799,56 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, return 0; } -static void print_location(FILE *f, struct perf_sample *sample, - struct addr_location *al, - bool print_dso, bool print_sym) +static int trace__pgfault_enter(struct trace *trace, + struct perf_evsel *evsel __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample) { + struct thread *thread; + struct thread_trace *ttrace; + int err = -1; + + thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + if (!thread) + goto out; + + ttrace = thread__trace(thread, trace->output); + if (ttrace == NULL) + goto out_put; + + ttrace->pgfault_entry_time = sample->time; + +out: + err = 0; +out_put: + thread__put(thread); + return err; +} + +static size_t scnprintf_location(char *bf, size_t size, + struct perf_sample *sample, + struct addr_location *al, + bool print_dso, bool print_sym) +{ + size_t printed = 0; if ((verbose || print_dso) && al->map) - fprintf(f, "%s@", al->map->dso->long_name); + printed += scnprintf(bf + printed, + size - printed, "%s@", al->map->dso->long_name); if ((verbose || print_sym) && al->sym) - fprintf(f, "%s+0x%" PRIx64, al->sym->name, - al->addr - al->sym->start); + printed += scnprintf(bf + printed, + size - printed, + "%s+0x%" PRIx64, al->sym->name, + al->addr - al->sym->start); else if (al->map) - fprintf(f, "0x%" PRIx64, al->addr); + printed += scnprintf(bf + printed, + size - printed, "0x%" PRIx64, al->addr); else - fprintf(f, "0x%" PRIx64, sample->addr); + printed += scnprintf(bf + printed, + size - printed, "0x%" PRIx64, sample->addr); + + return printed; } static int trace__pgfault(struct trace *trace, @@ -1823,13 +1860,22 @@ static int trace__pgfault(struct trace *trace, struct addr_location al; char map_type = 'd'; struct thread_trace *ttrace; + size_t printed = 0; int err = -1; int callchain_ret = 0; thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + if (!thread) + goto out; - if (sample->callchain) { - callchain_ret = trace__resolve_callchain(trace, evsel, sample, &callchain_cursor); + ttrace = thread__trace(thread, trace->output); + if (ttrace == NULL) + goto out_put; + + if (!ttrace->pgfault_entry_time && sample->callchain) { + callchain_ret = + trace__resolve_callchain(trace, evsel, + sample, &callchain_cursor); if (callchain_ret == 0) { if (callchain_cursor.nr < trac
[PATCH 0/2] perf: measure page fault duration in perf trace
Hi, Here are 2 small patches which try to fulfill a point in the perf todo list: * Forward port the page fault tracepoints and use it in 'trace'. http://git.kernel.org/?p=linux/kernel/git/acme/linux.git;a=commitdiff;h=d53b11976093b6d8afeb8181db53aaffc754920d;hp=32ba4abf60ae1b710d22a75725491815de649bc5 There are some questionable points: * With luck I think I found the patch related with the todo item (the link in the todo wiki page is broken); I hope I am not wrong... * In the patch mentioned above, I found only changes related with tracepoints creations and calls; the tracepoints were declared generic (in include/trace/events/kmem.h) but were only called in x86 (arch/x86/mm/fault.c); as in x86, the tracepoint "mm_pagefault_start" looks fairly like "page_fault_user" and "page_fault_kernel", I decided to only create one x86-specific tracepoint: "page_fault_exit"; maybe, you would prefer declaring generic tracepoints; * No option has been added for activating page-fault duration calculation: if the needed tracepoints are available, durations will be printed; maybe, that was not what you were looking for. The patches were generated against tip/perf/core. Alexis. Alexis Berlemont (2): perf, x86-mm: Add exit-fault tracing perf: add page fault duration measures in perf trace arch/x86/include/asm/trace/exceptions.h | 21 +++ arch/x86/mm/fault.c | 1 + tools/perf/builtin-trace.c | 225 3 files changed, 221 insertions(+), 26 deletions(-) -- 2.10.1
[tip:perf/core] perf trace: Implement --delay
Commit-ID: e36b7821a985325dd7074de96deface5c9c6d700 Gitweb: http://git.kernel.org/tip/e36b7821a985325dd7074de96deface5c9c6d700 Author: Alexis Berlemont AuthorDate: Mon, 10 Oct 2016 07:43:28 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 24 Oct 2016 11:07:43 -0300 perf trace: Implement --delay In the perf wiki todo-list[1], there is an entry regarding initial-delay and 'perf trace'; the following small patch tries to fulfill this point. It has been generated against the branch tip/perf/core. It has only been implemented in the "trace__run" case. Ex.: $ sudo strace -- ./perf trace --delay 5 sleep 1 2>&1 ... fcntl(7, F_SETFL, O_RDONLY|O_NONBLOCK) = 0 ioctl(7, PERF_EVENT_IOC_ID, 0x7ffc8fd35718) = 0 ioctl(11, PERF_EVENT_IOC_SET_OUTPUT, 0x7) = 0 fcntl(11, F_SETFL, O_RDONLY|O_NONBLOCK) = 0 ioctl(11, PERF_EVENT_IOC_ID, 0x7ffc8fd35718) = 0 write(6, "\0", 1) = 1 close(6)= 0 nanosleep({0, 500}, NULL) = 0 # DELAY OF 5 MS BEFORE ENABLING THE EVENTS ioctl(3, PERF_EVENT_IOC_ENABLE, 0) = 0 ioctl(4, PERF_EVENT_IOC_ENABLE, 0) = 0 ioctl(5, PERF_EVENT_IOC_ENABLE, 0) = 0 ioctl(7, PERF_EVENT_IOC_ENABLE, 0) = 0 ... [1]: https://perf.wiki.kernel.org/index.php/Todo Signed-off-by: Alexis Berlemont Suggested-and-Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20161010054328.4028-2-alexis.berlem...@gmail.com [ Add entry to the manpage, cut'n'pasted from stat's and record's ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-trace.txt | 5 + tools/perf/builtin-trace.c | 10 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt index 1ab0782..781b019 100644 --- a/tools/perf/Documentation/perf-trace.txt +++ b/tools/perf/Documentation/perf-trace.txt @@ -39,6 +39,11 @@ OPTIONS Prefixing with ! shows all syscalls but the ones specified. You may need to escape it. +-D msecs:: +--delay msecs:: +After starting the program, wait msecs before measuring. This is useful to +filter out the startup phase of the program, which is often very different. + -o:: --output=:: Output file name. diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index c298bd3..0bae454 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2310,12 +2310,17 @@ static int trace__run(struct trace *trace, int argc, const char **argv) if (err < 0) goto out_error_mmap; - if (!target__none(&trace->opts.target)) + if (!target__none(&trace->opts.target) && !trace->opts.initial_delay) perf_evlist__enable(evlist); if (forks) perf_evlist__start_workload(evlist); + if (trace->opts.initial_delay) { + usleep(trace->opts.initial_delay * 1000); + perf_evlist__enable(evlist); + } + trace->multiple_threads = thread_map__pid(evlist->threads, 0) == -1 || evlist->threads->nr > 1 || perf_evlist__first(evlist)->attr.inherit; @@ -2816,6 +2821,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)), OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout, "per thread proc mmap processing timeout in ms"), + OPT_UINTEGER('D', "delay", &trace.opts.initial_delay, +"ms to wait before starting measurement after program " +"start"), OPT_END() }; bool __maybe_unused max_stack_user_set = true;
[tip:perf/core] perf hists browser: Dynamically change verbosity level
Commit-ID: 21e8c81095cdbbde9d2aba8fffc51cb9b5e0eeaa Gitweb: http://git.kernel.org/tip/21e8c81095cdbbde9d2aba8fffc51cb9b5e0eeaa Author: Alexis Berlemont AuthorDate: Wed, 12 Oct 2016 23:48:23 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 24 Oct 2016 11:07:42 -0300 perf hists browser: Dynamically change verbosity level Here is a small patch which tries to fulfill a point in the perf todo list: * Make pressing 'V' multiple times to go on cycling thru various verbosity levels in 'perf top', so that info that is present in 'perf top -v' can be obtained without having to restart the tool (acme). After a small grep in the code, the max verbosity level seems 3; so, we cycle at 4; I did not dare define a MAX_VERBOSE_LEVEL constant. Signed-off-by: Alexis Berlemont Suggested-and-Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20161012214823.14324-2-alexis.berlem...@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/hists.c | 5 - tools/perf/util/map.c | 17 - 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 31d6d5a..ddc4c3e 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -2807,7 +2807,10 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, do_zoom_dso(browser, actions); continue; case 'V': - browser->show_dso = !browser->show_dso; + verbose = (verbose + 1) % 4; + browser->show_dso = verbose > 0; + ui_helpline__fpush("Verbosity level set to %d\n", + verbose); continue; case 't': actions->thread = thread; diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index c662fef..4f9a71c 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -682,9 +682,16 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp continue; if (verbose >= 2) { - fputs("overlapping maps:\n", fp); - map__fprintf(map, fp); - map__fprintf(pos, fp); + + if (use_browser) { + pr_warning("overlapping maps in %s " + "(disable tui for more info)\n", + map->dso->name); + } else { + fputs("overlapping maps:\n", fp); + map__fprintf(map, fp); + map__fprintf(pos, fp); + } } rb_erase_init(&pos->rb_node, root); @@ -702,7 +709,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp before->end = map->start; __map_groups__insert(pos->groups, before); - if (verbose >= 2) + if (verbose >= 2 && !use_browser) map__fprintf(before, fp); map__put(before); } @@ -717,7 +724,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp after->start = map->end; __map_groups__insert(pos->groups, after); - if (verbose >= 2) + if (verbose >= 2 && !use_browser) map__fprintf(after, fp); map__put(after); }
[PATCH] perf: dynamically change verbosity level in perf top
Signed-off-by: Alexis Berlemont --- tools/perf/ui/browsers/hists.c | 5 - tools/perf/util/map.c | 17 - 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index fb8e42c..6016909 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -2806,7 +2806,10 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, do_zoom_dso(browser, actions); continue; case 'V': - browser->show_dso = !browser->show_dso; + verbose = (verbose + 1) % 4; + browser->show_dso = verbose > 0; + ui_helpline__fpush("Verbosity level set to %d\n", + verbose); continue; case 't': actions->thread = thread; diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index c662fef..4f9a71c 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -682,9 +682,16 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp continue; if (verbose >= 2) { - fputs("overlapping maps:\n", fp); - map__fprintf(map, fp); - map__fprintf(pos, fp); + + if (use_browser) { + pr_warning("overlapping maps in %s " + "(disable tui for more info)\n", + map->dso->name); + } else { + fputs("overlapping maps:\n", fp); + map__fprintf(map, fp); + map__fprintf(pos, fp); + } } rb_erase_init(&pos->rb_node, root); @@ -702,7 +709,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp before->end = map->start; __map_groups__insert(pos->groups, before); - if (verbose >= 2) + if (verbose >= 2 && !use_browser) map__fprintf(before, fp); map__put(before); } @@ -717,7 +724,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp after->start = map->end; __map_groups__insert(pos->groups, after); - if (verbose >= 2) + if (verbose >= 2 && !use_browser) map__fprintf(after, fp); map__put(after); } -- 2.10.0
[PATCH] perf: dynamically change verbosity level in perf top
Hi, Here is a small patch which tries to fulfill a point in the perf todo list: * Make pressing 'V' multiple times to go on cycling thru various verbosity levels in 'perf top', so that info that is present in 'perf top -v' can be obtained without having to restart the tool (acme). After a small grep in the code, the max verbosity level seems 3; so, we cycle at 4; I did not dare define a MAX_VERBOSE_LEVEL constant. Alexis. Alexis Berlemont (1): perf: dynamically change verbosity level in perf top tools/perf/ui/browsers/hists.c | 5 - tools/perf/util/map.c | 17 - 2 files changed, 16 insertions(+), 6 deletions(-) -- 2.10.0
[PATCH] perf: implement --delay on perf trace
Signed-off-by: Alexis Berlemont --- tools/perf/builtin-trace.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index c298bd3..0bae454 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2310,12 +2310,17 @@ static int trace__run(struct trace *trace, int argc, const char **argv) if (err < 0) goto out_error_mmap; - if (!target__none(&trace->opts.target)) + if (!target__none(&trace->opts.target) && !trace->opts.initial_delay) perf_evlist__enable(evlist); if (forks) perf_evlist__start_workload(evlist); + if (trace->opts.initial_delay) { + usleep(trace->opts.initial_delay * 1000); + perf_evlist__enable(evlist); + } + trace->multiple_threads = thread_map__pid(evlist->threads, 0) == -1 || evlist->threads->nr > 1 || perf_evlist__first(evlist)->attr.inherit; @@ -2816,6 +2821,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)), OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout, "per thread proc mmap processing timeout in ms"), + OPT_UINTEGER('D', "delay", &trace.opts.initial_delay, +"ms to wait before starting measurement after program " +"start"), OPT_END() }; bool __maybe_unused max_stack_user_set = true; -- 2.10.0
[PATCH] Implement --delay on perf trace
Hi, In the perf wiki todo-list, there is an entry regarding initial-delay and perf trace; the following small patch tries to fulfill this point. It has been generated against the branch tip/perf/core. It has only been implemented in the "trace__run" case. Ex.: $ sudo strace -- ./perf trace --delay 5 sleep 1 2>&1 ... fcntl(7, F_SETFL, O_RDONLY|O_NONBLOCK) = 0 ioctl(7, PERF_EVENT_IOC_ID, 0x7ffc8fd35718) = 0 ioctl(11, PERF_EVENT_IOC_SET_OUTPUT, 0x7) = 0 fcntl(11, F_SETFL, O_RDONLY|O_NONBLOCK) = 0 ioctl(11, PERF_EVENT_IOC_ID, 0x7ffc8fd35718) = 0 write(6, "\0", 1) = 1 close(6)= 0 nanosleep({0, 500}, NULL) = 0 # DELAY OF 5 MS BEFORE ENABLING THE EVNTS ioctl(3, PERF_EVENT_IOC_ENABLE, 0) = 0 ioctl(4, PERF_EVENT_IOC_ENABLE, 0) = 0 ioctl(5, PERF_EVENT_IOC_ENABLE, 0) = 0 ioctl(7, PERF_EVENT_IOC_ENABLE, 0) = 0 ... Alexis. Alexis Berlemont (1): perf: implement --delay on perf trace tools/perf/builtin-trace.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.10.0
Re: [PATCH v4 04/14] perf tools: Add kbuild support into Makefile.kbuild
Jiri Olsa wrote: > On Sun, Oct 26, 2014 at 12:20:29AM +0200, Alexis Berlemont wrote: > > From: Jiri Olsa > > SNIP > > > --- > > tools/perf/Kbuild | 47 +++ > > tools/perf/Kconfig | 284 ++ > > tools/perf/Makefile.kbuild | 431 > > + > > tools/perf/Makefile.perf | 2 +- > > tools/perf/arch/Kbuild | 3 + > > tools/perf/arch/arm/Kbuild | 2 + > > tools/perf/arch/arm/Makefile | 14 - > > tools/perf/arch/arm/tests/Kbuild | 2 + > > tools/perf/arch/arm/util/Kbuild| 3 + > > tools/perf/arch/arm64/Kbuild | 1 + > > tools/perf/arch/arm64/Makefile | 7 - > > tools/perf/arch/arm64/util/Kbuild | 2 + > > tools/perf/arch/powerpc/Kbuild | 1 + > > tools/perf/arch/powerpc/Makefile | 6 - > > tools/perf/arch/powerpc/util/Kbuild| 3 + > > tools/perf/arch/s390/Kbuild| 1 + > > tools/perf/arch/s390/Makefile | 7 - > > tools/perf/arch/s390/util/Kbuild | 2 + > > tools/perf/arch/sh/Kbuild | 1 + > > tools/perf/arch/sh/Makefile| 4 - > > tools/perf/arch/sh/util/Kbuild | 1 + > > tools/perf/arch/sparc/Kbuild | 1 + > > tools/perf/arch/sparc/Makefile | 4 - > > tools/perf/arch/sparc/util/Kbuild | 1 + > > tools/perf/arch/x86/Kbuild | 1 + > > tools/perf/arch/x86/tests/Kbuild | 3 + > > tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c | 0 > > tools/perf/arch/x86/util/Kbuild| 5 + > > tools/perf/bench/Kbuild| 12 + > > tools/perf/builtin-cmds.h | 4 + > > tools/perf/config/Makefile | 55 ++- > > tools/perf/config/Makefile.fix-config | 104 + > > tools/perf/config/Makefile.fix-legacy | 46 +++ > > tools/perf/config/defconfig| 54 +++ > > tools/perf/perf-sys.h | 4 +- > > tools/perf/scripts/perl/Perf-Trace-Util/Kbuild | 6 + > > tools/perf/scripts/python/Perf-Trace-Util/Kbuild | 5 + > > tools/perf/tests/Kbuild| 38 ++ > > tools/perf/ui/Kbuild | 15 + > > tools/perf/ui/browsers/Kbuild | 9 + > > tools/perf/ui/gtk/Kbuild | 9 + > > tools/perf/ui/stdio/Kbuild | 1 + > > tools/perf/ui/tui/Kbuild | 4 + > > tools/perf/util/Kbuild | 126 ++ > > tools/perf/util/PERF-VERSION-GEN | 4 + > > tools/perf/util/generate-cmdlist.sh| 8 +- > > tools/perf/util/scripting-engines/Kbuild | 11 + > > tools/perf/util/setup.py | 8 +- > > so this patch took the perf Makefile (at that time) and changed it to > use the kbuild.. but since that time the Makefile.perf came and many > other changes, which need to be reflected in Makefile.kbuild > > I need to revisit the logic and split the change into more incremental > patches (the patchset is too big) > > I can redo patches 2,3,4 and get back to you, sounds ok? Of course. Which changes in Makefile.perf do you have in mind ? I thought that Makefile.kbuild was just supposed to build the few extra dependencies (libtraceevent, etc.). I thought that I updated your original patch accordingly with the changes before and after the add of Makefile.perf. Alexis. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 00/14] Kbuild for perf
Jiri Olsa wrote: > On Sun, Oct 26, 2014 at 12:20:25AM +0200, Alexis Berlemont wrote: > > Hello, > > > > Here is a proposal of perf's build process managed by Kbuild: > > * The file Makefile.perf is replaced by Makefile.kbuild > > * Makefile.kbuild generates a default .config file if none exists > > (allyesconfig) > > * Makefile.kbuild adapts the .config file according to the > > features-check tests results > > * Makefile.kbuild builds external dependencies (linux/tools/lib/*) > > * Makefile.kbuild leaves the rest to Kbuild > > > > Changes since v3: > > * Patchs were generated starting from the following branch: > > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git perf/core > > * Add Kconfig options for 32-bit compatibility VDSOs > > * Target build-test: for each .config-based test case, call "make > >olddefconfig" so as to prevent failure because of new Kconfig > >symbol(s) > > hi, > I tried 'make clean && make' and got attached errors. > I'm running Fedora 20 on x86_64 > OK. I may have an idea. The parameters CONFIG_LIBDWARF_DIR and CONFIG_LIBUNWIND_DIR are empty (default value). So the variable LDFLAGS stored into .config-detected contains things like "-L/lib" and your /lib directory contains 32bit binaries. Could you send me the files .config and .config-detected which were generated during the build? I will send a new patch set. * FYI, so far, I tested the build: * on my archlinux x86_64 system * and with many cross-toolchains (powerpc, arm, etc.) generated by crosstool-ng I should have tested on other distros especially fedora... Sorry. Thank you very much for testing it! Alexis. > jirka > > > --- > BUILD: Doing 'make [33m-j4[m' parallel build > GEN tools/perf/PERF-VERSION-FILE > make[3]: *** No rule to make target `kernelversion'. Stop. > MKDIRlibapi_dirs > CC /home/jolsa/kernel.org/linux-perf/tools/lib/api/fs/fs.o > CC /home/jolsa/kernel.org/linux-perf/tools/lib/api/fs/debugfs.o > CC /home/jolsa/kernel.org/linux-perf/tools/lib/api/fd/array.o > AR libapikfs.a > LD tools/perf/arch/built-in.o > LD tools/perf/built-in.o > LD tools/perf/perf > /bin/ld: skipping incompatible /lib/libpthread.so when searching for -lpthread > /bin/ld: skipping incompatible /lib/libpthread.a when searching for -lpthread > /bin/ld: skipping incompatible /lib/libpthread.so when searching for -lpthread > /bin/ld: skipping incompatible /lib/libpthread.a when searching for -lpthread > /bin/ld: skipping incompatible /lib/librt.so when searching for -lrt > /bin/ld: skipping incompatible /lib/librt.a when searching for -lrt > /bin/ld: skipping incompatible /lib/librt.so when searching for -lrt > /bin/ld: skipping incompatible /lib/librt.a when searching for -lrt > /bin/ld: skipping incompatible /lib/libm.so when searching for -lm > /bin/ld: skipping incompatible /lib/libm.a when searching for -lm > /bin/ld: skipping incompatible /lib/libm.so when searching for -lm > /bin/ld: skipping incompatible /lib/libm.a when searching for -lm > /bin/ld: skipping incompatible /lib/libdl.so when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.a when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.so when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.a when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.so when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.a when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.so when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.a when searching for -ldl > /bin/ld: skipping incompatible /lib/libresolv.so when searching for -lresolv > /bin/ld: skipping incompatible /lib/libresolv.a when searching for -lresolv > /bin/ld: skipping incompatible /lib/libresolv.so when searching for -lresolv > /bin/ld: skipping incompatible /lib/libresolv.a when searching for -lresolv > /bin/ld: skipping incompatible /lib/libnsl.so when searching for -lnsl > /bin/ld: skipping incompatible /lib/libnsl.a when searching for -lnsl > /bin/ld: skipping incompatible /lib/libnsl.so when searching for -lnsl > /bin/ld: skipping incompatible /lib/libnsl.a when searching for -lnsl > /bin/ld: skipping incompatible /lib/libdl.so when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.a when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.so when searching for -ldl > /bin/ld: skipping incompatible /lib/libdl.a when searching for -ldl > /bin/ld: skipping incompatible /lib/libm.so when searching for -lm > /bin/ld: skipping incompatible /lib/libm.a when searching
[PATCH v4 03/14] perf tools: Kbuild source related fixies
From: Jiri Olsa Fixing several sources config dependencies to allow separate config builds. This commit was originally created by Jiri Olsa in 2013. Minor changes were needed to get it working one year later: * Remove #ifdef directives related with GUI / TUI (because of code changes in ui/setup.c) * Fix a link issue if the option BUILTIN_TRACE is disabled. * Fix typo (CONFIG_BULTIN_ instead CONFIG_BUILTIN_) 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- tools/perf/builtin-annotate.c| 6 +++--- tools/perf/builtin-lock.c| 5 - tools/perf/builtin-report.c | 2 +- tools/perf/builtin-sched.c | 3 +++ tools/perf/builtin-top.c | 4 ++-- tools/perf/perf.c| 10 -- tools/perf/ui/browsers/scripts.c | 4 tools/perf/ui/setup.c| 6 +++--- 8 files changed, 28 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 19cb967..a46af8f 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -155,7 +155,7 @@ find_next: /* skip missing symbols */ nd = rb_next(nd); -#ifdef CONFIG_TUI +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) } else if (use_browser == 1) { struct rb_node *next = NULL; key = hist_entry__tui_annotate(he, evsel, NULL); @@ -303,9 +303,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 +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), -#endif /* CONFIG_TUI */ +#endif 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-lock.c b/tools/perf/builtin-lock.c index e7ec715..05c0e1c 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "builtin-cmds.h" #include "perf.h" #include "util/evlist.h" @@ -995,9 +996,11 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) usage_with_options(report_usage, report_options); } rc = __cmd_report(false); +#ifdef CONFIG_BUILTIN_SCRIPT } else if (!strcmp(argv[0], "script")) { /* Aliased to 'perf script' */ - return cmd_script(argc, argv, prefix); + rc = cmd_script(argc, argv, prefix); +#endif } else if (!strcmp(argv[0], "info")) { if (argc) { argc = parse_options(argc, argv, diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 00d93ff..b639e58 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -407,7 +407,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 +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) case 1: ret = perf_evlist__tui_browse_hists(evlist, help, NULL, rep->min_percent, diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 891c393..e38b021 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "builtin-cmds.h" #include "perf.h" #include "util/util.h" @@ -1742,11 +1743,13 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) if (!argc) usage_with_options(sched_usage, sched_options); +#ifdef CONFIG_BUILTIN_SCRIPT /* * Aliased to 'perf script' for now: */ if (!strcmp(argv[0], "script")) return cmd_script(argc, argv, prefix); +#endif if (!strncmp(argv[0], "rec", 3)) { return __cmd_record(argc, argv); diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a2ff8b7..6f04452 100644 --- a/tools/perf/builti
[PATCH v4 05/14] perf kbuild: remove Makefile.perf
The file Makefile.perf contained legacy build rules. It is replaced by Makefile.kbuild which relies on Kbuild. Consequently, some minor points need updates: * The constant CONFIG_KBUILD can be removed * The main Makefile wrapper now call Makefile.kbuild instead of Makefile.perf Signed-off-by: Alexis Berlemont --- tools/perf/Makefile | 2 +- tools/perf/Makefile.kbuild| 2 +- tools/perf/Makefile.perf | 981 -- tools/perf/builtin-annotate.c | 4 +- tools/perf/builtin-cmds.h | 25 -- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 4 +- tools/perf/ui/setup.c | 4 +- 8 files changed, 9 insertions(+), 1015 deletions(-) delete mode 100644 tools/perf/Makefile.perf diff --git a/tools/perf/Makefile b/tools/perf/Makefile index cb2e586..4512f16 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -55,7 +55,7 @@ define print_msg endef define make - @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ + @$(MAKE) -f Makefile.kbuild --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ endef # diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index 51eba07..8d9e8b0 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -43,7 +43,7 @@ export QUIET_BISON QUIET_FLEX ifeq ($(KBUILD_SRC),) -ifeq ("$(origin O)", "command line") +ifneq ($(O),) KBUILD_OUTPUT := $(O) else KBUILD_OUTPUT := $(objtree) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf deleted file mode 100644 index 0e84559..000 --- a/tools/perf/Makefile.perf +++ /dev/null @@ -1,981 +0,0 @@ -include ../scripts/Makefile.include - -# The default target of this Makefile is... -all: - -include config/utilities.mak - -# Define V to have a more verbose compile. -# -# Define VF to have a more verbose feature check output. -# -# Define O to save output files in a separate directory. -# -# Define ARCH as name of target architecture if you want cross-builds. -# -# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds. -# -# Define NO_LIBPERL to disable perl script extension. -# -# Define NO_LIBPYTHON to disable python script extension. -# -# Define PYTHON to point to the python binary if the default -# `python' is not correct; for example: PYTHON=python2 -# -# Define PYTHON_CONFIG to point to the python-config binary if -# the default `$(PYTHON)-config' is not correct. -# -# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8 -# -# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72. -# -# Define LDFLAGS=-static to build a static binary. -# -# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds. -# -# Define NO_DWARF if you do not want debug-info analysis feature at all. -# -# Define WERROR=0 to disable treating any warnings as errors. -# -# Define NO_NEWT if you do not want TUI support. (deprecated) -# -# Define NO_SLANG if you do not want TUI support. -# -# Define NO_GTK2 if you do not want GTK+ GUI support. -# -# Define NO_DEMANGLE if you do not want C++ symbol demangling. -# -# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) -# -# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf -# backtrace post unwind. -# -# Define NO_BACKTRACE if you do not want stack backtrace debug feature -# -# Define NO_LIBNUMA if you do not want numa perf benchmark -# -# Define NO_LIBAUDIT if you do not want libaudit support -# -# Define NO_LIBBIONIC if you do not want bionic support -# -# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support -# for dwarf backtrace post unwind. -# -# Define NO_PERF_READ_VDSO32 if you do not want to build perf-read-vdso32 -# for reading the 32-bit compatibility VDSO in 64-bit mode -# -# Define NO_PERF_READ_VDSOX32 if you do not want to build perf-read-vdsox32 -# for reading the x32 mode 32-bit compatibility VDSO in 64-bit mode - -ifeq ($(srctree),) -srctree := $(patsubst %/,%,$(dir $(shell pwd))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -#$(info Determined 'srctree' to be $(srctree)) -endif - -ifneq ($(objtree),) -#$(info Determined 'objtree' to be $(objtree)) -endif - -ifneq ($(OUTPUT),) -#$(info Determined 'OUTPUT' to be $(OUTPUT)) -endif - -$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD - @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) - @touch $(OUTPUT)PERF-VERSION-FILE - -CC = $(CROSS_COMPILE)gcc -AR = $(CROSS_COMPILE)ar -PKG_CONFIG = $(CROSS_COMPILE)pkg-config - -RM = rm -f -LN = ln -f -MKDIR = mkdir -FIND= find -INSTALL = install -FLEX= flex -BISON = bison -STRIP = strip - -LIB_DIR = $(srctree)/tools/lib/api/ -TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ - -# include config/Makefile by default and rule out -# non-config cases -config := 1 - -NON_CONFIG_TARGETS := clean TAG
[PATCH v4 13/14] perf kbuild: final cosmetic changes
* Correctly rename internal makefile variables * Remove makefiles in tools/perf/config which became empty and useless * Remove builtin-cmds.h * Remove arch/x86/Makefile * Improve outputs of clean and install targets * Remove creation of PERF-FEATURES file which is redundant with the .config file generated by Kconfig. * replace HAVE_KVM_STAT_SUPPORT by a Kconfig option * replace HAVE_SKIP_CALLCHAIN_IDX by a Kconfig option * add Kconfig options for 32-bit compatibility VDSOs Signed-off-by: Alexis Berlemont --- Changes since v3: * Add Kconfig options for 32-bit compatibility VDSOs tools/perf/Kconfig| 29 - tools/perf/Makefile.kbuild| 76 ++-- tools/perf/arch/s390/util/Kbuild | 2 +- tools/perf/arch/x86/Makefile | 17 -- tools/perf/arch/x86/util/Kbuild | 2 +- tools/perf/builtin-cmds.h | 6 -- tools/perf/builtin-help.c | 2 +- tools/perf/builtin-kvm.c | 6 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-sched.c| 2 +- tools/perf/config/Makefile| 108 +++--- tools/perf/config/Makefile.fix-config | 6 -- tools/perf/config/Makefile.fix-legacy | 2 - tools/perf/perf.c | 2 +- tools/perf/util/vdso.c| 5 +- 15 files changed, 115 insertions(+), 152 deletions(-) delete mode 100644 tools/perf/arch/x86/Makefile delete mode 100644 tools/perf/builtin-cmds.h delete mode 100644 tools/perf/config/Makefile.fix-config delete mode 100644 tools/perf/config/Makefile.fix-legacy diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 54a194d..83f3d6d 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -5,9 +5,9 @@ config TARGET_ARCH string option env="ARCH" -config TARGET_IS_X86_64 +config TARGET_IS_64_BIT string - option env="IS_X86_64" + option env="IS_64_BIT" config TARGET_CROSS_COMPILE string @@ -19,7 +19,7 @@ config ARCH config X86_64 bool - default y if TARGET_ARCH = "x86" && TARGET_IS_X86_64 = "1" + default y if TARGET_ARCH = "x86" && TARGET_IS_64_BIT = "1" config CROSS_COMPILE string @@ -128,6 +128,13 @@ config BUILTIN_KVM ---help--- Tool to trace/measure kvm guest os +config BUILTIN_KVM_STAT + bool "kvm-stat" + default y + depends on BUILTIN_KVM && (ARCH = "x86" || ARCH = "s390") +---help--- + Get performance counter statistics on a kvm guest os. + config BUILTIN_LIST bool "list" default y @@ -405,6 +412,22 @@ config PERF_REGS Cache register accesses for unwind processing to speed-up performances. +config READ_VDSO32 + bool "Support 32-bit compatibility" + depends on TARGET_IS_64_BIT = "1" + default y +---help--- + On 64-bits architecture, support 32-bit compatibility VDSOs + +config READ_VDSOX32 + bool "Support x32 compatibility" + depends on X86_64 + default y +---help--- + On x86_64 architecture, support x32 compatibility VDSOs + (code for x86_64 architecture but "long" and pointer types + set to 32 bits) + endmenu menu "Build" diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index b48fe7f..84b7c01 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -1,6 +1,5 @@ srctree := $(abspath $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)/../../)) objtree := $(abspath $(if $(KBUILD_SRC),$(CURDIR),$(CURDIR)/../..)) - VPATH := $(srctree) export srctree VPATH @@ -36,7 +35,8 @@ export quiet Q KBUILD_VERBOSE ifndef V QUIET_LINK = @echo ' LD $@'; QUIET_GEN = @echo ' GEN $@'; -QUIET_CLEAN = @echo ' CLEAN tools/perf'; +QUIET_CLEAN = @printf ' CLEAN%s\n' $1; +QUIET_INSTALL = @printf ' INSTALL %s\n' $1; endif export QUIET_BISON QUIET_FLEX @@ -127,7 +127,7 @@ export CONFIG_DETECTED # arch-related main variables include $(src-perf)/config/Makefile.arch -export ARCH IS_X86_64 CROSS_COMPILE +export ARCH IS_X86_64 IS_64_BIT CROSS_COMPILE # external .a libs LIBTRACEEVENT := $(obj-kernel)/tools/lib/traceevent/libtraceevent.a @@ -158,7 +158,6 @@ $(CONFIG_DETECTED): $(KCONFIG_CONFIG) # no need to include auto.conf.cmd, because .config # is the only dependency here $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) $(CONFIG_DETECTED) - $(Q)$(MAKE) -f $(src-perf)/config/Makefile.fix-config $(Q)mkdir -p $(obj-perf)/include/config $(Q)mkdir -p $(obj-perf)/include/generated $(Q)$(MAKE) -s $(build)=scripts/kconfig silentoldconfig @@ -167,22 +166,26 @@ $(KCONFIG_AUTOCONFIG): $(KCON
[PATCH v4 06/14] perf kbuild: remove legacy tui/gui-related build variables
Remove NO_SLANG (replaced by CONFIG_LIBSLANG) Remove HAVE_SLANG_SUPPORT from CFLAGS (replaced by CONFIG_LIBSLANG) Remove NO_GTK2 (replaced by CONFIG_LIBGTK2 or CONFIG_GTK2) Remove HAVE_GTK2_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2) Remove HAVE_GTK_INFO_BAR_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2_INFOBAR) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 21 + tools/perf/config/Makefile| 20 ++-- tools/perf/config/Makefile.fix-config | 24 tools/perf/config/Makefile.fix-legacy | 8 tools/perf/ui/gtk/browser.c | 4 +++- tools/perf/ui/gtk/gtk.h | 5 +++-- tools/perf/ui/gtk/util.c | 6 -- tools/perf/ui/setup.c | 4 +++- tools/perf/ui/ui.h| 4 +++- tools/perf/util/annotate.h| 4 +++- tools/perf/util/hist.h| 3 ++- 11 files changed, 48 insertions(+), 55 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index f9fcf9e..eb59567 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -171,6 +171,7 @@ config STDIO config TUI bool "Tui (slang based)" + depends on LIBSLANG default y ---help--- Text-based user interface which provides windowing @@ -179,6 +180,7 @@ config TUI config GTK2 bool "Gtk2" default y + depends on LIBGTK2 ---help--- Elaborate display mode based on libgtk2. @@ -186,12 +188,31 @@ endmenu menu "Libraries / Dependencies" +config LIBSLANG + bool "Slang (libslang)" + default y +---help--- + libslang + config LIBAUDIT bool "Audit (libaudit)" default y ---help--- Linux audit framework dependency. +config LIBGTK2 + bool "Gtk2 (libgtk2)" + default y +---help--- + libgtk2 + +config LIBGTK2_INFOBAR + bool "Gtk2 infobar (libgtk2)" + depends on LIBGTK2 + default y +---help--- + libgtk2-infobar + config LIBPERL bool "Perl" default y diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index d5fec7c..e41c9de 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -447,32 +447,26 @@ ifndef NO_LIBAUDIT endif endif -ifdef NO_NEWT - NO_SLANG=1 -endif - -ifndef NO_SLANG +ifdef CONFIG_LIBSLANG ifneq ($(feature-libslang), 1) -msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); -NO_SLANG := 1 +msg := $(warning slang not found, disables SLANG and TUI supports. Please install slang-devel or libslang-dev); +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBSLANG) else # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h CFLAGS += -I/usr/include/slang -CFLAGS += -DHAVE_SLANG_SUPPORT EXTLIBS += -lslang endif endif -ifndef NO_GTK2 +ifdef CONFIG_LIBGTK2 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) ifneq ($(feature-gtk2), 1) msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); -NO_GTK2 := 1 +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2) else ifeq ($(feature-gtk2-infobar), 1) - GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2_INFOBAR) endif -CFLAGS += -DHAVE_GTK2_SUPPORT GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null) GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null) EXTLIBS += -ldl @@ -828,8 +822,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_NEWT) - $(call store,NO_GTK2) $(call store,NO_DEMANGLE) $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) diff --git a/tools/perf/config/Makefile.fix-config b/tools/perf/config/Makefile.fix-config index 7f65fdb..3d84008 100644 --- a/tools/perf/config/Makefile.fix-config +++ b/tools/perf/config/Makefile.fix-config @@ -19,30 +19,6 @@ dummy := $(shell $(CONFIG) -d CONFIG_LIBPYTHON) endif endif -# NO_NEWT -ifdef CONFIG_TUI -ifdef NO_NEWT -dummy := $(info Disabling CONFIG_TUI) -dummy := $(shell $(CONFIG) -d CONFIG_TUI) -endif -endif - -# NO_NEWT -ifdef CONFIG_TUI -ifdef NO_SLANG -dummy := $(info Disabling CONFIG_TUI) -dummy := $(shell $(CONFIG) -d CONFIG_TUI) -endif -endif - -# NO_GTK2 -ifdef CONFIG_GTK2 -ifdef NO_GTK2 -dummy := $(info Disabling CONFIG_GTK2) -dummy := $(shell $(CONFIG) -d CONFIG_GTK2) -endif -endif - # NO_DEMANGLE ifdef CONFIG_DEMANGLE ifdef NO_DEMANGLE diff --git a/tools/perf/config/Makefile.fix-legacy b/tools/perf/config/Makefile.fix-legacy index 2ec91f3..ca219e7 100644 --- a/tools/
[PATCH v4 08/14] perf kbuild: cross-compilation variables are now handled in Kconfig
The variable CONFIG_ARCH and CONFIG_CROSS_COMPILE were added. Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig | 24 tools/perf/Makefile.kbuild | 8 tools/perf/arch/x86/include/perf_regs.h | 8 +--- tools/perf/arch/x86/tests/regs_load.S | 3 ++- tools/perf/arch/x86/util/unwind-libunwind.c | 5 +++-- tools/perf/bench/mem-memcpy-arch.h | 4 +++- tools/perf/bench/mem-memcpy.c | 4 +++- tools/perf/bench/mem-memset-arch.h | 4 +++- tools/perf/bench/mem-memset.c | 4 +++- tools/perf/config/Makefile | 7 ++- 10 files changed, 52 insertions(+), 19 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 026ef67..5f85923 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -1,6 +1,30 @@ mainmenu "The perf configuration" +config TARGET_ARCH + string + option env="ARCH" + +config TARGET_IS_X86_64 + string + option env="IS_X86_64" + +config TARGET_CROSS_COMPILE + string + option env="CROSS_COMPILE" + +config ARCH + string + default TARGET_ARCH + +config X86_64 + bool + default y if TARGET_ARCH = "x86" && TARGET_IS_X86_64 = "1" + +config CROSS_COMPILE + string + default TARGET_CROSS_COMPILE + menu "Built-in commands" config BUILTIN_RECORD diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index 8d9e8b0..b48fe7f 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -123,9 +123,12 @@ export KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG KCONFIG_SCRIPT # perf detected config CONFIG_DETECTED := $(obj-perf)/.config-detected - export CONFIG_DETECTED +# arch-related main variables +include $(src-perf)/config/Makefile.arch +export ARCH IS_X86_64 CROSS_COMPILE + # external .a libs LIBTRACEEVENT := $(obj-kernel)/tools/lib/traceevent/libtraceevent.a LIBAPIKFS := $(obj-kernel)/tools/lib/api/libapikfs.a @@ -202,9 +205,6 @@ ifndef dont-detect ifdef CONFIG_DETECTED_STORED # Following variables are needed within Kbuild files, we need # to export them as they are not part of the .config set. -export CONFIG_ARCH := $(ARCH) -export CROSS_COMPILE -export CONFIG_X86_64 export htmldir_SQ export infodir_SQ export mandir_SQ diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h index 7df517a..d969cca 100644 --- a/tools/perf/arch/x86/include/perf_regs.h +++ b/tools/perf/arch/x86/include/perf_regs.h @@ -5,9 +5,11 @@ #include #include +#include "generated/autoconf.h" + void perf_regs_load(u64 *regs); -#ifndef HAVE_ARCH_X86_64_SUPPORT +#ifndef CONFIG_X86_64 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) #define PERF_REGS_MAX PERF_REG_X86_32_MAX #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32 @@ -58,7 +60,7 @@ static inline const char *perf_reg_name(int id) return "FS"; case PERF_REG_X86_GS: return "GS"; -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 case PERF_REG_X86_R8: return "R8"; case PERF_REG_X86_R9: @@ -75,7 +77,7 @@ static inline const char *perf_reg_name(int id) return "R14"; case PERF_REG_X86_R15: return "R15"; -#endif /* HAVE_ARCH_X86_64_SUPPORT */ +#endif /* CONFIG_X86_64 */ default: return NULL; } diff --git a/tools/perf/arch/x86/tests/regs_load.S b/tools/perf/arch/x86/tests/regs_load.S index 60875d5..822a797 100644 --- a/tools/perf/arch/x86/tests/regs_load.S +++ b/tools/perf/arch/x86/tests/regs_load.S @@ -1,4 +1,5 @@ #include +#include "generated/autoconf.h" #define AX 0 #define BX 1 * 8 @@ -26,7 +27,7 @@ #define R1523 * 8 .text -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 ENTRY(perf_regs_load) movq %rax, AX(%rdi) movq %rbx, BX(%rdi) diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c index db25e93..e4960c1 100644 --- a/tools/perf/arch/x86/util/unwind-libunwind.c +++ b/tools/perf/arch/x86/util/unwind-libunwind.c @@ -1,11 +1,12 @@ #include #include +#include "generated/autoconf.h" #include "perf_regs.h" #include "../../util/unwind.h" #include "../../util/debug.h" -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 int libunwind__arch_reg_id(int regnum) { int id; @@ -109,4 +110,4 @@ int libunwind__arch_reg_id(int regnum) return id; } -#endif /* HAVE_ARCH_X86_64_SUPPORT */ +#endif /* CONFIG_X86_64 */ diff --git a/tools/perf/bench/mem-memcpy-arch.h b/tools/perf/bench/mem-memcpy-arch.h index 57b4ed8..8e3f0a9 100644 --- a/tools/perf/bench/mem-memc
[PATCH v4 10/14] perf kbuild: remove legacy libelf-related build variables
Remove NO_LIBELF (replaced by CONFIG_LIBELF) Remove HAVE_LIBELF_SUPPORT (replaced by CONFIG_LIBELF) Remove HAVE_LIBELF_MMAP_SUPPORT (replaced by CONFIG_LIBELF_MMAP) Remove HAVE_LIBELF_GETPHDRNUM__SUPPORT (replaced by CONFIG_LIBELF_GETPHDRNUM_) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 23 ++ tools/perf/builtin-inject.c | 2 +- tools/perf/config/Makefile| 37 +++ tools/perf/config/Makefile.fix-config | 18 - tools/perf/config/Makefile.fix-legacy | 4 tools/perf/perf.c | 2 +- tools/perf/util/generate-cmdlist.sh | 4 ++-- tools/perf/util/map.c | 3 ++- tools/perf/util/symbol-elf.c | 3 ++- tools/perf/util/symbol.h | 8 10 files changed, 51 insertions(+), 53 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 29853a6..2eaf3ca 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -256,6 +256,7 @@ config TIMERFD Timer via file descriptor config DEMANGLE + depends on LIBELF bool "Demangle symbols" default y ---help--- @@ -298,7 +299,29 @@ choice Builtin elf support. endchoice +config LIBELF_MMAP +depends on LIBELF + bool "Libelf mmap support" + default y +---help--- + libdelf mmap + +config LIBELF_GETPHDRNUM +depends on LIBELF + default y + bool "Libelf getphdrnum support" +---help--- + libdelf mmap + +config LIBDWARF + depends on LIBELF + bool "Dwarf (libdwarf)" + default y +---help--- + libdwarf + config LIBUNWIND +depends on LIBELF bool "User space libunwind callchains" default y ---help--- diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 06f1758..cb19ccc 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -229,7 +229,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, * account this as unresolved. */ } else { -#ifdef HAVE_LIBELF_SUPPORT +#ifdef CONFIG_LIBELF pr_warning("no symbols found in %s, maybe " "install a debug package?\n", al.map->dso->long_name); diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 15bd90b..19dab72 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -305,12 +305,7 @@ ifdef CONFIG_BIONIC endif endif -ifdef NO_LIBELF - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 - NO_LIBDW_DWARF_UNWIND := 1 -else +ifdef CONFIG_LIBELF ifeq ($(feature-libelf), 0) ifeq ($(feature-glibc), 1) LIBC_SUPPORT := 1 @@ -320,12 +315,9 @@ else endif ifeq ($(LIBC_SUPPORT),1) msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); - - NO_LIBELF := 1 - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 - NO_LIBDW_DWARF_UNWIND := 1 + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF) + $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBELF_MINIMAL) + EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) else ifneq ($(filter s% -static%,$(LDFLAGS),),) msg := $(error No static glibc found, please install glibc-static); @@ -334,6 +326,7 @@ else endif endif else +LIBELF = 1 ifndef NO_LIBDW_DWARF_UNWIND ifneq ($(feature-libdw-dwarf-unwind),1) NO_LIBDW_DWARF_UNWIND := 1 @@ -345,17 +338,20 @@ else NO_DWARF := 1 endif # Dwarf support endif # libelf support -endif # NO_LIBELF +endif # CONFIG_LIBELF -ifndef NO_LIBELF - CFLAGS += -DHAVE_LIBELF_SUPPORT +ifeq ($(LIBELF), 1) - ifeq ($(feature-libelf-mmap), 1) -CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT + ifdef CONFIG_LIBELF_MMAP +ifneq ($(feature-libelf-mmap), 1) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP) +endif endif - ifeq ($(feature-libelf-getphdrnum), 1) -CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT + ifdef CONFIG_LIBELF_MMAP +ifneq ($(feature-libelf-getphdrnum), 1) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP) +endif endif # include ARCH specific config @@ -371,7 +367,7 @@ ifndef NO_LIBELF EXTLIBS += -lelf -ldw endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF -endif # NO_LIBELF +endif # LIBELF ifeq ($(ARCH),powerpc) ifndef NO_DWARF @@ -814,7 +810,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) $(call store,NO_LIBBIONIC) $(call store,ETC_
[PATCH v4 12/14] perf kbuild: remove legacy script-related build variables
Remove NO_LIBPERL (replaced by CONFIG_LIBPERL) Remove NO_LIBPYTHON (replaced by CONFIG_LIBPYTHON) Signed-off-by: Alexis Berlemont --- tools/perf/builtin-script.c | 6 +++-- tools/perf/config/Makefile | 41 + tools/perf/config/Makefile.fix-config | 16 - tools/perf/config/Makefile.fix-legacy | 8 --- tools/perf/util/trace-event-scripting.c | 13 ++- 5 files changed, 22 insertions(+), 62 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index ce304df..2d077c1 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1,3 +1,5 @@ +#include "generated/autoconf.h" + #include "builtin.h" #include "perf.h" @@ -1370,11 +1372,11 @@ int find_scripts(char **scripts_array, char **scripts_path_array) for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, lang_dirent.d_name); -#ifdef NO_LIBPERL +#ifndef CONFIG_LIBPERL if (strstr(lang_path, "perl")) continue; #endif -#ifdef NO_LIBPYTHON +#ifndef CONFIG_LIBPYTHON if (strstr(lang_path, "python")) continue; #endif diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index fe375da..b628fa9 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -101,7 +101,7 @@ ifdef PARSER_DEBUG CFLAGS += -DPARSER_DEBUG endif -ifndef NO_LIBPYTHON +ifdef CONFIG_LIBPYTHON # Try different combinations to accommodate systems that only have # python[2][-config] in weird combinations but always preferring # python2 and python2-config as per pep-0394. If we catch a @@ -462,9 +462,7 @@ endif grep-libs = $(filter -l%,$(1)) strip-libs = $(filter-out -l%,$(1)) -ifdef NO_LIBPERL - CFLAGS += -DNO_LIBPERL -else +ifdef CONFIG_LIBPERL PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) @@ -472,9 +470,8 @@ else FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1) -CFLAGS += -DNO_LIBPERL -NO_LIBPERL := 1 msg := $(warning Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed); +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPERL) else LDFLAGS += $(PERL_EMBED_LDFLAGS) EXTLIBS += $(PERL_EMBED_LIBADD) @@ -488,17 +485,14 @@ ifdef CONFIG_TIMERFD endif endif -disable-python = $(eval $(disable-python_code)) -define disable-python_code - CFLAGS += -DNO_LIBPYTHON - $(if $(1),$(warning No $(1) was found)) - $(warning Python support will not be built) - NO_LIBPYTHON := 1 -endef +ifdef CONFIG_LIBPYTHON -ifdef NO_LIBPYTHON - $(call disable-python) -else + disable-python = $(eval $(disable-python_code)) + define disable-python_code +$(if $(1),$(warning No $(1) was found)) +$(warning Python support will not be built) +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPYTHON) + endef ifndef PYTHON $(call disable-python,python interpreter) @@ -522,18 +516,7 @@ else else ifneq ($(feature-libpython-version), 1) - $(warning Python 3 is not yet supported; please set) - $(warning PYTHON and/or PYTHON_CONFIG appropriately.) - $(warning If you also have Python 2 installed, then) - $(warning try something like:) - $(warning $(and ,)) - $(warning $(and ,) make PYTHON=python2) - $(warning $(and ,)) - $(warning Otherwise, disable Python support entirely:) - $(warning $(and ,)) - $(warning $(and ,) make NO_LIBPYTHON=1) - $(warning $(and ,)) - $(error $(and ,)) + $(call disable-python,python2 interpreter) else LDFLAGS += $(PYTHON_EMBED_LDFLAGS) EXTLIBS += $(PYTHON_EMBED_LIBADD) @@ -808,8 +791,6 @@ all: $(call store,PYTHON_EMBED_CCOPTS) $(call store,PERL_EMBED_CCOPTS) $(call store,NO_LIBUNWIND) - $(call store,NO_LIBPERL) - $(call store,NO_LIBPYTHON) $(call store,ETC_PERFCONFIG_SQ) $(call store,DESTDIR_SQ) $(call store,bindir_SQ) diff --git a/tools/perf/config/Makefile.fix-config b/tools/perf/config/Makefile.fix-config index e63539f..3f0e33e 100644 --- a/tools/perf/config/Makefile.fix-config +++ b/tools/perf/config/Makefile.fix-config @@ -3,20 +3,4 @@ include $(KCONFIG_CONFIG) CONFIG := $(srctree)/scripts/config --file $(KCONFIG_CONFIG) -# NO_LIBPERL -ifdef CONFIG_LIBPERL -ifdef NO_LIBPERL -dummy := $(info Disabling CONFIG_LIBPERL) -dummy := $(shell $(CONFIG) -d CONFIG_LIBPERL) -endif -endif - -# NO_LIBPYTHON -ifdef CONFIG_LIBPYTHON -ifdef NO_LIBPYTHON
[PATCH v4 07/14] perf kbuild: remove legacy demangle-related build variables
Remove NO_DEMANGLE (replaced by CONFIG_DEMANGLE) Remove HAVE_LIBBFD_SUPPORT (replaced by CONFIG_LIBBFD) Remove HAVE_CPLUS_DEMANGLE_SUPPORT (replaced by CONFIG_LIBIBERTY_ONLY) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 36 +-- tools/perf/config/Makefile| 46 ++- tools/perf/config/Makefile.fix-legacy | 4 --- tools/perf/util/srcline.c | 8 +++--- tools/perf/util/symbol.h | 25 +-- 5 files changed, 75 insertions(+), 44 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index eb59567..026ef67 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -225,6 +225,35 @@ config LIBPYTHON ---help--- Libpython dependency needed by the perf script feature. +config TIMERFD + bool "Timer via file descriptor" + default y +---help--- + Timer via file descriptor + +config DEMANGLE + bool "Demangle symbols" + default y +---help--- + Enable demangling so as to display human-readable + symbols. This option is convenient with C++ programs. + +choice DEMANGLE_DEPS + prompt "Demangle dependency(ies)" + depends on DEMANGLE + default LIBBFD + +config LIBBFD + bool "BFD + libiberty libraries" +---help--- + Binary File Descriptor and libiberty libraries + +config LIBIBERTY_ONLY + bool "Libiberty only" +---help--- + Libiberty +endchoice + choice prompt "Elf library" default LIBELF @@ -266,13 +295,6 @@ config NUMA The library libnuma offers facilities to configure NUMA policies supported by the linux kernel. -config DEMANGLE - bool "Demangle symbols" - default y ----help--- - Enable demangling so as to display human-readable - symbols. This option is convenient with C++ programs. - config BIONIC bool "Bionic support" default n diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index e41c9de..0e36bbe 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -575,33 +575,36 @@ ifeq ($(feature-libbfd), 1) endif endif -ifdef NO_DEMANGLE - CFLAGS += -DNO_DEMANGLE -else - ifdef HAVE_CPLUS_DEMANGLE_SUPPORT -EXTLIBS += -liberty -CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT - else -ifneq ($(feature-libbfd), 1) - ifneq ($(feature-liberty), 1) -ifneq ($(feature-liberty-z), 1) - # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT - # or any of 'bfd iberty z' trinity - ifeq ($(feature-cplus-demangle), 1) -EXTLIBS += -liberty -CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT - else -msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) -CFLAGS += -DNO_DEMANGLE - endif +ifdef CONFIG_LIBBFD + ifneq ($(feature-libbfd), 1) +# TODO: there might be an issue here: feature-liberty and +# feature-liberty-z cannot be set; they can be set only if +# feature-libbfd is set +ifneq ($(feature-liberty), 1) + ifneq ($(feature-liberty-z), 1) +# we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT +# or any of 'bfd iberty z' trinity +ifeq ($(feature-cplus-demangle), 1) + EXTLIBS += -liberty + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBBFD) + $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBIBERTY_ONLY) +else + msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE) endif endif endif endif endif -ifneq ($(filter -lbfd,$(EXTLIBS)),) - CFLAGS += -DHAVE_LIBBFD_SUPPORT +ifdef CONFIG_LIBIBERTY_ONLY + $(call feature_check,cplus-demangle) + ifeq ($(feature-cplus-demangle), 1) +EXTLIBS += -liberty + else +msg := $(warning No libiberty found, install binutils-dev[el]/zlib-static to gain symbol demangling) +$(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE) + endif endif ifndef NO_BACKTRACE @@ -822,7 +825,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_DEMANGLE) $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) $(call store,NO_BACKTRACE) diff --git a/tools/perf/config/Makefile.fix-legacy b/tools/perf/config/Makefile.fix-legacy index ca219e7..64dbb1a 100644 --- a/tools/perf/config/Makefile.fix-legacy +++ b/tools/perf/config/Makefile.fix-legacy @@ -9,10 +9,6 @@ ifndef CONFIG_LIBPYTHON NO_LIBPYTHON := 1 endif -ifndef CONFIG_DEMANGLE -NO_DEMANGLE := 1 -endif - ifndef CONFIG_LIBELF NO_LIBELF := 1 endif diff --git a/tools/perf/util/srcline.c b/tools/per
[PATCH v4 09/14] perf kbuild: remove legacy misc build variables
Remove NO_LIBAUDIT (replaced by CONFIG_LIBAUDIT) Remove HAVE_LIBAUDIT_SUPPORT from CFLAGS (replaced by CONFIG_LIBAUDIT) Remove HAVE_TIMERFD_SUPPORT (replaced by CONFIG_TIMERFD) Remove HAVE_ON_EXIT_SUPPORT (replaced by CONFIG_ON_EXIT) Remove HAVE_BACKTRACE_SUPPORT (replaced by CONFIG_BACKTRACE) Remove HAVE_LIBNUMA_SUPPORT (replaced by CONFIG_LIBNUMA) Remove NO_BIONIC (replaced by CONFIG_BIONIC) Remove NO_PERF_REGS (replaced by CONFIG_PERF_REGS) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 12 -- tools/perf/arch/arm/tests/Kbuild | 2 +- tools/perf/arch/x86/tests/Kbuild | 2 +- tools/perf/bench/Kbuild | 2 +- tools/perf/builtin-bench.c| 5 ++-- tools/perf/builtin-kvm.c | 13 ++- tools/perf/builtin-record.c | 2 ++ tools/perf/config/Makefile| 43 +-- tools/perf/config/Makefile.fix-config | 32 -- tools/perf/config/Makefile.fix-legacy | 16 - tools/perf/util/perf_regs.c | 3 +++ tools/perf/util/perf_regs.h | 6 +++-- tools/perf/util/util.c| 5 ++-- 13 files changed, 51 insertions(+), 92 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 5f85923..29853a6 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -312,8 +312,8 @@ config LIBUNWIND_DIR Directory holding the libuwind dependency (headers + libraries). -config NUMA - bool "Numa support (bench)" +config LIBNUMA + bool "Libnuma support" default y ---help--- The library libnuma offers facilities to configure NUMA @@ -327,6 +327,14 @@ config BIONIC library code developed by Google for their Android operating system. +config PERF_REGS + bool "Cache register accesses" + depends on (ARCH = "x86" || ARCH = "arm" || ARCH = "arm64") + default y +---help--- + Cache register accesses for unwind processing to speed-up + performances. + endmenu menu "Build" diff --git a/tools/perf/arch/arm/tests/Kbuild b/tools/perf/arch/arm/tests/Kbuild index 5d63e9d..1318ed0 100644 --- a/tools/perf/arch/arm/tests/Kbuild +++ b/tools/perf/arch/arm/tests/Kbuild @@ -1,2 +1,2 @@ -obj-y += regs_load.o +obj-$(CONFIG_PERF_REGS) += regs_load.o obj-y += dwarf-unwind.o diff --git a/tools/perf/arch/x86/tests/Kbuild b/tools/perf/arch/x86/tests/Kbuild index 3b5aa14..8287dae 100644 --- a/tools/perf/arch/x86/tests/Kbuild +++ b/tools/perf/arch/x86/tests/Kbuild @@ -1,3 +1,3 @@ obj-y += perf-time-to-tsc.o -obj-y += regs_load.o +obj-$(CONFIG_PERF_REGS) += regs_load.o obj-y += dwarf-unwind.o diff --git a/tools/perf/bench/Kbuild b/tools/perf/bench/Kbuild index e604fe2..863646a 100644 --- a/tools/perf/bench/Kbuild +++ b/tools/perf/bench/Kbuild @@ -6,7 +6,7 @@ obj-y += futex-hash.o obj-y += futex-requeue.o obj-y += futex-wake.o -obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_LIBNUMA) += numa.o obj-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o obj-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index b9a56fa..5116d25 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c @@ -14,6 +14,7 @@ * numa ... NUMA scheduling and MM performance * futex ... Futex performance */ +#include "generated/autoconf.h" #include "perf.h" #include "util/util.h" #include "util/parse-options.h" @@ -33,7 +34,7 @@ struct bench { bench_fn_t fn; }; -#ifdef HAVE_LIBNUMA_SUPPORT +#ifdef CONFIG_LIBNUMA static struct bench numa_benchmarks[] = { { "mem","Benchmark for NUMA workloads", bench_numa }, { "all","Test all NUMA benchmarks", NULL }, @@ -72,7 +73,7 @@ struct collection { static struct collection collections[] = { { "sched", "Scheduler and IPC benchmarks", sched_benchmarks}, { "mem","Memory access benchmarks", mem_benchmarks }, -#ifdef HAVE_LIBNUMA_SUPPORT +#ifdef CONFIG_LIBNUMA { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks }, #endif {"futex", "Futex stressing benchmarks", futex_benchmarks}, diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index e042728..19a1d17 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1,3 +1,4 @@ +#include "generated/autoconf.h" #include "builtin.h" #include "perf.h" @@ -20,7 +21,7 @@ #include "util/data.h" #include -#ifdef
[PATCH v4 11/14] perf kbuild: remove legacy libdwarf-related build variables
* Remove NO_DWARF (replaced by CONFIG_LIBDWARF) * Remove HAVE_DWARF_SUPPORT (replaced by CONFIG_LIBDWARF) * Remove the useless variable PERF_HAVE_DWARF_REGS * fix compilation issues if PERF_REGS is disabled Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig | 59 +- tools/perf/arch/arm/tests/Kbuild | 2 +- tools/perf/arch/arm/util/Kbuild | 4 +- tools/perf/arch/arm64/util/Kbuild| 2 +- tools/perf/arch/powerpc/util/Kbuild | 4 +- tools/perf/arch/s390/util/Kbuild | 2 +- tools/perf/arch/sh/util/Kbuild | 2 +- tools/perf/arch/sparc/util/Kbuild| 2 +- tools/perf/arch/x86/Kbuild | 1 + tools/perf/arch/x86/Makefile | 8 +- tools/perf/arch/x86/tests/Kbuild | 2 +- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 2 +- tools/perf/arch/x86/util/Kbuild | 3 +- tools/perf/builtin-probe.c | 15 +-- tools/perf/builtin-record.c | 2 +- tools/perf/config/Makefile | 170 +-- tools/perf/config/Makefile.fix-config| 8 -- tools/perf/config/Makefile.fix-legacy| 4 - tools/perf/tests/Kbuild | 2 + tools/perf/tests/builtin-test.c | 3 +- tools/perf/tests/tests.h | 6 +- tools/perf/util/Kbuild | 11 +- tools/perf/util/callchain.c | 11 +- tools/perf/util/callchain.h | 3 +- tools/perf/util/include/dwarf-regs.h | 4 +- tools/perf/util/machine.c| 3 +- tools/perf/util/perf_regs.c | 2 - tools/perf/util/probe-event.c| 6 +- tools/perf/util/probe-finder.h | 5 +- tools/perf/util/unwind-libunwind.c | 5 +- tools/perf/util/unwind.h | 7 +- 31 files changed, 203 insertions(+), 157 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 2eaf3ca..54a194d 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -287,7 +287,6 @@ choice these tasks, perf can rely on either the libelf library or a minimal builtin support. - config LIBELF bool "elf" ---help--- @@ -318,15 +317,51 @@ config LIBDWARF bool "Dwarf (libdwarf)" default y ---help--- - libdwarf + A library for parsing DWARF debug information. + +config LIBDWARF_DIR + string "libdwarf directory" + depends on LIBDWARF +---help--- + Directory holding the libdwarf dependency (headers + + libraries) + +config UNWIND +depends on (LIBELF && PERF_REGS) + bool "User space unwind callchains" + default y +---help--- + Enable call-chain unwinding of user-space application. + +choice UNWIND_DEPS + prompt "Unwind dependency" + depends on UNWIND + default LIBUNWIND config LIBUNWIND -depends on LIBELF - bool "User space libunwind callchains" +depends on (LIBELF && PERF_REGS) + bool "Libunwind" +---help--- + Rely on libunwind post unwind support to determine the + call-chain of a user-space program. The library libunwind + supports all the architectures. + +config LIBDWARF_UNWIND +depends on (LIBDWARF && PERF_REGS && (ARCH = "x86" || ARCH = "arm")) + bool "Libdwarf unwind" +---help--- + Rely on lidw DWARF post unwind support to determine the + call-chain of a user-space program. So far there's only x86 + and arm libdw unwind support merged in perf. + +endchoice + +config LIBUNWIND_DEBUG_FRAME +depends on LIBUNWIND + bool "libunwind debug frame" default y ---help--- - The library libunwind provides a portable C API to determine - the call-chain of a program. + libunwind debug frame config LIBUNWIND_DIR string "libunwind directory" @@ -335,6 +370,18 @@ config LIBUNWIND_DIR Directory holding the libuwind dependency (headers + libraries). +config SKIP_CALLCHAIN_IDX + depends on (LIBDWARF && ARCH = "powerpc") + bool "Skip unnecessary callchain entries thanks to Dwarf" + default y +---help--- + When saving the callchain on Power, the kernel + conservatively saves excess entries in the callchain. A few + of these entries are needed in some cases but not others. If + the unnecessary entries are not ignored, we end up with + duplicate arcs in the call-graphs. Use DWARF debug + information to skip over any unnecessary callchain e
[PATCH v4 14/14] perf kbuild: add generated Kconfig build-test cases
Thanks to the python module kconfiglib, we were able to generate build configurations. The set is, of course, not exhaustive but for each option, all the possible states are tested. If, during development step, a new symbol is added into the Kconfig file, the target build-test will not fail (olddefconfig is called so that new parameters are filled with their default value). Signed-off-by: Alexis Berlemont --- Changes since v3: * Target build-test: for each .config-based test case, call "make olddefconfig" so as to prevent failure because of new Kconfig symbol(s) tools/perf/MANIFEST| 1 + tools/perf/tests/configs/MINIMAL_config| 60 ++ tools/perf/tests/configs/NO_BACKTRACE_config | 73 ++ .../perf/tests/configs/NO_BUILTIN_ANNOTATE_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_BENCH_config | 73 ++ .../tests/configs/NO_BUILTIN_BUILDID_CACHE_config | 73 ++ .../tests/configs/NO_BUILTIN_BUILDID_LIST_config | 71 + tools/perf/tests/configs/NO_BUILTIN_DIFF_config| 71 + tools/perf/tests/configs/NO_BUILTIN_EVLIST_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_HELP_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_INJECT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_KMEM_config| 73 ++ .../perf/tests/configs/NO_BUILTIN_KVM_STAT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_KVM_config | 72 + tools/perf/tests/configs/NO_BUILTIN_LIST_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_LOCK_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_MEM_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_PROBE_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_RECORD_config | 63 +++ tools/perf/tests/configs/NO_BUILTIN_REPORT_config | 68 tools/perf/tests/configs/NO_BUILTIN_SCHED_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_SCRIPT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_STAT_config| 71 + tools/perf/tests/configs/NO_BUILTIN_TEST_config| 73 ++ .../perf/tests/configs/NO_BUILTIN_TIMECHART_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_TOP_config | 71 + tools/perf/tests/configs/NO_BUILTIN_TRACE_config | 73 ++ tools/perf/tests/configs/NO_DEMANGLE_config| 71 + tools/perf/tests/configs/NO_GTK2_config| 73 ++ tools/perf/tests/configs/NO_LIBAUDIT_config| 72 + tools/perf/tests/configs/NO_LIBDWARF_config| 71 + tools/perf/tests/configs/NO_LIBELF_MMAP_config | 73 ++ tools/perf/tests/configs/NO_LIBGTK2_INFOBAR_config | 73 ++ tools/perf/tests/configs/NO_LIBGTK2_config | 71 + tools/perf/tests/configs/NO_LIBNUMA_config | 73 ++ tools/perf/tests/configs/NO_LIBPERL_config | 73 ++ tools/perf/tests/configs/NO_LIBPYTHON_config | 73 ++ tools/perf/tests/configs/NO_LIBSLANG_config| 72 + .../tests/configs/NO_LIBUNWIND_DEBUG_FRAME_config | 73 ++ tools/perf/tests/configs/NO_PERF_REGS_config | 73 ++ tools/perf/tests/configs/NO_STDIO_config | 73 ++ tools/perf/tests/configs/NO_TIMERFD_config | 73 ++ tools/perf/tests/configs/NO_TUI_config | 73 ++ tools/perf/tests/configs/NO_UNWIND_config | 69 tools/perf/tests/configs/REF_config| 73 ++ tools/perf/tests/generate_configs.py | 43 + tools/perf/tests/make | 70 ++--- 47 files changed, 3227 insertions(+), 50 deletions(-) create mode 100644 tools/perf/tests/configs/MINIMAL_config create mode 100644 tools/perf/tests/configs/NO_BACKTRACE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_ANNOTATE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BENCH_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_CACHE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_LIST_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_DIFF_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_EVLIST_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_HELP_config create mode 100644
[PATCH v4 04/14] perf tools: Add kbuild support into Makefile.kbuild
From: Jiri Olsa Adding kbuild support into Makefile.kbuild. The 'legacy' Makefile still stays untouched as it was. It's possible to use kbuild by running 'make -f Makefile.kbuild' with any option supported by 'legacy' Makefile. We now have 2 config files: '.config' - user configured setup '.config-detected' - system detected setup The '.config-detected' affects '.config' and if there's configured feature in '.config' which was not detected it is automatically disabled. The '.config-detected' is re/created if: - there's no '.config-detected' - '.config' was changed In a cleaned tree the perf is built with 'allyesconfig' having disabled all non-detected features, just as it is done now. You can change '.config' via: make -f Makefile.kbuild menuconfig There's difference for O=DIR build. The DIR is populated based on kernel source tree, so the final binary is created under DIR/tools/perf. This commit was originally created by Jiri Olsa in February 2013; a few changes were necessary to fit the perf version of June 2014: * Add missing CFLAGS for specific .o targets * Update Kbuild files (new source files, ...) * Fix recursive invocation of config/features-checks * Store .config-detected missing variables (libdir, ...) * Fix missing dependencies between Kconfig options * Fix installation of traceevent plugins * Fix missing cleanings of feature-check binaries * CROSS_COMPILE was not used to define AS, CC, ... * CROSS_COMPILE was not stored in .config-detected * Take into account DESTDIR and prefix set in the command line * Add missing Kbuild files for non-x86 architectures (powerpc, arm, arm64, sh, s390, sparc) * Move perf-time-to-tsc.c into x86-specific tests directory 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- tools/perf/Kbuild | 47 +++ tools/perf/Kconfig | 284 ++ tools/perf/Makefile.kbuild | 431 + tools/perf/Makefile.perf | 2 +- tools/perf/arch/Kbuild | 3 + tools/perf/arch/arm/Kbuild | 2 + tools/perf/arch/arm/Makefile | 14 - tools/perf/arch/arm/tests/Kbuild | 2 + tools/perf/arch/arm/util/Kbuild| 3 + tools/perf/arch/arm64/Kbuild | 1 + tools/perf/arch/arm64/Makefile | 7 - tools/perf/arch/arm64/util/Kbuild | 2 + tools/perf/arch/powerpc/Kbuild | 1 + tools/perf/arch/powerpc/Makefile | 6 - tools/perf/arch/powerpc/util/Kbuild| 3 + tools/perf/arch/s390/Kbuild| 1 + tools/perf/arch/s390/Makefile | 7 - tools/perf/arch/s390/util/Kbuild | 2 + tools/perf/arch/sh/Kbuild | 1 + tools/perf/arch/sh/Makefile| 4 - tools/perf/arch/sh/util/Kbuild | 1 + tools/perf/arch/sparc/Kbuild | 1 + tools/perf/arch/sparc/Makefile | 4 - tools/perf/arch/sparc/util/Kbuild | 1 + tools/perf/arch/x86/Kbuild | 1 + tools/perf/arch/x86/tests/Kbuild | 3 + tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c | 0 tools/perf/arch/x86/util/Kbuild| 5 + tools/perf/bench/Kbuild| 12 + tools/perf/builtin-cmds.h | 4 + tools/perf/config/Makefile | 55 ++- tools/perf/config/Makefile.fix-config | 104 + tools/perf/config/Makefile.fix-legacy | 46 +++ tools/perf/config/defconfig| 54 +++ tools/perf/perf-sys.h | 4 +- tools/perf/scripts/perl/Perf-Trace-Util/Kbuild | 6 + tools/perf/scripts/python/Perf-Trace-Util/Kbuild | 5 + tools/perf/tests/Kbuild| 38 ++ tools/perf/ui/Kbuild | 15 + tools/perf/ui/browsers/Kbuild | 9 + tools/perf/ui/gtk/Kbuild | 9 + tools/perf/ui/stdio/Kbuild | 1 + tools/perf/ui/tui/Kbuild | 4 + tools/perf/util/Kbuild | 126 ++ tools/perf/util/PERF-VERSION-GEN | 4 + tools/perf/util/generate-cmdlist.sh| 8 +- tools/pe
[PATCH v4 02/14] perf tools: Kbuild builtin source related fixies
From: Jiri Olsa Adding CONFIG_BUILTIN_* defines to govern builtin commands. This will be useful 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- 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 e7417fe..19cb967 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" @@ -115,7 +116,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) { @@ -154,7 +155,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: @@ -173,6 +176,7 @@ find_next: if (next != NULL) nd = next; +#endif /* CONFIG_TUI */ } else { hist_entry__tty_annotate(he, evsel, ann); nd = rb_next(nd); @@ -299,7 +303,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 000..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 25d2062..fbbbaa4 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 3c0f3d4..e042728 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1556,20 +1556,25 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused) if (!strncmp(argv[0], "rec", 3))
[PATCH v4 01/14] kbuild: add support of custom paths for "auto.conf*" files
In the scripts/Makefile.build, use KCONFIG_AUTOCONFIG to include a custom path for the "auto.conf" file. The "*conf" programs were modified so as to work with the environment variable KCONFIG_AUTOCONFIG. Signed-off-by: Alexis Berlemont --- scripts/Makefile.build | 3 ++- scripts/kconfig/confdata.c | 23 ++- scripts/kconfig/lkc.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 649ce68..2abb82f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -31,7 +31,8 @@ subdir-asflags-y := subdir-ccflags-y := # Read auto.conf if it exists, otherwise ignore --include include/config/auto.conf +kconfig-autoconfig := $(if $(KCONFIG_AUTOCONFIG),$(KCONFIG_AUTOCONFIG),include/config/auto.conf) +-include $(kconfig-autoconfig) include scripts/Kbuild.include diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f88d90f..75cf6bf 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -75,6 +75,23 @@ const char *conf_get_autoconfig_name(void) return name ? name : "include/config/auto.conf"; } +const char *conf_get_autoconfigdep_name(void) +{ + static char res_value[PATH_MAX+1]; + + const char *name = conf_get_autoconfig_name(); + + if (strlen(name) > PATH_MAX - 4) + name = NULL; + else { + strcpy(res_value, name); + strcat(res_value, ".cmd"); + name = res_value; + } + + return name; +} + static char *conf_expand_value(const char *in) { struct symbol *sym; @@ -953,7 +970,11 @@ int conf_write_autoconf(void) sym_clear_all_valid(); - file_write_dep("include/config/auto.conf.cmd"); + name = conf_get_autoconfigdep_name(); + if (name == NULL) + return 1; + + file_write_dep(name); if (conf_split_config()) return 1; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index d5daa7a..ac99004 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -84,6 +84,7 @@ const char *zconf_curname(void); /* confdata.c */ const char *conf_get_configname(void); const char *conf_get_autoconfig_name(void); +const char *conf_get_autoconfigdep_name(void); char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); -- 2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v4 00/14] Kbuild for perf
Hello, Here is a proposal of perf's build process managed by Kbuild: * The file Makefile.perf is replaced by Makefile.kbuild * Makefile.kbuild generates a default .config file if none exists (allyesconfig) * Makefile.kbuild adapts the .config file according to the features-check tests results * Makefile.kbuild builds external dependencies (linux/tools/lib/*) * Makefile.kbuild leaves the rest to Kbuild Changes since v3: * Patchs were generated starting from the following branch: git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git perf/core * Add Kconfig options for 32-bit compatibility VDSOs * Target build-test: for each .config-based test case, call "make olddefconfig" so as to prevent failure because of new Kconfig symbol(s) Regards, Alexis. Alexis Berlemont (11): kbuild: add support of custom paths for "auto.conf*" files perf kbuild: remove Makefile.perf perf kbuild: remove legacy tui/gui-related build variables perf kbuild: remove legacy demangle-related build variables perf kbuild: cross-compilation variables are now handled in Kconfig perf kbuild: remove legacy misc build variables perf kbuild: remove legacy libelf-related build variables perf kbuild: remove legacy libdwarf-related build variables perf kbuild: remove legacy script-related build variables perf kbuild: final cosmetic changes perf kbuild: add generated Kconfig build-test cases Jiri Olsa (3): perf tools: Kbuild builtin source related fixies perf tools: Kbuild source related fixies perf tools: Add kbuild support into Makefile.kbuild scripts/Makefile.build | 3 +- scripts/kconfig/confdata.c | 23 +- scripts/kconfig/lkc.h | 1 + tools/perf/Kbuild | 47 + tools/perf/Kconfig | 452 ++ tools/perf/MANIFEST| 1 + tools/perf/Makefile| 2 +- tools/perf/Makefile.kbuild | 443 ++ tools/perf/Makefile.perf | 981 - tools/perf/arch/Kbuild | 3 + tools/perf/arch/arm/Kbuild | 2 + tools/perf/arch/arm/Makefile | 14 - tools/perf/arch/arm/tests/Kbuild | 2 + tools/perf/arch/arm/util/Kbuild| 3 + tools/perf/arch/arm64/Kbuild | 1 + tools/perf/arch/arm64/Makefile | 7 - tools/perf/arch/arm64/util/Kbuild | 2 + tools/perf/arch/powerpc/Kbuild | 1 + tools/perf/arch/powerpc/Makefile | 6 - tools/perf/arch/powerpc/util/Kbuild| 3 + tools/perf/arch/s390/Kbuild| 1 + tools/perf/arch/s390/Makefile | 7 - tools/perf/arch/s390/util/Kbuild | 2 + tools/perf/arch/sh/Kbuild | 1 + tools/perf/arch/sh/Makefile| 4 - tools/perf/arch/sh/util/Kbuild | 1 + tools/perf/arch/sparc/Kbuild | 1 + tools/perf/arch/sparc/Makefile | 4 - tools/perf/arch/sparc/util/Kbuild | 1 + tools/perf/arch/x86/Kbuild | 2 + tools/perf/arch/x86/Makefile | 19 - tools/perf/arch/x86/include/perf_regs.h| 8 +- tools/perf/arch/x86/tests/Kbuild | 3 + tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c | 2 +- tools/perf/arch/x86/tests/regs_load.S | 3 +- tools/perf/arch/x86/util/Kbuild| 6 + tools/perf/arch/x86/util/unwind-libunwind.c| 5 +- tools/perf/bench/Kbuild| 12 + tools/perf/bench/mem-memcpy-arch.h | 4 +- tools/perf/bench/mem-memcpy.c | 4 +- tools/perf/bench/mem-memset-arch.h | 4 +- tools/perf/bench/mem-memset.c | 4 +- tools/perf/builtin-annotate.c | 8 +- tools/perf/builtin-bench.c | 5 +- tools/perf/builtin-help.c | 1 + tools/perf/builtin-inject.c| 2 +- tools/perf/builtin-kvm.c | 38 +- tools/perf/builtin-lock.c | 5 +- tools/perf/builtin-probe.c | 15 +- tools/perf/builtin-record.c| 4 +- tools/perf/builtin-report.c| 3 + tools/perf/builtin-sched.c | 3 + tools/perf/builtin-script.c| 6 +- tools/perf/builtin-top.c | 19 +- tools/perf/config/Makefile | 459 +-
Re: [PATCH v3 00/14] Kbuild for perf
Arnaldo Carvalho de Melo wrote: > Em Fri, Oct 24, 2014 at 12:28:08AM +0200, Alexis Berlemont escreveu: > > Hello, > > > > Here is a proposal of perf's build process managed by Kbuild: > > * The file Makefile.perf is replaced by Makefile.kbuild > > * Makefile.kbuild generates a default .config file if none exists > > (allyesconfig) > > * Makefile.kbuild adapts the .config file according to the > > features-check tests results > > * Makefile.kbuild builds external dependencies (linux/tools/lib/*) > > * Makefile.kbuild leaves the rest to Kbuild > > > > Regards, > > Thanks for working on this! > > What was the branch this was made against? > I used Linus Torvalds' master branch: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Do you want me to use another branch ? Alexis. > > Alexis. > > > > Alexis Berlemont (11): > > kbuild: add support of custom paths for "auto.conf*" files > > perf kbuild: remove Makefile.perf > > perf kbuild: remove legacy tui/gui-related build variables > > perf kbuild: remove legacy demangle-related build variables > > perf kbuild: cross-compilation variables are now handled in Kconfig > > perf kbuild: remove legacy misc build variables > > perf kbuild: remove legacy libelf-related build variables > > perf kbuild: remove legacy libdwarf-related build variables > > perf kbuild: remove legacy script-related build variables > > perf kbuild: final cosmetic changes > > perf kbuild: add generated Kconfig build-test cases > > > > Jiri Olsa (3): > > perf tools: Kbuild builtin source related fixies > > perf tools: Kbuild source related fixies > > perf tools: Add kbuild support into Makefile.kbuild > > > > scripts/Makefile.build | 3 +- > > scripts/kconfig/confdata.c | 23 +- > > scripts/kconfig/lkc.h | 1 + > > tools/perf/Kbuild | 47 + > > tools/perf/Kconfig | 436 ++ > > tools/perf/MANIFEST| 1 + > > tools/perf/Makefile| 2 +- > > tools/perf/Makefile.kbuild | 443 ++ > > tools/perf/Makefile.perf | 949 > > - > > tools/perf/arch/Kbuild | 3 + > > tools/perf/arch/arm/Kbuild | 2 + > > tools/perf/arch/arm/Makefile | 14 - > > tools/perf/arch/arm/tests/Kbuild | 2 + > > tools/perf/arch/arm/util/Kbuild| 3 + > > tools/perf/arch/arm64/Kbuild | 1 + > > tools/perf/arch/arm64/Makefile | 7 - > > tools/perf/arch/arm64/util/Kbuild | 2 + > > tools/perf/arch/powerpc/Kbuild | 1 + > > tools/perf/arch/powerpc/Makefile | 6 - > > tools/perf/arch/powerpc/util/Kbuild| 3 + > > tools/perf/arch/s390/Kbuild| 1 + > > tools/perf/arch/s390/Makefile | 7 - > > tools/perf/arch/s390/util/Kbuild | 2 + > > tools/perf/arch/sh/Kbuild | 1 + > > tools/perf/arch/sh/Makefile| 4 - > > tools/perf/arch/sh/util/Kbuild | 1 + > > tools/perf/arch/sparc/Kbuild | 1 + > > tools/perf/arch/sparc/Makefile | 4 - > > tools/perf/arch/sparc/util/Kbuild | 1 + > > tools/perf/arch/x86/Kbuild | 2 + > > tools/perf/arch/x86/Makefile | 19 - > > tools/perf/arch/x86/include/perf_regs.h| 8 +- > > tools/perf/arch/x86/tests/Kbuild | 3 + > > tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c | 2 +- > > tools/perf/arch/x86/tests/regs_load.S | 3 +- > > tools/perf/arch/x86/util/Kbuild| 6 + > > tools/perf/arch/x86/util/unwind-libunwind.c| 5 +- > > tools/perf/bench/Kbuild| 12 + > > tools/perf/bench/mem-memcpy-arch.h | 4 +- > > tools/perf/bench/mem-memcpy.c | 4 +- > > tools/perf/bench/mem-memset-arch.h | 4 +- > > tools/perf/bench/mem-memset.c | 4 +- > > tools/perf/builtin-annotate.c
[PATCH v3 08/14] perf kbuild: cross-compilation variables are now handled in Kconfig
The variable CONFIG_ARCH and CONFIG_CROSS_COMPILE were added. Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig | 24 tools/perf/Makefile.kbuild | 8 tools/perf/arch/x86/include/perf_regs.h | 8 +--- tools/perf/arch/x86/tests/regs_load.S | 3 ++- tools/perf/arch/x86/util/unwind-libunwind.c | 5 +++-- tools/perf/bench/mem-memcpy-arch.h | 4 +++- tools/perf/bench/mem-memcpy.c | 4 +++- tools/perf/bench/mem-memset-arch.h | 4 +++- tools/perf/bench/mem-memset.c | 4 +++- tools/perf/config/Makefile | 7 ++- 10 files changed, 52 insertions(+), 19 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 026ef67..5f85923 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -1,6 +1,30 @@ mainmenu "The perf configuration" +config TARGET_ARCH + string + option env="ARCH" + +config TARGET_IS_X86_64 + string + option env="IS_X86_64" + +config TARGET_CROSS_COMPILE + string + option env="CROSS_COMPILE" + +config ARCH + string + default TARGET_ARCH + +config X86_64 + bool + default y if TARGET_ARCH = "x86" && TARGET_IS_X86_64 = "1" + +config CROSS_COMPILE + string + default TARGET_CROSS_COMPILE + menu "Built-in commands" config BUILTIN_RECORD diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index 8d9e8b0..b48fe7f 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -123,9 +123,12 @@ export KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG KCONFIG_SCRIPT # perf detected config CONFIG_DETECTED := $(obj-perf)/.config-detected - export CONFIG_DETECTED +# arch-related main variables +include $(src-perf)/config/Makefile.arch +export ARCH IS_X86_64 CROSS_COMPILE + # external .a libs LIBTRACEEVENT := $(obj-kernel)/tools/lib/traceevent/libtraceevent.a LIBAPIKFS := $(obj-kernel)/tools/lib/api/libapikfs.a @@ -202,9 +205,6 @@ ifndef dont-detect ifdef CONFIG_DETECTED_STORED # Following variables are needed within Kbuild files, we need # to export them as they are not part of the .config set. -export CONFIG_ARCH := $(ARCH) -export CROSS_COMPILE -export CONFIG_X86_64 export htmldir_SQ export infodir_SQ export mandir_SQ diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h index 7df517a..d969cca 100644 --- a/tools/perf/arch/x86/include/perf_regs.h +++ b/tools/perf/arch/x86/include/perf_regs.h @@ -5,9 +5,11 @@ #include #include +#include "generated/autoconf.h" + void perf_regs_load(u64 *regs); -#ifndef HAVE_ARCH_X86_64_SUPPORT +#ifndef CONFIG_X86_64 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) #define PERF_REGS_MAX PERF_REG_X86_32_MAX #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32 @@ -58,7 +60,7 @@ static inline const char *perf_reg_name(int id) return "FS"; case PERF_REG_X86_GS: return "GS"; -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 case PERF_REG_X86_R8: return "R8"; case PERF_REG_X86_R9: @@ -75,7 +77,7 @@ static inline const char *perf_reg_name(int id) return "R14"; case PERF_REG_X86_R15: return "R15"; -#endif /* HAVE_ARCH_X86_64_SUPPORT */ +#endif /* CONFIG_X86_64 */ default: return NULL; } diff --git a/tools/perf/arch/x86/tests/regs_load.S b/tools/perf/arch/x86/tests/regs_load.S index 60875d5..822a797 100644 --- a/tools/perf/arch/x86/tests/regs_load.S +++ b/tools/perf/arch/x86/tests/regs_load.S @@ -1,4 +1,5 @@ #include +#include "generated/autoconf.h" #define AX 0 #define BX 1 * 8 @@ -26,7 +27,7 @@ #define R1523 * 8 .text -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 ENTRY(perf_regs_load) movq %rax, AX(%rdi) movq %rbx, BX(%rdi) diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c index db25e93..e4960c1 100644 --- a/tools/perf/arch/x86/util/unwind-libunwind.c +++ b/tools/perf/arch/x86/util/unwind-libunwind.c @@ -1,11 +1,12 @@ #include #include +#include "generated/autoconf.h" #include "perf_regs.h" #include "../../util/unwind.h" #include "../../util/debug.h" -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 int libunwind__arch_reg_id(int regnum) { int id; @@ -109,4 +110,4 @@ int libunwind__arch_reg_id(int regnum) return id; } -#endif /* HAVE_ARCH_X86_64_SUPPORT */ +#endif /* CONFIG_X86_64 */ diff --git a/tools/perf/bench/mem-memcpy-arch.h b/tools/perf/bench/mem-memcpy-arch.h index 57b4ed8..8e3f0a9 100644 --- a/tools/perf/bench/mem-memc
[PATCH v3 06/14] perf kbuild: remove legacy tui/gui-related build variables
Remove NO_SLANG (replaced by CONFIG_LIBSLANG) Remove HAVE_SLANG_SUPPORT from CFLAGS (replaced by CONFIG_LIBSLANG) Remove NO_GTK2 (replaced by CONFIG_LIBGTK2 or CONFIG_GTK2) Remove HAVE_GTK2_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2) Remove HAVE_GTK_INFO_BAR_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2_INFOBAR) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 21 + tools/perf/config/Makefile| 20 ++-- tools/perf/config/Makefile.fix-config | 24 tools/perf/config/Makefile.fix-legacy | 8 tools/perf/ui/gtk/browser.c | 4 +++- tools/perf/ui/gtk/gtk.h | 5 +++-- tools/perf/ui/gtk/util.c | 6 -- tools/perf/ui/setup.c | 4 +++- tools/perf/ui/ui.h| 4 +++- tools/perf/util/annotate.h| 4 +++- tools/perf/util/hist.h| 3 ++- 11 files changed, 48 insertions(+), 55 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index f9fcf9e..eb59567 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -171,6 +171,7 @@ config STDIO config TUI bool "Tui (slang based)" + depends on LIBSLANG default y ---help--- Text-based user interface which provides windowing @@ -179,6 +180,7 @@ config TUI config GTK2 bool "Gtk2" default y + depends on LIBGTK2 ---help--- Elaborate display mode based on libgtk2. @@ -186,12 +188,31 @@ endmenu menu "Libraries / Dependencies" +config LIBSLANG + bool "Slang (libslang)" + default y +---help--- + libslang + config LIBAUDIT bool "Audit (libaudit)" default y ---help--- Linux audit framework dependency. +config LIBGTK2 + bool "Gtk2 (libgtk2)" + default y +---help--- + libgtk2 + +config LIBGTK2_INFOBAR + bool "Gtk2 infobar (libgtk2)" + depends on LIBGTK2 + default y +---help--- + libgtk2-infobar + config LIBPERL bool "Perl" default y diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 6106e24..27b092c 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -445,32 +445,26 @@ ifndef NO_LIBAUDIT endif endif -ifdef NO_NEWT - NO_SLANG=1 -endif - -ifndef NO_SLANG +ifdef CONFIG_LIBSLANG ifneq ($(feature-libslang), 1) -msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); -NO_SLANG := 1 +msg := $(warning slang not found, disables SLANG and TUI supports. Please install slang-devel or libslang-dev); +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBSLANG) else # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h CFLAGS += -I/usr/include/slang -CFLAGS += -DHAVE_SLANG_SUPPORT EXTLIBS += -lslang endif endif -ifndef NO_GTK2 +ifdef CONFIG_LIBGTK2 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) ifneq ($(feature-gtk2), 1) msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); -NO_GTK2 := 1 +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2) else ifeq ($(feature-gtk2-infobar), 1) - GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2_INFOBAR) endif -CFLAGS += -DHAVE_GTK2_SUPPORT GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null) GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null) EXTLIBS += -ldl @@ -801,8 +795,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_NEWT) - $(call store,NO_GTK2) $(call store,NO_DEMANGLE) $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) diff --git a/tools/perf/config/Makefile.fix-config b/tools/perf/config/Makefile.fix-config index 7f65fdb..3d84008 100644 --- a/tools/perf/config/Makefile.fix-config +++ b/tools/perf/config/Makefile.fix-config @@ -19,30 +19,6 @@ dummy := $(shell $(CONFIG) -d CONFIG_LIBPYTHON) endif endif -# NO_NEWT -ifdef CONFIG_TUI -ifdef NO_NEWT -dummy := $(info Disabling CONFIG_TUI) -dummy := $(shell $(CONFIG) -d CONFIG_TUI) -endif -endif - -# NO_NEWT -ifdef CONFIG_TUI -ifdef NO_SLANG -dummy := $(info Disabling CONFIG_TUI) -dummy := $(shell $(CONFIG) -d CONFIG_TUI) -endif -endif - -# NO_GTK2 -ifdef CONFIG_GTK2 -ifdef NO_GTK2 -dummy := $(info Disabling CONFIG_GTK2) -dummy := $(shell $(CONFIG) -d CONFIG_GTK2) -endif -endif - # NO_DEMANGLE ifdef CONFIG_DEMANGLE ifdef NO_DEMANGLE diff --git a/tools/perf/config/Makefile.fix-legacy b/tools/perf/config/Makefile.fix-legacy index 2ec91f3..ca219e7 100644 --- a/tools/
[PATCH v3 05/14] perf kbuild: remove Makefile.perf
The file Makefile.perf contained legacy build rules. It is replaced by Makefile.kbuild which relies on Kbuild. Consequently, some minor points need updates: * The constant CONFIG_KBUILD can be removed * The main Makefile wrapper now call Makefile.kbuild instead of Makefile.perf Signed-off-by: Alexis Berlemont --- tools/perf/Makefile | 2 +- tools/perf/Makefile.kbuild| 2 +- tools/perf/Makefile.perf | 949 -- tools/perf/builtin-annotate.c | 4 +- tools/perf/builtin-cmds.h | 25 -- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 4 +- tools/perf/ui/setup.c | 4 +- 8 files changed, 9 insertions(+), 983 deletions(-) delete mode 100644 tools/perf/Makefile.perf diff --git a/tools/perf/Makefile b/tools/perf/Makefile index cb2e586..4512f16 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -55,7 +55,7 @@ define print_msg endef define make - @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ + @$(MAKE) -f Makefile.kbuild --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ endef # diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index 51eba07..8d9e8b0 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -43,7 +43,7 @@ export QUIET_BISON QUIET_FLEX ifeq ($(KBUILD_SRC),) -ifeq ("$(origin O)", "command line") +ifneq ($(O),) KBUILD_OUTPUT := $(O) else KBUILD_OUTPUT := $(objtree) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf deleted file mode 100644 index dcf6248..000 --- a/tools/perf/Makefile.perf +++ /dev/null @@ -1,949 +0,0 @@ -include ../scripts/Makefile.include - -# The default target of this Makefile is... -all: - -include config/utilities.mak - -# Define V to have a more verbose compile. -# -# Define VF to have a more verbose feature check output. -# -# Define O to save output files in a separate directory. -# -# Define ARCH as name of target architecture if you want cross-builds. -# -# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds. -# -# Define NO_LIBPERL to disable perl script extension. -# -# Define NO_LIBPYTHON to disable python script extension. -# -# Define PYTHON to point to the python binary if the default -# `python' is not correct; for example: PYTHON=python2 -# -# Define PYTHON_CONFIG to point to the python-config binary if -# the default `$(PYTHON)-config' is not correct. -# -# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8 -# -# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72. -# -# Define LDFLAGS=-static to build a static binary. -# -# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds. -# -# Define NO_DWARF if you do not want debug-info analysis feature at all. -# -# Define WERROR=0 to disable treating any warnings as errors. -# -# Define NO_NEWT if you do not want TUI support. (deprecated) -# -# Define NO_SLANG if you do not want TUI support. -# -# Define NO_GTK2 if you do not want GTK+ GUI support. -# -# Define NO_DEMANGLE if you do not want C++ symbol demangling. -# -# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) -# -# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf -# backtrace post unwind. -# -# Define NO_BACKTRACE if you do not want stack backtrace debug feature -# -# Define NO_LIBNUMA if you do not want numa perf benchmark -# -# Define NO_LIBAUDIT if you do not want libaudit support -# -# Define NO_LIBBIONIC if you do not want bionic support -# -# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support -# for dwarf backtrace post unwind. - -ifeq ($(srctree),) -srctree := $(patsubst %/,%,$(dir $(shell pwd))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -#$(info Determined 'srctree' to be $(srctree)) -endif - -ifneq ($(objtree),) -#$(info Determined 'objtree' to be $(objtree)) -endif - -ifneq ($(OUTPUT),) -#$(info Determined 'OUTPUT' to be $(OUTPUT)) -endif - -$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD - @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) - @touch $(OUTPUT)PERF-VERSION-FILE - -CC = $(CROSS_COMPILE)gcc -AR = $(CROSS_COMPILE)ar -PKG_CONFIG = $(CROSS_COMPILE)pkg-config - -RM = rm -f -LN = ln -f -MKDIR = mkdir -FIND= find -INSTALL = install -FLEX= flex -BISON = bison -STRIP = strip - -LIB_DIR = $(srctree)/tools/lib/api/ -TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ - -# include config/Makefile by default and rule out -# non-config cases -config := 1 - -NON_CONFIG_TARGETS := clean TAGS tags cscope help - -ifdef MAKECMDGOALS -ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),) - config := 0 -endif -endif - -ifeq ($(config),1) -include config/Makefile -endif - -export prefix bindir sharedir sysconfdir DESTDIR - -# sparse is architecture-neutral, which mean
[PATCH v3 04/14] perf tools: Add kbuild support into Makefile.kbuild
From: Jiri Olsa Adding kbuild support into Makefile.kbuild. The 'legacy' Makefile still stays untouched as it was. It's possible to use kbuild by running 'make -f Makefile.kbuild' with any option supported by 'legacy' Makefile. We now have 2 config files: '.config' - user configured setup '.config-detected' - system detected setup The '.config-detected' affects '.config' and if there's configured feature in '.config' which was not detected it is automatically disabled. The '.config-detected' is re/created if: - there's no '.config-detected' - '.config' was changed In a cleaned tree the perf is built with 'allyesconfig' having disabled all non-detected features, just as it is done now. You can change '.config' via: make -f Makefile.kbuild menuconfig There's difference for O=DIR build. The DIR is populated based on kernel source tree, so the final binary is created under DIR/tools/perf. This commit was originally created by Jiri Olsa in February 2013; a few changes were necessary to fit the perf version of June 2014: * Add missing CFLAGS for specific .o targets * Update Kbuild files (new source files, ...) * Fix recursive invocation of config/features-checks * Store .config-detected missing variables (libdir, ...) * Fix missing dependencies between Kconfig options * Fix installation of traceevent plugins * Fix missing cleanings of feature-check binaries * CROSS_COMPILE was not used to define AS, CC, ... * CROSS_COMPILE was not stored in .config-detected * Take into account DESTDIR and prefix set in the command line * Add missing Kbuild files for non-x86 architectures (powerpc, arm, arm64, sh, s390, sparc) * Move perf-time-to-tsc.c into x86-specific tests directory 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- tools/perf/Kbuild | 47 +++ tools/perf/Kconfig | 284 ++ tools/perf/Makefile.kbuild | 431 + tools/perf/Makefile.perf | 2 +- tools/perf/arch/Kbuild | 3 + tools/perf/arch/arm/Kbuild | 2 + tools/perf/arch/arm/Makefile | 14 - tools/perf/arch/arm/tests/Kbuild | 2 + tools/perf/arch/arm/util/Kbuild| 3 + tools/perf/arch/arm64/Kbuild | 1 + tools/perf/arch/arm64/Makefile | 7 - tools/perf/arch/arm64/util/Kbuild | 2 + tools/perf/arch/powerpc/Kbuild | 1 + tools/perf/arch/powerpc/Makefile | 6 - tools/perf/arch/powerpc/util/Kbuild| 3 + tools/perf/arch/s390/Kbuild| 1 + tools/perf/arch/s390/Makefile | 7 - tools/perf/arch/s390/util/Kbuild | 2 + tools/perf/arch/sh/Kbuild | 1 + tools/perf/arch/sh/Makefile| 4 - tools/perf/arch/sh/util/Kbuild | 1 + tools/perf/arch/sparc/Kbuild | 1 + tools/perf/arch/sparc/Makefile | 4 - tools/perf/arch/sparc/util/Kbuild | 1 + tools/perf/arch/x86/Kbuild | 1 + tools/perf/arch/x86/tests/Kbuild | 3 + tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c | 0 tools/perf/arch/x86/util/Kbuild| 5 + tools/perf/bench/Kbuild| 12 + tools/perf/builtin-cmds.h | 4 + tools/perf/config/Makefile | 55 ++- tools/perf/config/Makefile.fix-config | 104 + tools/perf/config/Makefile.fix-legacy | 46 +++ tools/perf/config/defconfig| 54 +++ tools/perf/perf-sys.h | 4 +- tools/perf/scripts/perl/Perf-Trace-Util/Kbuild | 6 + tools/perf/scripts/python/Perf-Trace-Util/Kbuild | 5 + tools/perf/tests/Kbuild| 38 ++ tools/perf/ui/Kbuild | 15 + tools/perf/ui/browsers/Kbuild | 9 + tools/perf/ui/gtk/Kbuild | 9 + tools/perf/ui/stdio/Kbuild | 1 + tools/perf/ui/tui/Kbuild | 4 + tools/perf/util/Kbuild | 125 ++ tools/perf/util/PERF-VERSION-GEN | 4 + tools/perf/util/generate-cmdlist.sh| 8 +- tools/pe
[PATCH v3 09/14] perf kbuild: remove legacy misc build variables
Remove NO_LIBAUDIT (replaced by CONFIG_LIBAUDIT) Remove HAVE_LIBAUDIT_SUPPORT from CFLAGS (replaced by CONFIG_LIBAUDIT) Remove HAVE_TIMERFD_SUPPORT (replaced by CONFIG_TIMERFD) Remove HAVE_ON_EXIT_SUPPORT (replaced by CONFIG_ON_EXIT) Remove HAVE_BACKTRACE_SUPPORT (replaced by CONFIG_BACKTRACE) Remove HAVE_LIBNUMA_SUPPORT (replaced by CONFIG_LIBNUMA) Remove NO_BIONIC (replaced by CONFIG_BIONIC) Remove NO_PERF_REGS (replaced by CONFIG_PERF_REGS) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 12 -- tools/perf/arch/arm/tests/Kbuild | 2 +- tools/perf/arch/x86/tests/Kbuild | 2 +- tools/perf/bench/Kbuild | 2 +- tools/perf/builtin-bench.c| 5 ++-- tools/perf/builtin-kvm.c | 13 ++- tools/perf/builtin-record.c | 2 ++ tools/perf/config/Makefile| 43 +-- tools/perf/config/Makefile.fix-config | 32 -- tools/perf/config/Makefile.fix-legacy | 16 - tools/perf/util/perf_regs.c | 3 +++ tools/perf/util/perf_regs.h | 6 +++-- tools/perf/util/util.c| 5 ++-- 13 files changed, 51 insertions(+), 92 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 5f85923..29853a6 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -312,8 +312,8 @@ config LIBUNWIND_DIR Directory holding the libuwind dependency (headers + libraries). -config NUMA - bool "Numa support (bench)" +config LIBNUMA + bool "Libnuma support" default y ---help--- The library libnuma offers facilities to configure NUMA @@ -327,6 +327,14 @@ config BIONIC library code developed by Google for their Android operating system. +config PERF_REGS + bool "Cache register accesses" + depends on (ARCH = "x86" || ARCH = "arm" || ARCH = "arm64") + default y +---help--- + Cache register accesses for unwind processing to speed-up + performances. + endmenu menu "Build" diff --git a/tools/perf/arch/arm/tests/Kbuild b/tools/perf/arch/arm/tests/Kbuild index 5d63e9d..1318ed0 100644 --- a/tools/perf/arch/arm/tests/Kbuild +++ b/tools/perf/arch/arm/tests/Kbuild @@ -1,2 +1,2 @@ -obj-y += regs_load.o +obj-$(CONFIG_PERF_REGS) += regs_load.o obj-y += dwarf-unwind.o diff --git a/tools/perf/arch/x86/tests/Kbuild b/tools/perf/arch/x86/tests/Kbuild index 3b5aa14..8287dae 100644 --- a/tools/perf/arch/x86/tests/Kbuild +++ b/tools/perf/arch/x86/tests/Kbuild @@ -1,3 +1,3 @@ obj-y += perf-time-to-tsc.o -obj-y += regs_load.o +obj-$(CONFIG_PERF_REGS) += regs_load.o obj-y += dwarf-unwind.o diff --git a/tools/perf/bench/Kbuild b/tools/perf/bench/Kbuild index e604fe2..863646a 100644 --- a/tools/perf/bench/Kbuild +++ b/tools/perf/bench/Kbuild @@ -6,7 +6,7 @@ obj-y += futex-hash.o obj-y += futex-requeue.o obj-y += futex-wake.o -obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_LIBNUMA) += numa.o obj-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o obj-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index b9a56fa..5116d25 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c @@ -14,6 +14,7 @@ * numa ... NUMA scheduling and MM performance * futex ... Futex performance */ +#include "generated/autoconf.h" #include "perf.h" #include "util/util.h" #include "util/parse-options.h" @@ -33,7 +34,7 @@ struct bench { bench_fn_t fn; }; -#ifdef HAVE_LIBNUMA_SUPPORT +#ifdef CONFIG_LIBNUMA static struct bench numa_benchmarks[] = { { "mem","Benchmark for NUMA workloads", bench_numa }, { "all","Test all NUMA benchmarks", NULL }, @@ -72,7 +73,7 @@ struct collection { static struct collection collections[] = { { "sched", "Scheduler and IPC benchmarks", sched_benchmarks}, { "mem","Memory access benchmarks", mem_benchmarks }, -#ifdef HAVE_LIBNUMA_SUPPORT +#ifdef CONFIG_LIBNUMA { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks }, #endif {"futex", "Futex stressing benchmarks", futex_benchmarks}, diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 400e92e..28371f9 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1,3 +1,4 @@ +#include "generated/autoconf.h" #include "builtin.h" #include "perf.h" @@ -20,7 +21,7 @@ #include "util/data.h" #include -#ifdef
[PATCH v3 07/14] perf kbuild: remove legacy demangle-related build variables
Remove NO_DEMANGLE (replaced by CONFIG_DEMANGLE) Remove HAVE_LIBBFD_SUPPORT (replaced by CONFIG_LIBBFD) Remove HAVE_CPLUS_DEMANGLE_SUPPORT (replaced by CONFIG_LIBIBERTY_ONLY) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 36 +-- tools/perf/config/Makefile| 46 ++- tools/perf/config/Makefile.fix-legacy | 4 --- tools/perf/util/srcline.c | 8 +++--- tools/perf/util/symbol.h | 25 +-- 5 files changed, 75 insertions(+), 44 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index eb59567..026ef67 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -225,6 +225,35 @@ config LIBPYTHON ---help--- Libpython dependency needed by the perf script feature. +config TIMERFD + bool "Timer via file descriptor" + default y +---help--- + Timer via file descriptor + +config DEMANGLE + bool "Demangle symbols" + default y +---help--- + Enable demangling so as to display human-readable + symbols. This option is convenient with C++ programs. + +choice DEMANGLE_DEPS + prompt "Demangle dependency(ies)" + depends on DEMANGLE + default LIBBFD + +config LIBBFD + bool "BFD + libiberty libraries" +---help--- + Binary File Descriptor and libiberty libraries + +config LIBIBERTY_ONLY + bool "Libiberty only" +---help--- + Libiberty +endchoice + choice prompt "Elf library" default LIBELF @@ -266,13 +295,6 @@ config NUMA The library libnuma offers facilities to configure NUMA policies supported by the linux kernel. -config DEMANGLE - bool "Demangle symbols" - default y ----help--- - Enable demangling so as to display human-readable - symbols. This option is convenient with C++ programs. - config BIONIC bool "Bionic support" default n diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 27b092c..ce3a726 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -573,33 +573,36 @@ ifeq ($(feature-libbfd), 1) endif endif -ifdef NO_DEMANGLE - CFLAGS += -DNO_DEMANGLE -else - ifdef HAVE_CPLUS_DEMANGLE_SUPPORT -EXTLIBS += -liberty -CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT - else -ifneq ($(feature-libbfd), 1) - ifneq ($(feature-liberty), 1) -ifneq ($(feature-liberty-z), 1) - # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT - # or any of 'bfd iberty z' trinity - ifeq ($(feature-cplus-demangle), 1) -EXTLIBS += -liberty -CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT - else -msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) -CFLAGS += -DNO_DEMANGLE - endif +ifdef CONFIG_LIBBFD + ifneq ($(feature-libbfd), 1) +# TODO: there might be an issue here: feature-liberty and +# feature-liberty-z cannot be set; they can be set only if +# feature-libbfd is set +ifneq ($(feature-liberty), 1) + ifneq ($(feature-liberty-z), 1) +# we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT +# or any of 'bfd iberty z' trinity +ifeq ($(feature-cplus-demangle), 1) + EXTLIBS += -liberty + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBBFD) + $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBIBERTY_ONLY) +else + msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE) endif endif endif endif endif -ifneq ($(filter -lbfd,$(EXTLIBS)),) - CFLAGS += -DHAVE_LIBBFD_SUPPORT +ifdef CONFIG_LIBIBERTY_ONLY + $(call feature_check,cplus-demangle) + ifeq ($(feature-cplus-demangle), 1) +EXTLIBS += -liberty + else +msg := $(warning No libiberty found, install binutils-dev[el]/zlib-static to gain symbol demangling) +$(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE) + endif endif ifndef NO_BACKTRACE @@ -795,7 +798,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_DEMANGLE) $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) $(call store,NO_BACKTRACE) diff --git a/tools/perf/config/Makefile.fix-legacy b/tools/perf/config/Makefile.fix-legacy index ca219e7..64dbb1a 100644 --- a/tools/perf/config/Makefile.fix-legacy +++ b/tools/perf/config/Makefile.fix-legacy @@ -9,10 +9,6 @@ ifndef CONFIG_LIBPYTHON NO_LIBPYTHON := 1 endif -ifndef CONFIG_DEMANGLE -NO_DEMANGLE := 1 -endif - ifndef CONFIG_LIBELF NO_LIBELF := 1 endif diff --git a/tools/perf/util/srcline.c b/tools/per
[PATCH v3 10/14] perf kbuild: remove legacy libelf-related build variables
Remove NO_LIBELF (replaced by CONFIG_LIBELF) Remove HAVE_LIBELF_SUPPORT (replaced by CONFIG_LIBELF) Remove HAVE_LIBELF_MMAP_SUPPORT (replaced by CONFIG_LIBELF_MMAP) Remove HAVE_LIBELF_GETPHDRNUM__SUPPORT (replaced by CONFIG_LIBELF_GETPHDRNUM_) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 23 ++ tools/perf/builtin-inject.c | 2 +- tools/perf/config/Makefile| 37 +++ tools/perf/config/Makefile.fix-config | 18 - tools/perf/config/Makefile.fix-legacy | 4 tools/perf/perf.c | 2 +- tools/perf/util/generate-cmdlist.sh | 4 ++-- tools/perf/util/map.c | 3 ++- tools/perf/util/symbol-elf.c | 3 ++- tools/perf/util/symbol.h | 8 10 files changed, 51 insertions(+), 53 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 29853a6..2eaf3ca 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -256,6 +256,7 @@ config TIMERFD Timer via file descriptor config DEMANGLE + depends on LIBELF bool "Demangle symbols" default y ---help--- @@ -298,7 +299,29 @@ choice Builtin elf support. endchoice +config LIBELF_MMAP +depends on LIBELF + bool "Libelf mmap support" + default y +---help--- + libdelf mmap + +config LIBELF_GETPHDRNUM +depends on LIBELF + default y + bool "Libelf getphdrnum support" +---help--- + libdelf mmap + +config LIBDWARF + depends on LIBELF + bool "Dwarf (libdwarf)" + default y +---help--- + libdwarf + config LIBUNWIND +depends on LIBELF bool "User space libunwind callchains" default y ---help--- diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index de99ca1..9d59c7f 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -230,7 +230,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, * account this as unresolved. */ } else { -#ifdef HAVE_LIBELF_SUPPORT +#ifdef CONFIG_LIBELF pr_warning("no symbols found in %s, maybe " "install a debug package?\n", al.map->dso->long_name); diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 5be574c3..79fe047 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -303,12 +303,7 @@ ifdef CONFIG_BIONIC endif endif -ifdef NO_LIBELF - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 - NO_LIBDW_DWARF_UNWIND := 1 -else +ifdef CONFIG_LIBELF ifeq ($(feature-libelf), 0) ifeq ($(feature-glibc), 1) LIBC_SUPPORT := 1 @@ -318,12 +313,9 @@ else endif ifeq ($(LIBC_SUPPORT),1) msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); - - NO_LIBELF := 1 - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 - NO_LIBDW_DWARF_UNWIND := 1 + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF) + $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBELF_MINIMAL) + EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) else ifneq ($(filter s% -static%,$(LDFLAGS),),) msg := $(error No static glibc found, please install glibc-static); @@ -332,6 +324,7 @@ else endif endif else +LIBELF = 1 ifndef NO_LIBDW_DWARF_UNWIND ifneq ($(feature-libdw-dwarf-unwind),1) NO_LIBDW_DWARF_UNWIND := 1 @@ -343,17 +336,20 @@ else NO_DWARF := 1 endif # Dwarf support endif # libelf support -endif # NO_LIBELF +endif # CONFIG_LIBELF -ifndef NO_LIBELF - CFLAGS += -DHAVE_LIBELF_SUPPORT +ifeq ($(LIBELF), 1) - ifeq ($(feature-libelf-mmap), 1) -CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT + ifdef CONFIG_LIBELF_MMAP +ifneq ($(feature-libelf-mmap), 1) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP) +endif endif - ifeq ($(feature-libelf-getphdrnum), 1) -CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT + ifdef CONFIG_LIBELF_MMAP +ifneq ($(feature-libelf-getphdrnum), 1) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP) +endif endif # include ARCH specific config @@ -369,7 +365,7 @@ ifndef NO_LIBELF EXTLIBS += -lelf -ldw endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF -endif # NO_LIBELF +endif # LIBELF ifeq ($(ARCH),powerpc) ifndef NO_DWARF @@ -787,7 +783,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) $(call store,NO_LIBBIONIC) $(call store,ETC_
[PATCH v3 11/14] perf kbuild: remove legacy libdwarf-related build variables
* Remove NO_DWARF (replaced by CONFIG_LIBDWARF) * Remove HAVE_DWARF_SUPPORT (replaced by CONFIG_LIBDWARF) * Remove the useless variable PERF_HAVE_DWARF_REGS * fix compilation issues if PERF_REGS is disabled Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig | 59 +- tools/perf/arch/arm/tests/Kbuild | 2 +- tools/perf/arch/arm/util/Kbuild | 4 +- tools/perf/arch/arm64/util/Kbuild| 2 +- tools/perf/arch/powerpc/util/Kbuild | 4 +- tools/perf/arch/s390/util/Kbuild | 2 +- tools/perf/arch/sh/util/Kbuild | 2 +- tools/perf/arch/sparc/util/Kbuild| 2 +- tools/perf/arch/x86/Kbuild | 1 + tools/perf/arch/x86/Makefile | 8 +- tools/perf/arch/x86/tests/Kbuild | 2 +- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 2 +- tools/perf/arch/x86/util/Kbuild | 3 +- tools/perf/builtin-probe.c | 15 +-- tools/perf/builtin-record.c | 2 +- tools/perf/config/Makefile | 170 +-- tools/perf/config/Makefile.fix-config| 8 -- tools/perf/config/Makefile.fix-legacy| 4 - tools/perf/tests/Kbuild | 2 + tools/perf/tests/builtin-test.c | 3 +- tools/perf/tests/tests.h | 6 +- tools/perf/util/Kbuild | 11 +- tools/perf/util/callchain.c | 11 +- tools/perf/util/callchain.h | 3 +- tools/perf/util/include/dwarf-regs.h | 4 +- tools/perf/util/machine.c| 3 +- tools/perf/util/perf_regs.c | 2 - tools/perf/util/probe-event.c| 6 +- tools/perf/util/probe-finder.h | 5 +- tools/perf/util/unwind-libunwind.c | 5 +- tools/perf/util/unwind.h | 7 +- 31 files changed, 203 insertions(+), 157 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 2eaf3ca..54a194d 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -287,7 +287,6 @@ choice these tasks, perf can rely on either the libelf library or a minimal builtin support. - config LIBELF bool "elf" ---help--- @@ -318,15 +317,51 @@ config LIBDWARF bool "Dwarf (libdwarf)" default y ---help--- - libdwarf + A library for parsing DWARF debug information. + +config LIBDWARF_DIR + string "libdwarf directory" + depends on LIBDWARF +---help--- + Directory holding the libdwarf dependency (headers + + libraries) + +config UNWIND +depends on (LIBELF && PERF_REGS) + bool "User space unwind callchains" + default y +---help--- + Enable call-chain unwinding of user-space application. + +choice UNWIND_DEPS + prompt "Unwind dependency" + depends on UNWIND + default LIBUNWIND config LIBUNWIND -depends on LIBELF - bool "User space libunwind callchains" +depends on (LIBELF && PERF_REGS) + bool "Libunwind" +---help--- + Rely on libunwind post unwind support to determine the + call-chain of a user-space program. The library libunwind + supports all the architectures. + +config LIBDWARF_UNWIND +depends on (LIBDWARF && PERF_REGS && (ARCH = "x86" || ARCH = "arm")) + bool "Libdwarf unwind" +---help--- + Rely on lidw DWARF post unwind support to determine the + call-chain of a user-space program. So far there's only x86 + and arm libdw unwind support merged in perf. + +endchoice + +config LIBUNWIND_DEBUG_FRAME +depends on LIBUNWIND + bool "libunwind debug frame" default y ---help--- - The library libunwind provides a portable C API to determine - the call-chain of a program. + libunwind debug frame config LIBUNWIND_DIR string "libunwind directory" @@ -335,6 +370,18 @@ config LIBUNWIND_DIR Directory holding the libuwind dependency (headers + libraries). +config SKIP_CALLCHAIN_IDX + depends on (LIBDWARF && ARCH = "powerpc") + bool "Skip unnecessary callchain entries thanks to Dwarf" + default y +---help--- + When saving the callchain on Power, the kernel + conservatively saves excess entries in the callchain. A few + of these entries are needed in some cases but not others. If + the unnecessary entries are not ignored, we end up with + duplicate arcs in the call-graphs. Use DWARF debug + information to skip over any unnecessary callchain e
[PATCH v3 13/14] perf kbuild: final cosmetic changes
* Correctly rename internal makefile variables * Remove makefiles in tools/perf/config which became empty and useless * Remove builtin-cmds.h * Remove arch/x86/Makefile * Improve outputs of clean and install targets * Remove creation of PERF-FEATURES file which is redundant with the .config file generated by Kconfig. * replace HAVE_KVM_STAT_SUPPORT by a Kconfig option * replace HAVE_SKIP_CALLCHAIN_IDX by a Kconfig option Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 7 tools/perf/Makefile.kbuild| 74 ++-- tools/perf/arch/s390/util/Kbuild | 2 +- tools/perf/arch/x86/Makefile | 17 tools/perf/arch/x86/util/Kbuild | 2 +- tools/perf/builtin-cmds.h | 6 --- tools/perf/builtin-help.c | 2 +- tools/perf/builtin-kvm.c | 6 +-- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-sched.c| 2 +- tools/perf/config/Makefile| 79 +++ tools/perf/config/Makefile.fix-config | 6 --- tools/perf/config/Makefile.fix-legacy | 2 - tools/perf/perf.c | 2 +- 14 files changed, 83 insertions(+), 126 deletions(-) delete mode 100644 tools/perf/arch/x86/Makefile delete mode 100644 tools/perf/builtin-cmds.h delete mode 100644 tools/perf/config/Makefile.fix-config delete mode 100644 tools/perf/config/Makefile.fix-legacy diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 54a194d..d1b44c3 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -128,6 +128,13 @@ config BUILTIN_KVM ---help--- Tool to trace/measure kvm guest os +config BUILTIN_KVM_STAT + bool "kvm-stat" + default y + depends on BUILTIN_KVM && (ARCH = "x86" || ARCH = "s390") +---help--- + Get performance counter statistics on a kvm guest os. + config BUILTIN_LIST bool "list" default y diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index b48fe7f..90b168d 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -1,6 +1,5 @@ srctree := $(abspath $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)/../../)) objtree := $(abspath $(if $(KBUILD_SRC),$(CURDIR),$(CURDIR)/../..)) - VPATH := $(srctree) export srctree VPATH @@ -36,7 +35,8 @@ export quiet Q KBUILD_VERBOSE ifndef V QUIET_LINK = @echo ' LD $@'; QUIET_GEN = @echo ' GEN $@'; -QUIET_CLEAN = @echo ' CLEAN tools/perf'; +QUIET_CLEAN = @printf ' CLEAN%s\n' $1; +QUIET_INSTALL = @printf ' INSTALL %s\n' $1; endif export QUIET_BISON QUIET_FLEX @@ -158,7 +158,6 @@ $(CONFIG_DETECTED): $(KCONFIG_CONFIG) # no need to include auto.conf.cmd, because .config # is the only dependency here $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) $(CONFIG_DETECTED) - $(Q)$(MAKE) -f $(src-perf)/config/Makefile.fix-config $(Q)mkdir -p $(obj-perf)/include/config $(Q)mkdir -p $(obj-perf)/include/generated $(Q)$(MAKE) -s $(build)=scripts/kconfig silentoldconfig @@ -167,22 +166,26 @@ $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) $(CONFIG_DETECTED) clean-dirs := $(addprefix _clean_, tools/perf/) $(clean-dirs): + $(call QUIET_CLEAN, core-objs) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) -clean: $(clean-dirs) $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean - $(Q)$(QUIET_CLEAN) - $(Q)rm -f $(obj-perf)/perf - $(Q)rm -f $(obj-perf)/common-cmds.h - $(Q)rm -f $(obj-perf)/python/perf.so +config-clean: + $(call QUIET_CLEAN, config) + @$(MAKE) OUTPUT=$(obj-perf)/config/feature-checks/ -C $(src-perf)/config/feature-checks clean >/dev/null $(Q)rm -rf $(obj-perf)/include/generated $(obj-perf)/include/config + $(Q)rm -f $(CONFIG_DETECTED) $(KCONFIG_CONFIG) + $(Q)rm -f $(obj-perf)/common-cmds.h + +clean: $(clean-dirs) $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean config-clean + $(call QUIET_CLEAN, core-progs) + $(Q)rm -f $(obj-perf)/perf + $(call QUIET_CLEAN, misc) $(Q)find $(obj-perf) \ \( -name '*.[oas]' -o -name '.*.cmd' \ -o -name '.*.d' -o -name '.*.tmp' \ -o -name '*-flex.[ch]' -o -name '*-bison.[ch]' \ \) -type f -print | xargs rm -f - $(Q)$(python-clean) - $(Q)rm -f $(CONFIG_DETECTED) $(KCONFIG_CONFIG) - @$(MAKE) OUTPUT=$(obj-perf)/config/feature-checks/ -C $(src-perf)/config/feature-checks clean >/dev/null + $(python-clean) TAGS tags: $(Q)rm -f $(src-perf)/tags @@ -257,7 +260,7 @@ PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/ export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP -python-clean := rm -rf $(PYTHON_EXTBUILD) $(obj-perf)/python/perf.so +python-cl
[PATCH v3 14/14] perf kbuild: add generated Kconfig build-test cases
Thanks to the python module kconfiglib, we were able to generate build configurations. The set is, of course, not exhaustive but for each option, all the possible states are tested. Signed-off-by: Alexis Berlemont --- tools/perf/MANIFEST| 1 + tools/perf/tests/configs/MINIMAL_config| 60 ++ tools/perf/tests/configs/NO_BACKTRACE_config | 73 ++ .../perf/tests/configs/NO_BUILTIN_ANNOTATE_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_BENCH_config | 73 ++ .../tests/configs/NO_BUILTIN_BUILDID_CACHE_config | 73 ++ .../tests/configs/NO_BUILTIN_BUILDID_LIST_config | 71 + tools/perf/tests/configs/NO_BUILTIN_DIFF_config| 71 + tools/perf/tests/configs/NO_BUILTIN_EVLIST_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_HELP_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_INJECT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_KMEM_config| 73 ++ .../perf/tests/configs/NO_BUILTIN_KVM_STAT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_KVM_config | 72 + tools/perf/tests/configs/NO_BUILTIN_LIST_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_LOCK_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_MEM_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_PROBE_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_RECORD_config | 63 +++ tools/perf/tests/configs/NO_BUILTIN_REPORT_config | 68 tools/perf/tests/configs/NO_BUILTIN_SCHED_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_SCRIPT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_STAT_config| 71 + tools/perf/tests/configs/NO_BUILTIN_TEST_config| 73 ++ .../perf/tests/configs/NO_BUILTIN_TIMECHART_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_TOP_config | 71 + tools/perf/tests/configs/NO_BUILTIN_TRACE_config | 73 ++ tools/perf/tests/configs/NO_DEMANGLE_config| 71 + tools/perf/tests/configs/NO_GTK2_config| 73 ++ tools/perf/tests/configs/NO_LIBAUDIT_config| 72 + tools/perf/tests/configs/NO_LIBDWARF_config| 71 + tools/perf/tests/configs/NO_LIBELF_MMAP_config | 73 ++ tools/perf/tests/configs/NO_LIBGTK2_INFOBAR_config | 73 ++ tools/perf/tests/configs/NO_LIBGTK2_config | 71 + tools/perf/tests/configs/NO_LIBNUMA_config | 73 ++ tools/perf/tests/configs/NO_LIBPERL_config | 73 ++ tools/perf/tests/configs/NO_LIBPYTHON_config | 73 ++ tools/perf/tests/configs/NO_LIBSLANG_config| 72 + .../tests/configs/NO_LIBUNWIND_DEBUG_FRAME_config | 73 ++ tools/perf/tests/configs/NO_PERF_REGS_config | 73 ++ tools/perf/tests/configs/NO_STDIO_config | 73 ++ tools/perf/tests/configs/NO_TIMERFD_config | 73 ++ tools/perf/tests/configs/NO_TUI_config | 73 ++ tools/perf/tests/configs/NO_UNWIND_config | 69 tools/perf/tests/configs/REF_config| 73 ++ tools/perf/tests/generate_configs.py | 43 + tools/perf/tests/make | 70 ++--- 47 files changed, 3227 insertions(+), 50 deletions(-) create mode 100644 tools/perf/tests/configs/MINIMAL_config create mode 100644 tools/perf/tests/configs/NO_BACKTRACE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_ANNOTATE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BENCH_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_CACHE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_LIST_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_DIFF_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_EVLIST_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_HELP_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_INJECT_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KMEM_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KVM_STAT_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KVM_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_LIST_config create mode 100644 tools/perf/tests/configs
[PATCH v3 02/14] perf tools: Kbuild builtin source related fixies
From: Jiri Olsa Adding CONFIG_BUILTIN_* defines to govern builtin commands. This will be useful 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- 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 e7417fe..19cb967 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" @@ -115,7 +116,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) { @@ -154,7 +155,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: @@ -173,6 +176,7 @@ find_next: if (next != NULL) nd = next; +#endif /* CONFIG_TUI */ } else { hist_entry__tty_annotate(he, evsel, ann); nd = rb_next(nd); @@ -299,7 +303,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 000..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 25d2062..fbbbaa4 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 b65eb050..400e92e 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1531,20 +1531,25 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused) if (!strncmp(argv[0], "rec", 3))
[PATCH v3 03/14] perf tools: Kbuild source related fixies
From: Jiri Olsa Fixing several sources config dependencies to allow separate config builds. This commit was originally created by Jiri Olsa in 2013. Minor changes were needed to get it working one year later: * Remove #ifdef directives related with GUI / TUI (because of code changes in ui/setup.c) * Fix a link issue if the option BUILTIN_TRACE is disabled. * Fix typo (CONFIG_BULTIN_ instead CONFIG_BUILTIN_) 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- tools/perf/builtin-annotate.c| 6 +++--- tools/perf/builtin-lock.c| 5 - tools/perf/builtin-report.c | 2 +- tools/perf/builtin-sched.c | 3 +++ tools/perf/builtin-top.c | 4 ++-- tools/perf/perf.c| 10 -- tools/perf/ui/browsers/scripts.c | 4 tools/perf/ui/setup.c| 6 +++--- 8 files changed, 28 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 19cb967..a46af8f 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -155,7 +155,7 @@ find_next: /* skip missing symbols */ nd = rb_next(nd); -#ifdef CONFIG_TUI +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) } else if (use_browser == 1) { struct rb_node *next = NULL; key = hist_entry__tui_annotate(he, evsel, NULL); @@ -303,9 +303,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 +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), -#endif /* CONFIG_TUI */ +#endif 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-lock.c b/tools/perf/builtin-lock.c index e7ec715..05c0e1c 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "builtin-cmds.h" #include "perf.h" #include "util/evlist.h" @@ -995,9 +996,11 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) usage_with_options(report_usage, report_options); } rc = __cmd_report(false); +#ifdef CONFIG_BUILTIN_SCRIPT } else if (!strcmp(argv[0], "script")) { /* Aliased to 'perf script' */ - return cmd_script(argc, argv, prefix); + rc = cmd_script(argc, argv, prefix); +#endif } else if (!strcmp(argv[0], "info")) { if (argc) { argc = parse_options(argc, argv, diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 00d93ff..b639e58 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -407,7 +407,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 +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) case 1: ret = perf_evlist__tui_browse_hists(evlist, help, NULL, rep->min_percent, diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 891c393..e38b021 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "builtin-cmds.h" #include "perf.h" #include "util/util.h" @@ -1742,11 +1743,13 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) if (!argc) usage_with_options(sched_usage, sched_options); +#ifdef CONFIG_BUILTIN_SCRIPT /* * Aliased to 'perf script' for now: */ if (!strcmp(argv[0], "script")) return cmd_script(argc, argv, prefix); +#endif if (!strncmp(argv[0], "rec", 3)) { return __cmd_record(argc, argv); diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a2ff8b7..6f04452 100644 --- a/tools/perf/builti
[PATCH v3 12/14] perf kbuild: remove legacy script-related build variables
Remove NO_LIBPERL (replaced by CONFIG_LIBPERL) Remove NO_LIBPYTHON (replaced by CONFIG_LIBPYTHON) Signed-off-by: Alexis Berlemont --- tools/perf/builtin-script.c | 6 +++-- tools/perf/config/Makefile | 41 + tools/perf/config/Makefile.fix-config | 16 - tools/perf/config/Makefile.fix-legacy | 8 --- tools/perf/util/trace-event-scripting.c | 13 ++- 5 files changed, 22 insertions(+), 62 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9708a12..cc9c305 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1,3 +1,5 @@ +#include "generated/autoconf.h" + #include "builtin.h" #include "perf.h" @@ -1372,11 +1374,11 @@ int find_scripts(char **scripts_array, char **scripts_path_array) for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, lang_dirent.d_name); -#ifdef NO_LIBPERL +#ifndef CONFIG_LIBPERL if (strstr(lang_path, "perl")) continue; #endif -#ifdef NO_LIBPYTHON +#ifndef CONFIG_LIBPYTHON if (strstr(lang_path, "python")) continue; #endif diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index f667229..00d118c 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -101,7 +101,7 @@ ifdef PARSER_DEBUG CFLAGS += -DPARSER_DEBUG endif -ifndef NO_LIBPYTHON +ifdef CONFIG_LIBPYTHON # Try different combinations to accommodate systems that only have # python[2][-config] in weird combinations but always preferring # python2 and python2-config as per pep-0394. If we catch a @@ -460,9 +460,7 @@ endif grep-libs = $(filter -l%,$(1)) strip-libs = $(filter-out -l%,$(1)) -ifdef NO_LIBPERL - CFLAGS += -DNO_LIBPERL -else +ifdef CONFIG_LIBPERL PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) @@ -470,9 +468,8 @@ else FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1) -CFLAGS += -DNO_LIBPERL -NO_LIBPERL := 1 msg := $(warning Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed); +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPERL) else LDFLAGS += $(PERL_EMBED_LDFLAGS) EXTLIBS += $(PERL_EMBED_LIBADD) @@ -486,17 +483,14 @@ ifdef CONFIG_TIMERFD endif endif -disable-python = $(eval $(disable-python_code)) -define disable-python_code - CFLAGS += -DNO_LIBPYTHON - $(if $(1),$(warning No $(1) was found)) - $(warning Python support will not be built) - NO_LIBPYTHON := 1 -endef +ifdef CONFIG_LIBPYTHON -ifdef NO_LIBPYTHON - $(call disable-python) -else + disable-python = $(eval $(disable-python_code)) + define disable-python_code +$(if $(1),$(warning No $(1) was found)) +$(warning Python support will not be built) +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPYTHON) + endef ifndef PYTHON $(call disable-python,python interpreter) @@ -520,18 +514,7 @@ else else ifneq ($(feature-libpython-version), 1) - $(warning Python 3 is not yet supported; please set) - $(warning PYTHON and/or PYTHON_CONFIG appropriately.) - $(warning If you also have Python 2 installed, then) - $(warning try something like:) - $(warning $(and ,)) - $(warning $(and ,) make PYTHON=python2) - $(warning $(and ,)) - $(warning Otherwise, disable Python support entirely:) - $(warning $(and ,)) - $(warning $(and ,) make NO_LIBPYTHON=1) - $(warning $(and ,)) - $(error $(and ,)) + $(call disable-python,python2 interpreter) else LDFLAGS += $(PYTHON_EMBED_LDFLAGS) EXTLIBS += $(PYTHON_EMBED_LIBADD) @@ -781,8 +764,6 @@ all: $(call store,PYTHON_EMBED_CCOPTS) $(call store,PERL_EMBED_CCOPTS) $(call store,NO_LIBUNWIND) - $(call store,NO_LIBPERL) - $(call store,NO_LIBPYTHON) $(call store,ETC_PERFCONFIG_SQ) $(call store,DESTDIR_SQ) $(call store,bindir_SQ) diff --git a/tools/perf/config/Makefile.fix-config b/tools/perf/config/Makefile.fix-config index e63539f..3f0e33e 100644 --- a/tools/perf/config/Makefile.fix-config +++ b/tools/perf/config/Makefile.fix-config @@ -3,20 +3,4 @@ include $(KCONFIG_CONFIG) CONFIG := $(srctree)/scripts/config --file $(KCONFIG_CONFIG) -# NO_LIBPERL -ifdef CONFIG_LIBPERL -ifdef NO_LIBPERL -dummy := $(info Disabling CONFIG_LIBPERL) -dummy := $(shell $(CONFIG) -d CONFIG_LIBPERL) -endif -endif - -# NO_LIBPYTHON -ifdef CONFIG_LIBPYTHON -ifdef NO_LIBPYTHON
[PATCH v3 00/14] Kbuild for perf
Hello, Here is a proposal of perf's build process managed by Kbuild: * The file Makefile.perf is replaced by Makefile.kbuild * Makefile.kbuild generates a default .config file if none exists (allyesconfig) * Makefile.kbuild adapts the .config file according to the features-check tests results * Makefile.kbuild builds external dependencies (linux/tools/lib/*) * Makefile.kbuild leaves the rest to Kbuild Regards, Alexis. Alexis Berlemont (11): kbuild: add support of custom paths for "auto.conf*" files perf kbuild: remove Makefile.perf perf kbuild: remove legacy tui/gui-related build variables perf kbuild: remove legacy demangle-related build variables perf kbuild: cross-compilation variables are now handled in Kconfig perf kbuild: remove legacy misc build variables perf kbuild: remove legacy libelf-related build variables perf kbuild: remove legacy libdwarf-related build variables perf kbuild: remove legacy script-related build variables perf kbuild: final cosmetic changes perf kbuild: add generated Kconfig build-test cases Jiri Olsa (3): perf tools: Kbuild builtin source related fixies perf tools: Kbuild source related fixies perf tools: Add kbuild support into Makefile.kbuild scripts/Makefile.build | 3 +- scripts/kconfig/confdata.c | 23 +- scripts/kconfig/lkc.h | 1 + tools/perf/Kbuild | 47 + tools/perf/Kconfig | 436 ++ tools/perf/MANIFEST| 1 + tools/perf/Makefile| 2 +- tools/perf/Makefile.kbuild | 443 ++ tools/perf/Makefile.perf | 949 - tools/perf/arch/Kbuild | 3 + tools/perf/arch/arm/Kbuild | 2 + tools/perf/arch/arm/Makefile | 14 - tools/perf/arch/arm/tests/Kbuild | 2 + tools/perf/arch/arm/util/Kbuild| 3 + tools/perf/arch/arm64/Kbuild | 1 + tools/perf/arch/arm64/Makefile | 7 - tools/perf/arch/arm64/util/Kbuild | 2 + tools/perf/arch/powerpc/Kbuild | 1 + tools/perf/arch/powerpc/Makefile | 6 - tools/perf/arch/powerpc/util/Kbuild| 3 + tools/perf/arch/s390/Kbuild| 1 + tools/perf/arch/s390/Makefile | 7 - tools/perf/arch/s390/util/Kbuild | 2 + tools/perf/arch/sh/Kbuild | 1 + tools/perf/arch/sh/Makefile| 4 - tools/perf/arch/sh/util/Kbuild | 1 + tools/perf/arch/sparc/Kbuild | 1 + tools/perf/arch/sparc/Makefile | 4 - tools/perf/arch/sparc/util/Kbuild | 1 + tools/perf/arch/x86/Kbuild | 2 + tools/perf/arch/x86/Makefile | 19 - tools/perf/arch/x86/include/perf_regs.h| 8 +- tools/perf/arch/x86/tests/Kbuild | 3 + tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c | 2 +- tools/perf/arch/x86/tests/regs_load.S | 3 +- tools/perf/arch/x86/util/Kbuild| 6 + tools/perf/arch/x86/util/unwind-libunwind.c| 5 +- tools/perf/bench/Kbuild| 12 + tools/perf/bench/mem-memcpy-arch.h | 4 +- tools/perf/bench/mem-memcpy.c | 4 +- tools/perf/bench/mem-memset-arch.h | 4 +- tools/perf/bench/mem-memset.c | 4 +- tools/perf/builtin-annotate.c | 8 +- tools/perf/builtin-bench.c | 5 +- tools/perf/builtin-help.c | 1 + tools/perf/builtin-inject.c| 2 +- tools/perf/builtin-kvm.c | 38 +- tools/perf/builtin-lock.c | 5 +- tools/perf/builtin-probe.c | 15 +- tools/perf/builtin-record.c| 4 +- tools/perf/builtin-report.c| 3 + tools/perf/builtin-sched.c | 3 + tools/perf/builtin-script.c| 6 +- tools/perf/builtin-top.c | 19 +- tools/perf/config/Makefile | 430 +- tools/perf/config/defconfig| 54 ++ tools/perf/perf-sys.h | 4 +- tools/perf/perf.c | 53 +- tools/perf/scripts/perl/Perf-Trace-Util/Kbuild | 6 + tools/perf/scripts/python/Perf-Trace-Util/Kbuild | 5 + tools/perf/tests/Kbuild| 40 + tools/perf/te
[PATCH v3 01/14] kbuild: add support of custom paths for "auto.conf*" files
In the scripts/Makefile.build, use KCONFIG_AUTOCONFIG to include a custom path for the "auto.conf" file. The "*conf" programs were modified so as to work with the environment variable KCONFIG_AUTOCONFIG. Signed-off-by: Alexis Berlemont --- scripts/Makefile.build | 3 ++- scripts/kconfig/confdata.c | 23 ++- scripts/kconfig/lkc.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 649ce68..2abb82f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -31,7 +31,8 @@ subdir-asflags-y := subdir-ccflags-y := # Read auto.conf if it exists, otherwise ignore --include include/config/auto.conf +kconfig-autoconfig := $(if $(KCONFIG_AUTOCONFIG),$(KCONFIG_AUTOCONFIG),include/config/auto.conf) +-include $(kconfig-autoconfig) include scripts/Kbuild.include diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f88d90f..75cf6bf 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -75,6 +75,23 @@ const char *conf_get_autoconfig_name(void) return name ? name : "include/config/auto.conf"; } +const char *conf_get_autoconfigdep_name(void) +{ + static char res_value[PATH_MAX+1]; + + const char *name = conf_get_autoconfig_name(); + + if (strlen(name) > PATH_MAX - 4) + name = NULL; + else { + strcpy(res_value, name); + strcat(res_value, ".cmd"); + name = res_value; + } + + return name; +} + static char *conf_expand_value(const char *in) { struct symbol *sym; @@ -953,7 +970,11 @@ int conf_write_autoconf(void) sym_clear_all_valid(); - file_write_dep("include/config/auto.conf.cmd"); + name = conf_get_autoconfigdep_name(); + if (name == NULL) + return 1; + + file_write_dep(name); if (conf_split_config()) return 1; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index d5daa7a..ac99004 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -84,6 +84,7 @@ const char *zconf_curname(void); /* confdata.c */ const char *conf_get_configname(void); const char *conf_get_autoconfig_name(void); +const char *conf_get_autoconfigdep_name(void); char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); -- 2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 05/14] perf kbuild: remove Makefile.perf
The file Makefile.perf contained legacy build rules. It is replaced by Makefile.kbuild which relies on Kbuild. Consequently, some minor points need updates: * The constant CONFIG_KBUILD can be removed * The main Makefile wrapper now call Makefile.kbuild instead of Makefile.perf Signed-off-by: Alexis Berlemont --- tools/perf/Makefile | 2 +- tools/perf/Makefile.kbuild| 2 +- tools/perf/Makefile.perf | 949 -- tools/perf/builtin-annotate.c | 4 +- tools/perf/builtin-cmds.h | 25 -- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 4 +- tools/perf/ui/setup.c | 4 +- 8 files changed, 9 insertions(+), 983 deletions(-) delete mode 100644 tools/perf/Makefile.perf diff --git a/tools/perf/Makefile b/tools/perf/Makefile index cb2e586..4512f16 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -55,7 +55,7 @@ define print_msg endef define make - @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ + @$(MAKE) -f Makefile.kbuild --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ endef # diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index 51eba07..8d9e8b0 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -43,7 +43,7 @@ export QUIET_BISON QUIET_FLEX ifeq ($(KBUILD_SRC),) -ifeq ("$(origin O)", "command line") +ifneq ($(O),) KBUILD_OUTPUT := $(O) else KBUILD_OUTPUT := $(objtree) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf deleted file mode 100644 index dcf6248..000 --- a/tools/perf/Makefile.perf +++ /dev/null @@ -1,949 +0,0 @@ -include ../scripts/Makefile.include - -# The default target of this Makefile is... -all: - -include config/utilities.mak - -# Define V to have a more verbose compile. -# -# Define VF to have a more verbose feature check output. -# -# Define O to save output files in a separate directory. -# -# Define ARCH as name of target architecture if you want cross-builds. -# -# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds. -# -# Define NO_LIBPERL to disable perl script extension. -# -# Define NO_LIBPYTHON to disable python script extension. -# -# Define PYTHON to point to the python binary if the default -# `python' is not correct; for example: PYTHON=python2 -# -# Define PYTHON_CONFIG to point to the python-config binary if -# the default `$(PYTHON)-config' is not correct. -# -# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8 -# -# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72. -# -# Define LDFLAGS=-static to build a static binary. -# -# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds. -# -# Define NO_DWARF if you do not want debug-info analysis feature at all. -# -# Define WERROR=0 to disable treating any warnings as errors. -# -# Define NO_NEWT if you do not want TUI support. (deprecated) -# -# Define NO_SLANG if you do not want TUI support. -# -# Define NO_GTK2 if you do not want GTK+ GUI support. -# -# Define NO_DEMANGLE if you do not want C++ symbol demangling. -# -# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) -# -# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf -# backtrace post unwind. -# -# Define NO_BACKTRACE if you do not want stack backtrace debug feature -# -# Define NO_LIBNUMA if you do not want numa perf benchmark -# -# Define NO_LIBAUDIT if you do not want libaudit support -# -# Define NO_LIBBIONIC if you do not want bionic support -# -# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support -# for dwarf backtrace post unwind. - -ifeq ($(srctree),) -srctree := $(patsubst %/,%,$(dir $(shell pwd))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -#$(info Determined 'srctree' to be $(srctree)) -endif - -ifneq ($(objtree),) -#$(info Determined 'objtree' to be $(objtree)) -endif - -ifneq ($(OUTPUT),) -#$(info Determined 'OUTPUT' to be $(OUTPUT)) -endif - -$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD - @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) - @touch $(OUTPUT)PERF-VERSION-FILE - -CC = $(CROSS_COMPILE)gcc -AR = $(CROSS_COMPILE)ar -PKG_CONFIG = $(CROSS_COMPILE)pkg-config - -RM = rm -f -LN = ln -f -MKDIR = mkdir -FIND= find -INSTALL = install -FLEX= flex -BISON = bison -STRIP = strip - -LIB_DIR = $(srctree)/tools/lib/api/ -TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ - -# include config/Makefile by default and rule out -# non-config cases -config := 1 - -NON_CONFIG_TARGETS := clean TAGS tags cscope help - -ifdef MAKECMDGOALS -ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),) - config := 0 -endif -endif - -ifeq ($(config),1) -include config/Makefile -endif - -export prefix bindir sharedir sysconfdir DESTDIR - -# sparse is architecture-neutral, which mean
[PATCH v2 00/14] Kbuild for perf
Hello, Here is a proposal of perf's build process managed by Kbuild: * The file Makefile.perf is replaced by Makefile.kbuild * Makefile.kbuild generates a default .config file if none exists (allyesconfig) * Makefile.kbuild adapts the .config file according to the features-check tests results * Makefile.kbuild builds external dependencies (linux/tools/lib/*) * Makefile.kbuild leaves the rest to Kbuild Regards, Alexis. Alexis Berlemont (11): kbuild: add support of custom paths for "auto.conf*" files perf kbuild: remove Makefile.perf perf kbuild: remove legacy tui/gui-related build variables perf kbuild: remove legacy demangle-related build variables perf kbuild: cross-compilation variables are now handled in Kconfig perf kbuild: remove legacy misc build variables perf kbuild: remove legacy libelf-related build variables perf kbuild: remove legacy libdwarf-related build variables perf kbuild: remove legacy script-related build variables perf kbuild: final cosmetic changes perf kbuild: add generated Kconfig build-test cases Jiri Olsa (3): perf tools: Kbuild builtin source related fixies perf tools: Kbuild source related fixies perf tools: Add kbuild support into Makefile.kbuild scripts/Makefile.build | 3 +- scripts/kconfig/confdata.c | 23 +- scripts/kconfig/lkc.h | 1 + tools/perf/Kbuild | 47 + tools/perf/Kconfig | 436 ++ tools/perf/MANIFEST| 1 + tools/perf/Makefile| 2 +- tools/perf/Makefile.kbuild | 443 ++ tools/perf/Makefile.perf | 949 - tools/perf/arch/Kbuild | 3 + tools/perf/arch/arm/Kbuild | 2 + tools/perf/arch/arm/Makefile | 14 - tools/perf/arch/arm/tests/Kbuild | 2 + tools/perf/arch/arm/util/Kbuild| 3 + tools/perf/arch/arm64/Kbuild | 1 + tools/perf/arch/arm64/Makefile | 7 - tools/perf/arch/arm64/util/Kbuild | 2 + tools/perf/arch/powerpc/Kbuild | 1 + tools/perf/arch/powerpc/Makefile | 6 - tools/perf/arch/powerpc/util/Kbuild| 3 + tools/perf/arch/s390/Kbuild| 1 + tools/perf/arch/s390/Makefile | 7 - tools/perf/arch/s390/util/Kbuild | 2 + tools/perf/arch/sh/Kbuild | 1 + tools/perf/arch/sh/Makefile| 4 - tools/perf/arch/sh/util/Kbuild | 1 + tools/perf/arch/sparc/Kbuild | 1 + tools/perf/arch/sparc/Makefile | 4 - tools/perf/arch/sparc/util/Kbuild | 1 + tools/perf/arch/x86/Kbuild | 2 + tools/perf/arch/x86/Makefile | 19 - tools/perf/arch/x86/include/perf_regs.h| 8 +- tools/perf/arch/x86/tests/Kbuild | 3 + tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c | 2 +- tools/perf/arch/x86/tests/regs_load.S | 3 +- tools/perf/arch/x86/util/Kbuild| 6 + tools/perf/arch/x86/util/unwind-libunwind.c| 5 +- tools/perf/bench/Kbuild| 12 + tools/perf/bench/mem-memcpy-arch.h | 4 +- tools/perf/bench/mem-memcpy.c | 4 +- tools/perf/bench/mem-memset-arch.h | 4 +- tools/perf/bench/mem-memset.c | 4 +- tools/perf/builtin-annotate.c | 8 +- tools/perf/builtin-bench.c | 5 +- tools/perf/builtin-help.c | 1 + tools/perf/builtin-inject.c| 2 +- tools/perf/builtin-kvm.c | 38 +- tools/perf/builtin-lock.c | 5 +- tools/perf/builtin-probe.c | 15 +- tools/perf/builtin-record.c| 4 +- tools/perf/builtin-report.c| 3 + tools/perf/builtin-sched.c | 3 + tools/perf/builtin-script.c| 6 +- tools/perf/builtin-top.c | 19 +- tools/perf/config/Makefile | 430 +- tools/perf/config/defconfig| 54 ++ tools/perf/perf-sys.h | 4 +- tools/perf/perf.c | 53 +- tools/perf/scripts/perl/Perf-Trace-Util/Kbuild | 6 + tools/perf/scripts/python/Perf-Trace-Util/Kbuild | 5 + tools/perf/tests/Kbuild| 40 + tools/perf/te
[PATCH v2 04/14] perf tools: Add kbuild support into Makefile.kbuild
From: Jiri Olsa Adding kbuild support into Makefile.kbuild. The 'legacy' Makefile still stays untouched as it was. It's possible to use kbuild by running 'make -f Makefile.kbuild' with any option supported by 'legacy' Makefile. We now have 2 config files: '.config' - user configured setup '.config-detected' - system detected setup The '.config-detected' affects '.config' and if there's configured feature in '.config' which was not detected it is automatically disabled. The '.config-detected' is re/created if: - there's no '.config-detected' - '.config' was changed In a cleaned tree the perf is built with 'allyesconfig' having disabled all non-detected features, just as it is done now. You can change '.config' via: make -f Makefile.kbuild menuconfig There's difference for O=DIR build. The DIR is populated based on kernel source tree, so the final binary is created under DIR/tools/perf. This commit was originally created by Jiri Olsa in February 2013; a few changes were necessary to fit the perf version of June 2014: * Add missing CFLAGS for specific .o targets * Update Kbuild files (new source files, ...) * Fix recursive invocation of config/features-checks * Store .config-detected missing variables (libdir, ...) * Fix missing dependencies between Kconfig options * Fix installation of traceevent plugins * Fix missing cleanings of feature-check binaries * CROSS_COMPILE was not used to define AS, CC, ... * CROSS_COMPILE was not stored in .config-detected * Take into account DESTDIR and prefix set in the command line * Add missing Kbuild files for non-x86 architectures (powerpc, arm, arm64, sh, s390, sparc) * Move perf-time-to-tsc.c into x86-specific tests directory 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- tools/perf/Kbuild | 47 +++ tools/perf/Kconfig | 284 ++ tools/perf/Makefile.kbuild | 431 + tools/perf/Makefile.perf | 2 +- tools/perf/arch/Kbuild | 3 + tools/perf/arch/arm/Kbuild | 2 + tools/perf/arch/arm/Makefile | 14 - tools/perf/arch/arm/tests/Kbuild | 2 + tools/perf/arch/arm/util/Kbuild| 3 + tools/perf/arch/arm64/Kbuild | 1 + tools/perf/arch/arm64/Makefile | 7 - tools/perf/arch/arm64/util/Kbuild | 2 + tools/perf/arch/powerpc/Kbuild | 1 + tools/perf/arch/powerpc/Makefile | 6 - tools/perf/arch/powerpc/util/Kbuild| 3 + tools/perf/arch/s390/Kbuild| 1 + tools/perf/arch/s390/Makefile | 7 - tools/perf/arch/s390/util/Kbuild | 2 + tools/perf/arch/sh/Kbuild | 1 + tools/perf/arch/sh/Makefile| 4 - tools/perf/arch/sh/util/Kbuild | 1 + tools/perf/arch/sparc/Kbuild | 1 + tools/perf/arch/sparc/Makefile | 4 - tools/perf/arch/sparc/util/Kbuild | 1 + tools/perf/arch/x86/Kbuild | 1 + tools/perf/arch/x86/tests/Kbuild | 3 + tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c | 0 tools/perf/arch/x86/util/Kbuild| 5 + tools/perf/bench/Kbuild| 12 + tools/perf/builtin-cmds.h | 4 + tools/perf/config/Makefile | 55 ++- tools/perf/config/Makefile.fix-config | 104 + tools/perf/config/Makefile.fix-legacy | 46 +++ tools/perf/config/defconfig| 54 +++ tools/perf/perf-sys.h | 4 +- tools/perf/scripts/perl/Perf-Trace-Util/Kbuild | 6 + tools/perf/scripts/python/Perf-Trace-Util/Kbuild | 5 + tools/perf/tests/Kbuild| 38 ++ tools/perf/ui/Kbuild | 15 + tools/perf/ui/browsers/Kbuild | 9 + tools/perf/ui/gtk/Kbuild | 9 + tools/perf/ui/stdio/Kbuild | 1 + tools/perf/ui/tui/Kbuild | 4 + tools/perf/util/Kbuild | 125 ++ tools/perf/util/PERF-VERSION-GEN | 4 + tools/perf/util/generate-cmdlist.sh| 8 +- tools/pe
[PATCH v2 06/14] perf kbuild: remove legacy tui/gui-related build variables
Remove NO_SLANG (replaced by CONFIG_LIBSLANG) Remove HAVE_SLANG_SUPPORT from CFLAGS (replaced by CONFIG_LIBSLANG) Remove NO_GTK2 (replaced by CONFIG_LIBGTK2 or CONFIG_GTK2) Remove HAVE_GTK2_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2) Remove HAVE_GTK_INFO_BAR_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2_INFOBAR) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 21 + tools/perf/config/Makefile| 20 ++-- tools/perf/config/Makefile.fix-config | 24 tools/perf/config/Makefile.fix-legacy | 8 tools/perf/ui/gtk/browser.c | 4 +++- tools/perf/ui/gtk/gtk.h | 5 +++-- tools/perf/ui/gtk/util.c | 6 -- tools/perf/ui/setup.c | 4 +++- tools/perf/ui/ui.h| 4 +++- tools/perf/util/annotate.h| 4 +++- tools/perf/util/hist.h| 3 ++- 11 files changed, 48 insertions(+), 55 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index f9fcf9e..eb59567 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -171,6 +171,7 @@ config STDIO config TUI bool "Tui (slang based)" + depends on LIBSLANG default y ---help--- Text-based user interface which provides windowing @@ -179,6 +180,7 @@ config TUI config GTK2 bool "Gtk2" default y + depends on LIBGTK2 ---help--- Elaborate display mode based on libgtk2. @@ -186,12 +188,31 @@ endmenu menu "Libraries / Dependencies" +config LIBSLANG + bool "Slang (libslang)" + default y +---help--- + libslang + config LIBAUDIT bool "Audit (libaudit)" default y ---help--- Linux audit framework dependency. +config LIBGTK2 + bool "Gtk2 (libgtk2)" + default y +---help--- + libgtk2 + +config LIBGTK2_INFOBAR + bool "Gtk2 infobar (libgtk2)" + depends on LIBGTK2 + default y +---help--- + libgtk2-infobar + config LIBPERL bool "Perl" default y diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 6106e24..27b092c 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -445,32 +445,26 @@ ifndef NO_LIBAUDIT endif endif -ifdef NO_NEWT - NO_SLANG=1 -endif - -ifndef NO_SLANG +ifdef CONFIG_LIBSLANG ifneq ($(feature-libslang), 1) -msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); -NO_SLANG := 1 +msg := $(warning slang not found, disables SLANG and TUI supports. Please install slang-devel or libslang-dev); +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBSLANG) else # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h CFLAGS += -I/usr/include/slang -CFLAGS += -DHAVE_SLANG_SUPPORT EXTLIBS += -lslang endif endif -ifndef NO_GTK2 +ifdef CONFIG_LIBGTK2 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) ifneq ($(feature-gtk2), 1) msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); -NO_GTK2 := 1 +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2) else ifeq ($(feature-gtk2-infobar), 1) - GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2_INFOBAR) endif -CFLAGS += -DHAVE_GTK2_SUPPORT GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null) GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null) EXTLIBS += -ldl @@ -801,8 +795,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_NEWT) - $(call store,NO_GTK2) $(call store,NO_DEMANGLE) $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) diff --git a/tools/perf/config/Makefile.fix-config b/tools/perf/config/Makefile.fix-config index 7f65fdb..3d84008 100644 --- a/tools/perf/config/Makefile.fix-config +++ b/tools/perf/config/Makefile.fix-config @@ -19,30 +19,6 @@ dummy := $(shell $(CONFIG) -d CONFIG_LIBPYTHON) endif endif -# NO_NEWT -ifdef CONFIG_TUI -ifdef NO_NEWT -dummy := $(info Disabling CONFIG_TUI) -dummy := $(shell $(CONFIG) -d CONFIG_TUI) -endif -endif - -# NO_NEWT -ifdef CONFIG_TUI -ifdef NO_SLANG -dummy := $(info Disabling CONFIG_TUI) -dummy := $(shell $(CONFIG) -d CONFIG_TUI) -endif -endif - -# NO_GTK2 -ifdef CONFIG_GTK2 -ifdef NO_GTK2 -dummy := $(info Disabling CONFIG_GTK2) -dummy := $(shell $(CONFIG) -d CONFIG_GTK2) -endif -endif - # NO_DEMANGLE ifdef CONFIG_DEMANGLE ifdef NO_DEMANGLE diff --git a/tools/perf/config/Makefile.fix-legacy b/tools/perf/config/Makefile.fix-legacy index 2ec91f3..ca219e7 100644 --- a/tools/
[PATCH v2 07/14] perf kbuild: remove legacy demangle-related build variables
Remove NO_DEMANGLE (replaced by CONFIG_DEMANGLE) Remove HAVE_LIBBFD_SUPPORT (replaced by CONFIG_LIBBFD) Remove HAVE_CPLUS_DEMANGLE_SUPPORT (replaced by CONFIG_LIBIBERTY_ONLY) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 36 +-- tools/perf/config/Makefile| 46 ++- tools/perf/config/Makefile.fix-legacy | 4 --- tools/perf/util/srcline.c | 8 +++--- tools/perf/util/symbol.h | 25 +-- 5 files changed, 75 insertions(+), 44 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index eb59567..026ef67 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -225,6 +225,35 @@ config LIBPYTHON ---help--- Libpython dependency needed by the perf script feature. +config TIMERFD + bool "Timer via file descriptor" + default y +---help--- + Timer via file descriptor + +config DEMANGLE + bool "Demangle symbols" + default y +---help--- + Enable demangling so as to display human-readable + symbols. This option is convenient with C++ programs. + +choice DEMANGLE_DEPS + prompt "Demangle dependency(ies)" + depends on DEMANGLE + default LIBBFD + +config LIBBFD + bool "BFD + libiberty libraries" +---help--- + Binary File Descriptor and libiberty libraries + +config LIBIBERTY_ONLY + bool "Libiberty only" +---help--- + Libiberty +endchoice + choice prompt "Elf library" default LIBELF @@ -266,13 +295,6 @@ config NUMA The library libnuma offers facilities to configure NUMA policies supported by the linux kernel. -config DEMANGLE - bool "Demangle symbols" - default y ----help--- - Enable demangling so as to display human-readable - symbols. This option is convenient with C++ programs. - config BIONIC bool "Bionic support" default n diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 27b092c..ce3a726 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -573,33 +573,36 @@ ifeq ($(feature-libbfd), 1) endif endif -ifdef NO_DEMANGLE - CFLAGS += -DNO_DEMANGLE -else - ifdef HAVE_CPLUS_DEMANGLE_SUPPORT -EXTLIBS += -liberty -CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT - else -ifneq ($(feature-libbfd), 1) - ifneq ($(feature-liberty), 1) -ifneq ($(feature-liberty-z), 1) - # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT - # or any of 'bfd iberty z' trinity - ifeq ($(feature-cplus-demangle), 1) -EXTLIBS += -liberty -CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT - else -msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) -CFLAGS += -DNO_DEMANGLE - endif +ifdef CONFIG_LIBBFD + ifneq ($(feature-libbfd), 1) +# TODO: there might be an issue here: feature-liberty and +# feature-liberty-z cannot be set; they can be set only if +# feature-libbfd is set +ifneq ($(feature-liberty), 1) + ifneq ($(feature-liberty-z), 1) +# we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT +# or any of 'bfd iberty z' trinity +ifeq ($(feature-cplus-demangle), 1) + EXTLIBS += -liberty + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBBFD) + $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBIBERTY_ONLY) +else + msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE) endif endif endif endif endif -ifneq ($(filter -lbfd,$(EXTLIBS)),) - CFLAGS += -DHAVE_LIBBFD_SUPPORT +ifdef CONFIG_LIBIBERTY_ONLY + $(call feature_check,cplus-demangle) + ifeq ($(feature-cplus-demangle), 1) +EXTLIBS += -liberty + else +msg := $(warning No libiberty found, install binutils-dev[el]/zlib-static to gain symbol demangling) +$(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE) + endif endif ifndef NO_BACKTRACE @@ -795,7 +798,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_DEMANGLE) $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) $(call store,NO_BACKTRACE) diff --git a/tools/perf/config/Makefile.fix-legacy b/tools/perf/config/Makefile.fix-legacy index ca219e7..64dbb1a 100644 --- a/tools/perf/config/Makefile.fix-legacy +++ b/tools/perf/config/Makefile.fix-legacy @@ -9,10 +9,6 @@ ifndef CONFIG_LIBPYTHON NO_LIBPYTHON := 1 endif -ifndef CONFIG_DEMANGLE -NO_DEMANGLE := 1 -endif - ifndef CONFIG_LIBELF NO_LIBELF := 1 endif diff --git a/tools/perf/util/srcline.c b/tools/per
[PATCH v2 03/14] perf tools: Kbuild source related fixies
From: Jiri Olsa Fixing several sources config dependencies to allow separate config builds. This commit was originally created by Jiri Olsa in 2013. Minor changes were needed to get it working one year later: * Remove #ifdef directives related with GUI / TUI (because of code changes in ui/setup.c) * Fix a link issue if the option BUILTIN_TRACE is disabled. * Fix typo (CONFIG_BULTIN_ instead CONFIG_BUILTIN_) 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- tools/perf/builtin-annotate.c| 6 +++--- tools/perf/builtin-lock.c| 5 - tools/perf/builtin-report.c | 2 +- tools/perf/builtin-sched.c | 3 +++ tools/perf/builtin-top.c | 4 ++-- tools/perf/perf.c| 10 -- tools/perf/ui/browsers/scripts.c | 4 tools/perf/ui/setup.c| 6 +++--- 8 files changed, 28 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 19cb967..a46af8f 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -155,7 +155,7 @@ find_next: /* skip missing symbols */ nd = rb_next(nd); -#ifdef CONFIG_TUI +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) } else if (use_browser == 1) { struct rb_node *next = NULL; key = hist_entry__tui_annotate(he, evsel, NULL); @@ -303,9 +303,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 +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), -#endif /* CONFIG_TUI */ +#endif 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-lock.c b/tools/perf/builtin-lock.c index e7ec715..05c0e1c 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "builtin-cmds.h" #include "perf.h" #include "util/evlist.h" @@ -995,9 +996,11 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) usage_with_options(report_usage, report_options); } rc = __cmd_report(false); +#ifdef CONFIG_BUILTIN_SCRIPT } else if (!strcmp(argv[0], "script")) { /* Aliased to 'perf script' */ - return cmd_script(argc, argv, prefix); + rc = cmd_script(argc, argv, prefix); +#endif } else if (!strcmp(argv[0], "info")) { if (argc) { argc = parse_options(argc, argv, diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 00d93ff..b639e58 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -407,7 +407,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 +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) case 1: ret = perf_evlist__tui_browse_hists(evlist, help, NULL, rep->min_percent, diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 891c393..e38b021 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "builtin-cmds.h" #include "perf.h" #include "util/util.h" @@ -1742,11 +1743,13 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) if (!argc) usage_with_options(sched_usage, sched_options); +#ifdef CONFIG_BUILTIN_SCRIPT /* * Aliased to 'perf script' for now: */ if (!strcmp(argv[0], "script")) return cmd_script(argc, argv, prefix); +#endif if (!strncmp(argv[0], "rec", 3)) { return __cmd_record(argc, argv); diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a2ff8b7..6f04452 100644 --- a/tools/perf/builti
[PATCH v2 14/14] perf kbuild: add generated Kconfig build-test cases
Thanks to the python module kconfiglib, we were able to generate build configurations. The set is, of course, not exhaustive but for each option, all the possible states are tested. Signed-off-by: Alexis Berlemont --- tools/perf/MANIFEST| 1 + tools/perf/tests/configs/MINIMAL_config| 60 ++ tools/perf/tests/configs/NO_BACKTRACE_config | 73 ++ .../perf/tests/configs/NO_BUILTIN_ANNOTATE_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_BENCH_config | 73 ++ .../tests/configs/NO_BUILTIN_BUILDID_CACHE_config | 73 ++ .../tests/configs/NO_BUILTIN_BUILDID_LIST_config | 71 + tools/perf/tests/configs/NO_BUILTIN_DIFF_config| 71 + tools/perf/tests/configs/NO_BUILTIN_EVLIST_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_HELP_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_INJECT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_KMEM_config| 73 ++ .../perf/tests/configs/NO_BUILTIN_KVM_STAT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_KVM_config | 72 + tools/perf/tests/configs/NO_BUILTIN_LIST_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_LOCK_config| 73 ++ tools/perf/tests/configs/NO_BUILTIN_MEM_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_PROBE_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_RECORD_config | 63 +++ tools/perf/tests/configs/NO_BUILTIN_REPORT_config | 68 tools/perf/tests/configs/NO_BUILTIN_SCHED_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_SCRIPT_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_STAT_config| 71 + tools/perf/tests/configs/NO_BUILTIN_TEST_config| 73 ++ .../perf/tests/configs/NO_BUILTIN_TIMECHART_config | 73 ++ tools/perf/tests/configs/NO_BUILTIN_TOP_config | 71 + tools/perf/tests/configs/NO_BUILTIN_TRACE_config | 73 ++ tools/perf/tests/configs/NO_DEMANGLE_config| 71 + tools/perf/tests/configs/NO_GTK2_config| 73 ++ tools/perf/tests/configs/NO_LIBAUDIT_config| 72 + tools/perf/tests/configs/NO_LIBDWARF_config| 71 + tools/perf/tests/configs/NO_LIBELF_MMAP_config | 73 ++ tools/perf/tests/configs/NO_LIBGTK2_INFOBAR_config | 73 ++ tools/perf/tests/configs/NO_LIBGTK2_config | 71 + tools/perf/tests/configs/NO_LIBNUMA_config | 73 ++ tools/perf/tests/configs/NO_LIBPERL_config | 73 ++ tools/perf/tests/configs/NO_LIBPYTHON_config | 73 ++ tools/perf/tests/configs/NO_LIBSLANG_config| 72 + .../tests/configs/NO_LIBUNWIND_DEBUG_FRAME_config | 73 ++ tools/perf/tests/configs/NO_PERF_REGS_config | 73 ++ tools/perf/tests/configs/NO_STDIO_config | 73 ++ tools/perf/tests/configs/NO_TIMERFD_config | 73 ++ tools/perf/tests/configs/NO_TUI_config | 73 ++ tools/perf/tests/configs/NO_UNWIND_config | 69 tools/perf/tests/configs/REF_config| 73 ++ tools/perf/tests/generate_configs.py | 43 + tools/perf/tests/make | 70 ++--- 47 files changed, 3227 insertions(+), 50 deletions(-) create mode 100644 tools/perf/tests/configs/MINIMAL_config create mode 100644 tools/perf/tests/configs/NO_BACKTRACE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_ANNOTATE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BENCH_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_CACHE_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_LIST_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_DIFF_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_EVLIST_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_HELP_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_INJECT_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KMEM_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KVM_STAT_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KVM_config create mode 100644 tools/perf/tests/configs/NO_BUILTIN_LIST_config create mode 100644 tools/perf/tests/configs
[PATCH v2 11/14] perf kbuild: remove legacy libdwarf-related build variables
* Remove NO_DWARF (replaced by CONFIG_LIBDWARF) * Remove HAVE_DWARF_SUPPORT (replaced by CONFIG_LIBDWARF) * Remove the useless variable PERF_HAVE_DWARF_REGS * fix compilation issues if PERF_REGS is disabled Signed-off-by: Alexis Berlemont --- Changes since v1: * Add the config parameter SKIP_CALLCHAIN_IDX * Fix LIBDWARF_UNWIND directives tools/perf/Kconfig | 59 +- tools/perf/arch/arm/tests/Kbuild | 2 +- tools/perf/arch/arm/util/Kbuild | 4 +- tools/perf/arch/arm64/util/Kbuild| 2 +- tools/perf/arch/powerpc/util/Kbuild | 4 +- tools/perf/arch/s390/util/Kbuild | 2 +- tools/perf/arch/sh/util/Kbuild | 2 +- tools/perf/arch/sparc/util/Kbuild| 2 +- tools/perf/arch/x86/Kbuild | 1 + tools/perf/arch/x86/Makefile | 8 +- tools/perf/arch/x86/tests/Kbuild | 2 +- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 2 +- tools/perf/arch/x86/util/Kbuild | 3 +- tools/perf/builtin-probe.c | 15 +-- tools/perf/builtin-record.c | 2 +- tools/perf/config/Makefile | 170 +-- tools/perf/config/Makefile.fix-config| 8 -- tools/perf/config/Makefile.fix-legacy| 4 - tools/perf/tests/Kbuild | 2 + tools/perf/tests/builtin-test.c | 3 +- tools/perf/tests/tests.h | 6 +- tools/perf/util/Kbuild | 11 +- tools/perf/util/callchain.c | 11 +- tools/perf/util/callchain.h | 3 +- tools/perf/util/include/dwarf-regs.h | 4 +- tools/perf/util/machine.c| 3 +- tools/perf/util/perf_regs.c | 2 - tools/perf/util/probe-event.c| 6 +- tools/perf/util/probe-finder.h | 5 +- tools/perf/util/unwind-libunwind.c | 5 +- tools/perf/util/unwind.h | 7 +- 31 files changed, 203 insertions(+), 157 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 2eaf3ca..54a194d 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -287,7 +287,6 @@ choice these tasks, perf can rely on either the libelf library or a minimal builtin support. - config LIBELF bool "elf" ---help--- @@ -318,15 +317,51 @@ config LIBDWARF bool "Dwarf (libdwarf)" default y ---help--- - libdwarf + A library for parsing DWARF debug information. + +config LIBDWARF_DIR + string "libdwarf directory" + depends on LIBDWARF +---help--- + Directory holding the libdwarf dependency (headers + + libraries) + +config UNWIND +depends on (LIBELF && PERF_REGS) + bool "User space unwind callchains" + default y +---help--- + Enable call-chain unwinding of user-space application. + +choice UNWIND_DEPS + prompt "Unwind dependency" + depends on UNWIND + default LIBUNWIND config LIBUNWIND -depends on LIBELF - bool "User space libunwind callchains" +depends on (LIBELF && PERF_REGS) + bool "Libunwind" +---help--- + Rely on libunwind post unwind support to determine the + call-chain of a user-space program. The library libunwind + supports all the architectures. + +config LIBDWARF_UNWIND +depends on (LIBDWARF && PERF_REGS && (ARCH = "x86" || ARCH = "arm")) + bool "Libdwarf unwind" +---help--- + Rely on lidw DWARF post unwind support to determine the + call-chain of a user-space program. So far there's only x86 + and arm libdw unwind support merged in perf. + +endchoice + +config LIBUNWIND_DEBUG_FRAME +depends on LIBUNWIND + bool "libunwind debug frame" default y ---help--- - The library libunwind provides a portable C API to determine - the call-chain of a program. + libunwind debug frame config LIBUNWIND_DIR string "libunwind directory" @@ -335,6 +370,18 @@ config LIBUNWIND_DIR Directory holding the libuwind dependency (headers + libraries). +config SKIP_CALLCHAIN_IDX + depends on (LIBDWARF && ARCH = "powerpc") + bool "Skip unnecessary callchain entries thanks to Dwarf" + default y +---help--- + When saving the callchain on Power, the kernel + conservatively saves excess entries in the callchain. A few + of these entries are needed in some cases but not others. If + the unnecessary entries are not ignored, we end up with + duplicate arcs
[PATCH v2 09/14] perf kbuild: remove legacy misc build variables
Remove NO_LIBAUDIT (replaced by CONFIG_LIBAUDIT) Remove HAVE_LIBAUDIT_SUPPORT from CFLAGS (replaced by CONFIG_LIBAUDIT) Remove HAVE_TIMERFD_SUPPORT (replaced by CONFIG_TIMERFD) Remove HAVE_ON_EXIT_SUPPORT (replaced by CONFIG_ON_EXIT) Remove HAVE_BACKTRACE_SUPPORT (replaced by CONFIG_BACKTRACE) Remove HAVE_LIBNUMA_SUPPORT (replaced by CONFIG_LIBNUMA) Remove NO_BIONIC (replaced by CONFIG_BIONIC) Remove NO_PERF_REGS (replaced by CONFIG_PERF_REGS) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 12 -- tools/perf/arch/arm/tests/Kbuild | 2 +- tools/perf/arch/x86/tests/Kbuild | 2 +- tools/perf/bench/Kbuild | 2 +- tools/perf/builtin-bench.c| 5 ++-- tools/perf/builtin-kvm.c | 13 ++- tools/perf/builtin-record.c | 2 ++ tools/perf/config/Makefile| 43 +-- tools/perf/config/Makefile.fix-config | 32 -- tools/perf/config/Makefile.fix-legacy | 16 - tools/perf/util/perf_regs.c | 3 +++ tools/perf/util/perf_regs.h | 6 +++-- tools/perf/util/util.c| 5 ++-- 13 files changed, 51 insertions(+), 92 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 5f85923..29853a6 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -312,8 +312,8 @@ config LIBUNWIND_DIR Directory holding the libuwind dependency (headers + libraries). -config NUMA - bool "Numa support (bench)" +config LIBNUMA + bool "Libnuma support" default y ---help--- The library libnuma offers facilities to configure NUMA @@ -327,6 +327,14 @@ config BIONIC library code developed by Google for their Android operating system. +config PERF_REGS + bool "Cache register accesses" + depends on (ARCH = "x86" || ARCH = "arm" || ARCH = "arm64") + default y +---help--- + Cache register accesses for unwind processing to speed-up + performances. + endmenu menu "Build" diff --git a/tools/perf/arch/arm/tests/Kbuild b/tools/perf/arch/arm/tests/Kbuild index 5d63e9d..1318ed0 100644 --- a/tools/perf/arch/arm/tests/Kbuild +++ b/tools/perf/arch/arm/tests/Kbuild @@ -1,2 +1,2 @@ -obj-y += regs_load.o +obj-$(CONFIG_PERF_REGS) += regs_load.o obj-y += dwarf-unwind.o diff --git a/tools/perf/arch/x86/tests/Kbuild b/tools/perf/arch/x86/tests/Kbuild index 3b5aa14..8287dae 100644 --- a/tools/perf/arch/x86/tests/Kbuild +++ b/tools/perf/arch/x86/tests/Kbuild @@ -1,3 +1,3 @@ obj-y += perf-time-to-tsc.o -obj-y += regs_load.o +obj-$(CONFIG_PERF_REGS) += regs_load.o obj-y += dwarf-unwind.o diff --git a/tools/perf/bench/Kbuild b/tools/perf/bench/Kbuild index e604fe2..863646a 100644 --- a/tools/perf/bench/Kbuild +++ b/tools/perf/bench/Kbuild @@ -6,7 +6,7 @@ obj-y += futex-hash.o obj-y += futex-requeue.o obj-y += futex-wake.o -obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_LIBNUMA) += numa.o obj-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o obj-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index b9a56fa..5116d25 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c @@ -14,6 +14,7 @@ * numa ... NUMA scheduling and MM performance * futex ... Futex performance */ +#include "generated/autoconf.h" #include "perf.h" #include "util/util.h" #include "util/parse-options.h" @@ -33,7 +34,7 @@ struct bench { bench_fn_t fn; }; -#ifdef HAVE_LIBNUMA_SUPPORT +#ifdef CONFIG_LIBNUMA static struct bench numa_benchmarks[] = { { "mem","Benchmark for NUMA workloads", bench_numa }, { "all","Test all NUMA benchmarks", NULL }, @@ -72,7 +73,7 @@ struct collection { static struct collection collections[] = { { "sched", "Scheduler and IPC benchmarks", sched_benchmarks}, { "mem","Memory access benchmarks", mem_benchmarks }, -#ifdef HAVE_LIBNUMA_SUPPORT +#ifdef CONFIG_LIBNUMA { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks }, #endif {"futex", "Futex stressing benchmarks", futex_benchmarks}, diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 400e92e..28371f9 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1,3 +1,4 @@ +#include "generated/autoconf.h" #include "builtin.h" #include "perf.h" @@ -20,7 +21,7 @@ #include "util/data.h" #include -#ifdef
[PATCH v2 10/14] perf kbuild: remove legacy libelf-related build variables
Remove NO_LIBELF (replaced by CONFIG_LIBELF) Remove HAVE_LIBELF_SUPPORT (replaced by CONFIG_LIBELF) Remove HAVE_LIBELF_MMAP_SUPPORT (replaced by CONFIG_LIBELF_MMAP) Remove HAVE_LIBELF_GETPHDRNUM__SUPPORT (replaced by CONFIG_LIBELF_GETPHDRNUM_) Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 23 ++ tools/perf/builtin-inject.c | 2 +- tools/perf/config/Makefile| 37 +++ tools/perf/config/Makefile.fix-config | 18 - tools/perf/config/Makefile.fix-legacy | 4 tools/perf/perf.c | 2 +- tools/perf/util/generate-cmdlist.sh | 4 ++-- tools/perf/util/map.c | 3 ++- tools/perf/util/symbol-elf.c | 3 ++- tools/perf/util/symbol.h | 8 10 files changed, 51 insertions(+), 53 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 29853a6..2eaf3ca 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -256,6 +256,7 @@ config TIMERFD Timer via file descriptor config DEMANGLE + depends on LIBELF bool "Demangle symbols" default y ---help--- @@ -298,7 +299,29 @@ choice Builtin elf support. endchoice +config LIBELF_MMAP +depends on LIBELF + bool "Libelf mmap support" + default y +---help--- + libdelf mmap + +config LIBELF_GETPHDRNUM +depends on LIBELF + default y + bool "Libelf getphdrnum support" +---help--- + libdelf mmap + +config LIBDWARF + depends on LIBELF + bool "Dwarf (libdwarf)" + default y +---help--- + libdwarf + config LIBUNWIND +depends on LIBELF bool "User space libunwind callchains" default y ---help--- diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index de99ca1..9d59c7f 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -230,7 +230,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, * account this as unresolved. */ } else { -#ifdef HAVE_LIBELF_SUPPORT +#ifdef CONFIG_LIBELF pr_warning("no symbols found in %s, maybe " "install a debug package?\n", al.map->dso->long_name); diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 5be574c3..79fe047 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -303,12 +303,7 @@ ifdef CONFIG_BIONIC endif endif -ifdef NO_LIBELF - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 - NO_LIBDW_DWARF_UNWIND := 1 -else +ifdef CONFIG_LIBELF ifeq ($(feature-libelf), 0) ifeq ($(feature-glibc), 1) LIBC_SUPPORT := 1 @@ -318,12 +313,9 @@ else endif ifeq ($(LIBC_SUPPORT),1) msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); - - NO_LIBELF := 1 - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 - NO_LIBDW_DWARF_UNWIND := 1 + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF) + $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBELF_MINIMAL) + EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) else ifneq ($(filter s% -static%,$(LDFLAGS),),) msg := $(error No static glibc found, please install glibc-static); @@ -332,6 +324,7 @@ else endif endif else +LIBELF = 1 ifndef NO_LIBDW_DWARF_UNWIND ifneq ($(feature-libdw-dwarf-unwind),1) NO_LIBDW_DWARF_UNWIND := 1 @@ -343,17 +336,20 @@ else NO_DWARF := 1 endif # Dwarf support endif # libelf support -endif # NO_LIBELF +endif # CONFIG_LIBELF -ifndef NO_LIBELF - CFLAGS += -DHAVE_LIBELF_SUPPORT +ifeq ($(LIBELF), 1) - ifeq ($(feature-libelf-mmap), 1) -CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT + ifdef CONFIG_LIBELF_MMAP +ifneq ($(feature-libelf-mmap), 1) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP) +endif endif - ifeq ($(feature-libelf-getphdrnum), 1) -CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT + ifdef CONFIG_LIBELF_MMAP +ifneq ($(feature-libelf-getphdrnum), 1) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP) +endif endif # include ARCH specific config @@ -369,7 +365,7 @@ ifndef NO_LIBELF EXTLIBS += -lelf -ldw endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF -endif # NO_LIBELF +endif # LIBELF ifeq ($(ARCH),powerpc) ifndef NO_DWARF @@ -787,7 +783,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) $(call store,NO_LIBBIONIC) $(call store,ETC_
[PATCH v2 12/14] perf kbuild: remove legacy script-related build variables
Remove NO_LIBPERL (replaced by CONFIG_LIBPERL) Remove NO_LIBPYTHON (replaced by CONFIG_LIBPYTHON) Signed-off-by: Alexis Berlemont --- tools/perf/builtin-script.c | 6 +++-- tools/perf/config/Makefile | 41 + tools/perf/config/Makefile.fix-config | 16 - tools/perf/config/Makefile.fix-legacy | 8 --- tools/perf/util/trace-event-scripting.c | 13 ++- 5 files changed, 22 insertions(+), 62 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9708a12..cc9c305 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1,3 +1,5 @@ +#include "generated/autoconf.h" + #include "builtin.h" #include "perf.h" @@ -1372,11 +1374,11 @@ int find_scripts(char **scripts_array, char **scripts_path_array) for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, lang_dirent.d_name); -#ifdef NO_LIBPERL +#ifndef CONFIG_LIBPERL if (strstr(lang_path, "perl")) continue; #endif -#ifdef NO_LIBPYTHON +#ifndef CONFIG_LIBPYTHON if (strstr(lang_path, "python")) continue; #endif diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index f667229..00d118c 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -101,7 +101,7 @@ ifdef PARSER_DEBUG CFLAGS += -DPARSER_DEBUG endif -ifndef NO_LIBPYTHON +ifdef CONFIG_LIBPYTHON # Try different combinations to accommodate systems that only have # python[2][-config] in weird combinations but always preferring # python2 and python2-config as per pep-0394. If we catch a @@ -460,9 +460,7 @@ endif grep-libs = $(filter -l%,$(1)) strip-libs = $(filter-out -l%,$(1)) -ifdef NO_LIBPERL - CFLAGS += -DNO_LIBPERL -else +ifdef CONFIG_LIBPERL PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) @@ -470,9 +468,8 @@ else FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1) -CFLAGS += -DNO_LIBPERL -NO_LIBPERL := 1 msg := $(warning Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed); +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPERL) else LDFLAGS += $(PERL_EMBED_LDFLAGS) EXTLIBS += $(PERL_EMBED_LIBADD) @@ -486,17 +483,14 @@ ifdef CONFIG_TIMERFD endif endif -disable-python = $(eval $(disable-python_code)) -define disable-python_code - CFLAGS += -DNO_LIBPYTHON - $(if $(1),$(warning No $(1) was found)) - $(warning Python support will not be built) - NO_LIBPYTHON := 1 -endef +ifdef CONFIG_LIBPYTHON -ifdef NO_LIBPYTHON - $(call disable-python) -else + disable-python = $(eval $(disable-python_code)) + define disable-python_code +$(if $(1),$(warning No $(1) was found)) +$(warning Python support will not be built) +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPYTHON) + endef ifndef PYTHON $(call disable-python,python interpreter) @@ -520,18 +514,7 @@ else else ifneq ($(feature-libpython-version), 1) - $(warning Python 3 is not yet supported; please set) - $(warning PYTHON and/or PYTHON_CONFIG appropriately.) - $(warning If you also have Python 2 installed, then) - $(warning try something like:) - $(warning $(and ,)) - $(warning $(and ,) make PYTHON=python2) - $(warning $(and ,)) - $(warning Otherwise, disable Python support entirely:) - $(warning $(and ,)) - $(warning $(and ,) make NO_LIBPYTHON=1) - $(warning $(and ,)) - $(error $(and ,)) + $(call disable-python,python2 interpreter) else LDFLAGS += $(PYTHON_EMBED_LDFLAGS) EXTLIBS += $(PYTHON_EMBED_LIBADD) @@ -781,8 +764,6 @@ all: $(call store,PYTHON_EMBED_CCOPTS) $(call store,PERL_EMBED_CCOPTS) $(call store,NO_LIBUNWIND) - $(call store,NO_LIBPERL) - $(call store,NO_LIBPYTHON) $(call store,ETC_PERFCONFIG_SQ) $(call store,DESTDIR_SQ) $(call store,bindir_SQ) diff --git a/tools/perf/config/Makefile.fix-config b/tools/perf/config/Makefile.fix-config index e63539f..3f0e33e 100644 --- a/tools/perf/config/Makefile.fix-config +++ b/tools/perf/config/Makefile.fix-config @@ -3,20 +3,4 @@ include $(KCONFIG_CONFIG) CONFIG := $(srctree)/scripts/config --file $(KCONFIG_CONFIG) -# NO_LIBPERL -ifdef CONFIG_LIBPERL -ifdef NO_LIBPERL -dummy := $(info Disabling CONFIG_LIBPERL) -dummy := $(shell $(CONFIG) -d CONFIG_LIBPERL) -endif -endif - -# NO_LIBPYTHON -ifdef CONFIG_LIBPYTHON -ifdef NO_LIBPYTHON
[PATCH v2 08/14] perf kbuild: cross-compilation variables are now handled in Kconfig
The variable CONFIG_ARCH and CONFIG_CROSS_COMPILE were added. Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig | 24 tools/perf/Makefile.kbuild | 8 tools/perf/arch/x86/include/perf_regs.h | 8 +--- tools/perf/arch/x86/tests/regs_load.S | 3 ++- tools/perf/arch/x86/util/unwind-libunwind.c | 5 +++-- tools/perf/bench/mem-memcpy-arch.h | 4 +++- tools/perf/bench/mem-memcpy.c | 4 +++- tools/perf/bench/mem-memset-arch.h | 4 +++- tools/perf/bench/mem-memset.c | 4 +++- tools/perf/config/Makefile | 7 ++- 10 files changed, 52 insertions(+), 19 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 026ef67..5f85923 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -1,6 +1,30 @@ mainmenu "The perf configuration" +config TARGET_ARCH + string + option env="ARCH" + +config TARGET_IS_X86_64 + string + option env="IS_X86_64" + +config TARGET_CROSS_COMPILE + string + option env="CROSS_COMPILE" + +config ARCH + string + default TARGET_ARCH + +config X86_64 + bool + default y if TARGET_ARCH = "x86" && TARGET_IS_X86_64 = "1" + +config CROSS_COMPILE + string + default TARGET_CROSS_COMPILE + menu "Built-in commands" config BUILTIN_RECORD diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index 8d9e8b0..b48fe7f 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -123,9 +123,12 @@ export KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG KCONFIG_SCRIPT # perf detected config CONFIG_DETECTED := $(obj-perf)/.config-detected - export CONFIG_DETECTED +# arch-related main variables +include $(src-perf)/config/Makefile.arch +export ARCH IS_X86_64 CROSS_COMPILE + # external .a libs LIBTRACEEVENT := $(obj-kernel)/tools/lib/traceevent/libtraceevent.a LIBAPIKFS := $(obj-kernel)/tools/lib/api/libapikfs.a @@ -202,9 +205,6 @@ ifndef dont-detect ifdef CONFIG_DETECTED_STORED # Following variables are needed within Kbuild files, we need # to export them as they are not part of the .config set. -export CONFIG_ARCH := $(ARCH) -export CROSS_COMPILE -export CONFIG_X86_64 export htmldir_SQ export infodir_SQ export mandir_SQ diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h index 7df517a..d969cca 100644 --- a/tools/perf/arch/x86/include/perf_regs.h +++ b/tools/perf/arch/x86/include/perf_regs.h @@ -5,9 +5,11 @@ #include #include +#include "generated/autoconf.h" + void perf_regs_load(u64 *regs); -#ifndef HAVE_ARCH_X86_64_SUPPORT +#ifndef CONFIG_X86_64 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) #define PERF_REGS_MAX PERF_REG_X86_32_MAX #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32 @@ -58,7 +60,7 @@ static inline const char *perf_reg_name(int id) return "FS"; case PERF_REG_X86_GS: return "GS"; -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 case PERF_REG_X86_R8: return "R8"; case PERF_REG_X86_R9: @@ -75,7 +77,7 @@ static inline const char *perf_reg_name(int id) return "R14"; case PERF_REG_X86_R15: return "R15"; -#endif /* HAVE_ARCH_X86_64_SUPPORT */ +#endif /* CONFIG_X86_64 */ default: return NULL; } diff --git a/tools/perf/arch/x86/tests/regs_load.S b/tools/perf/arch/x86/tests/regs_load.S index 60875d5..822a797 100644 --- a/tools/perf/arch/x86/tests/regs_load.S +++ b/tools/perf/arch/x86/tests/regs_load.S @@ -1,4 +1,5 @@ #include +#include "generated/autoconf.h" #define AX 0 #define BX 1 * 8 @@ -26,7 +27,7 @@ #define R1523 * 8 .text -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 ENTRY(perf_regs_load) movq %rax, AX(%rdi) movq %rbx, BX(%rdi) diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c index db25e93..e4960c1 100644 --- a/tools/perf/arch/x86/util/unwind-libunwind.c +++ b/tools/perf/arch/x86/util/unwind-libunwind.c @@ -1,11 +1,12 @@ #include #include +#include "generated/autoconf.h" #include "perf_regs.h" #include "../../util/unwind.h" #include "../../util/debug.h" -#ifdef HAVE_ARCH_X86_64_SUPPORT +#ifdef CONFIG_X86_64 int libunwind__arch_reg_id(int regnum) { int id; @@ -109,4 +110,4 @@ int libunwind__arch_reg_id(int regnum) return id; } -#endif /* HAVE_ARCH_X86_64_SUPPORT */ +#endif /* CONFIG_X86_64 */ diff --git a/tools/perf/bench/mem-memcpy-arch.h b/tools/perf/bench/mem-memcpy-arch.h index 57b4ed8..8e3f0a9 100644 --- a/tools/perf/bench/mem-memc
[PATCH v2 02/14] perf tools: Kbuild builtin source related fixies
From: Jiri Olsa Adding CONFIG_BUILTIN_* defines to govern builtin commands. This will be useful 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-kbu...@vger.kernel.org Cc: Stephane Eranian Signed-off-by: Alexis Berlemont --- 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 e7417fe..19cb967 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" @@ -115,7 +116,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) { @@ -154,7 +155,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: @@ -173,6 +176,7 @@ find_next: if (next != NULL) nd = next; +#endif /* CONFIG_TUI */ } else { hist_entry__tty_annotate(he, evsel, ann); nd = rb_next(nd); @@ -299,7 +303,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 000..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 25d2062..fbbbaa4 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 b65eb050..400e92e 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1531,20 +1531,25 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused) if (!strncmp(argv[0], "rec", 3))
[PATCH v2 13/14] perf kbuild: final cosmetic changes
* Correctly rename internal makefile variables * Remove makefiles in tools/perf/config which became empty and useless * Remove builtin-cmds.h * Remove arch/x86/Makefile * Improve outputs of clean and install targets * Remove creation of PERF-FEATURES file which is redundant with the .config file generated by Kconfig. * replace HAVE_KVM_STAT_SUPPORT by a Kconfig option * replace HAVE_SKIP_CALLCHAIN_IDX by a Kconfig option Signed-off-by: Alexis Berlemont --- tools/perf/Kconfig| 7 tools/perf/Makefile.kbuild| 74 ++-- tools/perf/arch/s390/util/Kbuild | 2 +- tools/perf/arch/x86/Makefile | 17 tools/perf/arch/x86/util/Kbuild | 2 +- tools/perf/builtin-cmds.h | 6 --- tools/perf/builtin-help.c | 2 +- tools/perf/builtin-kvm.c | 6 +-- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-sched.c| 2 +- tools/perf/config/Makefile| 79 +++ tools/perf/config/Makefile.fix-config | 6 --- tools/perf/config/Makefile.fix-legacy | 2 - tools/perf/perf.c | 2 +- 14 files changed, 83 insertions(+), 126 deletions(-) delete mode 100644 tools/perf/arch/x86/Makefile delete mode 100644 tools/perf/builtin-cmds.h delete mode 100644 tools/perf/config/Makefile.fix-config delete mode 100644 tools/perf/config/Makefile.fix-legacy diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 54a194d..d1b44c3 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -128,6 +128,13 @@ config BUILTIN_KVM ---help--- Tool to trace/measure kvm guest os +config BUILTIN_KVM_STAT + bool "kvm-stat" + default y + depends on BUILTIN_KVM && (ARCH = "x86" || ARCH = "s390") +---help--- + Get performance counter statistics on a kvm guest os. + config BUILTIN_LIST bool "list" default y diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index b48fe7f..90b168d 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -1,6 +1,5 @@ srctree := $(abspath $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)/../../)) objtree := $(abspath $(if $(KBUILD_SRC),$(CURDIR),$(CURDIR)/../..)) - VPATH := $(srctree) export srctree VPATH @@ -36,7 +35,8 @@ export quiet Q KBUILD_VERBOSE ifndef V QUIET_LINK = @echo ' LD $@'; QUIET_GEN = @echo ' GEN $@'; -QUIET_CLEAN = @echo ' CLEAN tools/perf'; +QUIET_CLEAN = @printf ' CLEAN%s\n' $1; +QUIET_INSTALL = @printf ' INSTALL %s\n' $1; endif export QUIET_BISON QUIET_FLEX @@ -158,7 +158,6 @@ $(CONFIG_DETECTED): $(KCONFIG_CONFIG) # no need to include auto.conf.cmd, because .config # is the only dependency here $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) $(CONFIG_DETECTED) - $(Q)$(MAKE) -f $(src-perf)/config/Makefile.fix-config $(Q)mkdir -p $(obj-perf)/include/config $(Q)mkdir -p $(obj-perf)/include/generated $(Q)$(MAKE) -s $(build)=scripts/kconfig silentoldconfig @@ -167,22 +166,26 @@ $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) $(CONFIG_DETECTED) clean-dirs := $(addprefix _clean_, tools/perf/) $(clean-dirs): + $(call QUIET_CLEAN, core-objs) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) -clean: $(clean-dirs) $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean - $(Q)$(QUIET_CLEAN) - $(Q)rm -f $(obj-perf)/perf - $(Q)rm -f $(obj-perf)/common-cmds.h - $(Q)rm -f $(obj-perf)/python/perf.so +config-clean: + $(call QUIET_CLEAN, config) + @$(MAKE) OUTPUT=$(obj-perf)/config/feature-checks/ -C $(src-perf)/config/feature-checks clean >/dev/null $(Q)rm -rf $(obj-perf)/include/generated $(obj-perf)/include/config + $(Q)rm -f $(CONFIG_DETECTED) $(KCONFIG_CONFIG) + $(Q)rm -f $(obj-perf)/common-cmds.h + +clean: $(clean-dirs) $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean config-clean + $(call QUIET_CLEAN, core-progs) + $(Q)rm -f $(obj-perf)/perf + $(call QUIET_CLEAN, misc) $(Q)find $(obj-perf) \ \( -name '*.[oas]' -o -name '.*.cmd' \ -o -name '.*.d' -o -name '.*.tmp' \ -o -name '*-flex.[ch]' -o -name '*-bison.[ch]' \ \) -type f -print | xargs rm -f - $(Q)$(python-clean) - $(Q)rm -f $(CONFIG_DETECTED) $(KCONFIG_CONFIG) - @$(MAKE) OUTPUT=$(obj-perf)/config/feature-checks/ -C $(src-perf)/config/feature-checks clean >/dev/null + $(python-clean) TAGS tags: $(Q)rm -f $(src-perf)/tags @@ -257,7 +260,7 @@ PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/ export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP -python-clean := rm -rf $(PYTHON_EXTBUILD) $(obj-perf)/python/perf.so +python-cl
[PATCH v2 01/14] kbuild: add support of custom paths for "auto.conf*" files
In the scripts/Makefile.build, use KCONFIG_AUTOCONFIG to include a custom path for the "auto.conf" file. The "*conf" programs were modified so as to work with the environment variable KCONFIG_AUTOCONFIG. Signed-off-by: Alexis Berlemont --- Changes since v1: * Use PATH_MAX instead of PATH_MAXLENGTH * Simplify conf_get_autoconfigdep_name() according to Micheal Marek's advices * Remove a superfluous assignment scripts/Makefile.build | 3 ++- scripts/kconfig/confdata.c | 23 ++- scripts/kconfig/lkc.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 649ce68..2abb82f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -31,7 +31,8 @@ subdir-asflags-y := subdir-ccflags-y := # Read auto.conf if it exists, otherwise ignore --include include/config/auto.conf +kconfig-autoconfig := $(if $(KCONFIG_AUTOCONFIG),$(KCONFIG_AUTOCONFIG),include/config/auto.conf) +-include $(kconfig-autoconfig) include scripts/Kbuild.include diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f88d90f..75cf6bf 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -75,6 +75,23 @@ const char *conf_get_autoconfig_name(void) return name ? name : "include/config/auto.conf"; } +const char *conf_get_autoconfigdep_name(void) +{ + static char res_value[PATH_MAX+1]; + + const char *name = conf_get_autoconfig_name(); + + if (strlen(name) > PATH_MAX - 4) + name = NULL; + else { + strcpy(res_value, name); + strcat(res_value, ".cmd"); + name = res_value; + } + + return name; +} + static char *conf_expand_value(const char *in) { struct symbol *sym; @@ -953,7 +970,11 @@ int conf_write_autoconf(void) sym_clear_all_valid(); - file_write_dep("include/config/auto.conf.cmd"); + name = conf_get_autoconfigdep_name(); + if (name == NULL) + return 1; + + file_write_dep(name); if (conf_split_config()) return 1; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index d5daa7a..ac99004 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -84,6 +84,7 @@ const char *zconf_curname(void); /* confdata.c */ const char *conf_get_configname(void); const char *conf_get_autoconfig_name(void); +const char *conf_get_autoconfigdep_name(void); char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); -- 2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 15/15] perf: replace _BSD_SOURCE macro by _DEFAULT_SOURCE
Aaro Koskinen wrote: > Hi, > > On Mon, Sep 22, 2014 at 11:53:16PM +0200, Alexis Berlemont wrote: > > Starting from glibc-2.20, the macro _BSD_SOURCE is deprecated and > > should be replaced by _DEFAULT_SOURCE. > > This patch fixes perf build breakage with glibc-2.20, so _DEFAULT_SOURCE > is needed. > > But shouldn't you also keep _BSD_SOURCE still there for a while for > backwards compatibility? (Not sure if it has relevance for those > using older glibcs...). One more terrible mistake... Sorry. > > Anyway to fix the perf + glibc-2.20 build failure: > > Tested-by: Aaro Koskinen > > (BTW, your patch was missing Signed-off-by.) > OK. I fixed that on the next patch set (and I read the doc linux/Documentation/SubmittingPatches). I hope my next patch set will be less ludicrous... Thank you for your feedback. Alexis > A. > > > --- > > tools/perf/util/util.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h > > index 6686436..f56b4e0 100644 > > --- a/tools/perf/util/util.h > > +++ b/tools/perf/util/util.h > > @@ -38,7 +38,7 @@ > > #define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) > > > > #define _ALL_SOURCE 1 > > -#define _BSD_SOURCE 1 > > +#define _DEFAULT_SOURCE 1 > > #define HAS_BOOL > > > > #include > > -- > > 2.1.0 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > > the body of a message to majord...@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 01/15] kbuild: add support of custom paths for "auto.conf*" files
Michal Marek wrote: > On 2014-09-22 23:53, Alexis Berlemont wrote: > > In the scripts/Makefile.build, use KCONFIG_AUTOCONFIG to include a > > custom path for the "auto.conf" file. > > > > The "*conf" programs were modified so as to work with the environment > > variable KCONFIG_AUTOCONFIG. > > --- > > scripts/Makefile.build | 3 ++- > > scripts/kconfig/confdata.c | 27 ++- > > scripts/kconfig/lkc.h | 1 + > > 3 files changed, 29 insertions(+), 2 deletions(-) > > > > diff --git a/scripts/Makefile.build b/scripts/Makefile.build > > index bf3e677..ef60769 100644 > > --- a/scripts/Makefile.build > > +++ b/scripts/Makefile.build > > @@ -31,7 +31,8 @@ subdir-asflags-y := > > subdir-ccflags-y := > > > > # Read auto.conf if it exists, otherwise ignore > > --include include/config/auto.conf > > +kconfig-autoconfig := $(if > > $(KCONFIG_AUTOCONFIG),$(KCONFIG_AUTOCONFIG),include/config/auto.conf) > > +-include $(kconfig-autoconfig) > > > > include scripts/Kbuild.include > > > > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c > > index f88d90f..d4d8920 100644 > > --- a/scripts/kconfig/confdata.c > > +++ b/scripts/kconfig/confdata.c > > @@ -75,6 +75,27 @@ const char *conf_get_autoconfig_name(void) > > return name ? name : "include/config/auto.conf"; > > } > > > > +#define PATH_MAXLENGTH 4096 > > +const char *conf_get_autoconfigdep_name(void) > > +{ > > + static char res_value[PATH_MAXLENGTH]; > > + > > + char *name = getenv("KCONFIG_AUTOCONFIG"); > > + > > + if (name == NULL) > > + name = "include/config/auto.conf.cmd"; > > This will result in "include/config/auto.conf.cmd.cmd". Better simplify > it to name = conf_get_autoconfig_name(). > Sorry for such a terrible mistake. I broke everything just to make kconfig work for perf... > > > + if (strlen(name) > PATH_MAXLENGTH - 5) > > + name = NULL; > > + else { > > + res_value[0] = 0; > > This assignment is superfluous. OK. > > > > + strncpy(res_value, name, PATH_MAXLENGTH); > > + strcat(res_value, ".cmd"); > > + name = res_value; > > Michal > Alexis -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 01/15] kbuild: add support of custom paths for "auto.conf*" files
Michal Marek wrote: > On 2014-09-22 23:53, Alexis Berlemont wrote: > > +#define PATH_MAXLENGTH 4096 > > +const char *conf_get_autoconfigdep_name(void) > > +{ > > + static char res_value[PATH_MAXLENGTH]; > > Please use the PATH_MAX macro instead. One month later, I take time to answer and apologize... I have some trouble with my free time. Thanks you. This is fixed in the next patch set. Alexis -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 03/15] perf tools: Kbuild source related fixies
From: Jiri Olsa Fixing several sources config dependencies to allow separate config builds. This commit was originally created by Jiri Olsa in 2013. Minor changes were needed to get it working one year later: * Remove #ifdef directives related with GUI / TUI (because of code changes in ui/setup.c) * Fix a link issue if the option BUILTIN_TRACE is disabled. * Fix typo (CONFIG_BULTIN_ instead CONFIG_BUILTIN_) 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-kbu...@vger.kernel.org Cc: Stephane Eranian --- tools/perf/builtin-annotate.c| 6 +++--- tools/perf/builtin-lock.c| 5 - tools/perf/builtin-report.c | 2 +- tools/perf/builtin-sched.c | 3 +++ tools/perf/builtin-top.c | 4 ++-- tools/perf/perf.c| 10 -- tools/perf/ui/browsers/scripts.c | 4 tools/perf/ui/setup.c| 6 +++--- 8 files changed, 28 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index d40070f..aea56c5 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -154,7 +154,7 @@ find_next: /* skip missing symbols */ nd = rb_next(nd); -#ifdef CONFIG_TUI +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) } else if (use_browser == 1) { struct rb_node *next = NULL; key = hist_entry__tui_annotate(he, evsel, NULL); @@ -318,9 +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 +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), -#endif /* CONFIG_TUI */ +#endif 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-lock.c b/tools/perf/builtin-lock.c index 6148afc..f5404dc 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "builtin-cmds.h" #include "perf.h" #include "util/evlist.h" @@ -994,9 +995,11 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) usage_with_options(report_usage, report_options); } rc = __cmd_report(false); +#ifdef CONFIG_BUILTIN_SCRIPT } else if (!strcmp(argv[0], "script")) { /* Aliased to 'perf script' */ - return cmd_script(argc, argv, prefix); + rc = cmd_script(argc, argv, prefix); +#endif } else if (!strcmp(argv[0], "info")) { if (argc) { argc = parse_options(argc, argv, diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c97410a..8dc8077 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -392,7 +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 +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) case 1: ret = perf_evlist__tui_browse_hists(evlist, help, NULL, rep->min_percent, diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index f83c08c..edda0b2 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "builtin-cmds.h" #include "perf.h" #include "util/util.h" @@ -1741,11 +1742,13 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) if (!argc) usage_with_options(sched_usage, sched_options); +#ifdef CONFIG_BUILTIN_SCRIPT /* * Aliased to 'perf script' for now: */ if (!strcmp(argv[0], "script")) return cmd_script(argc, argv, prefix); +#endif symbol__init(); if (!strncmp(argv[0], "rec", 3)) { diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c668b0a..1c807c3 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -535,7 +535,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c) return ret; } -#ifdef CONFIG_TUI +#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD) static void perf_top__sort_new_samples(void *arg) { struct perf_top *t = arg; @@ -958,7 +958,7 @@ static int __cmd_top(struct per
[PATCH 05/15] perf kbuild: remove Makefile.perf
The file Makefile.perf contained legacy build rules. It is replaced by Makefile.kbuild which relies on Kbuild. Consequently, some minor points need updates: * The constant CONFIG_KBUILD can be removed * The main Makefile wrapper now call Makefile.kbuild instead of Makefile.perf --- tools/perf/Makefile | 2 +- tools/perf/Makefile.kbuild| 2 +- tools/perf/Makefile.perf | 942 -- tools/perf/builtin-annotate.c | 4 +- tools/perf/builtin-cmds.h | 25 -- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 4 +- tools/perf/ui/setup.c | 4 +- 8 files changed, 9 insertions(+), 976 deletions(-) delete mode 100644 tools/perf/Makefile.perf diff --git a/tools/perf/Makefile b/tools/perf/Makefile index cb2e586..4512f16 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -55,7 +55,7 @@ define print_msg endef define make - @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ + @$(MAKE) -f Makefile.kbuild --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ endef # diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild index 51eba07..8d9e8b0 100644 --- a/tools/perf/Makefile.kbuild +++ b/tools/perf/Makefile.kbuild @@ -43,7 +43,7 @@ export QUIET_BISON QUIET_FLEX ifeq ($(KBUILD_SRC),) -ifeq ("$(origin O)", "command line") +ifneq ($(O),) KBUILD_OUTPUT := $(O) else KBUILD_OUTPUT := $(objtree) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf deleted file mode 100644 index 16eda216..000 --- a/tools/perf/Makefile.perf +++ /dev/null @@ -1,942 +0,0 @@ -include ../scripts/Makefile.include - -# The default target of this Makefile is... -all: - -include config/utilities.mak - -# Define V to have a more verbose compile. -# -# Define VF to have a more verbose feature check output. -# -# Define O to save output files in a separate directory. -# -# Define ARCH as name of target architecture if you want cross-builds. -# -# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds. -# -# Define NO_LIBPERL to disable perl script extension. -# -# Define NO_LIBPYTHON to disable python script extension. -# -# Define PYTHON to point to the python binary if the default -# `python' is not correct; for example: PYTHON=python2 -# -# Define PYTHON_CONFIG to point to the python-config binary if -# the default `$(PYTHON)-config' is not correct. -# -# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8 -# -# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72. -# -# Define LDFLAGS=-static to build a static binary. -# -# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds. -# -# Define NO_DWARF if you do not want debug-info analysis feature at all. -# -# Define WERROR=0 to disable treating any warnings as errors. -# -# Define NO_NEWT if you do not want TUI support. (deprecated) -# -# Define NO_SLANG if you do not want TUI support. -# -# Define NO_GTK2 if you do not want GTK+ GUI support. -# -# Define NO_DEMANGLE if you do not want C++ symbol demangling. -# -# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) -# -# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf -# backtrace post unwind. -# -# Define NO_BACKTRACE if you do not want stack backtrace debug feature -# -# Define NO_LIBNUMA if you do not want numa perf benchmark -# -# Define NO_LIBAUDIT if you do not want libaudit support -# -# Define NO_LIBBIONIC if you do not want bionic support -# -# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support -# for dwarf backtrace post unwind. - -ifeq ($(srctree),) -srctree := $(patsubst %/,%,$(dir $(shell pwd))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -#$(info Determined 'srctree' to be $(srctree)) -endif - -ifneq ($(objtree),) -#$(info Determined 'objtree' to be $(objtree)) -endif - -ifneq ($(OUTPUT),) -#$(info Determined 'OUTPUT' to be $(OUTPUT)) -endif - -$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD - @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) - @touch $(OUTPUT)PERF-VERSION-FILE - -CC = $(CROSS_COMPILE)gcc -AR = $(CROSS_COMPILE)ar -PKG_CONFIG = $(CROSS_COMPILE)pkg-config - -RM = rm -f -LN = ln -f -MKDIR = mkdir -FIND= find -INSTALL = install -FLEX= flex -BISON = bison -STRIP = strip - -LIB_DIR = $(srctree)/tools/lib/api/ -TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ - -# include config/Makefile by default and rule out -# non-config cases -config := 1 - -NON_CONFIG_TARGETS := clean TAGS tags cscope help - -ifdef MAKECMDGOALS -ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),) - config := 0 -endif -endif - -ifeq ($(config),1) -include config/Makefile -endif - -export prefix bindir sharedir sysconfdir DESTDIR - -# sparse is architecture-neutral, which means that we need to tell it -# explicitly what architecture to check for. Fix this up for yours.. -S
[PATCH 06/15] perf kbuild: remove legacy tui/gui-related build variables
Remove NO_SLANG (replaced by CONFIG_LIBSLANG) Remove HAVE_SLANG_SUPPORT from CFLAGS (replaced by CONFIG_LIBSLANG) Remove NO_GTK2 (replaced by CONFIG_LIBGTK2 or CONFIG_GTK2) Remove HAVE_GTK2_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2) Remove HAVE_GTK_INFO_BAR_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2_INFOBAR) --- tools/perf/Kconfig| 21 + tools/perf/config/Makefile| 20 ++-- tools/perf/config/Makefile.fix-config | 24 tools/perf/config/Makefile.fix-legacy | 8 tools/perf/ui/gtk/browser.c | 4 +++- tools/perf/ui/gtk/gtk.h | 5 +++-- tools/perf/ui/gtk/util.c | 6 -- tools/perf/ui/setup.c | 4 +++- tools/perf/ui/ui.h| 4 +++- tools/perf/util/annotate.h| 4 +++- tools/perf/util/hist.h| 4 +++- 11 files changed, 49 insertions(+), 55 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index f9fcf9e..eb59567 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -171,6 +171,7 @@ config STDIO config TUI bool "Tui (slang based)" + depends on LIBSLANG default y ---help--- Text-based user interface which provides windowing @@ -179,6 +180,7 @@ config TUI config GTK2 bool "Gtk2" default y + depends on LIBGTK2 ---help--- Elaborate display mode based on libgtk2. @@ -186,12 +188,31 @@ endmenu menu "Libraries / Dependencies" +config LIBSLANG + bool "Slang (libslang)" + default y +---help--- + libslang + config LIBAUDIT bool "Audit (libaudit)" default y ---help--- Linux audit framework dependency. +config LIBGTK2 + bool "Gtk2 (libgtk2)" + default y +---help--- + libgtk2 + +config LIBGTK2_INFOBAR + bool "Gtk2 infobar (libgtk2)" + depends on LIBGTK2 + default y +---help--- + libgtk2-infobar + config LIBPERL bool "Perl" default y diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 1434b2f..d6c040c 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -420,32 +420,26 @@ ifndef NO_LIBAUDIT endif endif -ifdef NO_NEWT - NO_SLANG=1 -endif - -ifndef NO_SLANG +ifdef CONFIG_LIBSLANG ifneq ($(feature-libslang), 1) -msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); -NO_SLANG := 1 +msg := $(warning slang not found, disables SLANG and TUI supports. Please install slang-devel or libslang-dev); +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBSLANG) else # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h CFLAGS += -I/usr/include/slang -CFLAGS += -DHAVE_SLANG_SUPPORT EXTLIBS += -lslang endif endif -ifndef NO_GTK2 +ifdef CONFIG_LIBGTK2 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) ifneq ($(feature-gtk2), 1) msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); -NO_GTK2 := 1 +$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2) else ifeq ($(feature-gtk2-infobar), 1) - GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2_INFOBAR) endif -CFLAGS += -DHAVE_GTK2_SUPPORT GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null) GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null) EXTLIBS += -ldl @@ -781,8 +775,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_NEWT) - $(call store,NO_GTK2) $(call store,NO_DEMANGLE) $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) diff --git a/tools/perf/config/Makefile.fix-config b/tools/perf/config/Makefile.fix-config index 7f65fdb..3d84008 100644 --- a/tools/perf/config/Makefile.fix-config +++ b/tools/perf/config/Makefile.fix-config @@ -19,30 +19,6 @@ dummy := $(shell $(CONFIG) -d CONFIG_LIBPYTHON) endif endif -# NO_NEWT -ifdef CONFIG_TUI -ifdef NO_NEWT -dummy := $(info Disabling CONFIG_TUI) -dummy := $(shell $(CONFIG) -d CONFIG_TUI) -endif -endif - -# NO_NEWT -ifdef CONFIG_TUI -ifdef NO_SLANG -dummy := $(info Disabling CONFIG_TUI) -dummy := $(shell $(CONFIG) -d CONFIG_TUI) -endif -endif - -# NO_GTK2 -ifdef CONFIG_GTK2 -ifdef NO_GTK2 -dummy := $(info Disabling CONFIG_GTK2) -dummy := $(shell $(CONFIG) -d CONFIG_GTK2) -endif -endif - # NO_DEMANGLE ifdef CONFIG_DEMANGLE ifdef NO_DEMANGLE diff --git a/tools/perf/config/Makefile.fix-legacy b/tools/perf/config/Makefile.fix-legacy index 2ec91f3..ca219e7 100644 --- a/tools/perf/config/Makefile.fix-legacy +++ b/tools/perf/config/Makefile.fix-legacy @@ -9,14 +9,6 @@ ifndef CONFIG_LIBPYTHON NO_LIBPYTHON
[PATCH 10/15] perf kbuild: remove legacy libelf-related build variables
Remove NO_LIBELF (replaced by CONFIG_LIBELF) Remove HAVE_LIBELF_SUPPORT (replaced by CONFIG_LIBELF) Remove HAVE_LIBELF_MMAP_SUPPORT (replaced by CONFIG_LIBELF_MMAP) Remove HAVE_LIBELF_GETPHDRNUM__SUPPORT (replaced by CONFIG_LIBELF_GETPHDRNUM_) --- tools/perf/Kconfig| 23 ++ tools/perf/builtin-inject.c | 2 +- tools/perf/config/Makefile| 37 +++ tools/perf/config/Makefile.fix-config | 18 - tools/perf/config/Makefile.fix-legacy | 4 tools/perf/perf.c | 2 +- tools/perf/util/generate-cmdlist.sh | 4 ++-- tools/perf/util/map.c | 3 ++- tools/perf/util/symbol-elf.c | 3 ++- tools/perf/util/symbol.h | 8 10 files changed, 51 insertions(+), 53 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 29853a6..2eaf3ca 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -256,6 +256,7 @@ config TIMERFD Timer via file descriptor config DEMANGLE + depends on LIBELF bool "Demangle symbols" default y ---help--- @@ -298,7 +299,29 @@ choice Builtin elf support. endchoice +config LIBELF_MMAP +depends on LIBELF + bool "Libelf mmap support" + default y +---help--- + libdelf mmap + +config LIBELF_GETPHDRNUM +depends on LIBELF + default y + bool "Libelf getphdrnum support" +---help--- + libdelf mmap + +config LIBDWARF + depends on LIBELF + bool "Dwarf (libdwarf)" + default y +---help--- + libdwarf + config LIBUNWIND +depends on LIBELF bool "User space libunwind callchains" default y ---help--- diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 9a02807..ac3ae45 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -229,7 +229,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, * account this as unresolved. */ } else { -#ifdef HAVE_LIBELF_SUPPORT +#ifdef CONFIG_LIBELF pr_warning("no symbols found in %s, maybe " "install a debug package?\n", al.map->dso->long_name); diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 051ea5b..53b094e 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -284,12 +284,7 @@ ifdef CONFIG_BIONIC endif endif -ifdef NO_LIBELF - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 - NO_LIBDW_DWARF_UNWIND := 1 -else +ifdef CONFIG_LIBELF ifeq ($(feature-libelf), 0) ifeq ($(feature-glibc), 1) LIBC_SUPPORT := 1 @@ -299,12 +294,9 @@ else endif ifeq ($(LIBC_SUPPORT),1) msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); - - NO_LIBELF := 1 - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 - NO_LIBDW_DWARF_UNWIND := 1 + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF) + $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBELF_MINIMAL) + EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) else ifneq ($(filter s% -static%,$(LDFLAGS),),) msg := $(error No static glibc found, please install glibc-static); @@ -313,6 +305,7 @@ else endif endif else +LIBELF = 1 ifndef NO_LIBDW_DWARF_UNWIND ifneq ($(feature-libdw-dwarf-unwind),1) NO_LIBDW_DWARF_UNWIND := 1 @@ -324,17 +317,20 @@ else NO_DWARF := 1 endif # Dwarf support endif # libelf support -endif # NO_LIBELF +endif # CONFIG_LIBELF -ifndef NO_LIBELF - CFLAGS += -DHAVE_LIBELF_SUPPORT +ifeq ($(LIBELF), 1) - ifeq ($(feature-libelf-mmap), 1) -CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT + ifdef CONFIG_LIBELF_MMAP +ifneq ($(feature-libelf-mmap), 1) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP) +endif endif - ifeq ($(feature-libelf-getphdrnum), 1) -CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT + ifdef CONFIG_LIBELF_MMAP +ifneq ($(feature-libelf-getphdrnum), 1) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP) +endif endif # include ARCH specific config @@ -350,7 +346,7 @@ ifndef NO_LIBELF EXTLIBS += -lelf -ldw endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF -endif # NO_LIBELF +endif # LIBELF ifndef NO_LIBUNWIND ifneq ($(feature-libunwind), 1) @@ -767,7 +763,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) $(call store,NO_LIBBIONIC) $(call store,ETC_PERFCONFIG_SQ) diff --git a/tools/perf/config/Makefile.fix-config b/tools/perf/config/Makefile.fix-config index 2b
[PATCH 07/15] perf kbuild: remove legacy demangle-related build variables
Remove NO_DEMANGLE (replaced by CONFIG_DEMANGLE) Remove HAVE_LIBBFD_SUPPORT (replaced by CONFIG_LIBBFD) Remove HAVE_CPLUS_DEMANGLE_SUPPORT (replaced by CONFIG_LIBIBERTY_ONLY) --- tools/perf/Kconfig| 36 +-- tools/perf/config/Makefile| 46 ++- tools/perf/config/Makefile.fix-legacy | 4 --- tools/perf/util/srcline.c | 8 +++--- tools/perf/util/symbol.h | 25 +-- 5 files changed, 75 insertions(+), 44 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index eb59567..026ef67 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -225,6 +225,35 @@ config LIBPYTHON ---help--- Libpython dependency needed by the perf script feature. +config TIMERFD + bool "Timer via file descriptor" + default y +---help--- + Timer via file descriptor + +config DEMANGLE + bool "Demangle symbols" + default y +---help--- + Enable demangling so as to display human-readable + symbols. This option is convenient with C++ programs. + +choice DEMANGLE_DEPS + prompt "Demangle dependency(ies)" + depends on DEMANGLE + default LIBBFD + +config LIBBFD + bool "BFD + libiberty libraries" +---help--- + Binary File Descriptor and libiberty libraries + +config LIBIBERTY_ONLY + bool "Libiberty only" +---help--- + Libiberty +endchoice + choice prompt "Elf library" default LIBELF @@ -266,13 +295,6 @@ config NUMA The library libnuma offers facilities to configure NUMA policies supported by the linux kernel. -config DEMANGLE - bool "Demangle symbols" - default y ----help--- - Enable demangling so as to display human-readable - symbols. This option is convenient with C++ programs. - config BIONIC bool "Bionic support" default n diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index d6c040c..ed666c4 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -555,33 +555,36 @@ ifeq ($(feature-libbfd), 1) endif endif -ifdef NO_DEMANGLE - CFLAGS += -DNO_DEMANGLE -else - ifdef HAVE_CPLUS_DEMANGLE_SUPPORT -EXTLIBS += -liberty -CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT - else -ifneq ($(feature-libbfd), 1) - ifneq ($(feature-liberty), 1) -ifneq ($(feature-liberty-z), 1) - # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT - # or any of 'bfd iberty z' trinity - ifeq ($(feature-cplus-demangle), 1) -EXTLIBS += -liberty -CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT - else -msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) -CFLAGS += -DNO_DEMANGLE - endif +ifdef CONFIG_LIBBFD + ifneq ($(feature-libbfd), 1) +# TODO: there might be an issue here: feature-liberty and +# feature-liberty-z cannot be set; they can be set only if +# feature-libbfd is set +ifneq ($(feature-liberty), 1) + ifneq ($(feature-liberty-z), 1) +# we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT +# or any of 'bfd iberty z' trinity +ifeq ($(feature-cplus-demangle), 1) + EXTLIBS += -liberty + $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBBFD) + $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBIBERTY_ONLY) +else + msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) + $(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE) endif endif endif endif endif -ifneq ($(filter -lbfd,$(EXTLIBS)),) - CFLAGS += -DHAVE_LIBBFD_SUPPORT +ifdef CONFIG_LIBIBERTY_ONLY + $(call feature_check,cplus-demangle) + ifeq ($(feature-cplus-demangle), 1) +EXTLIBS += -liberty + else +msg := $(warning No libiberty found, install binutils-dev[el]/zlib-static to gain symbol demangling) +$(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE) + endif endif ifndef NO_BACKTRACE @@ -775,7 +778,6 @@ all: $(call store,NO_LIBUNWIND) $(call store,NO_LIBPERL) $(call store,NO_LIBPYTHON) - $(call store,NO_DEMANGLE) $(call store,NO_LIBELF) $(call store,NO_LIBUNWIND) $(call store,NO_BACKTRACE) diff --git a/tools/perf/config/Makefile.fix-legacy b/tools/perf/config/Makefile.fix-legacy index ca219e7..64dbb1a 100644 --- a/tools/perf/config/Makefile.fix-legacy +++ b/tools/perf/config/Makefile.fix-legacy @@ -9,10 +9,6 @@ ifndef CONFIG_LIBPYTHON NO_LIBPYTHON := 1 endif -ifndef CONFIG_DEMANGLE -NO_DEMANGLE := 1 -endif - ifndef CONFIG_LIBELF NO_LIBELF := 1 endif diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index f3e4bc5..38df8f4 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -4,11 +4,13 @@ #incl
[PATCH 09/15] perf kbuild: remove legacy misc build variables
Remove NO_LIBAUDIT (replaced by CONFIG_LIBAUDIT) Remove HAVE_LIBAUDIT_SUPPORT from CFLAGS (replaced by CONFIG_LIBAUDIT) Remove HAVE_TIMERFD_SUPPORT (replaced by CONFIG_TIMERFD) Remove HAVE_ON_EXIT_SUPPORT (replaced by CONFIG_ON_EXIT) Remove HAVE_BACKTRACE_SUPPORT (replaced by CONFIG_BACKTRACE) Remove HAVE_LIBNUMA_SUPPORT (replaced by CONFIG_LIBNUMA) Remove NO_BIONIC (replaced by CONFIG_BIONIC) Remove NO_PERF_REGS (replaced by CONFIG_PERF_REGS) --- tools/perf/Kconfig| 12 -- tools/perf/arch/arm/tests/Kbuild | 2 +- tools/perf/arch/x86/tests/Kbuild | 2 +- tools/perf/bench/Kbuild | 2 +- tools/perf/builtin-bench.c| 5 ++-- tools/perf/builtin-kvm.c | 13 ++- tools/perf/builtin-record.c | 2 ++ tools/perf/config/Makefile| 43 +-- tools/perf/config/Makefile.fix-config | 32 -- tools/perf/config/Makefile.fix-legacy | 16 - tools/perf/util/perf_regs.c | 3 +++ tools/perf/util/perf_regs.h | 6 +++-- tools/perf/util/util.c| 5 ++-- 13 files changed, 51 insertions(+), 92 deletions(-) diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig index 5f85923..29853a6 100644 --- a/tools/perf/Kconfig +++ b/tools/perf/Kconfig @@ -312,8 +312,8 @@ config LIBUNWIND_DIR Directory holding the libuwind dependency (headers + libraries). -config NUMA - bool "Numa support (bench)" +config LIBNUMA + bool "Libnuma support" default y ---help--- The library libnuma offers facilities to configure NUMA @@ -327,6 +327,14 @@ config BIONIC library code developed by Google for their Android operating system. +config PERF_REGS + bool "Cache register accesses" + depends on (ARCH = "x86" || ARCH = "arm" || ARCH = "arm64") + default y +---help--- + Cache register accesses for unwind processing to speed-up + performances. + endmenu menu "Build" diff --git a/tools/perf/arch/arm/tests/Kbuild b/tools/perf/arch/arm/tests/Kbuild index 5d63e9d..1318ed0 100644 --- a/tools/perf/arch/arm/tests/Kbuild +++ b/tools/perf/arch/arm/tests/Kbuild @@ -1,2 +1,2 @@ -obj-y += regs_load.o +obj-$(CONFIG_PERF_REGS) += regs_load.o obj-y += dwarf-unwind.o diff --git a/tools/perf/arch/x86/tests/Kbuild b/tools/perf/arch/x86/tests/Kbuild index 3b5aa14..8287dae 100644 --- a/tools/perf/arch/x86/tests/Kbuild +++ b/tools/perf/arch/x86/tests/Kbuild @@ -1,3 +1,3 @@ obj-y += perf-time-to-tsc.o -obj-y += regs_load.o +obj-$(CONFIG_PERF_REGS) += regs_load.o obj-y += dwarf-unwind.o diff --git a/tools/perf/bench/Kbuild b/tools/perf/bench/Kbuild index e604fe2..863646a 100644 --- a/tools/perf/bench/Kbuild +++ b/tools/perf/bench/Kbuild @@ -6,7 +6,7 @@ obj-y += futex-hash.o obj-y += futex-requeue.o obj-y += futex-wake.o -obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_LIBNUMA) += numa.o obj-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o obj-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index b9a56fa..5116d25 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c @@ -14,6 +14,7 @@ * numa ... NUMA scheduling and MM performance * futex ... Futex performance */ +#include "generated/autoconf.h" #include "perf.h" #include "util/util.h" #include "util/parse-options.h" @@ -33,7 +34,7 @@ struct bench { bench_fn_t fn; }; -#ifdef HAVE_LIBNUMA_SUPPORT +#ifdef CONFIG_LIBNUMA static struct bench numa_benchmarks[] = { { "mem","Benchmark for NUMA workloads", bench_numa }, { "all","Test all NUMA benchmarks", NULL }, @@ -72,7 +73,7 @@ struct collection { static struct collection collections[] = { { "sched", "Scheduler and IPC benchmarks", sched_benchmarks}, { "mem","Memory access benchmarks", mem_benchmarks }, -#ifdef HAVE_LIBNUMA_SUPPORT +#ifdef CONFIG_LIBNUMA { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks }, #endif {"futex", "Futex stressing benchmarks", futex_benchmarks}, diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index eb92ec0..0e1f244 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1,3 +1,4 @@ +#include "generated/autoconf.h" #include "builtin.h" #include "perf.h" @@ -20,7 +21,7 @@ #include "util/data.h" #include -#ifdef HAVE_TIMERFD_SUPPORT +#ifdef CONFIG_TIMERFD #include #endif @@ -123,7 +124,7 @@ static void init_kvm_event_record(struct perf_kvm_stat *kvm) INIT_LIST_HEAD(&kvm->kvm_events_cache[i]); } -#ifdef HAVE_TIMERFD_SUPPORT +#ifdef CONFIG_TIMERFD static void clear_events_cache_stats(struct