2014-11-14 01:18:04

by Steven Rostedt

[permalink] [raw]
Subject: [RFC][PATCH 09/23 v4] tracing/probes: Do not use return value of trace_seq_printf()

From: "Steven Rostedt (Red Hat)" <[email protected]>

The functions trace_seq_printf() and friends will soon not have a return
value and will only be a void function. Use trace_seq_has_overflowed()
instead to know if the trace_seq operations succeeded or not.

Cc: Masami Hiramatsu <[email protected]>
Cc: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
kernel/trace/trace_probe.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index d4b9fc22cd27..b983b2fd2ca1 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -40,7 +40,8 @@ const char *reserved_field_names[] = {
int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, const char *name, \
void *data, void *ent) \
{ \
- return trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \
+ trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \
+ return !trace_seq_has_overflowed(s); \
} \
const char PRINT_TYPE_FMT_NAME(type)[] = fmt; \
NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(type));
@@ -61,10 +62,11 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, const char *name,
int len = *(u32 *)data >> 16;

if (!len)
- return trace_seq_printf(s, " %s=(fault)", name);
+ trace_seq_printf(s, " %s=(fault)", name);
else
- return trace_seq_printf(s, " %s=\"%s\"", name,
- (const char *)get_loc_data(data, ent));
+ trace_seq_printf(s, " %s=\"%s\"", name,
+ (const char *)get_loc_data(data, ent));
+ return !trace_seq_has_overflowed(s);
}
NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(string));

--
2.1.1


Subject: Re: [RFC][PATCH 09/23 v4] tracing/probes: Do not use return value of trace_seq_printf()

(2014/11/14 10:12), Steven Rostedt wrote:
> From: "Steven Rostedt (Red Hat)" <[email protected]>
>
> The functions trace_seq_printf() and friends will soon not have a return
> value and will only be a void function. Use trace_seq_has_overflowed()
> instead to know if the trace_seq operations succeeded or not.
>

OK, Looks good to me.

Acked-by: Masami Hiramatsu <[email protected]>

> Cc: Masami Hiramatsu <[email protected]>
> Cc: Namhyung Kim <[email protected]>
> Signed-off-by: Steven Rostedt <[email protected]>
> ---
> kernel/trace/trace_probe.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index d4b9fc22cd27..b983b2fd2ca1 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -40,7 +40,8 @@ const char *reserved_field_names[] = {
> int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, const char *name, \
> void *data, void *ent) \
> { \
> - return trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \
> + trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \
> + return !trace_seq_has_overflowed(s); \
> } \
> const char PRINT_TYPE_FMT_NAME(type)[] = fmt; \
> NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(type));
> @@ -61,10 +62,11 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, const char *name,
> int len = *(u32 *)data >> 16;
>
> if (!len)
> - return trace_seq_printf(s, " %s=(fault)", name);
> + trace_seq_printf(s, " %s=(fault)", name);
> else
> - return trace_seq_printf(s, " %s=\"%s\"", name,
> - (const char *)get_loc_data(data, ent));
> + trace_seq_printf(s, " %s=\"%s\"", name,
> + (const char *)get_loc_data(data, ent));
> + return !trace_seq_has_overflowed(s);
> }
> NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(string));
>


--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]

2014-11-18 00:31:07

by Namhyung Kim

[permalink] [raw]
Subject: Re: [RFC][PATCH 09/23 v4] tracing/probes: Do not use return value of trace_seq_printf()

Hi Steve,

On Thu, 13 Nov 2014 20:12:53 -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Red Hat)" <[email protected]>
>
> The functions trace_seq_printf() and friends will soon not have a return
> value and will only be a void function. Use trace_seq_has_overflowed()
> instead to know if the trace_seq operations succeeded or not.
>
> Cc: Masami Hiramatsu <[email protected]>
> Cc: Namhyung Kim <[email protected]>
> Signed-off-by: Steven Rostedt <[email protected]>
> ---
> kernel/trace/trace_probe.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index d4b9fc22cd27..b983b2fd2ca1 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -40,7 +40,8 @@ const char *reserved_field_names[] = {
> int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, const char *name, \
> void *data, void *ent) \
> { \
> - return trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \
> + trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \
> + return !trace_seq_has_overflowed(s); \

At first, I wondered why you used this instead of trace_handle_return()
but I found out that it's only used for checking loop break so I'm okay
with this.

Acked-by: Namhyung Kim <[email protected]>

Thanks,
Namhyung


> } \
> const char PRINT_TYPE_FMT_NAME(type)[] = fmt; \
> NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(type));
> @@ -61,10 +62,11 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, const char *name,
> int len = *(u32 *)data >> 16;
>
> if (!len)
> - return trace_seq_printf(s, " %s=(fault)", name);
> + trace_seq_printf(s, " %s=(fault)", name);
> else
> - return trace_seq_printf(s, " %s=\"%s\"", name,
> - (const char *)get_loc_data(data, ent));
> + trace_seq_printf(s, " %s=\"%s\"", name,
> + (const char *)get_loc_data(data, ent));
> + return !trace_seq_has_overflowed(s);
> }
> NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(string));