Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 1/2] perf tools: Move graph_line and graph_dotted_line from top

0 views
Skip to first unread message

Arnaldo Carvalho de Melo

unread,
Nov 23, 2009, 2:51:36 PM11/23/09
to Ingo Molnar, linux-...@vger.kernel.org, Arnaldo Carvalho de Melo, Frédéric Weisbecker, Mike Galbraith, Peter Zijlstra, Paul Mackerras
From: Arnaldo Carvalho de Melo <ac...@redhat.com>

So that they can be used in other tools.

Cc: Frédéric Weisbecker <fwei...@gmail.com>
Cc: Mike Galbraith <efa...@gmx.de>
Cc: Peter Zijlstra <a.p.zi...@chello.nl>
Cc: Paul Mackerras <pau...@samba.org>
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>
---
tools/perf/builtin-top.c | 7 -------
tools/perf/util/ctype.c | 8 ++++++++
tools/perf/util/util.h | 3 +++
3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index eef9caa..6a5de90 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -80,13 +80,6 @@ static bool hide_kernel_symbols = false;
static bool hide_user_symbols = false;
static struct winsize winsize;
const char *vmlinux_name;
-static const char *graph_line =
- "_____________________________________________________________________"
- "_____________________________________________________________________";
-static const char *graph_dotted_line =
- "---------------------------------------------------------------------"
- "---------------------------------------------------------------------"
- "---------------------------------------------------------------------";

/*
* Source
diff --git a/tools/perf/util/ctype.c b/tools/perf/util/ctype.c
index 0b791bd..3507362 100644
--- a/tools/perf/util/ctype.c
+++ b/tools/perf/util/ctype.c
@@ -29,3 +29,11 @@ unsigned char sane_ctype[256] = {
A, A, A, A, A, A, A, A, A, A, A, R, R, P, P, 0, /* 112..127 */
/* Nothing in the 128.. range */
};
+
+const char *graph_line =
+ "_____________________________________________________________________"
+ "_____________________________________________________________________";
+const char *graph_dotted_line =
+ "---------------------------------------------------------------------"
+ "---------------------------------------------------------------------"
+ "---------------------------------------------------------------------";
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index f2203a0..e1c623e 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -84,6 +84,9 @@
#include <iconv.h>
#endif

+extern const char *graph_line;
+extern const char *graph_dotted_line;
+
/* On most systems <limits.h> would have given us this, but
* not on some systems (e.g. GNU/Hurd).
*/
--
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Arnaldo Carvalho de Melo

unread,
Nov 23, 2009, 2:51:48 PM11/23/09
to Ingo Molnar, linux-...@vger.kernel.org, Arnaldo Carvalho de Melo, Eduard - Gabriel Munteanu, Frédéric Weisbecker, linu...@kvack.org, Li Zefan, Mike Galbraith, Paul Mackerras, Pekka Enberg, Peter Zijlstra, Steven Rostedt
From: Arnaldo Carvalho de Melo <ac...@redhat.com>

E.g.

[root@doppio linux-2.6-tip]# perf kmem record sleep 3s
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.804 MB perf.data (~35105 samples) ]
[root@doppio linux-2.6-tip]# perf kmem --stat caller | head -10
------------------------------------------------------------------------------
Callsite |Total_alloc/Per | Total_req/Per | Hit | Frag
------------------------------------------------------------------------------
getname/40 | 1519616/4096 | 1519616/4096 | 371| 0.000%
seq_read/a2 | 987136/4096 | 987136/4096 | 241| 0.000%
__netdev_alloc_skb/43 | 260368/1049 | 259968/1048 | 248| 0.154%
__alloc_skb/5a | 77312/256 | 77312/256 | 302| 0.000%
proc_alloc_inode/33 | 76480/632 | 76472/632 | 121| 0.010%
get_empty_filp/8d | 70272/192 | 70272/192 | 366| 0.000%
split_vma/8e | 42064/176 | 42064/176 | 239| 0.000%
[root@doppio linux-2.6-tip]#

Cc: Eduard - Gabriel Munteanu <eduard....@linux360.ro>
Cc: Frédéric Weisbecker <fwei...@gmail.com>
Cc: linu...@kvack.org <linu...@kvack.org>
Cc: Li Zefan <li...@cn.fujitsu.com>
Cc: Mike Galbraith <efa...@gmx.de>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Pekka Enberg <pen...@cs.helsinki.fi>
Cc: Peter Zijlstra <a.p.zi...@chello.nl>
Cc: Steven Rostedt <ros...@goodmis.org>


Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>
---

tools/perf/builtin-kmem.c | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 5d8aeae..256d18f 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -307,25 +307,34 @@ static void __print_result(struct rb_root *root, int n_lines, int is_caller)
{
struct rb_node *next;

- printf("\n ------------------------------------------------------------------------------\n");
- if (is_caller)
- printf(" Callsite |");
- else
- printf(" Alloc Ptr |");
- printf(" Total_alloc/Per | Total_req/Per | Hit | Fragmentation\n");
- printf(" ------------------------------------------------------------------------------\n");
+ printf("%.78s\n", graph_dotted_line);
+ printf("%-28s|", is_caller ? "Callsite": "Alloc Ptr");
+ printf("Total_alloc/Per | Total_req/Per | Hit | Frag\n");
+ printf("%.78s\n", graph_dotted_line);

next = rb_first(root);

while (next && n_lines--) {
- struct alloc_stat *data;
-
- data = rb_entry(next, struct alloc_stat, node);
+ struct alloc_stat *data = rb_entry(next, struct alloc_stat,
+ node);
+ struct symbol *sym = NULL;
+ char bf[BUFSIZ];
+ u64 addr;
+
+ if (is_caller) {
+ addr = data->call_site;
+ sym = kernel_maps__find_symbol(addr, NULL, NULL);
+ } else
+ addr = data->ptr;
+
+ if (sym != NULL)
+ snprintf(bf, sizeof(bf), "%s/%Lx", sym->name,
+ addr - sym->start);
+ else
+ snprintf(bf, sizeof(bf), "%#Lx", addr);

- printf(" %-16p | %8llu/%-6lu | %8llu/%-6lu | %6lu | %8.3f%%\n",
- is_caller ? (void *)(unsigned long)data->call_site :
- (void *)(unsigned long)data->ptr,
- (unsigned long long)data->bytes_alloc,
+ printf("%-28s|%8llu/%-6lu |%8llu/%-6lu|%6lu|%8.3f%%\n",
+ bf, (unsigned long long)data->bytes_alloc,
(unsigned long)data->bytes_alloc / data->hit,
(unsigned long long)data->bytes_req,
(unsigned long)data->bytes_req / data->hit,

Pekka Enberg

unread,
Nov 23, 2009, 3:03:36 PM11/23/09
to Arnaldo Carvalho de Melo, Ingo Molnar, linux-...@vger.kernel.org, Arnaldo Carvalho de Melo, Eduard - Gabriel Munteanu, Frédéric Weisbecker, linu...@kvack.org, Li Zefan, Mike Galbraith, Paul Mackerras, Peter Zijlstra, Steven Rostedt
On Mon, Nov 23, 2009 at 9:51 PM, Arnaldo Carvalho de Melo
<ac...@infradead.org> wrote:
> From: Arnaldo Carvalho de Melo <ac...@redhat.com>
>
> E.g.
>
> [root@doppio linux-2.6-tip]# perf kmem record sleep 3s
> [ perf record: Woken up 2 times to write data ]
> [ perf record: Captured and wrote 0.804 MB perf.data (~35105 samples) ]
> [root@doppio linux-2.6-tip]# perf kmem --stat caller | head -10
> ------------------------------------------------------------------------------
> Callsite � � � � � � � � � �|Total_alloc/Per | Total_req/Per | Hit �| Frag
> ------------------------------------------------------------------------------
> getname/40 � � � � � � � � �| 1519616/4096 � | 1519616/4096 �| � 371| � 0.000%
> seq_read/a2 � � � � � � � � | �987136/4096 � | �987136/4096 �| � 241| � 0.000%
> __netdev_alloc_skb/43 � � � | �260368/1049 � | �259968/1048 �| � 248| � 0.154%
> __alloc_skb/5a � � � � � � �| � 77312/256 � �| � 77312/256 � | � 302| � 0.000%
> proc_alloc_inode/33 � � � � | � 76480/632 � �| � 76472/632 � | � 121| � 0.010%
> get_empty_filp/8d � � � � � | � 70272/192 � �| � 70272/192 � | � 366| � 0.000%
> split_vma/8e � � � � � � � �| � 42064/176 � �| � 42064/176 � | � 239| � 0.000%
> [root@doppio linux-2.6-tip]#
>
> Cc: Eduard - Gabriel Munteanu <eduard....@linux360.ro>
> Cc: Fr�d�ric Weisbecker <fwei...@gmail.com>

> Cc: linu...@kvack.org <linu...@kvack.org>
> Cc: Li Zefan <li...@cn.fujitsu.com>
> Cc: Mike Galbraith <efa...@gmx.de>
> Cc: Paul Mackerras <pau...@samba.org>
> Cc: Pekka Enberg <pen...@cs.helsinki.fi>
> Cc: Peter Zijlstra <a.p.zi...@chello.nl>
> Cc: Steven Rostedt <ros...@goodmis.org>
> Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>

Looks good to me!

Acked-by: Pekka Enberg <pen...@cs.helsinki.fi>

Li Zefan

unread,
Nov 23, 2009, 7:51:50 PM11/23/09
to Arnaldo Carvalho de Melo, Ingo Molnar, linux-...@vger.kernel.org, Arnaldo Carvalho de Melo, Eduard - Gabriel Munteanu, Frédéric Weisbecker, linu...@kvack.org, Mike Galbraith, Paul Mackerras, Pekka Enberg, Peter Zijlstra, Steven Rostedt

I was about to send out my version. Any, thanks for doing this!

Arnaldo Carvalho de Melo

unread,
Nov 23, 2009, 8:20:54 PM11/23/09
to Li Zefan, Ingo Molnar, linux-...@vger.kernel.org, Eduard - Gabriel Munteanu, Frédéric Weisbecker, linu...@kvack.org, Mike Galbraith, Paul Mackerras, Pekka Enberg, Peter Zijlstra, Steven Rostedt
Em Tue, Nov 24, 2009 at 08:50:57AM +0800, Li Zefan escreveu:
> Arnaldo Carvalho de Melo wrote:
> > From: Arnaldo Carvalho de Melo <ac...@redhat.com>
> > tools/perf/builtin-kmem.c | 37 +++++++++++++++++++++++--------------
> > 1 files changed, 23 insertions(+), 14 deletions(-)
>
> I was about to send out my version. Any, thanks for doing this!

Ok, I'll have some sleep now, hack away! :-)

- Arnaldo

0 new messages