All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>,
	Clemens Ladisch <clemens@ladisch.de>,
	Sultan Alsawaf <sultan@kerneltoast.com>,
	Waiman Long <longman@redhat.com>, X86 ML <x86@kernel.org>
Subject: Re: infinite loop in read_hpet from ktime_get_boot_fast_ns
Date: Tue, 18 Jun 2019 19:34:23 +0200	[thread overview]
Message-ID: <CAHmME9pZpJj3zL3nEmz6CSouZs8pmt4D1VO26Zv8imVEPuJFeA@mail.gmail.com> (raw)
In-Reply-To: <20190612122843.GJ3436@hirez.programming.kicks-ass.net>

Hi Peter,

On Wed, Jun 12, 2019 at 2:29 PM Peter Zijlstra <peterz@infradead.org> wrote:
> > and the comment at the top mentions explicit sleep hooks. I wasn't
> > sure which function to use from here, though.
>
> Either local_clock() or cpu_clock(cpu). The sleep hooks are not
> something the consumer has to worry about.

I'm not sure whether this is another bug or just a misunderstanding on
what we meant about sleep, but I observed the following behavior,
below, with local_clock(). Notably, local_clock() isn't advanced
during sleep in the way that the other mechanisms are.

Regards,
Jason

[50865.699714] wireguard: local_clock: 1, jiffies: 1,
jiffies_monotoany: 1, ktime_boot: 1, ktime_boot_coarse: 1
[50866.723923] wireguard: local_clock: 2, jiffies: 2,
jiffies_monotoany: 2, ktime_boot: 2, ktime_boot_coarse: 2
[50867.747896] wireguard: local_clock: 3, jiffies: 3,
jiffies_monotoany: 3, ktime_boot: 3, ktime_boot_coarse: 3
[50868.772297] wireguard: local_clock: 4, jiffies: 4,
jiffies_monotoany: 4, ktime_boot: 4, ktime_boot_coarse: 4
[50869.796419] wireguard: local_clock: 5, jiffies: 5,
jiffies_monotoany: 5, ktime_boot: 5, ktime_boot_coarse: 5
[50870.820719] wireguard: local_clock: 6, jiffies: 6,
jiffies_monotoany: 6, ktime_boot: 6, ktime_boot_coarse: 6
[50871.834768] wireguard: local_clock: 7, jiffies: 7,
jiffies_monotoany: 10, ktime_boot: 10, ktime_boot_coarse: 10
[50869.918760] PM: suspend entry (deep)
[50872.846134] PM: suspend exit
[50872.874955] wireguard: local_clock: 8, jiffies: 8,
jiffies_monotoany: 11, ktime_boot: 11, ktime_boot_coarse: 11
[50873.899142] wireguard: local_clock: 9, jiffies: 9,
jiffies_monotoany: 12, ktime_boot: 12, ktime_boot_coarse: 12
[50874.923368] wireguard: local_clock: 10, jiffies: 10,
jiffies_monotoany: 13, ktime_boot: 13, ktime_boot_coarse: 13
[50875.947641] wireguard: local_clock: 11, jiffies: 11,
jiffies_monotoany: 14, ktime_boot: 14, ktime_boot_coarse: 14
[50876.971833] wireguard: local_clock: 12, jiffies: 12,
jiffies_monotoany: 15, ktime_boot: 15, ktime_boot_coarse: 15
[50877.995969] wireguard: local_clock: 13, jiffies: 13,
jiffies_monotoany: 16, ktime_boot: 16, ktime_boot_coarse: 16
[50879.020220] wireguard: local_clock: 14, jiffies: 14,
jiffies_monotoany: 17, ktime_boot: 17, ktime_boot_coarse: 17
[50880.044395] wireguard: local_clock: 15, jiffies: 15,
jiffies_monotoany: 18, ktime_boot: 18, ktime_boot_coarse: 18

static void ugh(struct work_struct *w)
{
  int i;
  u64 start_localclock = local_clock(), end_localclock;
  u64 start_jiffies = jiffies64_to_nsecs(get_jiffies_64()), end_jiffies;
  u64 start_jiffiesmonotoany =
ktime_to_ns(ktime_mono_to_any(ns_to_ktime(jiffies64_to_nsecs(get_jiffies_64())),
TK_OFFS_BOOT)), end_jiffiesmonotoany;
  u64 start_ktimeboot = ktime_get_boot_ns(), end_ktimeboot;
  u64 start_ktimebootcoarse =
ktime_to_ns(ktime_get_coarse_boottime()), end_ktimebootcoarse;

  for (i = 0; i < 15; ++i) {
    msleep(1000);
    end_localclock = local_clock();
    end_jiffies = jiffies64_to_nsecs(get_jiffies_64());
    end_jiffiesmonotoany =
ktime_to_ns(ktime_mono_to_any(ns_to_ktime(jiffies64_to_nsecs(get_jiffies_64())),
TK_OFFS_BOOT));
    end_ktimeboot = ktime_get_boot_ns();
    end_ktimebootcoarse = ktime_to_ns(ktime_get_coarse_boottime());
    pr_err("local_clock: %llu, jiffies: %llu, jiffies_monotoany: %llu,
ktime_boot: %llu, ktime_boot_coarse: %llu\n",
           (end_localclock - start_localclock) / NSEC_PER_SEC,
           (end_jiffies - start_jiffies) / NSEC_PER_SEC,
           (end_jiffiesmonotoany - start_jiffiesmonotoany) / NSEC_PER_SEC,
           (end_ktimeboot - start_ktimeboot) / NSEC_PER_SEC,
           (end_ktimebootcoarse - start_ktimebootcoarse) / NSEC_PER_SEC);
  }
}

static DECLARE_WORK(blah, ugh);

static int __init mod_init(void)
{
  schedule_work(&blah);
  return 0;
}

  parent reply	other threads:[~2019-06-18 17:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07 14:14 infinite loop in read_hpet from ktime_get_boot_fast_ns Jason A. Donenfeld
2019-06-11 21:09 ` Thomas Gleixner
2019-06-11 21:40   ` Waiman Long
2019-06-12  9:02   ` Peter Zijlstra
2019-06-12  9:44     ` Jason A. Donenfeld
2019-06-12 12:28       ` Peter Zijlstra
2019-06-12 12:31         ` Peter Zijlstra
2019-06-12 12:58         ` Jason A. Donenfeld
2019-06-12 15:27           ` Peter Zijlstra
2019-06-12 19:46         ` Arnd Bergmann
2019-06-18 17:34         ` Jason A. Donenfeld [this message]
2019-06-12 14:01       ` Arnd Bergmann
2019-06-13 15:18         ` Jason A. Donenfeld
2019-06-13 15:40           ` Arnd Bergmann
2019-06-13 16:17             ` Jason A. Donenfeld
2019-06-13 16:26               ` Thomas Gleixner
2019-06-13 16:34                 ` Jason A. Donenfeld
2019-06-13 16:41                   ` Jason A. Donenfeld
2019-06-13 19:53                   ` Thomas Gleixner
2019-06-14  9:14                     ` Jason A. Donenfeld
2019-06-14  9:44                       ` Thomas Gleixner
2019-06-14  9:56                         ` Jason A. Donenfeld
2019-06-14  9:48                       ` [PATCH] timekeeping: add get_jiffies_boot_64() for jiffies including sleep Jason A. Donenfeld
2019-06-14  9:55                     ` [tip:timers/urgent] timekeeping: Repair ktime_get_coarse*() granularity tip-bot for Thomas Gleixner
2019-06-14 11:18                       ` Arnd Bergmann
2019-06-12  9:29   ` infinite loop in read_hpet from ktime_get_boot_fast_ns Peter Zijlstra

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=CAHmME9pZpJj3zL3nEmz6CSouZs8pmt4D1VO26Zv8imVEPuJFeA@mail.gmail.com \
    --to=jason@zx2c4.com \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sultan@kerneltoast.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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.