[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5295D7C1.3040806@hitachi.com>
Date: Wed, 27 Nov 2013 20:30:09 +0900
From: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Steven Rostedt <rostedt@...dmis.org>,
Namhyung Kim <namhyung.kim@....com>,
Frederic Weisbecker <fweisbec@...il.com>,
Ingo Molnar <mingo@...hat.com>, Jiri Olsa <jolsa@...hat.com>,
linux-kernel@...r.kernel.org, Rusty Russell <rusty@...tcorp.com.au>
Subject: Re: [RFC PATCH 2/2] tracing: Teach FETCH_MTD_symbol to handle per-cpu
data
(2013/11/27 2:44), Oleg Nesterov wrote:
> FETCH_FUNC_NAME(symbol) blindly dereferences sc->addr + sc->offset,
> this is not what we want if this symbol is per-cpu. Change this code
> to use this_cpu_ptr(sc->addr) in this case.
This looks good for me :)
Thanks!
> Note: this doesn't work for modules, but module's per-cpu data is
> not visible for kallsyms_lookup_name() anyway.
>
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
> ---
> kernel/trace/trace_probe.c | 22 ++++++++++++++++++----
> 1 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 097cc80..a0144b6 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -252,14 +252,28 @@ static struct symbol_cache *alloc_symbol_cache(const char *sym, long offset)
> return sc;
> }
>
> +static void *sc_calc_addr(struct symbol_cache *sc)
> +{
> + void *addr = (void*)sc->addr;
> +
> + if (addr) {
> + if (addr >= (void *)__per_cpu_start &&
> + addr < (void *)__per_cpu_end)
> + addr = this_cpu_ptr(addr);
> +
> + addr += sc->offset;
> + }
> +
> + return addr;
> +}
> +
> #define DEFINE_FETCH_symbol(type) \
> static __kprobes void FETCH_FUNC_NAME(symbol, type)(struct pt_regs *regs,\
> void *data, void *dest) \
> { \
> - struct symbol_cache *sc = data; \
> - long off = sc->offset; \
> - if (sc->addr) \
> - fetch_memory_##type(regs, (void *)sc->addr + off, dest);\
> + void *addr = sc_calc_addr(data); \
> + if (addr) \
> + fetch_memory_##type(regs, addr, dest); \
> else \
> *(type *)dest = 0; \
> }
>
--
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@...achi.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists