From: Masami Hiramatsu on
Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme(a)redhat.com>
>
> Removing one extra step needed in the tools that need this, fixing a bug
> in 'perf probe' where this was not being done.

Thanks,
BTW, when O_WRONLY should be used? I guess I might misunderstand something
in builtin-probe.c, and it should use O_RDONLY ...



--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat(a)redhat.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Arnaldo Carvalho de Melo on
Em Wed, Jan 27, 2010 at 06:17:58PM -0500, Masami Hiramatsu escreveu:
> Arnaldo Carvalho de Melo wrote:
> > From: Arnaldo Carvalho de Melo <acme(a)redhat.com>
> >
> > Removing one extra step needed in the tools that need this, fixing a bug
> > in 'perf probe' where this was not being done.
>
> Thanks,
> BTW, when O_WRONLY should be used? I guess I might misunderstand something
> in builtin-probe.c, and it should use O_RDONLY ...

O_RDONLY only when you have a perf.data file, O_WRONLY was thought for
'perf record', then for tools that want only to do symbol lookup it was
reused...

I think we should have a proper enum and more clearly specify these
semantics, as well as adding a MMAP mode so that we can lift the code
now in perf top somehow.

But for now using O_WRONLY provides what 'perf probe' needs, I guess :-)

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Masami Hiramatsu on
Arnaldo Carvalho de Melo wrote:
> Em Wed, Jan 27, 2010 at 06:17:58PM -0500, Masami Hiramatsu escreveu:
>> Arnaldo Carvalho de Melo wrote:
>>> From: Arnaldo Carvalho de Melo <acme(a)redhat.com>
>>>
>>> Removing one extra step needed in the tools that need this, fixing a bug
>>> in 'perf probe' where this was not being done.
>>
>> Thanks,
>> BTW, when O_WRONLY should be used? I guess I might misunderstand something
>> in builtin-probe.c, and it should use O_RDONLY ...
>
> O_RDONLY only when you have a perf.data file, O_WRONLY was thought for
> 'perf record', then for tools that want only to do symbol lookup it was
> reused...

Ah, so that is the mode for perf.data.

> I think we should have a proper enum and more clearly specify these
> semantics, as well as adding a MMAP mode so that we can lift the code
> now in perf top somehow.

Yeah, and if you can separate an interface only for handling symbols
from debug/elf binaries, it will be helpful for me too.

> But for now using O_WRONLY provides what 'perf probe' needs, I guess :-)

I think so ;-)

Acked-by: Masami Hiramatsu <mhiramat(a)redhat.com>

Thank you,

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat(a)redhat.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Arnaldo Carvalho de Melo on
Em Thu, Jan 28, 2010 at 11:28:29AM -0500, Masami Hiramatsu escreveu:

> Yeah, and if you can separate an interface only for handling symbols
> from debug/elf binaries, it will be helpful for me too.

It was done on this same series, now you can do as the patch at the end
of this message, that will be on my next series, does.

Testing with this patch:

[root(a)doppio ~]# perf probe --list
[root(a)doppio ~]# perf probe schedule
Added new event:
probe:schedule (on schedule+0)

You can now use it on all perf tools, such as:

perf record -e probe:schedule -a sleep 1

[root(a)doppio ~]# perf record -e probe:schedule -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.158 MB perf.data (~6923 samples) ]
[root(a)doppio ~]# perf report | head -9
# Samples: 4
#
# Overhead Command Shared Object Symbol
# ........ ............... ..................... ......
#
25.00% perf libc-2.10.2.so [.] __GI___libc_read
25.00% kondemand/1 [kernel.kallsyms] [k] kernel_thread_helper
25.00% kondemand/0 [kernel.kallsyms] [k] kernel_thread_helper
[root(a)doppio ~]#

And what about support for modules? You have everything you need there
as well :-)

If you do:

struct map *mod;
struct symbol *sym;

mod = map_groups__find_by_name(&session.kmap_groups,
MAP__FUNCTION, "[ipv6]");

sym = map__find_symbol_by_name(module, "ip6_xmit");

you'll get ipv6.ko located and loaded, mod->dso->long_name thus will
have the file to use with libdwarf and sym->start will have the
unrelocated address, and mod->start will have where ipv6 is loaded in
kernel space.

Also you should be able to find variables by name or address too, just
use MAP__VARIABLE where above you see MAP__FUNCTION.

- Arnaldo

From 387ab05301cce32c8b091ba9feb94c906124e8a8 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <acme(a)redhat.com>
Date: Thu, 28 Jan 2010 16:12:31 -0200
Subject: [PATCH 1/1] perf probe: Don't use a perf_session instance just to resolve symbols
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

With the recent modifications done to untie the session and symbol
layers, 'perf probe' now can use just the symbols layer.

Cc: Fr�d�ric Weisbecker <fweisbec(a)gmail.com>
Cc: Masami Hiramatsu <mhiramat(a)redhat.com>
Cc: Mike Galbraith <efault(a)gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra(a)chello.nl>
Cc: Paul Mackerras <paulus(a)samba.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme(a)redhat.com>
---
tools/perf/builtin-probe.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 4fa73ec..cd45e02 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -41,7 +41,6 @@
#include "util/debugfs.h"
#include "util/symbol.h"
#include "util/thread.h"
-#include "util/session.h"
#include "util/parse-options.h"
#include "util/parse-events.h" /* For debugfs_path */
#include "util/probe-finder.h"
@@ -59,7 +58,8 @@ static struct {
int nr_probe;
struct probe_point probes[MAX_PROBES];
struct strlist *dellist;
- struct perf_session *psession;
+ struct map_groups kmap_groups;
+ struct map *kmaps[MAP__NR_TYPES];
struct map *kmap;
struct line_range line_range;
} session;
@@ -212,10 +212,13 @@ static void init_vmlinux(void)
pr_debug("Use vmlinux: %s\n", symbol_conf.vmlinux_name);
if (symbol__init() < 0)
die("Failed to init symbol map.");
- session.psession = perf_session__new(NULL, O_WRONLY, false);
- if (session.psession == NULL)
- die("Failed to init perf_session.");
- session.kmap = session.psession->vmlinux_maps[MAP__FUNCTION];
+
+ map_groups__init(&session.kmap_groups);
+ if (map_groups__create_kernel_maps(&session.kmap_groups,
+ session.kmaps) < 0)
+ die("Failed to create kernel maps.");
+
+ session.kmap = session.kmaps[MAP__FUNCTION];
if (!session.kmap)
die("Could not find kernel map.\n");
}
--
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Masami Hiramatsu on
Arnaldo Carvalho de Melo wrote:
> Em Thu, Jan 28, 2010 at 11:28:29AM -0500, Masami Hiramatsu escreveu:
>
>> Yeah, and if you can separate an interface only for handling symbols
>> from debug/elf binaries, it will be helpful for me too.
>
> It was done on this same series, now you can do as the patch at the end
> of this message, that will be on my next series, does.

Great! thank you!

>
> Testing with this patch:
>
> [root(a)doppio ~]# perf probe --list
> [root(a)doppio ~]# perf probe schedule
> Added new event:
> probe:schedule (on schedule+0)
>
> You can now use it on all perf tools, such as:
>
> perf record -e probe:schedule -a sleep 1
>
> [root(a)doppio ~]# perf record -e probe:schedule -a sleep 1
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.158 MB perf.data (~6923 samples) ]
> [root(a)doppio ~]# perf report | head -9
> # Samples: 4
> #
> # Overhead Command Shared Object Symbol
> # ........ ............... ..................... ......
> #
> 25.00% perf libc-2.10.2.so [.] __GI___libc_read
> 25.00% kondemand/1 [kernel.kallsyms] [k] kernel_thread_helper
> 25.00% kondemand/0 [kernel.kallsyms] [k] kernel_thread_helper
> [root(a)doppio ~]#
>
> And what about support for modules? You have everything you need there
> as well :-)
>
> If you do:
>
> struct map *mod;
> struct symbol *sym;
>
> mod = map_groups__find_by_name(&session.kmap_groups,
> MAP__FUNCTION, "[ipv6]");
>
> sym = map__find_symbol_by_name(module, "ip6_xmit");
>
> you'll get ipv6.ko located and loaded, mod->dso->long_name thus will
> have the file to use with libdwarf and sym->start will have the
> unrelocated address, and mod->start will have where ipv6 is loaded in
> kernel space

Oh, nice :-) Is that available for the modules which aren't loaded?
And yeah, I'd like to support modules and it will requires some
enhancement in kprobe-tracer too.

..
> Also you should be able to find variables by name or address too, just
> use MAP__VARIABLE where above you see MAP__FUNCTION.
>
> - Arnaldo
>
> From 387ab05301cce32c8b091ba9feb94c906124e8a8 Mon Sep 17 00:00:00 2001
> From: Arnaldo Carvalho de Melo <acme(a)redhat.com>
> Date: Thu, 28 Jan 2010 16:12:31 -0200
> Subject: [PATCH 1/1] perf probe: Don't use a perf_session instance just to resolve symbols
> MIME-Version: 1.0
> Content-Type: text/plain; charset=utf-8
> Content-Transfer-Encoding: 8bit
>
> With the recent modifications done to untie the session and symbol
> layers, 'perf probe' now can use just the symbols layer.

Could you remove session.kmap too?
other parts look good to me.

Thank you,

>
> Cc: Fr�d�ric Weisbecker <fweisbec(a)gmail.com>
> Cc: Masami Hiramatsu <mhiramat(a)redhat.com>
> Cc: Mike Galbraith <efault(a)gmx.de>
> Cc: Peter Zijlstra <a.p.zijlstra(a)chello.nl>
> Cc: Paul Mackerras <paulus(a)samba.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme(a)redhat.com>
> ---
> tools/perf/builtin-probe.c | 15 +++++++++------
> 1 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> index 4fa73ec..cd45e02 100644
> --- a/tools/perf/builtin-probe.c
> +++ b/tools/perf/builtin-probe.c
> @@ -41,7 +41,6 @@
> #include "util/debugfs.h"
> #include "util/symbol.h"
> #include "util/thread.h"
> -#include "util/session.h"
> #include "util/parse-options.h"
> #include "util/parse-events.h" /* For debugfs_path */
> #include "util/probe-finder.h"
> @@ -59,7 +58,8 @@ static struct {
> int nr_probe;
> struct probe_point probes[MAX_PROBES];
> struct strlist *dellist;
> - struct perf_session *psession;
> + struct map_groups kmap_groups;
> + struct map *kmaps[MAP__NR_TYPES];
> struct map *kmap;


> struct line_range line_range;
> } session;
> @@ -212,10 +212,13 @@ static void init_vmlinux(void)
> pr_debug("Use vmlinux: %s\n", symbol_conf.vmlinux_name);
> if (symbol__init() < 0)
> die("Failed to init symbol map.");
> - session.psession = perf_session__new(NULL, O_WRONLY, false);
> - if (session.psession == NULL)
> - die("Failed to init perf_session.");
> - session.kmap = session.psession->vmlinux_maps[MAP__FUNCTION];
> +
> + map_groups__init(&session.kmap_groups);
> + if (map_groups__create_kernel_maps(&session.kmap_groups,
> + session.kmaps) < 0)
> + die("Failed to create kernel maps.");
> +
> + session.kmap = session.kmaps[MAP__FUNCTION];
> if (!session.kmap)
> die("Could not find kernel map.\n");
> }

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat(a)redhat.com

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