Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers)
Subject: [lttng-dev] [PATCH 1/2] Makes write operation a parameter for	tp_memcpy macro
Date: Tue, 5 Jun 2012 11:14:59 -0400	[thread overview]
Message-ID: <20120605151459.GB21009@Krystal> (raw)
In-Reply-To: <1338888051-20879-2-git-send-email-francis.giraldeau@gmail.com>

* Francis Giraldeau (francis.giraldeau at gmail.com) wrote:
> Memcpy source can be either user-space or kernel-space. To avoid code
> duplication, this patch makes the operation a parameter to the macros.
> Available macros are thus:
> 
> * tp_memcpy:               kernel-space array copy
> * tp_memcpy_from_user:     user-space array copy
> * tp_memcpy_dyn:           kernel-space sequence copy
> * tp_memcpy_dyn_from_user: user-space sequence copy
> 
> Those are TP_fast_assign macros that can be used with __dynamic_array
> macros in TP_STRUCT__entry in a TRACE_EVENT.

Merged, thanks !

Mathieu

> 
> Signed-off-by: Francis Giraldeau <francis.giraldeau at gmail.com>
> ---
>  probes/lttng-events.h |   37 +++++++++++++++++++++++--------------
>  1 file changed, 23 insertions(+), 14 deletions(-)
> 
> diff --git a/probes/lttng-events.h b/probes/lttng-events.h
> index 05e17b9..492423a 100644
> --- a/probes/lttng-events.h
> +++ b/probes/lttng-events.h
> @@ -523,17 +523,27 @@ __assign_##dest:							\
>  	}								\
>  	goto __end_field_##dest;
>  
> -#undef tp_memcpy
> -#define tp_memcpy(dest, src, len)					\
> +/* fixed length array memcpy */
> +#undef tp_memcpy_gen
> +#define tp_memcpy_gen(write_ops, dest, src, len)			\
>  __assign_##dest:							\
>  	if (0)								\
>  		(void) __typemap.dest;					\
>  	lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));	\
> -	__chan->ops->event_write(&__ctx, src, len);			\
> +	__chan->ops->write_ops(&__ctx, src, len);			\
>  	goto __end_field_##dest;
>  
> -#undef tp_memcpy_dyn
> -#define tp_memcpy_dyn(dest, src)					\
> +#undef tp_memcpy
> +#define tp_memcpy(dest, src, len)					\
> +	tp_memcpy_gen(event_write, dest, src, len)
> +
> +#undef tp_memcpy_from_user
> +#define tp_memcpy_from_user(dest, src, len)				\
> +	tp_memcpy_gen(event_write_from_user, dest, src, len)
> +
> +/* variable length sequence memcpy */
> +#undef tp_memcpy_dyn_gen
> +#define tp_memcpy_dyn_gen(write_ops, dest, src)				\
>  __assign_##dest##_1:							\
>  	{								\
>  		u32 __tmpl = __dynamic_len[__dynamic_len_idx];		\
> @@ -543,18 +553,17 @@ __assign_##dest##_1:							\
>  	goto __end_field_##dest##_1;					\
>  __assign_##dest##_2:							\
>  	lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));	\
> -	__chan->ops->event_write(&__ctx, src,				\
> +	__chan->ops->write_ops(&__ctx, src,				\
>  		sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\
>  	goto __end_field_##dest##_2;
>  
> -#undef tp_memcpy_from_user
> -#define tp_memcpy_from_user(dest, src, len)				\
> -	__assign_##dest:						\
> -	if (0)								\
> -		(void) __typemap.dest;					\
> -	lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));	\
> -	__chan->ops->event_write_from_user(&__ctx, src, len);		\
> -	goto __end_field_##dest;
> +#undef tp_memcpy_dyn
> +#define tp_memcpy_dyn(dest, src)					\
> +	tp_memcpy_dyn_gen(event_write, dest, src)
> +
> +#undef tp_memcpy_dyn_from_user
> +#define tp_memcpy_dyn_from_user(dest, src)				\
> +	tp_memcpy_dyn_gen(event_write_from_user, dest, src)
>  
>  /*
>   * The string length including the final \0.
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



  reply	other threads:[~2012-06-05 15:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-05  9:20 [lttng-dev] Expose kernel tracer to user-space Francis Giraldeau
2012-06-05  9:20 ` [lttng-dev] [PATCH 1/2] Makes write operation a parameter for tp_memcpy macro Francis Giraldeau
2012-06-05 15:14   ` Mathieu Desnoyers [this message]
2012-06-05  9:20 ` [lttng-dev] [PATCH 2/2] Expose kernel tracer to user-space Francis Giraldeau
2012-06-05 15:16   ` Mathieu Desnoyers

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=20120605151459.GB21009@Krystal \
    --to=mathieu.desnoyers@efficios.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