From 2190de2f59b3a371f7a5bf8dcc7a0c3f71723679 Mon Sep 17 00:00:00 2001 From: Thavidu Ranatunga Date: Mon, 5 Jul 2010 18:00:14 +1000 Subject: perf: Version String fix, using kernel version Changes the Perf --version string such that it shows the kernel version as suggested by Ingo as follows: That way the perf that comes with v2.6.34 will be: perf version v2.6.34 while interim versions will have the version of the interim kernel - for example: perf version v2.6.35-rc4-70-g39ef13a This functionality was already in the perf version generator file except that it was looking for a .git in the perf directory instead of the kernel directory. Signed-off-by: Thavidu Ranatunga Acked-by: Ian Munsie Acked-by: Peter Zijlstra Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo LKML-Reference: <1278316815-6099-1-git-send-email-tharan@au1.ibm.com> Signed-off-by: Ingo Molnar --- tools/perf/util/PERF-VERSION-GEN | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index 49ece79..1b32e8c 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN @@ -15,7 +15,7 @@ LF=' if test -f version then VN=$(cat version) || VN="$DEF_VER" -elif test -d .git -o -f .git && +elif test -d ../../.git -o -f ../../.git && VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && case "$VN" in *$LF*) (exit 1) ;; -- cgit v1.1 From 869599ceda4a035cdb3345c563b74cdeef10f790 Mon Sep 17 00:00:00 2001 From: Thavidu Ranatunga Date: Mon, 5 Jul 2010 18:00:15 +1000 Subject: perf: Version String fix, for fallback if not from git This gets rid of the default version fallback for Perf and changes it so that it returns the version of the kernel from it's Makefile (if sources were not from git, ie. if it was downloaded from a tarball) Signed-off-by: Thavidu Ranatunga Acked-by: Ian Munsie Acked-by: Peter Zijlstra Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo LKML-Reference: <1278316815-6099-2-git-send-email-tharan@au1.ibm.com> Signed-off-by: Ingo Molnar --- tools/perf/util/PERF-VERSION-GEN | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tools') diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index 1b32e8c..97d7656 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN @@ -5,17 +5,13 @@ if [ $# -eq 1 ] ; then fi GVF=${OUTPUT}PERF-VERSION-FILE -DEF_VER=v0.0.2.PERF LF=' ' -# First see if there is a version file (included in release tarballs), -# then try git-describe, then default. -if test -f version -then - VN=$(cat version) || VN="$DEF_VER" -elif test -d ../../.git -o -f ../../.git && +# First check if there is a .git to get the version from git describe +# otherwise try to get the version from the kernel makefile +if test -d ../../.git -o -f ../../.git && VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && case "$VN" in *$LF*) (exit 1) ;; @@ -27,7 +23,12 @@ elif test -d ../../.git -o -f ../../.git && then VN=$(echo "$VN" | sed -e 's/-/./g'); else - VN="$DEF_VER" + eval `grep '^VERSION\s*=' ../../Makefile|tr -d ' '` + eval `grep '^PATCHLEVEL\s*=' ../../Makefile|tr -d ' '` + eval `grep '^SUBLEVEL\s*=' ../../Makefile|tr -d ' '` + eval `grep '^EXTRAVERSION\s*=' ../../Makefile|tr -d ' '` + + VN="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}" fi VN=$(expr "$VN" : v*'\(.*\)') -- cgit v1.1 From 97aa1052739c6a06cb6b0467dbf410613d20bc97 Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Thu, 8 Jul 2010 06:06:17 +0200 Subject: perf: Resurrect flat callchains Initialize the callchain radix tree root correctly. When we walk through the parents, we must stop after the root, but since it wasn't well initialized, its parent pointer was random. Also the number of hits was random because uninitialized, hence it was part of the callchain while the root doesn't contain anything. This fixes segfaults and percentages followed by empty callchains while running: perf report -g flat Reported-by: Ingo Molnar Signed-off-by: Frederic Weisbecker Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Cc: Paul Mackerras Cc: 2.6.31.x-2.6.34.x --- tools/perf/util/callchain.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tools') diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 1ca73e4..22dbaec 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h @@ -49,6 +49,9 @@ static inline void callchain_init(struct callchain_node *node) INIT_LIST_HEAD(&node->brothers); INIT_LIST_HEAD(&node->children); INIT_LIST_HEAD(&node->val); + + node->parent = NULL; + node->hit = 0; } static inline u64 cumul_hits(struct callchain_node *node) -- cgit v1.1 From 108553e1f3c45a92d23681a378ad9e4c3230eebc Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Thu, 8 Jul 2010 03:41:46 +0200 Subject: perf: Sync callchains with period based hits Hists have their hits increased by the event period. And this period based counting is the foundation of all the stats in perf report. But callchains still use the raw number of hits, without taking the period into account. So when we compute the percentage, absolute based percentages are totally broken, and relative ones too in the first parent level. Because we pass the number of events muliplied by their period as the total number of hits to the callchain filtering, while callchains expect this number to be the number of raw hits. perf report -g graph was simply not working, showing no graph unless the min percent was zero. And even there the percentage of the branches was always 0. And may be fractal filtering was broken on the first branch level too. flat also was broken, but it was hidden because of other breakages. Anyway fix this by counting using periods on callchains. Signed-off-by: Frederic Weisbecker Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Cc: Paul Mackerras --- tools/perf/builtin-report.c | 2 +- tools/perf/util/callchain.c | 35 ++++++++++++++++++----------------- tools/perf/util/callchain.h | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) (limited to 'tools') diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 3592057..fd7407c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -107,7 +107,7 @@ static int perf_session__add_hist_entry(struct perf_session *self, goto out_free_syms; err = 0; if (symbol_conf.use_callchain) { - err = append_chain(he->callchain, data->callchain, syms); + err = append_chain(he->callchain, data->callchain, syms, data->period); if (err) goto out_free_syms; } diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 62b69ad..52c777e 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -230,7 +230,7 @@ fill_node(struct callchain_node *node, struct resolved_chain *chain, int start) static void add_child(struct callchain_node *parent, struct resolved_chain *chain, - int start) + int start, u64 period) { struct callchain_node *new; @@ -238,7 +238,7 @@ add_child(struct callchain_node *parent, struct resolved_chain *chain, fill_node(new, chain, start); new->children_hit = 0; - new->hit = 1; + new->hit = period; } /* @@ -248,7 +248,8 @@ add_child(struct callchain_node *parent, struct resolved_chain *chain, */ static void split_add_child(struct callchain_node *parent, struct resolved_chain *chain, - struct callchain_list *to_split, int idx_parents, int idx_local) + struct callchain_list *to_split, int idx_parents, int idx_local, + u64 period) { struct callchain_node *new; struct list_head *old_tail; @@ -275,41 +276,41 @@ split_add_child(struct callchain_node *parent, struct resolved_chain *chain, /* create a new child for the new branch if any */ if (idx_total < chain->nr) { parent->hit = 0; - add_child(parent, chain, idx_total); - parent->children_hit++; + add_child(parent, chain, idx_total, period); + parent->children_hit += period; } else { - parent->hit = 1; + parent->hit = period; } } static int __append_chain(struct callchain_node *root, struct resolved_chain *chain, - unsigned int start); + unsigned int start, u64 period); static void __append_chain_children(struct callchain_node *root, struct resolved_chain *chain, - unsigned int start) + unsigned int start, u64 period) { struct callchain_node *rnode; /* lookup in childrens */ chain_for_each_child(rnode, root) { - unsigned int ret = __append_chain(rnode, chain, start); + unsigned int ret = __append_chain(rnode, chain, start, period); if (!ret) goto inc_children_hit; } /* nothing in children, add to the current node */ - add_child(root, chain, start); + add_child(root, chain, start, period); inc_children_hit: - root->children_hit++; + root->children_hit += period; } static int __append_chain(struct callchain_node *root, struct resolved_chain *chain, - unsigned int start) + unsigned int start, u64 period) { struct callchain_list *cnode; unsigned int i = start; @@ -345,18 +346,18 @@ __append_chain(struct callchain_node *root, struct resolved_chain *chain, /* we match only a part of the node. Split it and add the new chain */ if (i - start < root->val_nr) { - split_add_child(root, chain, cnode, start, i - start); + split_add_child(root, chain, cnode, start, i - start, period); return 0; } /* we match 100% of the path, increment the hit */ if (i - start == root->val_nr && i == chain->nr) { - root->hit++; + root->hit += period; return 0; } /* We match the node and still have a part remaining */ - __append_chain_children(root, chain, i); + __append_chain_children(root, chain, i, period); return 0; } @@ -380,7 +381,7 @@ static void filter_context(struct ip_callchain *old, struct resolved_chain *new, int append_chain(struct callchain_node *root, struct ip_callchain *chain, - struct map_symbol *syms) + struct map_symbol *syms, u64 period) { struct resolved_chain *filtered; @@ -397,7 +398,7 @@ int append_chain(struct callchain_node *root, struct ip_callchain *chain, if (!filtered->nr) goto end; - __append_chain_children(root, filtered, 0); + __append_chain_children(root, filtered, 0, period); end: free(filtered); diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 22dbaec..f2e9ee1 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h @@ -61,7 +61,7 @@ static inline u64 cumul_hits(struct callchain_node *node) int register_callchain_param(struct callchain_param *param); int append_chain(struct callchain_node *root, struct ip_callchain *chain, - struct map_symbol *syms); + struct map_symbol *syms, u64 period); bool ip_callchain__valid(struct ip_callchain *chain, event_t *event); #endif /* __PERF_CALLCHAIN_H */ -- cgit v1.1 From 1fa6ac379c6353faa628703b7ed1ee3e2023ef75 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 14 Jul 2010 22:59:00 -0700 Subject: perf: Add DWARF register lookup for sparc Signed-off-by: David S. Miller --- tools/perf/arch/sparc/Makefile | 4 +++ tools/perf/arch/sparc/util/dwarf-regs.c | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tools/perf/arch/sparc/Makefile create mode 100644 tools/perf/arch/sparc/util/dwarf-regs.c (limited to 'tools') diff --git a/tools/perf/arch/sparc/Makefile b/tools/perf/arch/sparc/Makefile new file mode 100644 index 0000000..15130b50 --- /dev/null +++ b/tools/perf/arch/sparc/Makefile @@ -0,0 +1,4 @@ +ifndef NO_DWARF +PERF_HAVE_DWARF_REGS := 1 +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o +endif diff --git a/tools/perf/arch/sparc/util/dwarf-regs.c b/tools/perf/arch/sparc/util/dwarf-regs.c new file mode 100644 index 0000000..0ab8848 --- /dev/null +++ b/tools/perf/arch/sparc/util/dwarf-regs.c @@ -0,0 +1,43 @@ +/* + * Mapping of DWARF debug register numbers into register names. + * + * Copyright (C) 2010 David S. Miller + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include + +#define SPARC_MAX_REGS 96 + +const char *sparc_regs_table[SPARC_MAX_REGS] = { + "%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", + "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", + "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", + "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", + "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", + "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", + "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", + "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31", + "%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39", + "%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47", + "%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55", + "%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63", +}; + +/** + * get_arch_regstr() - lookup register name from it's DWARF register number + * @n: the DWARF register number + * + * get_arch_regstr() returns the name of the register in struct + * regdwarfnum_table from it's DWARF register number. If the register is not + * found in the table, this returns NULL; + */ +const char *get_arch_regstr(unsigned int n) +{ + return (n <= SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL; +} -- cgit v1.1