From: Steven Rostedt <rostedt@goodmis.org>
To: Tony Luck <tony.luck@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>, <fweisbec@gmail.com>,
<m.chehab@samsung.com>, "Xie XiuQi" <xiexiuqi@huawei.com>
Subject: Re: [PATCH] tracing: Fix wraparound problems in "uptime" tracer
Date: Fri, 18 Jul 2014 14:47:33 -0400 [thread overview]
Message-ID: <20140718144733.5ef33d64@gandalf.local.home> (raw)
In-Reply-To: <99d63c5bfe9b320a3b428d773825a37095bf6a51.1405708254.git.tony.luck@intel.com>
On Fri, 18 Jul 2014 11:43:01 -0700
Tony Luck <tony.luck@intel.com> wrote:
> The "uptime" tracer added in:
>
> commit 8aacf017b065a805d27467843490c976835eb4a5
> tracing: Add "uptime" trace clock that uses jiffies
>
> has wraparound problems when the system has been up more
> than 1 hour 11 minutes and 34 seconds. It converts jiffies
> to nanoseconds using:
> (u64)jiffies_to_usecs(jiffy) * 1000ULL
> but since jiffies_to_usecs() only returns a 32-bit value, it
> truncates at 2^32 microseconds. An additional problem on 32-bit
> systems is that the argument is "unsigned long", so fixing the
> return value only helps until 2^32 jiffies (49.7 days on a HZ=1000
> system).
>
> Avoid these problems by using jiffies_64 as our basis, and
> not converting to nanoseconds (we do convert to clock_t because
> user facing API must not be dependent on internal kernel
> HZ values).
>
Do you think this is worthy of stable and 3.16 material?
-- Steve
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---
> kernel/trace/trace.c | 2 +-
> kernel/trace/trace_clock.c | 9 +++++----
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 384ede311717..eb7d56480545 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -809,7 +809,7 @@ static struct {
> { trace_clock_local, "local", 1 },
> { trace_clock_global, "global", 1 },
> { trace_clock_counter, "counter", 0 },
> - { trace_clock_jiffies, "uptime", 1 },
> + { trace_clock_jiffies, "uptime", 0 },
> { trace_clock, "perf", 1 },
> ARCH_TRACE_CLOCKS
> };
> diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
> index 26dc348332b7..57b67b1f24d1 100644
> --- a/kernel/trace/trace_clock.c
> +++ b/kernel/trace/trace_clock.c
> @@ -59,13 +59,14 @@ u64 notrace trace_clock(void)
>
> /*
> * trace_jiffy_clock(): Simply use jiffies as a clock counter.
> + * Note that this use of jiffies_64 is not completely safe on
> + * 32-bit systems. But the window is tiny, and the effect if
> + * we are affected is that we will have an obviously bogus
> + * timestamp on a trace event - i.e. not life threatening.
> */
> u64 notrace trace_clock_jiffies(void)
> {
> - u64 jiffy = jiffies - INITIAL_JIFFIES;
> -
> - /* Return nsecs */
> - return (u64)jiffies_to_usecs(jiffy) * 1000ULL;
> + return jiffies_64_to_clock_t(jiffies_64 - INITIAL_JIFFIES);
> }
>
> /*
next prev parent reply other threads:[~2014-07-18 18:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-28 11:09 [PATCH 0/2] tracing: fix uptime overflow problem Xie XiuQi
2014-06-28 11:10 ` [PATCH 1/2] " Xie XiuQi
2014-06-30 15:10 ` Steven Rostedt
2014-06-30 18:17 ` [PATCH] tracing: Fix wraparound problems in "uptime" tracer Tony Luck
2014-06-30 18:40 ` Steven Rostedt
2014-06-30 20:31 ` [PATCH-v2] " Tony Luck
2014-07-17 23:02 ` Tony Luck
2014-07-18 2:08 ` Steven Rostedt
2014-07-18 17:05 ` Tony Luck
2014-07-18 17:36 ` Steven Rostedt
2014-07-18 18:43 ` [PATCH] " Tony Luck
2014-07-18 18:47 ` Steven Rostedt [this message]
2014-07-18 18:54 ` Tony Luck
2014-06-28 11:10 ` [PATCH 2/2] tracing: update Documentation/trace/ftrace.txt for uptime Xie XiuQi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140718144733.5ef33d64@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=mingo@redhat.com \
--cc=tony.luck@intel.com \
--cc=xiexiuqi@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®