lkml.org 
[lkml]   [2022]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v8 08/12] user_events: Optimize writing events by only copying data once
On Thu, Dec 23, 2021 at 12:11:42AM +0900, Masami Hiramatsu wrote:
> On Thu, 16 Dec 2021 09:35:07 -0800
> Beau Belgrave <beaub@linux.microsoft.com> wrote:
>
> > Pass iterator through to probes to allow copying data directly to the
> > probe buffers instead of taking multiple copies. Enables eBPF user and
> > raw iterator types out to programs for no-copy scenarios.
>
> This looks good to me, except for 1 nitpick. See below.
>
> Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
>
> >
> > Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
> > ---
> > kernel/trace/trace_events_user.c | 113 +++++++++++++++++++++++--------
> > 1 file changed, 85 insertions(+), 28 deletions(-)
> >
> > diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
> > index cc30d1fcbb63..fa3e26281fc3 100644
> > --- a/kernel/trace/trace_events_user.c
> > +++ b/kernel/trace/trace_events_user.c
> > @@ -41,6 +41,9 @@
> > #define MAX_FIELD_ARRAY_SIZE 1024
> > #define MAX_FIELD_ARG_NAME 256
> >

[..]

> > -static void user_event_ftrace(struct user_event *user, void *data, u32 datalen,
> > +static void user_event_ftrace(struct user_event *user, struct iov_iter *i,
> > void *tpdata)
> > {
> > struct trace_event_file *file;
> > @@ -540,41 +556,85 @@ static void user_event_ftrace(struct user_event *user, void *data, u32 datalen,
> >
> > /* Allocates and fills trace_entry, + 1 of this is data payload */
> > entry = trace_event_buffer_reserve(&event_buffer, file,
> > - sizeof(*entry) + datalen);
> > + sizeof(*entry) + i->count);
> >
> > if (unlikely(!entry))
> > return;
> >
> > - memcpy(entry + 1, data, datalen);
> > + if (unlikely(!copy_nofault(entry + 1, i->count, i))) {
> > + __trace_event_discard_commit(event_buffer.buffer,
> > + event_buffer.event);
> > + return;
> > + }
> >
> > trace_event_buffer_commit(&event_buffer);
>
> Will this be
>
> if (unlikely(!copy_nofault(entry + 1, i->count, i)))
> __trace_event_discard_commit(event_buffer.buffer,
> event_buffer.event);
> else
> trace_event_buffer_commit(&event_buffer);
>
> ?

Sure, why not.

Thanks,
-Beau

\
 
 \ /
  Last update: 2022-01-03 19:59    [W:0.137 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site