Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [ltt-dev] [PATCH take2 07/13] implement fmt align
@ 2009-02-05  3:31 Lai Jiangshan
  2009-02-23 19:11 ` Mathieu Desnoyers
  0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2009-02-05  3:31 UTC (permalink / raw)


we need know the align for accessing the binary data from
event.(skip the padding data, calculate offset).

Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
diff --git a/include/linux/ltt-tracer.h b/include/linux/ltt-tracer.h
index 7cb8f14..d9a8471 100644
--- a/include/linux/ltt-tracer.h
+++ b/include/linux/ltt-tracer.h
@@ -152,6 +152,9 @@ static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type)
 	size_t alignment = min(sizeof(void *), size_of_type);
 	return (alignment - align_drift) & (alignment - 1);
 }
+
+extern unsigned int ltt_fmt_largest_align(size_t align_drift, const char *fmt);
+
 /* Default arch alignment */
 #define LTT_ALIGN
 
@@ -168,6 +171,12 @@ static inline unsigned int ltt_align(size_t align_drift,
 	return 0;
 }
 
+static inline unsigned int ltt_fmt_largest_align(size_t align_drift,
+		const char *fmt)
+{
+	return 0;
+}
+
 #define LTT_ALIGN __attribute__((packed))
 
 static inline int ltt_get_alignment(void)
diff --git a/ltt/ltt-serialize.c b/ltt/ltt-serialize.c
index b1e9f7e..71cb3b2 100644
--- a/ltt/ltt-serialize.c
+++ b/ltt/ltt-serialize.c
@@ -692,6 +692,67 @@ size_t ltt_serialize_printf(struct rchan_buf *buf, size_t buf_offset,
 }
 EXPORT_SYMBOL_GPL(ltt_serialize_printf);
 
+#ifdef CONFIG_LTT_ALIGNMENT
+
+unsigned int ltt_fmt_largest_align(size_t align_drift, const char *fmt)
+{
+	char trace_size = 0, c_size = 0;
+	enum ltt_type trace_type = LTT_TYPE_NONE, c_type = LTT_TYPE_NONE;
+	unsigned long attributes = 0;
+	int largest_align = 1;
+
+	for (; *fmt ; ++fmt) {
+		switch (*fmt) {
+		case '#':
+			/* tracetypes (#) */
+			++fmt;			/* skip first '#' */
+			if (*fmt == '#')	/* Escaped ## */
+				break;
+			attributes = 0;
+			fmt = parse_trace_type(fmt, &trace_size, &trace_type,
+				&attributes);
+
+			largest_align = max_t(int, largest_align, trace_size);
+			if (largest_align >= ltt_get_alignment())
+				goto exit;
+			break;
+		case '%':
+			/* c types (%) */
+			++fmt;			/* skip first '%' */
+			if (*fmt == '%')	/* Escaped %% */
+				break;
+			fmt = parse_c_type(fmt, &c_size, &c_type, NULL);
+			/*
+			 * Output c types if no trace types has been
+			 * specified.
+			 */
+			if (!trace_size)
+				trace_size = c_size;
+			if (trace_type == LTT_TYPE_NONE)
+				trace_type = c_type;
+			if (c_type == LTT_TYPE_STRING)
+				trace_type = LTT_TYPE_STRING;
+
+			largest_align = max_t(int, largest_align, trace_size);
+			if (largest_align >= ltt_get_alignment())
+				goto exit;
+
+			trace_size = 0;
+			c_size = 0;
+			trace_type = LTT_TYPE_NONE;
+			c_size = LTT_TYPE_NONE;
+			break;
+		}
+	}
+
+exit:
+	largest_align = min_t(int, largest_align, ltt_get_alignment());
+	return (largest_align - align_drift) & (largest_align - 1);
+}
+EXPORT_SYMBOL_GPL(ltt_fmt_largest_align);
+
+#endif
+
 /*
  * Calculate data size
  * Assume that the padding for alignment starts at a sizeof(void *) address.






^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ltt-dev] [PATCH take2 07/13] implement fmt align
  2009-02-05  3:31 [ltt-dev] [PATCH take2 07/13] implement fmt align Lai Jiangshan
@ 2009-02-23 19:11 ` Mathieu Desnoyers
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2009-02-23 19:11 UTC (permalink / raw)


* Lai Jiangshan (laijs at cn.fujitsu.com) wrote:
> we need know the align for accessing the binary data from
> event.(skip the padding data, calculate offset).
> 

Sounds good. I'll let you repost it after the serialize_printf
modifications, because it will generate failed hunks.

Acked-by: Mathieu Desnoyers <mathieu.desnoyers at polymtl.ca>

> Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
> ---
> diff --git a/include/linux/ltt-tracer.h b/include/linux/ltt-tracer.h
> index 7cb8f14..d9a8471 100644
> --- a/include/linux/ltt-tracer.h
> +++ b/include/linux/ltt-tracer.h
> @@ -152,6 +152,9 @@ static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type)
>  	size_t alignment = min(sizeof(void *), size_of_type);
>  	return (alignment - align_drift) & (alignment - 1);
>  }
> +
> +extern unsigned int ltt_fmt_largest_align(size_t align_drift, const char *fmt);
> +
>  /* Default arch alignment */
>  #define LTT_ALIGN
>  
> @@ -168,6 +171,12 @@ static inline unsigned int ltt_align(size_t align_drift,
>  	return 0;
>  }
>  
> +static inline unsigned int ltt_fmt_largest_align(size_t align_drift,
> +		const char *fmt)
> +{
> +	return 0;
> +}
> +
>  #define LTT_ALIGN __attribute__((packed))
>  
>  static inline int ltt_get_alignment(void)
> diff --git a/ltt/ltt-serialize.c b/ltt/ltt-serialize.c
> index b1e9f7e..71cb3b2 100644
> --- a/ltt/ltt-serialize.c
> +++ b/ltt/ltt-serialize.c
> @@ -692,6 +692,67 @@ size_t ltt_serialize_printf(struct rchan_buf *buf, size_t buf_offset,
>  }
>  EXPORT_SYMBOL_GPL(ltt_serialize_printf);
>  
> +#ifdef CONFIG_LTT_ALIGNMENT
> +
> +unsigned int ltt_fmt_largest_align(size_t align_drift, const char *fmt)
> +{
> +	char trace_size = 0, c_size = 0;
> +	enum ltt_type trace_type = LTT_TYPE_NONE, c_type = LTT_TYPE_NONE;
> +	unsigned long attributes = 0;
> +	int largest_align = 1;
> +
> +	for (; *fmt ; ++fmt) {
> +		switch (*fmt) {
> +		case '#':
> +			/* tracetypes (#) */
> +			++fmt;			/* skip first '#' */
> +			if (*fmt == '#')	/* Escaped ## */
> +				break;
> +			attributes = 0;
> +			fmt = parse_trace_type(fmt, &trace_size, &trace_type,
> +				&attributes);
> +
> +			largest_align = max_t(int, largest_align, trace_size);
> +			if (largest_align >= ltt_get_alignment())
> +				goto exit;
> +			break;
> +		case '%':
> +			/* c types (%) */
> +			++fmt;			/* skip first '%' */
> +			if (*fmt == '%')	/* Escaped %% */
> +				break;
> +			fmt = parse_c_type(fmt, &c_size, &c_type, NULL);
> +			/*
> +			 * Output c types if no trace types has been
> +			 * specified.
> +			 */
> +			if (!trace_size)
> +				trace_size = c_size;
> +			if (trace_type == LTT_TYPE_NONE)
> +				trace_type = c_type;
> +			if (c_type == LTT_TYPE_STRING)
> +				trace_type = LTT_TYPE_STRING;
> +
> +			largest_align = max_t(int, largest_align, trace_size);
> +			if (largest_align >= ltt_get_alignment())
> +				goto exit;
> +
> +			trace_size = 0;
> +			c_size = 0;
> +			trace_type = LTT_TYPE_NONE;
> +			c_size = LTT_TYPE_NONE;
> +			break;
> +		}
> +	}
> +
> +exit:
> +	largest_align = min_t(int, largest_align, ltt_get_alignment());
> +	return (largest_align - align_drift) & (largest_align - 1);
> +}
> +EXPORT_SYMBOL_GPL(ltt_fmt_largest_align);
> +
> +#endif
> +
>  /*
>   * Calculate data size
>   * Assume that the padding for alignment starts at a sizeof(void *) address.
> 
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-23 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-05  3:31 [ltt-dev] [PATCH take2 07/13] implement fmt align Lai Jiangshan
2009-02-23 19:11 ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox