Re: [PATCH V3 7/9] tracing: Add __print_ns_to_secs() and __print_ns_without_secs() helpers

From: Daniel Bristot de Oliveira
Date: Fri Jun 04 2021 - 12:09:04 EST


On 6/3/21 11:29 PM, Steven Rostedt wrote:
> On Fri, 14 May 2021 22:51:16 +0200
> Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:
>
>> +++ b/include/trace/trace_events.h
>> @@ -358,6 +358,21 @@ TRACE_MAKE_SYSTEM_STR();
>> trace_print_hex_dump_seq(p, prefix_str, prefix_type, \
>> rowsize, groupsize, buf, len, ascii)
>>
>> +#undef __print_ns_to_secs
>> +#define __print_ns_to_secs(value) \
>> + ({ \
>> + u64 ____val = (u64)value; \
>> + do_div(____val, NSEC_PER_SEC); \
>> + ____val; \
>> + })
>
> I know my name is on this, but we need parenthesis around "value".
>
>> +
>> +#undef __print_ns_without_secs
>> +#define __print_ns_without_secs(value) \
>> + ({ \
>> + u64 ____val = (u64)value; \
>
> Here too.
>
>> + (u32) do_div(____val, NSEC_PER_SEC); \
>> + })
>> +
>> #undef DECLARE_EVENT_CLASS
>> #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
>> static notrace enum print_line_t \
>> @@ -736,6 +751,16 @@ static inline void ftrace_test_probe_##call(void) \
>> #undef __print_array
>> #undef __print_hex_dump
>>
>> +/*
>> + * The below is not executed in the kernel. It is only what is
>> + * displayed in the print format for userspace to parse.
>> + */
>> +#undef __print_ns_to_secs
>> +#define __print_ns_to_secs(val) val / 1000000000UL
>> +
>> +#undef __print_ns_without_secs
>> +#define __print_ns_without_secs(val) val % 1000000000UL
>
> And around "val" in the above two macros.

Fixing in the v4.

Thanks Steven!
-- Daniel

> -- Steve
>
>> +
>> #undef TP_printk
>> #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
>>
>