Re: [PATCH] tracing/function-graph-tracer: strip ending newlines on comments

From: Frédéric Weisbecker
Date: Tue Dec 23 2008 - 07:14:51 EST


2008/12/23 Ingo Molnar <mingo@xxxxxxx>:
>
> * Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:
>
>> Impact: trivial output improvement
>>
>> Ending newlines are appended automatically on comments by the function graph tracer
>> because the newlines needs to be placed after the "*/" characters.
>> So if the user puts an ending whitespace, we want to strip it.
>>
>> Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
>
> applied to tip/tracing/function-graph-tracer, thanks Frederic!
>
>> @@ -584,6 +585,11 @@ print_graph_comment(struct print_entry *trace, struct trace_seq *s,
>> return TRACE_TYPE_PARTIAL_LINE;
>> }
>>
>> + /* Strip ending newline on the comment */
>> + len = strlen(trace->buf);
>> + if (trace->buf[len - 1] == '\n')
>> + trace->buf[len - 1] = '\0';
>> +
>
> Hm, dont we know the length of the buffer already, so that we could avoid
> the strlen() overhead?
>
> Ingo
>

We know it during the insertion. But we need a new field struct print_entry.
That makes me remind that I didn't considered the TRACE_CONT rest of
the buffer in this patch.
Actually, the most easy solution would be to print entirely the buffer
to the seq, and then delete
the newline directly to the seq. That would be a bit crappy but
actually the only solution.

So my patch is wrong in cases of long messages.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/