From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Oleg Nesterov <oleg@redhat.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
Hyeoncheol Lee <cheol.lee@lge.com>,
"zhangwei(Jovi)" <jovi.zhangwei@huawei.com>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Hemant Kumar <hkshaw@linux.vnet.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
Namhyung Kim <namhyung.kim@lge.com>
Subject: Re: [PATCH 09/17] tracing/probes: Implement 'stack' fetch method for uprobes
Date: Mon, 16 Dec 2013 17:17:40 +0900 [thread overview]
Message-ID: <52AEB724.8040009@hitachi.com> (raw)
In-Reply-To: <1387168336-13213-10-git-send-email-namhyung@kernel.org>
(2013/12/16 13:32), Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
>
> Use separate method to fetch from stack. Move existing functions to
> trace_kprobe.c and make them static. Also add new stack fetch
> implementation for uprobes.
>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: zhangwei(Jovi) <jovi.zhangwei@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Looks good for me :)
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Thank you!
> ---
> kernel/trace/trace_kprobe.c | 15 +++++++++++++++
> kernel/trace/trace_probe.c | 22 ----------------------
> kernel/trace/trace_probe.h | 14 ++++++++++----
> kernel/trace/trace_uprobe.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 66 insertions(+), 26 deletions(-)
>
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index 23c6c3feff82..11478020f76c 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -88,6 +88,21 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs);
> static int kretprobe_dispatcher(struct kretprobe_instance *ri,
> struct pt_regs *regs);
>
> +/*
> + * Kprobes-specific fetch functions
> + */
> +#define DEFINE_FETCH_stack(type) \
> +static __kprobes void FETCH_FUNC_NAME(stack, type)(struct pt_regs *regs,\
> + void *offset, void *dest) \
> +{ \
> + *(type *)dest = (type)regs_get_kernel_stack_nth(regs, \
> + (unsigned int)((unsigned long)offset)); \
> +}
> +DEFINE_BASIC_FETCH_FUNCS(stack)
> +/* No string on the stack entry */
> +#define fetch_stack_string NULL
> +#define fetch_stack_string_size NULL
> +
> /* Fetch type information table */
> const struct fetch_type kprobes_fetch_type_table[] = {
> /* Special types */
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 541036ec7392..77aa7d18821e 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -70,16 +70,6 @@ __kprobes int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s,
>
> const char PRINT_TYPE_FMT_NAME(string)[] = "\\\"%s\\\"";
>
> -/*
> - * Define macro for basic types - we don't need to define s* types, because
> - * we have to care only about bitwidth at recording time.
> - */
> -#define DEFINE_BASIC_FETCH_FUNCS(method) \
> -DEFINE_FETCH_##method(u8) \
> -DEFINE_FETCH_##method(u16) \
> -DEFINE_FETCH_##method(u32) \
> -DEFINE_FETCH_##method(u64)
> -
> #define CHECK_FETCH_FUNCS(method, fn) \
> (((FETCH_FUNC_NAME(method, u8) == fn) || \
> (FETCH_FUNC_NAME(method, u16) == fn) || \
> @@ -102,18 +92,6 @@ DEFINE_BASIC_FETCH_FUNCS(reg)
> #define fetch_reg_string NULL
> #define fetch_reg_string_size NULL
>
> -#define DEFINE_FETCH_stack(type) \
> -__kprobes void FETCH_FUNC_NAME(stack, type)(struct pt_regs *regs, \
> - void *offset, void *dest) \
> -{ \
> - *(type *)dest = (type)regs_get_kernel_stack_nth(regs, \
> - (unsigned int)((unsigned long)offset)); \
> -}
> -DEFINE_BASIC_FETCH_FUNCS(stack)
> -/* No string on the stack entry */
> -#define fetch_stack_string NULL
> -#define fetch_stack_string_size NULL
> -
> #define DEFINE_FETCH_retval(type) \
> __kprobes void FETCH_FUNC_NAME(retval, type)(struct pt_regs *regs, \
> void *dummy, void *dest) \
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index 5b77798d1130..8211dd674ab6 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -167,10 +167,6 @@ DECLARE_BASIC_FETCH_FUNCS(reg);
> #define fetch_reg_string NULL
> #define fetch_reg_string_size NULL
>
> -DECLARE_BASIC_FETCH_FUNCS(stack);
> -#define fetch_stack_string NULL
> -#define fetch_stack_string_size NULL
> -
> DECLARE_BASIC_FETCH_FUNCS(retval);
> #define fetch_retval_string NULL
> #define fetch_retval_string_size NULL
> @@ -191,6 +187,16 @@ DECLARE_BASIC_FETCH_FUNCS(bitfield);
> #define fetch_bitfield_string NULL
> #define fetch_bitfield_string_size NULL
>
> +/*
> + * Define macro for basic types - we don't need to define s* types, because
> + * we have to care only about bitwidth at recording time.
> + */
> +#define DEFINE_BASIC_FETCH_FUNCS(method) \
> +DEFINE_FETCH_##method(u8) \
> +DEFINE_FETCH_##method(u16) \
> +DEFINE_FETCH_##method(u32) \
> +DEFINE_FETCH_##method(u64)
> +
> /* Default (unsigned long) fetch type */
> #define __DEFAULT_FETCH_TYPE(t) u##t
> #define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t)
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index 2c60925ea073..5395d37e5e72 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -74,6 +74,47 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs);
> static int uretprobe_dispatcher(struct uprobe_consumer *con,
> unsigned long func, struct pt_regs *regs);
>
> +#ifdef CONFIG_STACK_GROWSUP
> +static unsigned long adjust_stack_addr(unsigned long addr, unsigned int n)
> +{
> + return addr - (n * sizeof(long));
> +}
> +#else
> +static unsigned long adjust_stack_addr(unsigned long addr, unsigned int n)
> +{
> + return addr + (n * sizeof(long));
> +}
> +#endif
> +
> +static unsigned long get_user_stack_nth(struct pt_regs *regs, unsigned int n)
> +{
> + unsigned long ret;
> + unsigned long addr = user_stack_pointer(regs);
> +
> + addr = adjust_stack_addr(addr, n);
> +
> + if (copy_from_user(&ret, (void __force __user *) addr, sizeof(ret)))
> + return 0;
> +
> + return ret;
> +}
> +
> +/*
> + * Uprobes-specific fetch functions
> + */
> +#define DEFINE_FETCH_stack(type) \
> +static __kprobes void FETCH_FUNC_NAME(stack, type)(struct pt_regs *regs,\
> + void *offset, void *dest) \
> +{ \
> + *(type *)dest = (type)get_user_stack_nth(regs, \
> + ((unsigned long)offset)); \
> +}
> +DEFINE_BASIC_FETCH_FUNCS(stack)
> +/* No string on the stack entry */
> +#define fetch_stack_string NULL
> +#define fetch_stack_string_size NULL
> +
> +
> /* Fetch type information table */
> const struct fetch_type uprobes_fetch_type_table[] = {
> /* Special types */
>
--
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2013-12-16 8:18 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-16 4:31 [PATCHSET 00/17] tracing/uprobes: Add support for more fetch methods (v9) Namhyung Kim
2013-12-16 4:32 ` [PATCH 01/17] tracing/uprobes: Fix documentation of uprobe registration syntax Namhyung Kim
2013-12-16 4:32 ` [PATCH 02/17] tracing/probes: Fix basic print type functions Namhyung Kim
2013-12-16 4:32 ` [PATCH 03/17] tracing/kprobes: Factor out struct trace_probe Namhyung Kim
2013-12-16 4:32 ` [PATCH 04/17] tracing/uprobes: Convert to " Namhyung Kim
2013-12-16 4:32 ` [PATCH 05/17] tracing/kprobes: Move common functions to trace_probe.h Namhyung Kim
2013-12-16 4:32 ` [PATCH 06/17] tracing/probes: Integrate duplicate set_print_fmt() Namhyung Kim
2013-12-16 4:32 ` [PATCH 07/17] tracing/probes: Move fetch function helpers to trace_probe.h Namhyung Kim
2013-12-16 4:32 ` [PATCH 08/17] tracing/probes: Split [ku]probes_fetch_type_table Namhyung Kim
2013-12-16 4:32 ` [PATCH 09/17] tracing/probes: Implement 'stack' fetch method for uprobes Namhyung Kim
2013-12-16 8:17 ` Masami Hiramatsu [this message]
2013-12-16 4:32 ` [PATCH 10/17] tracing/probes: Move 'symbol' fetch method to kprobes Namhyung Kim
2013-12-16 8:23 ` Masami Hiramatsu
2013-12-16 8:40 ` Namhyung Kim
2013-12-17 0:16 ` Namhyung Kim
2013-12-18 20:25 ` Steven Rostedt
2013-12-18 20:34 ` Oleg Nesterov
2013-12-19 8:55 ` Namhyung Kim
2013-12-19 8:54 ` Namhyung Kim
2013-12-18 20:23 ` Steven Rostedt
2013-12-19 7:34 ` Namhyung Kim
2013-12-19 14:18 ` Steven Rostedt
2013-12-20 1:05 ` Namhyung Kim
2013-12-16 4:32 ` [PATCH 11/17] tracing/probes: Add fetch{,_size} member into deref fetch method Namhyung Kim
2013-12-16 4:32 ` [PATCH 12/17] tracing/probes: Implement 'memory' fetch method for uprobes Namhyung Kim
2013-12-16 4:32 ` [PATCH 13/17] tracing/uprobes: Pass 'is_return' to traceprobe_parse_probe_arg() Namhyung Kim
2013-12-16 4:32 ` [PATCH 14/17] tracing/uprobes: Fetch args before reserving a ring buffer Namhyung Kim
2013-12-16 4:32 ` [PATCH 15/17] tracing/uprobes: Add support for full argument access methods Namhyung Kim
2014-01-02 20:58 ` Steven Rostedt
2014-01-02 21:02 ` Steven Rostedt
2014-01-03 1:17 ` Hyeoncheol Lee
2014-01-03 1:53 ` Steven Rostedt
2013-12-16 4:32 ` [PATCH 16/17] uprobes: Allocate ->utask before handler_chain() for tracing handlers Namhyung Kim
2013-12-16 4:32 ` [PATCH 17/17] tracing/uprobes: Add @+file_offset fetch method Namhyung Kim
2013-12-21 5:22 ` [PATCHSET 00/17] tracing/uprobes: Add support for more fetch methods (v9) Steven Rostedt
2013-12-22 12:32 ` Namhyung Kim
2013-12-23 18:00 ` Oleg Nesterov
2013-12-24 8:02 ` Namhyung Kim
-- strict thread matches above, loose matches on Subject: below --
2013-12-09 6:19 [PATCHSET 00/17] tracing/uprobes: Add support for more fetch methods (v8) Namhyung Kim
2013-12-09 6:19 ` [PATCH 09/17] tracing/probes: Implement 'stack' fetch method for uprobes Namhyung Kim
2013-11-27 6:19 [PATCHSET 00/17] tracing/uprobes: Add support for more fetch methods (v7) Namhyung Kim
2013-11-27 6:19 ` [PATCH 09/17] tracing/probes: Implement 'stack' fetch method for uprobes Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52AEB724.8040009@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=acme@ghostprotocols.net \
--cc=cheol.lee@lge.com \
--cc=hkshaw@linux.vnet.ibm.com \
--cc=jovi.zhangwei@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung.kim@lge.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=rostedt@goodmis.org \
--cc=srikar@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome