From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Anton Arapov <anton@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Subject: Re: [PATCH 4/4] uprobes/tracing: generalize struct uprobe_trace_entry_head
Date: Thu, 4 Apr 2013 19:55:39 +0530 [thread overview]
Message-ID: <20130404142539.GD8986@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130329181548.GA20700@redhat.com>
* Oleg Nesterov <oleg@redhat.com> [2013-03-29 19:15:48]:
> struct uprobe_trace_entry_head has a single member for reporting,
> "unsigned long ip". If we want to support uretprobes we need to
> create another struct which has "func" and "ret_ip" and duplicate
> a lot of functions, like trace_kprobe.c does.
>
> To avoid this copy-and-paste horror we turn ->ip into ->vaddr[]
> and add couple of trivial helpers to calculate sizeof/data. This
> uglifies the code a bit, but this allows us to avoid a lot more
> complications later, when we add the support for ret-probes.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Also copying Masami.
> ---
> kernel/trace/trace.h | 5 ---
> kernel/trace/trace_uprobe.c | 61 ++++++++++++++++++++++++------------------
> 2 files changed, 35 insertions(+), 31 deletions(-)
>
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 57d7e53..6ca57cf 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -103,11 +103,6 @@ struct kretprobe_trace_entry_head {
> unsigned long ret_ip;
> };
>
> -struct uprobe_trace_entry_head {
> - struct trace_entry ent;
> - unsigned long ip;
> -};
> -
> /*
> * trace_flag_type is an enumeration that holds different
> * states when a trace occurs. These are:
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index 43d258d..92a4b08 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -28,6 +28,17 @@
>
> #define UPROBE_EVENT_SYSTEM "uprobes"
>
> +struct uprobe_trace_entry_head {
> + struct trace_entry ent;
> + unsigned long vaddr[];
> +};
> +
> +#define SIZEOF_TRACE_ENTRY(nr) \
> + (sizeof(struct uprobe_trace_entry_head) + sizeof(unsigned long) * (nr))
> +
> +#define DATAOF_TRACE_ENTRY(entry, nr) \
> + ((void*)&(entry)->vaddr[nr])
> +
> struct trace_uprobe_filter {
> rwlock_t rwlock;
> int nr_systemwide;
> @@ -491,20 +502,19 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
> struct uprobe_trace_entry_head *entry;
> struct ring_buffer_event *event;
> struct ring_buffer *buffer;
> - u8 *data;
> + void *data;
> int size, i;
> struct ftrace_event_call *call = &tu->call;
>
> - size = sizeof(*entry) + tu->size;
> -
> + size = SIZEOF_TRACE_ENTRY(1) + tu->size;
> event = trace_current_buffer_lock_reserve(&buffer, call->event.type,
> size, 0, 0);
> if (!event)
> return 0;
>
> entry = ring_buffer_event_data(event);
> - entry->ip = instruction_pointer(regs);
> - data = (u8 *)&entry[1];
> + entry->vaddr[0] = instruction_pointer(regs);
> + data = DATAOF_TRACE_ENTRY(entry, 1);
> for (i = 0; i < tu->nr_args; i++)
> call_fetch(&tu->args[i].fetch, regs, data + tu->args[i].offset);
>
> @@ -518,22 +528,22 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
> static enum print_line_t
> print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *event)
> {
> - struct uprobe_trace_entry_head *field;
> + struct uprobe_trace_entry_head *entry;
> struct trace_seq *s = &iter->seq;
> struct trace_uprobe *tu;
> u8 *data;
> int i;
>
> - field = (struct uprobe_trace_entry_head *)iter->ent;
> + entry = (struct uprobe_trace_entry_head *)iter->ent;
> tu = container_of(event, struct trace_uprobe, call.event);
>
> - if (!trace_seq_printf(s, "%s: (0x%lx)", tu->call.name, field->ip))
> + if (!trace_seq_printf(s, "%s: (0x%lx)", tu->call.name, entry->vaddr[0]))
> goto partial;
>
> - data = (u8 *)&field[1];
> + data = DATAOF_TRACE_ENTRY(entry, 1);
> for (i = 0; i < tu->nr_args; i++) {
> if (!tu->args[i].type->print(s, tu->args[i].name,
> - data + tu->args[i].offset, field))
> + data + tu->args[i].offset, entry))
> goto partial;
> }
>
> @@ -585,16 +595,17 @@ static void probe_event_disable(struct trace_uprobe *tu, int flag)
>
> static int uprobe_event_define_fields(struct ftrace_event_call *event_call)
> {
> - int ret, i;
> + int ret, i, size;
> struct uprobe_trace_entry_head field;
> - struct trace_uprobe *tu = (struct trace_uprobe *)event_call->data;
> + struct trace_uprobe *tu = event_call->data;
>
> - DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0);
> + DEFINE_FIELD(unsigned long, vaddr[0], FIELD_STRING_IP, 0);
> + size = SIZEOF_TRACE_ENTRY(1);
> /* Set argument names as fields */
> for (i = 0; i < tu->nr_args; i++) {
> ret = trace_define_field(event_call, tu->args[i].type->fmttype,
> tu->args[i].name,
> - sizeof(field) + tu->args[i].offset,
> + size + tu->args[i].offset,
> tu->args[i].type->size,
> tu->args[i].type->is_signed,
> FILTER_OTHER);
> @@ -748,33 +759,31 @@ static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
> struct ftrace_event_call *call = &tu->call;
> struct uprobe_trace_entry_head *entry;
> struct hlist_head *head;
> - u8 *data;
> - int size, __size, i;
> - int rctx;
> + unsigned long ip;
> + void *data;
> + int size, rctx, i;
>
> if (!uprobe_perf_filter(&tu->consumer, 0, current->mm))
> return UPROBE_HANDLER_REMOVE;
>
> - __size = sizeof(*entry) + tu->size;
> - size = ALIGN(__size + sizeof(u32), sizeof(u64));
> - size -= sizeof(u32);
> + size = SIZEOF_TRACE_ENTRY(1);
> + size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32);
> if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough"))
> return 0;
>
> preempt_disable();
> -
> entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
> if (!entry)
> goto out;
>
> - entry->ip = instruction_pointer(regs);
> - data = (u8 *)&entry[1];
> + ip = instruction_pointer(regs);
> + entry->vaddr[0] = ip;
> + data = DATAOF_TRACE_ENTRY(entry, 1);
> for (i = 0; i < tu->nr_args; i++)
> call_fetch(&tu->args[i].fetch, regs, data + tu->args[i].offset);
>
> head = this_cpu_ptr(call->perf_events);
> - perf_trace_buf_submit(entry, size, rctx, entry->ip, 1, regs, head, NULL);
> -
> + perf_trace_buf_submit(entry, size, rctx, ip, 1, regs, head, NULL);
> out:
> preempt_enable();
> return 0;
> @@ -784,7 +793,7 @@ static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
> static
> int trace_uprobe_register(struct ftrace_event_call *event, enum trace_reg type, void *data)
> {
> - struct trace_uprobe *tu = (struct trace_uprobe *)event->data;
> + struct trace_uprobe *tu = event->data;
>
> switch (type) {
> case TRACE_REG_REGISTER:
> --
> 1.5.5.1
>
--
Thanks and Regards
Srikar Dronamraju
next prev parent reply other threads:[~2013-04-04 14:31 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-29 18:15 [PATCH 0/4] uprobes/tracing: uretprobes, initial preparations Oleg Nesterov
2013-03-29 18:15 ` [PATCH 1/4] uprobes/tracing: Kill the pointless task_pt_regs() calls Oleg Nesterov
2013-04-02 8:57 ` Anton Arapov
2013-04-04 14:24 ` Srikar Dronamraju
2013-03-29 18:15 ` [PATCH 2/4] uprobes/tracing: Kill the pointless seq_print_ip_sym() call Oleg Nesterov
2013-04-02 8:57 ` Anton Arapov
2013-04-04 14:24 ` Srikar Dronamraju
2013-03-29 18:15 ` [PATCH 3/4] uprobes/tracing: Kill the pointless local_save_flags/preempt_count calls Oleg Nesterov
2013-04-02 8:58 ` Anton Arapov
2013-04-04 14:25 ` Srikar Dronamraju
2013-04-05 3:47 ` Masami Hiramatsu
2013-04-05 15:01 ` Oleg Nesterov
2013-04-08 9:29 ` Masami Hiramatsu
2013-04-10 14:58 ` [PATCH 0/1] uprobes/tracing: Don't pass addr=ip to perf_trace_buf_submit() Oleg Nesterov
2013-04-10 14:58 ` [PATCH 1/1] " Oleg Nesterov
2013-04-11 10:19 ` Masami Hiramatsu
2013-04-13 9:28 ` Srikar Dronamraju
2013-04-11 10:38 ` [PATCH 0/1] " Masami Hiramatsu
2013-04-11 11:59 ` Oleg Nesterov
2013-04-12 18:01 ` Steven Rostedt
2013-04-12 21:19 ` Steven Rostedt
2013-04-13 14:02 ` [PATCH 0/1] uprobes/perf: Avoid perf_trace_buf_prepare/submit if ->perf_events is empty Oleg Nesterov
2013-04-13 14:02 ` [PATCH 1/1] " Oleg Nesterov
2013-04-13 18:22 ` [PATCH 0/1] " Oleg Nesterov
2013-04-08 15:58 ` [PATCH 3/4] uprobes/tracing: Kill the pointless local_save_flags/preempt_count calls Steven Rostedt
2013-04-09 14:58 ` Oleg Nesterov
2013-04-09 15:12 ` Steven Rostedt
2013-03-29 18:15 ` [PATCH 4/4] uprobes/tracing: generalize struct uprobe_trace_entry_head Oleg Nesterov
2013-04-02 8:59 ` Anton Arapov
2013-04-04 14:25 ` Srikar Dronamraju [this message]
2013-04-08 15:55 ` Steven Rostedt
2013-04-09 14:50 ` Oleg Nesterov
2013-04-09 15:07 ` Steven Rostedt
2013-04-09 19:32 ` [PATCH v2 0/7] uprobes/tracing: uretprobes Oleg Nesterov
2013-04-09 19:32 ` [PATCH v2 1/7] uprobes/tracing: Generalize struct uprobe_trace_entry_head Oleg Nesterov
2013-04-09 19:32 ` [PATCH v2 2/7] uprobes/tracing: Introduce uprobe_{trace,perf}_print() helpers Oleg Nesterov
2013-04-09 19:32 ` [PATCH v2 3/7] uprobes/tracing: Introduce is_ret_probe() and uretprobe_dispatcher() Oleg Nesterov
2013-04-09 19:32 ` [PATCH v2 4/7] uprobes/tracing: Make uprobe_{trace,perf}_print() uretprobe-friendly Oleg Nesterov
2013-04-13 9:33 ` Srikar Dronamraju
2013-04-09 19:32 ` [PATCH v2 5/7] uprobes/tracing: Make register_uprobe_event() paths uretprobe-friendly Oleg Nesterov
2013-04-09 19:32 ` [PATCH v2 6/7] uprobes/tracing: Make seq_printf() code uretprobe-friendly Oleg Nesterov
2013-04-09 19:32 ` [PATCH v2 7/7] uprobes/tracing: Change create_trace_uprobe() to support uretprobes Oleg Nesterov
2013-04-01 16:08 ` [PATCH 0/6] uprobes/tracing: uretprobes Oleg Nesterov
2013-04-01 16:08 ` [PATCH 1/6] uprobes/tracing: Introduce uprobe_{trace,perf}_print() helpers Oleg Nesterov
2013-04-07 13:58 ` Srikar Dronamraju
2013-04-01 16:08 ` [PATCH 2/6] uprobes/tracing: Introduce is_ret_probe() and uretprobe_dispatcher() Oleg Nesterov
2013-04-07 14:12 ` Srikar Dronamraju
2013-04-01 16:08 ` [PATCH 3/6] uprobes/tracing: Make uprobe_{trace,perf}_print() uretprobe-friendly Oleg Nesterov
2013-04-07 10:31 ` Srikar Dronamraju
2013-04-09 13:33 ` Oleg Nesterov
2013-04-13 9:31 ` Srikar Dronamraju
2013-04-08 17:08 ` Steven Rostedt
2013-04-01 16:08 ` [PATCH 4/6] uprobes/tracing: Make register_uprobe_event() paths uretprobe-friendly Oleg Nesterov
2013-04-07 14:14 ` Srikar Dronamraju
2013-04-01 16:08 ` [PATCH 5/6] uprobes/tracing: Make seq_printf() code uretprobe-friendly Oleg Nesterov
2013-04-07 14:15 ` Srikar Dronamraju
2013-04-01 16:09 ` [PATCH 6/6] uprobes/tracing: Change create_trace_uprobe() to support uretprobes Oleg Nesterov
2013-04-07 14:17 ` Srikar Dronamraju
2013-04-02 13:25 ` [PATCH 0/6] uprobes/tracing: uretprobes Anton Arapov
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=20130404142539.GD8986@linux.vnet.ibm.com \
--to=srikar@linux.vnet.ibm.com \
--cc=ananth@in.ibm.com \
--cc=anton@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=rostedt@goodmis.org \
/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;
as well as URLs for NNTP newsgroup(s).