Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1609397 > unrolled thread

[PATCH] trace: Make trace_hwlat timestamp y2038 safe

Started byDeepa Dinamani <deepa.kernel@gmail.com>
First post2017-03-26 23:00 +0200
Last post2017-03-27 12:10 +0200
Articles 11 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] trace: Make trace_hwlat timestamp y2038 safe Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-26 23:00 +0200
    Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe kbuild test robot <lkp@intel.com> - 2017-03-27 11:30 +0200
      Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe Arnd Bergmann <arnd@arndb.de> - 2017-03-27 12:00 +0200
        Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe Steven Rostedt <rostedt@goodmis.org> - 2017-03-27 16:40 +0200
          Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe Arnd Bergmann <arnd@arndb.de> - 2017-03-27 17:00 +0200
            Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe Arnd Bergmann <arnd@arndb.de> - 2017-03-27 17:40 +0200
              Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe Steven Rostedt <rostedt@goodmis.org> - 2017-03-27 18:20 +0200
            Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe Steven Rostedt <rostedt@goodmis.org> - 2017-03-27 17:40 +0200
            Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-27 23:10 +0200
              Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe Arnd Bergmann <arnd@arndb.de> - 2017-03-28 09:30 +0200
    Re: [PATCH] trace: Make trace_hwlat timestamp y2038 safe kbuild test robot <lkp@intel.com> - 2017-03-27 12:10 +0200

#1609397 — [PATCH] trace: Make trace_hwlat timestamp y2038 safe

FromDeepa Dinamani <deepa.kernel@gmail.com>
Date2017-03-26 23:00 +0200
Subject[PATCH] trace: Make trace_hwlat timestamp y2038 safe
Message-ID<tpnqx-5w1-5@gated-at.bofh.it>
struct timespec is not y2038 safe on 32 bit machines
and needs to be replaced by struct timespec64
in order to represent times beyond year 2038 on such
machines.

Fix all the timestamp representation in struct trace_hwlat
and all the corresponding implementations.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
---
 kernel/trace/trace_entries.h | 6 +++---
 kernel/trace/trace_hwlat.c   | 4 ++--
 kernel/trace/trace_output.c  | 5 ++---
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h
index c203ac4..adcdbbe 100644
--- a/kernel/trace/trace_entries.h
+++ b/kernel/trace/trace_entries.h
@@ -348,14 +348,14 @@ FTRACE_ENTRY(hwlat, hwlat_entry,
 		__field(	u64,			duration	)
 		__field(	u64,			outer_duration	)
 		__field(	u64,			nmi_total_ts	)
-		__field_struct( struct timespec,	timestamp	)
-		__field_desc(	long,	timestamp,	tv_sec		)
+		__field_struct( struct timespec64,	timestamp	)
+		__field_desc(	s64,	timestamp,	tv_sec		)
 		__field_desc(	long,	timestamp,	tv_nsec		)
 		__field(	unsigned int,		nmi_count	)
 		__field(	unsigned int,		seqnum		)
 	),
 
-	F_printk("cnt:%u\tts:%010lu.%010lu\tinner:%llu\touter:%llunmi-ts:%llu\tnmi-count:%u\n",
+	F_printk("cnt:%u\tts:%010llu.%010lu\tinner:%llu\touter:%llunmi-ts:%llu\tnmi-count:%u\n",
 		 __entry->seqnum,
 		 __entry->tv_sec,
 		 __entry->tv_nsec,
diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index 21ea6ae..2257ff1 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -83,7 +83,7 @@ struct hwlat_sample {
 	u64		duration;	/* delta */
 	u64		outer_duration;	/* delta (outer loop) */
 	u64		nmi_total_ts;	/* Total time spent in NMIs */
-	struct timespec	timestamp;	/* wall time */
+	struct timespec64	timestamp;	/* wall time */
 	int		nmi_count;	/* # NMIs during this sample */
 };
 
@@ -250,7 +250,7 @@ static int get_sample(void)
 		s.seqnum = hwlat_data.count;
 		s.duration = sample;
 		s.outer_duration = outer_sample;
-		s.timestamp = CURRENT_TIME;
+		ktime_get_real_ts64(&s.timestamp);
 		s.nmi_total_ts = nmi_total_ts;
 		s.nmi_count = nmi_count;
 		trace_hwlat_sample(&s);
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 02a4aeb..bf7c757 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -4,7 +4,6 @@
  * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
  *
  */
-
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/ftrace.h>
@@ -1161,7 +1160,7 @@ trace_hwlat_print(struct trace_iterator *iter, int flags,
 
 	trace_assign_type(field, entry);
 
-	trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%ld.%09ld",
+	trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%lld.%09ld",
 			 field->seqnum,
 			 field->duration,
 			 field->outer_duration,
@@ -1195,7 +1194,7 @@ trace_hwlat_raw(struct trace_iterator *iter, int flags,
 
 	trace_assign_type(field, iter->ent);
 
-	trace_seq_printf(s, "%llu %lld %ld %09ld %u\n",
+	trace_seq_printf(s, "%llu %lld %lld %09ld %u\n",
 			 field->duration,
 			 field->outer_duration,
 			 field->timestamp.tv_sec,
-- 
2.7.4

[toc] | [next] | [standalone]


#1609606

Fromkbuild test robot <lkp@intel.com>
Date2017-03-27 11:30 +0200
Message-ID<tpz8l-5M6-9@gated-at.bofh.it>
In reply to#1609397

[Multipart message — attachments visible in raw view] — view raw

Hi Deepa,

[auto build test WARNING on tip/perf/core]
[also build test WARNING on v4.11-rc4 next-20170327]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Deepa-Dinamani/trace-Make-trace_hwlat-timestamp-y2038-safe/20170327-150010
config: x86_64-randconfig-n0-03271517 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   kernel/trace/trace_output.c: In function 'trace_hwlat_print':
>> kernel/trace/trace_output.c:1168:5: warning: format '%lld' expects argument of type 'long long int', but argument 6 has type '__kernel_time_t' [-Wformat=]
        field->timestamp.tv_nsec);
        ^
   kernel/trace/trace_output.c: In function 'trace_hwlat_raw':
   kernel/trace/trace_output.c:1202:5: warning: format '%lld' expects argument of type 'long long int', but argument 5 has type '__kernel_time_t' [-Wformat=]
        field->seqnum);
        ^
   Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:__ffs
   Cyclomatic Complexity 1 include/linux/list.h:INIT_LIST_HEAD
   Cyclomatic Complexity 2 include/linux/list.h:__list_add
   Cyclomatic Complexity 1 include/linux/list.h:list_add_tail
   Cyclomatic Complexity 1 include/linux/list.h:__list_del
   Cyclomatic Complexity 2 include/linux/list.h:__list_del_entry
   Cyclomatic Complexity 1 include/linux/list.h:list_del
   Cyclomatic Complexity 1 include/linux/list.h:list_empty
   Cyclomatic Complexity 2 include/linux/list.h:__hlist_del
   Cyclomatic Complexity 1 include/linux/list.h:hlist_del
   Cyclomatic Complexity 2 include/linux/list.h:hlist_add_head
   Cyclomatic Complexity 1 include/linux/rcupdate.h:rcu_lock_acquire
   Cyclomatic Complexity 1 include/linux/rcupdate.h:rcu_lock_release
   Cyclomatic Complexity 4 include/linux/rcupdate.h:rcu_read_lock
   Cyclomatic Complexity 4 include/linux/rcupdate.h:rcu_read_unlock
   Cyclomatic Complexity 1 include/linux/seq_buf.h:seq_buf_clear
   Cyclomatic Complexity 1 include/linux/seq_buf.h:seq_buf_init
   Cyclomatic Complexity 1 include/linux/seq_buf.h:seq_buf_has_overflowed
   Cyclomatic Complexity 1 include/linux/seq_buf.h:seq_buf_used
   Cyclomatic Complexity 1 include/linux/trace_seq.h:trace_seq_init
   Cyclomatic Complexity 1 include/linux/trace_seq.h:trace_seq_buffer_ptr
   Cyclomatic Complexity 3 include/linux/trace_seq.h:trace_seq_has_overflowed
   Cyclomatic Complexity 2 include/linux/trace_events.h:trace_handle_return
   Cyclomatic Complexity 3 include/linux/trace_events.h:trace_event_name
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:kretprobed
   Cyclomatic Complexity 3 kernel/trace/trace_output.c:task_state_char
   Cyclomatic Complexity 5 kernel/trace/trace_output.c:trace_search_list
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_nop_print
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_hwlat_raw
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_print_raw
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_bprint_raw
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_bputs_raw
   Cyclomatic Complexity 3 kernel/trace/trace_output.c:trace_ctxwake_raw
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_wake_raw
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_ctx_raw
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_fn_raw
   Cyclomatic Complexity 3 kernel/trace/trace_output.c:trace_raw_data
   Cyclomatic Complexity 3 kernel/trace/trace_output.c:trace_hwlat_print
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_output_raw
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:seq_print_sym_offset
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:seq_print_sym_short
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_ctxwake_print
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_wake_print
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_ctx_print
   Cyclomatic Complexity 9 kernel/trace/trace_output.c:seq_print_user_ip
   Cyclomatic Complexity 9 kernel/trace/trace_output.c:trace_user_stack_print
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_ctxwake_bin
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_fn_bin
   Cyclomatic Complexity 3 kernel/trace/trace_output.c:trace_ctxwake_hex
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_wake_hex
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_ctx_hex
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_fn_hex
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_print_bputs_msg_only
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_print_bprintk_msg_only
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_print_printk_msg_only
   Cyclomatic Complexity 7 kernel/trace/trace_output.c:trace_print_flags_seq
   Cyclomatic Complexity 4 kernel/trace/trace_output.c:trace_print_symbols_seq
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_print_bitmask_seq
   Cyclomatic Complexity 3 kernel/trace/trace_output.c:trace_print_hex_seq
   Cyclomatic Complexity 6 kernel/trace/trace_output.c:trace_print_array_seq
   Cyclomatic Complexity 5 kernel/trace/trace_output.c:trace_raw_output_prep
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_output_call
   Cyclomatic Complexity 4 kernel/trace/trace_output.c:seq_print_ip_sym
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_print_print
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_bprint_print
   Cyclomatic Complexity 2 kernel/trace/trace_output.c:trace_bputs_print
   Cyclomatic Complexity 6 kernel/trace/trace_output.c:trace_stack_print
   Cyclomatic Complexity 4 kernel/trace/trace_output.c:trace_fn_trace
   Cyclomatic Complexity 12 kernel/trace/trace_output.c:trace_print_lat_fmt
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:lat_print_generic
   Cyclomatic Complexity 4 kernel/trace/trace_output.c:trace_find_mark
   Cyclomatic Complexity 5 kernel/trace/trace_output.c:lat_print_timestamp
   Cyclomatic Complexity 3 kernel/trace/trace_output.c:trace_print_context
   Cyclomatic Complexity 3 kernel/trace/trace_output.c:trace_print_lat_context
   Cyclomatic Complexity 5 kernel/trace/trace_output.c:ftrace_find_event
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_event_read_lock
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:trace_event_read_unlock
   Cyclomatic Complexity 17 kernel/trace/trace_output.c:register_trace_event
   Cyclomatic Complexity 6 kernel/trace/trace_output.c:init_events
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:__unregister_trace_event
   Cyclomatic Complexity 1 kernel/trace/trace_output.c:unregister_trace_event

vim +1168 kernel/trace/trace_output.c

e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1152) /* TRACE_HWLAT */
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1153) static enum print_line_t
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1154) trace_hwlat_print(struct trace_iterator *iter, int flags,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1155) 		  struct trace_event *event)
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1156) {
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1157) 	struct trace_entry *entry = iter->ent;
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1158) 	struct trace_seq *s = &iter->seq;
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1159) 	struct hwlat_entry *field;
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1160) 
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1161) 	trace_assign_type(field, entry);
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1162) 
df001907 Deepa Dinamani           2017-03-26  1163  	trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%lld.%09ld",
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1164) 			 field->seqnum,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1165) 			 field->duration,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1166) 			 field->outer_duration,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1167) 			 field->timestamp.tv_sec,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23 @1168) 			 field->timestamp.tv_nsec);
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1169) 
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1170) 	if (field->nmi_count) {
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1171) 		/*
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1172) 		 * The generic sched_clock() is not NMI safe, thus
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1173) 		 * we only record the count and not the time.
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1174) 		 */
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1175) 		if (!IS_ENABLED(CONFIG_GENERIC_SCHED_CLOCK))
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1176) 			trace_seq_printf(s, " nmi-total:%llu",

:::::: The code at line 1168 was first introduced by commit
:::::: e7c15cd8a113335cf7154f027c9c8da1a92238ee tracing: Added hardware latency tracer

:::::: TO: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
:::::: CC: Steven Rostedt <rostedt@goodmis.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1609660

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-27 12:00 +0200
Message-ID<tpzBp-66r-31@gated-at.bofh.it>
In reply to#1609606
On Mon, Mar 27, 2017 at 11:25 AM, kbuild test robot <lkp@intel.com> wrote:
> Hi Deepa,
>
> [auto build test WARNING on tip/perf/core]
> [also build test WARNING on v4.11-rc4 next-20170327]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Deepa-Dinamani/trace-Make-trace_hwlat-timestamp-y2038-safe/20170327-150010
> config: x86_64-randconfig-n0-03271517 (attached as .config)
> compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=x86_64
>
> All warnings (new ones prefixed by >>):
>
>    kernel/trace/trace_output.c: In function 'trace_hwlat_print':
>>> kernel/trace/trace_output.c:1168:5: warning: format '%lld' expects argument of type 'long long int', but argument 6 has type '__kernel_time_t' [-Wformat=]
>         field->timestamp.tv_nsec);

This happens on 64-bit architectures because 'struct timespec64' is defined to
be equal to 'struct timespec', which has a 'long' tv_sec rather than
'long long'.

A cast to 's64' is probably the best workaround.

>    kernel/trace/trace_output.c: In function 'trace_hwlat_raw':
>    kernel/trace/trace_output.c:1202:5: warning: format '%lld' expects argument of type 'long long int', but argument 5 has type '__kernel_time_t' [-Wformat=]
>         field->seqnum);

Same here.


      Arnd

[toc] | [prev] | [next] | [standalone]


#1609891

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-03-27 16:40 +0200
Message-ID<tpDYl-XG-11@gated-at.bofh.it>
In reply to#1609660
On Mon, 27 Mar 2017 11:55:52 +0200
Arnd Bergmann <arnd@arndb.de> wrote:

> On Mon, Mar 27, 2017 at 11:25 AM, kbuild test robot <lkp@intel.com> wrote:
> > Hi Deepa,
> >
> > [auto build test WARNING on tip/perf/core]
> > [also build test WARNING on v4.11-rc4 next-20170327]
> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> >
> > url:    https://github.com/0day-ci/linux/commits/Deepa-Dinamani/trace-Make-trace_hwlat-timestamp-y2038-safe/20170327-150010
> > config: x86_64-randconfig-n0-03271517 (attached as .config)
> > compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
> > reproduce:
> >         # save the attached .config to linux build tree
> >         make ARCH=x86_64
> >
> > All warnings (new ones prefixed by >>):
> >
> >    kernel/trace/trace_output.c: In function 'trace_hwlat_print':  
> >>> kernel/trace/trace_output.c:1168:5: warning: format '%lld' expects argument of type 'long long int', but argument 6 has type '__kernel_time_t' [-Wformat=]  
> >         field->timestamp.tv_nsec);  
> 
> This happens on 64-bit architectures because 'struct timespec64' is defined to
> be equal to 'struct timespec', which has a 'long' tv_sec rather than
> 'long long'.
> 
> A cast to 's64' is probably the best workaround.
> 
> >    kernel/trace/trace_output.c: In function 'trace_hwlat_raw':
> >    kernel/trace/trace_output.c:1202:5: warning: format '%lld' expects argument of type 'long long int', but argument 5 has type '__kernel_time_t' [-Wformat=]
> >         field->seqnum);  
> 
> Same here.
> 

Actually, I believe that "%zd" will work. It's made to work with size_t
which is long long on 32 and long on 64.

-- Steve

[toc] | [prev] | [next] | [standalone]


#1609907

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-27 17:00 +0200
Message-ID<tpEhH-17e-15@gated-at.bofh.it>
In reply to#1609891
On Mon, Mar 27, 2017 at 4:28 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 27 Mar 2017 11:55:52 +0200
> Arnd Bergmann <arnd@arndb.de> wrote:
>
>> On Mon, Mar 27, 2017 at 11:25 AM, kbuild test robot <lkp@intel.com> wrote:
>> > Hi Deepa,
>> >
>> > [auto build test WARNING on tip/perf/core]
>> > [also build test WARNING on v4.11-rc4 next-20170327]
>> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>> >
>> > url:    https://github.com/0day-ci/linux/commits/Deepa-Dinamani/trace-Make-trace_hwlat-timestamp-y2038-safe/20170327-150010
>> > config: x86_64-randconfig-n0-03271517 (attached as .config)
>> > compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
>> > reproduce:
>> >         # save the attached .config to linux build tree
>> >         make ARCH=x86_64
>> >
>> > All warnings (new ones prefixed by >>):
>> >
>> >    kernel/trace/trace_output.c: In function 'trace_hwlat_print':
>> >>> kernel/trace/trace_output.c:1168:5: warning: format '%lld' expects argument of type 'long long int', but argument 6 has type '__kernel_time_t' [-Wformat=]
>> >         field->timestamp.tv_nsec);
>>
>> This happens on 64-bit architectures because 'struct timespec64' is defined to
>> be equal to 'struct timespec', which has a 'long' tv_sec rather than
>> 'long long'.
>>
>> A cast to 's64' is probably the best workaround.
>>
>> >    kernel/trace/trace_output.c: In function 'trace_hwlat_raw':
>> >    kernel/trace/trace_output.c:1202:5: warning: format '%lld' expects argument of type 'long long int', but argument 5 has type '__kernel_time_t' [-Wformat=]
>> >         field->seqnum);
>>
>> Same here.
>>
>
> Actually, I believe that "%zd" will work. It's made to work with size_t
> which is long long on 32 and long on 64.

size_t is always 'long', not 'long long'. We have %pad for dma_addr_t
which may be 'long' or 'long long', but it is configuration dependent
which one it is on 32-bit.

We could probably introduce a %pts format string for timespec64
and have that pretty-printed.

         Arnd

[toc] | [prev] | [next] | [standalone]


#1609953

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-27 17:40 +0200
Message-ID<tpEUq-1P8-21@gated-at.bofh.it>
In reply to#1609907
On Mon, Mar 27, 2017 at 5:30 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 27 Mar 2017 16:53:09 +0200
>> We could probably introduce a %pts format string for timespec64
>> and have that pretty-printed.
>
> Hmm, probably don't want a %p as that suggests its a pointer, which it
> should not be. Unless we pass in the address of the number.

The special format strings that the kernel defines all start with %p and
require passing by reference so we don't get a warning from gcc. We can't
just make up new format strings otherwise, but we can create new meaning
for special pointers as we do for struct resource and others.

       Arnd

[toc] | [prev] | [next] | [standalone]


#1609971

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-03-27 18:20 +0200
Message-ID<tpFx8-2mb-25@gated-at.bofh.it>
In reply to#1609953
On Mon, 27 Mar 2017 17:35:13 +0200
Arnd Bergmann <arnd@arndb.de> wrote:

> On Mon, Mar 27, 2017 at 5:30 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> > On Mon, 27 Mar 2017 16:53:09 +0200  
> >> We could probably introduce a %pts format string for timespec64
> >> and have that pretty-printed.  
> >
> > Hmm, probably don't want a %p as that suggests its a pointer, which it
> > should not be. Unless we pass in the address of the number.  
> 
> The special format strings that the kernel defines all start with %p and
> require passing by reference so we don't get a warning from gcc. We can't
> just make up new format strings otherwise, but we can create new meaning
> for special pointers as we do for struct resource and others.
> 

That's fine, but we need to be careful when it comes to tracing.
Passing in the address of a structure in the ring buffer may be fine,
but we need to make sure that an address pointing to something other
than the ring buffer is forbidden.

I'll need to update libtraceevent to handle such cases too.

-- Steve

[toc] | [prev] | [next] | [standalone]


#1609954

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-03-27 17:40 +0200
Message-ID<tpEUp-1P8-13@gated-at.bofh.it>
In reply to#1609907
On Mon, 27 Mar 2017 16:53:09 +0200
Arnd Bergmann <arnd@arndb.de> wrote:


> > Actually, I believe that "%zd" will work. It's made to work with size_t
> > which is long long on 32 and long on 64.  
> 
> size_t is always 'long', not 'long long'. We have %pad for dma_addr_t
> which may be 'long' or 'long long', but it is configuration dependent
> which one it is on 32-bit.

Ah your right. It was that it was defined as "int" on 32 and "long" on
64, and that caused problems with warnings when using "%d" when it was
defined as long.

> 
> We could probably introduce a %pts format string for timespec64
> and have that pretty-printed.

Hmm, probably don't want a %p as that suggests its a pointer, which it
should not be. Unless we pass in the address of the number.

-- Steve

[toc] | [prev] | [next] | [standalone]


#1610113

FromDeepa Dinamani <deepa.kernel@gmail.com>
Date2017-03-27 23:10 +0200
Message-ID<tpK3M-5Ky-23@gated-at.bofh.it>
In reply to#1609907
>>> >
>>> >    kernel/trace/trace_output.c: In function 'trace_hwlat_print':
>>> >>> kernel/trace/trace_output.c:1168:5: warning: format '%lld' expects argument of type 'long long int', but argument 6 has type '__kernel_time_t' [-Wformat=]
>>> >         field->timestamp.tv_nsec);
>>>
>>> This happens on 64-bit architectures because 'struct timespec64' is defined to
>>> be equal to 'struct timespec', which has a 'long' tv_sec rather than
>>> 'long long'.
>>>
>>> A cast to 's64' is probably the best workaround.

We have been using long long cast to print timespec64 tv_sec.

I'm not sure what format specifier we would use if we cast to s64.
printk-formats suggests %lld or %llx.
Meaning a cast to long long.

>>>
>>> >    kernel/trace/trace_output.c: In function 'trace_hwlat_raw':
>>> >    kernel/trace/trace_output.c:1202:5: warning: format '%lld' expects argument of type 'long long int', but argument 5 has type '__kernel_time_t' [-Wformat=]
>>> >         field->seqnum);
>>>
>>> Same here.
>>>
>>
>> Actually, I believe that "%zd" will work. It's made to work with size_t
>> which is long long on 32 and long on 64.
>
> size_t is always 'long', not 'long long'. We have %pad for dma_addr_t
> which may be 'long' or 'long long', but it is configuration dependent
> which one it is on 32-bit.
>
> We could probably introduce a %pts format string for timespec64
> and have that pretty-printed.

dma_addr_t can be u64 or u32 based on architecture be it 32 bit or 64 bit.
But, timespec64 tv_sec is always s64. This is the opposite problem
from dma_addr_t that it is 64 bits regardless of architecture.
So, wouldn't it be easier to use long long cast for tv_sec and then
print tv_nsec as long?

-Deepa

[toc] | [prev] | [next] | [standalone]


#1610380

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-28 09:30 +0200
Message-ID<tpTJL-4au-5@gated-at.bofh.it>
In reply to#1610113
On Mon, Mar 27, 2017 at 11:02 PM, Deepa Dinamani <deepa.kernel@gmail.com> wrote:
>>>> >
>>>> >    kernel/trace/trace_output.c: In function 'trace_hwlat_print':
>>>> >>> kernel/trace/trace_output.c:1168:5: warning: format '%lld' expects argument of type 'long long int', but argument 6 has type '__kernel_time_t' [-Wformat=]
>>>> >         field->timestamp.tv_nsec);
>>>>
>>>> This happens on 64-bit architectures because 'struct timespec64' is defined to
>>>> be equal to 'struct timespec', which has a 'long' tv_sec rather than
>>>> 'long long'.
>>>>
>>>> A cast to 's64' is probably the best workaround.
>
> We have been using long long cast to print timespec64 tv_sec.
>
> I'm not sure what format specifier we would use if we cast to s64.
> printk-formats suggests %lld or %llx.
> Meaning a cast to long long.

Right, s64 is alway 'long long'. Out of the two, the former feels
more natural as we normally count seconds in decimal.

>>>>
>>>> >    kernel/trace/trace_output.c: In function 'trace_hwlat_raw':
>>>> >    kernel/trace/trace_output.c:1202:5: warning: format '%lld' expects argument of type 'long long int', but argument 5 has type '__kernel_time_t' [-Wformat=]
>>>> >         field->seqnum);
>>>>
>>>> Same here.
>>>>
>>>
>>> Actually, I believe that "%zd" will work. It's made to work with size_t
>>> which is long long on 32 and long on 64.
>>
>> size_t is always 'long', not 'long long'. We have %pad for dma_addr_t
>> which may be 'long' or 'long long', but it is configuration dependent
>> which one it is on 32-bit.
>>
>> We could probably introduce a %pts format string for timespec64
>> and have that pretty-printed.
>
> dma_addr_t can be u64 or u32 based on architecture be it 32 bit or 64 bit.
> But, timespec64 tv_sec is always s64. This is the opposite problem
> from dma_addr_t that it is 64 bits regardless of architecture.
> So, wouldn't it be easier to use long long cast for tv_sec and then
> print tv_nsec as long?

The cast is clearly easier for this one instance, and that's what we should
do here.

Generally speaking I think it would be nice to have have a way to print
a timespec64 and I thought it would also address this instance but as
Steve pointed out, we can't print objects by reference in trace output
without duplicating the logic there, so let's not go there now.

      Arnd

[toc] | [prev] | [next] | [standalone]


#1609698

Fromkbuild test robot <lkp@intel.com>
Date2017-03-27 12:10 +0200
Message-ID<tpzL5-6pP-55@gated-at.bofh.it>
In reply to#1609397

[Multipart message — attachments visible in raw view] — view raw

Hi Deepa,

[auto build test WARNING on tip/perf/core]
[also build test WARNING on v4.11-rc4 next-20170327]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Deepa-Dinamani/trace-Make-trace_hwlat-timestamp-y2038-safe/20170327-150010
config: x86_64-randconfig-s2-03271627 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   kernel/trace/trace_output.c: In function 'trace_hwlat_print':
>> kernel/trace/trace_output.c:1168: warning: format '%lld' expects type 'long long int', but argument 6 has type '__kernel_time_t'
   kernel/trace/trace_output.c: In function 'trace_hwlat_raw':
   kernel/trace/trace_output.c:1202: warning: format '%lld' expects type 'long long int', but argument 5 has type '__kernel_time_t'

vim +1168 kernel/trace/trace_output.c

e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1152) /* TRACE_HWLAT */
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1153) static enum print_line_t
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1154) trace_hwlat_print(struct trace_iterator *iter, int flags,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1155) 		  struct trace_event *event)
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1156) {
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1157) 	struct trace_entry *entry = iter->ent;
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1158) 	struct trace_seq *s = &iter->seq;
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1159) 	struct hwlat_entry *field;
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1160) 
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1161) 	trace_assign_type(field, entry);
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1162) 
df001907 Deepa Dinamani           2017-03-26  1163  	trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%lld.%09ld",
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1164) 			 field->seqnum,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1165) 			 field->duration,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1166) 			 field->outer_duration,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1167) 			 field->timestamp.tv_sec,
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23 @1168) 			 field->timestamp.tv_nsec);
e7c15cd8 Steven Rostedt (Red Hat  2016-06-23  1169) 
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1170) 	if (field->nmi_count) {
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1171) 		/*
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1172) 		 * The generic sched_clock() is not NMI safe, thus
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1173) 		 * we only record the count and not the time.
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1174) 		 */
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1175) 		if (!IS_ENABLED(CONFIG_GENERIC_SCHED_CLOCK))
7b2c8625 Steven Rostedt (Red Hat  2016-08-04  1176) 			trace_seq_printf(s, " nmi-total:%llu",

:::::: The code at line 1168 was first introduced by commit
:::::: e7c15cd8a113335cf7154f027c9c8da1a92238ee tracing: Added hardware latency tracer

:::::: TO: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
:::::: CC: Steven Rostedt <rostedt@goodmis.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web