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


Groups > linux.kernel > #1690721

Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char *prefix_msg)

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char *prefix_msg)
Date 2017-07-19 00:00 +0200
Message-ID <u4IH8-7NO-23@gated-at.bofh.it> (permalink)
References <u4I4q-7z6-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 18 Jul 2017, Mark Salyzyn wrote:

> Go directly to the rtc for persistent wall clock time and print.
> Useful if REALTIME is required to be logged in a low level power
> management function or when clock activities are suspended.  An
> aid to permit user space alignment of kernel activities.

That's a horrible idea, really. And there is no point at all.

> +void rtc_show_time(const char *prefix_msg)
> +{
> +	struct timespec ts;
> +	struct rtc_time tm;
> +
> +	getnstimeofday(&ts);

It calls getnstimeofday(), which is wrong to begin with as we switch
everything in kernel to the 64bit variants.

> +	rtc_time64_to_tm(ts.tv_sec, &tm);

This is even more wrong as rtc_time64_to_tm is for 64 bit wide second
values....

> +	pr_info("%s %d-%02d-%02d %02d:%02d:%02d.%09lu UTC\n",
> +		prefix_msg ? prefix_msg : "Time:",
> +		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
> +		tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);

Why on earth do you need to print that information in RTC format? What's
wrong with just doing:

      pr_info("My so important log message %lld\n", ktime_get_real_seconds());

and then decoding the seconds in post processing? That's completely
sufficient as you intend that for logging. Correlation with user space
CLOCK_REALTIME is even simpler as this is the same as reading it from user
space.

If your main intention is logging/debugging, then you can just use
tracepoints. The tracer allows correlation to user space tracing already.

So unless you can come up with a reasonable explanation why all this voodoo
is required, this is going nowhere.

Thanks,

	tglx

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char *prefix_msg) Mark Salyzyn <salyzyn@android.com> - 2017-07-18 23:20 +0200
  Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Thomas Gleixner <tglx@linutronix.de> - 2017-07-19 00:00 +0200
    Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Mark Salyzyn <salyzyn@android.com> - 2017-07-19 00:10 +0200
      Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Thomas Gleixner <tglx@linutronix.de> - 2017-07-19 00:40 +0200
        Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Mark Salyzyn <salyzyn@android.com> - 2017-07-19 01:30 +0200
          Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Thomas Gleixner <tglx@linutronix.de> - 2017-07-19 09:30 +0200
            Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Prarit Bhargava <prarit@redhat.com> - 2017-07-19 14:10 +0200
              Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Thomas Gleixner <tglx@linutronix.de> - 2017-07-19 14:30 +0200
                Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Prarit Bhargava <prarit@redhat.com> - 2017-07-19 16:30 +0200
              Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Mark Salyzyn <salyzyn@android.com> - 2017-07-19 20:20 +0200
      Re: [PATCH v2 1/4] time: rtc-lib: Add rtc_show_time(const char  *prefix_msg) Pavel Machek <pavel@ucw.cz> - 2017-07-20 10:30 +0200

csiph-web