All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <johnstul@us.ibm.com>
To: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Kees Cook <keescook@chromium.org>,
	linux-kernel@vger.kernel.org, Colin Cross <ccross@android.com>,
	Tony Luck <tony.luck@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2] pstore/ram: no timekeeping calls when unavailable
Date: Fri, 16 Nov 2012 19:16:41 -0800	[thread overview]
Message-ID: <50A70199.9030109@us.ibm.com> (raw)
In-Reply-To: <20121117025355.GC29966@lizard>

On 11/16/2012 06:53 PM, Anton Vorontsov wrote:
> On Fri, Nov 09, 2012 at 05:26:53PM -0800, Kees Cook wrote:
> [....]
>>>> @@ -171,7 +171,13 @@ static size_t ramoops_write_kmsg_hdr(struct
>>>> persistent_ram_zone *prz)
>>>>          struct timeval timestamp;
>>>>          size_t len;
>>>>
>>>> -       do_gettimeofday(&timestamp);
>>>> +       /* Handle dumping before timekeeping has resumed. */
>>>> +       if (unlikely(timekeeping_suspended)) {
>>>> +               timestamp.tv_sec = 0;
>>>> +               timestamp.tv_usec = 0;
>>>> +       } else
>>>> +               do_gettimeofday(&timestamp);
>>>> +
>>> Would nulling out the timestamp be better done in do_gettimeofday()?  That
>>> way we don't have to export timekeeping internals and users would get
>>> something more sane for this corner case.
>> Well... I'm not sure. If we don't want to expose the
>> timekeeping_suspended variable, maybe we need a function to check
>> this? I think it's probably better to find the users of timekeeping
>> that could call it when suspended. That's why I figured the BUG was
>> there. Very very few things should be attempting to call gettimeofday
>> in a place where it might be suspended. As such, it seems like those
>> things should be able to determine how to handle it. Maybe not
>> everything would be sensible to get back 0s.
>>
>> In this particular case, I'm fine with removing the BUG and returning
>> 0 instead, since that's fine for ramoops. :)
> In the lack of agreement on kernel/time/timekeeping.c change, I can't
> apply the patch. And personally I tend to agree that doing this workaround
> in the pstore code is odd. How about introducing ___do_gettimeofday() that
> is safe to call when suspened, and the func would have good kernel doc
> comments explaining the purpose of it?
Yea, I wanted to revisit this, because it is an odd case.

We don't want to call getnstimeofday() while the timekeeping code is 
suspended, since the clocksource cycle_last value may be invalid if the 
hardware was reset during suspend.  Kees is correct,  the WARN_ONs were 
there to make sure no one tries to use the timekeeping core before its 
resumed, so removing them is problematic.

Your sugggestion of having the __do_gettimeofday() internal accessor 
that maybe returns an error if timekeeping has been suspended could work.

The other possibility is depending on the needs for accuracy with the 
timestamp, current_kernel_time() might be a better interface to use, 
since it will return the time at the last tick, and doesn't require 
accessing the clocksource hardware.  Might that be a simpler solution? 
Or is sub-tick granularity necessary?

thanks
-john








  reply	other threads:[~2012-11-17  3:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05 22:00 [PATCH v2] pstore/ram: no timekeeping calls when unavailable Kees Cook
2012-11-10  0:56 ` John Stultz
2012-11-10  1:26   ` Kees Cook
2012-11-17  2:53     ` Anton Vorontsov
2012-11-17  3:16       ` John Stultz [this message]
2012-11-18 20:09         ` Kees Cook
2012-11-19 17:23           ` John Stultz
2012-11-19 17:45             ` Kees Cook
2012-11-19 18:57               ` John Stultz
2012-11-19 21:42                 ` Kees Cook

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=50A70199.9030109@us.ibm.com \
    --to=johnstul@us.ibm.com \
    --cc=anton.vorontsov@linaro.org \
    --cc=ccross@android.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.