[PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
From: Namhyung Kim The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Acked-by: Masami Hiramatsu Cc: Srikar Dronamraju Cc: Oleg Nesterov Cc: zhangwei(Jovi) Cc: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 6d33cfee9448..2a668516f0e4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -909,54 +909,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, -struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i < tp->nr_args; i++) - if (unlikely(tp->args[i].fetch_size.fn)) { - call_fetch(>args[i].fetch_size, regs, ); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, - struct pt_regs *regs, - u8 *data, int maxlen) -{ - int i; - u32 end = tp->size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i < tp->nr_args; i++) { - if (unlikely(tp->args[i].fetch_size.fn)) { - /* -* First, we set the relative location and -* maximum data length to *dl -*/ - dl = (u32 *)(data + tp->args[i].offset); - *dl = make_data_rloc(maxlen, end - tp->args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(>args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, -ent_size + tp->args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(>args[i].fetch, regs, - data + tp->args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i < tp->nr_args; i++) + if (unlikely(tp->args[i].fetch_size.fn)) { + call_fetch(>args[i].fetch_size, regs, ); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, +u8 *data, int maxlen) +{ + int i; + u32 end = tp->size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i < tp->nr_args; i++) { + if (unlikely(tp->args[i].fetch_size.fn)) { + /* +* First, we set the relative location and +* maximum data length to *dl +*/ + dl = (u32 *)(data + tp->args[i].offset); + *dl = make_data_rloc(maxlen, end - tp->args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(>args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert data_rloc to data_loc */ + *dl = convert_rloc_to_loc(*dl, +ent_size + tp->args[i].offset); + } else + /* Just fetching data normally */ +
[PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
From: Namhyung Kim namhyung@lge.com The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Acked-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Srikar Dronamraju sri...@linux.vnet.ibm.com Cc: Oleg Nesterov o...@redhat.com Cc: zhangwei(Jovi) jovi.zhang...@huawei.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Signed-off-by: Namhyung Kim namhy...@kernel.org --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 6d33cfee9448..2a668516f0e4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -909,54 +909,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, -struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i tp-nr_args; i++) - if (unlikely(tp-args[i].fetch_size.fn)) { - call_fetch(tp-args[i].fetch_size, regs, len); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, - struct pt_regs *regs, - u8 *data, int maxlen) -{ - int i; - u32 end = tp-size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i tp-nr_args; i++) { - if (unlikely(tp-args[i].fetch_size.fn)) { - /* -* First, we set the relative location and -* maximum data length to *dl -*/ - dl = (u32 *)(data + tp-args[i].offset); - *dl = make_data_rloc(maxlen, end - tp-args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(tp-args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, -ent_size + tp-args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(tp-args[i].fetch, regs, - data + tp-args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i tp-nr_args; i++) + if (unlikely(tp-args[i].fetch_size.fn)) { + call_fetch(tp-args[i].fetch_size, regs, len); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, +u8 *data, int maxlen) +{ + int i; + u32 end = tp-size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i tp-nr_args; i++) { + if (unlikely(tp-args[i].fetch_size.fn)) { + /* +* First, we set the relative location and +* maximum data length to *dl +*/ + dl = (u32 *)(data + tp-args[i].offset); + *dl = make_data_rloc(maxlen, end - tp-args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(tp-args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert data_rloc to data_loc */ + *dl = convert_rloc_to_loc(*dl, +
[PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
From: Namhyung Kim The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Acked-by: Masami Hiramatsu Cc: Srikar Dronamraju Cc: Oleg Nesterov Cc: zhangwei(Jovi) Cc: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 6d33cfee9448..2a668516f0e4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -909,54 +909,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, -struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i < tp->nr_args; i++) - if (unlikely(tp->args[i].fetch_size.fn)) { - call_fetch(>args[i].fetch_size, regs, ); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, - struct pt_regs *regs, - u8 *data, int maxlen) -{ - int i; - u32 end = tp->size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i < tp->nr_args; i++) { - if (unlikely(tp->args[i].fetch_size.fn)) { - /* -* First, we set the relative location and -* maximum data length to *dl -*/ - dl = (u32 *)(data + tp->args[i].offset); - *dl = make_data_rloc(maxlen, end - tp->args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(>args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, -ent_size + tp->args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(>args[i].fetch, regs, - data + tp->args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i < tp->nr_args; i++) + if (unlikely(tp->args[i].fetch_size.fn)) { + call_fetch(>args[i].fetch_size, regs, ); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, +u8 *data, int maxlen) +{ + int i; + u32 end = tp->size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i < tp->nr_args; i++) { + if (unlikely(tp->args[i].fetch_size.fn)) { + /* +* First, we set the relative location and +* maximum data length to *dl +*/ + dl = (u32 *)(data + tp->args[i].offset); + *dl = make_data_rloc(maxlen, end - tp->args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(>args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert data_rloc to data_loc */ + *dl = convert_rloc_to_loc(*dl, +ent_size + tp->args[i].offset); + } else + /* Just fetching data normally */ +
[PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
From: Namhyung Kim namhyung@lge.com The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Acked-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Srikar Dronamraju sri...@linux.vnet.ibm.com Cc: Oleg Nesterov o...@redhat.com Cc: zhangwei(Jovi) jovi.zhang...@huawei.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Signed-off-by: Namhyung Kim namhy...@kernel.org --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 6d33cfee9448..2a668516f0e4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -909,54 +909,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, -struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i tp-nr_args; i++) - if (unlikely(tp-args[i].fetch_size.fn)) { - call_fetch(tp-args[i].fetch_size, regs, len); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, - struct pt_regs *regs, - u8 *data, int maxlen) -{ - int i; - u32 end = tp-size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i tp-nr_args; i++) { - if (unlikely(tp-args[i].fetch_size.fn)) { - /* -* First, we set the relative location and -* maximum data length to *dl -*/ - dl = (u32 *)(data + tp-args[i].offset); - *dl = make_data_rloc(maxlen, end - tp-args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(tp-args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, -ent_size + tp-args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(tp-args[i].fetch, regs, - data + tp-args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i tp-nr_args; i++) + if (unlikely(tp-args[i].fetch_size.fn)) { + call_fetch(tp-args[i].fetch_size, regs, len); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, +u8 *data, int maxlen) +{ + int i; + u32 end = tp-size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i tp-nr_args; i++) { + if (unlikely(tp-args[i].fetch_size.fn)) { + /* +* First, we set the relative location and +* maximum data length to *dl +*/ + dl = (u32 *)(data + tp-args[i].offset); + *dl = make_data_rloc(maxlen, end - tp-args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(tp-args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert data_rloc to data_loc */ + *dl = convert_rloc_to_loc(*dl, +
[PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
From: Namhyung Kim The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Acked-by: Masami Hiramatsu Cc: Srikar Dronamraju Cc: Oleg Nesterov Cc: zhangwei(Jovi) Cc: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 6d33cfee9448..2a668516f0e4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -909,54 +909,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, -struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i < tp->nr_args; i++) - if (unlikely(tp->args[i].fetch_size.fn)) { - call_fetch(>args[i].fetch_size, regs, ); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, - struct pt_regs *regs, - u8 *data, int maxlen) -{ - int i; - u32 end = tp->size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i < tp->nr_args; i++) { - if (unlikely(tp->args[i].fetch_size.fn)) { - /* -* First, we set the relative location and -* maximum data length to *dl -*/ - dl = (u32 *)(data + tp->args[i].offset); - *dl = make_data_rloc(maxlen, end - tp->args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(>args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, -ent_size + tp->args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(>args[i].fetch, regs, - data + tp->args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i < tp->nr_args; i++) + if (unlikely(tp->args[i].fetch_size.fn)) { + call_fetch(>args[i].fetch_size, regs, ); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, +u8 *data, int maxlen) +{ + int i; + u32 end = tp->size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i < tp->nr_args; i++) { + if (unlikely(tp->args[i].fetch_size.fn)) { + /* +* First, we set the relative location and +* maximum data length to *dl +*/ + dl = (u32 *)(data + tp->args[i].offset); + *dl = make_data_rloc(maxlen, end - tp->args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(>args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert data_rloc to data_loc */ + *dl = convert_rloc_to_loc(*dl, +ent_size + tp->args[i].offset); + } else + /* Just fetching data normally */ +
[PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
From: Namhyung Kim namhyung@lge.com The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Acked-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Srikar Dronamraju sri...@linux.vnet.ibm.com Cc: Oleg Nesterov o...@redhat.com Cc: zhangwei(Jovi) jovi.zhang...@huawei.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Signed-off-by: Namhyung Kim namhy...@kernel.org --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 6d33cfee9448..2a668516f0e4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -909,54 +909,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, -struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i tp-nr_args; i++) - if (unlikely(tp-args[i].fetch_size.fn)) { - call_fetch(tp-args[i].fetch_size, regs, len); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, - struct pt_regs *regs, - u8 *data, int maxlen) -{ - int i; - u32 end = tp-size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i tp-nr_args; i++) { - if (unlikely(tp-args[i].fetch_size.fn)) { - /* -* First, we set the relative location and -* maximum data length to *dl -*/ - dl = (u32 *)(data + tp-args[i].offset); - *dl = make_data_rloc(maxlen, end - tp-args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(tp-args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, -ent_size + tp-args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(tp-args[i].fetch, regs, - data + tp-args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i tp-nr_args; i++) + if (unlikely(tp-args[i].fetch_size.fn)) { + call_fetch(tp-args[i].fetch_size, regs, len); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, +u8 *data, int maxlen) +{ + int i; + u32 end = tp-size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i tp-nr_args; i++) { + if (unlikely(tp-args[i].fetch_size.fn)) { + /* +* First, we set the relative location and +* maximum data length to *dl +*/ + dl = (u32 *)(data + tp-args[i].offset); + *dl = make_data_rloc(maxlen, end - tp-args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(tp-args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert data_rloc to data_loc */ + *dl = convert_rloc_to_loc(*dl, +
Re: [PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
(2013/08/09 17:45), Namhyung Kim wrote: > From: Namhyung Kim > > The __get_data_size() and store_trace_args() will be used by uprobes > too. Move them to a common location. > Acked-by: Masami Hiramatsu Thanks! > Cc: Masami Hiramatsu > Cc: Srikar Dronamraju > Cc: Oleg Nesterov > Cc: zhangwei(Jovi) > Cc: Arnaldo Carvalho de Melo > Signed-off-by: Namhyung Kim > --- > kernel/trace/trace_kprobe.c | 48 > - > kernel/trace/trace_probe.h | 48 > + > 2 files changed, 48 insertions(+), 48 deletions(-) > > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c > index d3f60d29c765..ede99332b255 100644 > --- a/kernel/trace/trace_kprobe.c > +++ b/kernel/trace/trace_kprobe.c > @@ -904,54 +904,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { > ASSIGN_FETCH_TYPE(s64, u64, 1), > }; > > -/* Sum up total data length for dynamic arraies (strings) */ > -static __kprobes int __get_data_size(struct trace_probe *tp, > - struct pt_regs *regs) > -{ > - int i, ret = 0; > - u32 len; > - > - for (i = 0; i < tp->nr_args; i++) > - if (unlikely(tp->args[i].fetch_size.fn)) { > - call_fetch(>args[i].fetch_size, regs, ); > - ret += len; > - } > - > - return ret; > -} > - > -/* Store the value of each argument */ > -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, > -struct pt_regs *regs, > -u8 *data, int maxlen) > -{ > - int i; > - u32 end = tp->size; > - u32 *dl;/* Data (relative) location */ > - > - for (i = 0; i < tp->nr_args; i++) { > - if (unlikely(tp->args[i].fetch_size.fn)) { > - /* > - * First, we set the relative location and > - * maximum data length to *dl > - */ > - dl = (u32 *)(data + tp->args[i].offset); > - *dl = make_data_rloc(maxlen, end - tp->args[i].offset); > - /* Then try to fetch string or dynamic array data */ > - call_fetch(>args[i].fetch, regs, dl); > - /* Reduce maximum length */ > - end += get_rloc_len(*dl); > - maxlen -= get_rloc_len(*dl); > - /* Trick here, convert data_rloc to data_loc */ > - *dl = convert_rloc_to_loc(*dl, > - ent_size + tp->args[i].offset); > - } else > - /* Just fetching data normally */ > - call_fetch(>args[i].fetch, regs, > -data + tp->args[i].offset); > - } > -} > - > /* Kprobe handler */ > static __kprobes void > __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, > diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h > index 63e5da4e3073..189a40baea98 100644 > --- a/kernel/trace/trace_probe.h > +++ b/kernel/trace/trace_probe.h > @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, > int (*createfn)(int, char**)); > > extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); > + > +/* Sum up total data length for dynamic arraies (strings) */ > +static inline __kprobes int > +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) > +{ > + int i, ret = 0; > + u32 len; > + > + for (i = 0; i < tp->nr_args; i++) > + if (unlikely(tp->args[i].fetch_size.fn)) { > + call_fetch(>args[i].fetch_size, regs, ); > + ret += len; > + } > + > + return ret; > +} > + > +/* Store the value of each argument */ > +static inline __kprobes void > +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, > + u8 *data, int maxlen) > +{ > + int i; > + u32 end = tp->size; > + u32 *dl;/* Data (relative) location */ > + > + for (i = 0; i < tp->nr_args; i++) { > + if (unlikely(tp->args[i].fetch_size.fn)) { > + /* > + * First, we set the relative location and > + * maximum data length to *dl > + */ > + dl = (u32 *)(data + tp->args[i].offset); > + *dl = make_data_rloc(maxlen, end - tp->args[i].offset); > + /* Then try to fetch string or dynamic array data */ > + call_fetch(>args[i].fetch, regs, dl); > + /* Reduce maximum length */ > + end += get_rloc_len(*dl); > + maxlen -= get_rloc_len(*dl); > + /* Trick here, convert data_rloc to data_loc */ > + *dl =
[PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
From: Namhyung Kim The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Cc: Masami Hiramatsu Cc: Srikar Dronamraju Cc: Oleg Nesterov Cc: zhangwei(Jovi) Cc: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index d3f60d29c765..ede99332b255 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -904,54 +904,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, -struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i < tp->nr_args; i++) - if (unlikely(tp->args[i].fetch_size.fn)) { - call_fetch(>args[i].fetch_size, regs, ); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, - struct pt_regs *regs, - u8 *data, int maxlen) -{ - int i; - u32 end = tp->size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i < tp->nr_args; i++) { - if (unlikely(tp->args[i].fetch_size.fn)) { - /* -* First, we set the relative location and -* maximum data length to *dl -*/ - dl = (u32 *)(data + tp->args[i].offset); - *dl = make_data_rloc(maxlen, end - tp->args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(>args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, -ent_size + tp->args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(>args[i].fetch, regs, - data + tp->args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i < tp->nr_args; i++) + if (unlikely(tp->args[i].fetch_size.fn)) { + call_fetch(>args[i].fetch_size, regs, ); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, +u8 *data, int maxlen) +{ + int i; + u32 end = tp->size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i < tp->nr_args; i++) { + if (unlikely(tp->args[i].fetch_size.fn)) { + /* +* First, we set the relative location and +* maximum data length to *dl +*/ + dl = (u32 *)(data + tp->args[i].offset); + *dl = make_data_rloc(maxlen, end - tp->args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(>args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert data_rloc to data_loc */ + *dl = convert_rloc_to_loc(*dl, +ent_size + tp->args[i].offset); + } else + /* Just fetching data normally */ +
[PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
From: Namhyung Kim namhyung@lge.com The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Srikar Dronamraju sri...@linux.vnet.ibm.com Cc: Oleg Nesterov o...@redhat.com Cc: zhangwei(Jovi) jovi.zhang...@huawei.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Signed-off-by: Namhyung Kim namhy...@kernel.org --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index d3f60d29c765..ede99332b255 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -904,54 +904,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, -struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i tp-nr_args; i++) - if (unlikely(tp-args[i].fetch_size.fn)) { - call_fetch(tp-args[i].fetch_size, regs, len); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, - struct pt_regs *regs, - u8 *data, int maxlen) -{ - int i; - u32 end = tp-size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i tp-nr_args; i++) { - if (unlikely(tp-args[i].fetch_size.fn)) { - /* -* First, we set the relative location and -* maximum data length to *dl -*/ - dl = (u32 *)(data + tp-args[i].offset); - *dl = make_data_rloc(maxlen, end - tp-args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(tp-args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, -ent_size + tp-args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(tp-args[i].fetch, regs, - data + tp-args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i tp-nr_args; i++) + if (unlikely(tp-args[i].fetch_size.fn)) { + call_fetch(tp-args[i].fetch_size, regs, len); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, +u8 *data, int maxlen) +{ + int i; + u32 end = tp-size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i tp-nr_args; i++) { + if (unlikely(tp-args[i].fetch_size.fn)) { + /* +* First, we set the relative location and +* maximum data length to *dl +*/ + dl = (u32 *)(data + tp-args[i].offset); + *dl = make_data_rloc(maxlen, end - tp-args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(tp-args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert data_rloc to data_loc */ + *dl = convert_rloc_to_loc(*dl, +
Re: [PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h
(2013/08/09 17:45), Namhyung Kim wrote: From: Namhyung Kim namhyung@lge.com The __get_data_size() and store_trace_args() will be used by uprobes too. Move them to a common location. Acked-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Thanks! Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com Cc: Srikar Dronamraju sri...@linux.vnet.ibm.com Cc: Oleg Nesterov o...@redhat.com Cc: zhangwei(Jovi) jovi.zhang...@huawei.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Signed-off-by: Namhyung Kim namhy...@kernel.org --- kernel/trace/trace_kprobe.c | 48 - kernel/trace/trace_probe.h | 48 + 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index d3f60d29c765..ede99332b255 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -904,54 +904,6 @@ const struct fetch_type kprobes_fetch_type_table[] = { ASSIGN_FETCH_TYPE(s64, u64, 1), }; -/* Sum up total data length for dynamic arraies (strings) */ -static __kprobes int __get_data_size(struct trace_probe *tp, - struct pt_regs *regs) -{ - int i, ret = 0; - u32 len; - - for (i = 0; i tp-nr_args; i++) - if (unlikely(tp-args[i].fetch_size.fn)) { - call_fetch(tp-args[i].fetch_size, regs, len); - ret += len; - } - - return ret; -} - -/* Store the value of each argument */ -static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, -struct pt_regs *regs, -u8 *data, int maxlen) -{ - int i; - u32 end = tp-size; - u32 *dl;/* Data (relative) location */ - - for (i = 0; i tp-nr_args; i++) { - if (unlikely(tp-args[i].fetch_size.fn)) { - /* - * First, we set the relative location and - * maximum data length to *dl - */ - dl = (u32 *)(data + tp-args[i].offset); - *dl = make_data_rloc(maxlen, end - tp-args[i].offset); - /* Then try to fetch string or dynamic array data */ - call_fetch(tp-args[i].fetch, regs, dl); - /* Reduce maximum length */ - end += get_rloc_len(*dl); - maxlen -= get_rloc_len(*dl); - /* Trick here, convert data_rloc to data_loc */ - *dl = convert_rloc_to_loc(*dl, - ent_size + tp-args[i].offset); - } else - /* Just fetching data normally */ - call_fetch(tp-args[i].fetch, regs, -data + tp-args[i].offset); - } -} - /* Kprobe handler */ static __kprobes void __kprobe_trace_func(struct trace_kprobe *tp, struct pt_regs *regs, diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 63e5da4e3073..189a40baea98 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -302,3 +302,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, int (*createfn)(int, char**)); extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); + +/* Sum up total data length for dynamic arraies (strings) */ +static inline __kprobes int +__get_data_size(struct trace_probe *tp, struct pt_regs *regs) +{ + int i, ret = 0; + u32 len; + + for (i = 0; i tp-nr_args; i++) + if (unlikely(tp-args[i].fetch_size.fn)) { + call_fetch(tp-args[i].fetch_size, regs, len); + ret += len; + } + + return ret; +} + +/* Store the value of each argument */ +static inline __kprobes void +store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, + u8 *data, int maxlen) +{ + int i; + u32 end = tp-size; + u32 *dl;/* Data (relative) location */ + + for (i = 0; i tp-nr_args; i++) { + if (unlikely(tp-args[i].fetch_size.fn)) { + /* + * First, we set the relative location and + * maximum data length to *dl + */ + dl = (u32 *)(data + tp-args[i].offset); + *dl = make_data_rloc(maxlen, end - tp-args[i].offset); + /* Then try to fetch string or dynamic array data */ + call_fetch(tp-args[i].fetch, regs, dl); + /* Reduce maximum length */ + end += get_rloc_len(*dl); + maxlen -= get_rloc_len(*dl); + /* Trick here, convert