29 Nov, 2019

1 commit

  • sched_clock_running is enabled early at bootup stage and never
    disabled. So hint that to the compiler by using static_branch_likely()
    rather than static_branch_unlikely().

    The branch probability mis-annotation was introduced in the original
    commit that converted the plain sched_clock_running flag to a static key:

    46457ea464f5 ("sched/clock: Use static key for sched_clock_running")

    Steve further notes:

    | Looks like the confusion was the moving of the "!":
    |
    | - if (unlikely(!sched_clock_running))
    | + if (!static_branch_unlikely(&sched_clock_running))
    |
    | Where, it was unlikely that !sched_clock_running would be true, but
    | because the "!" was moved outside the "unlikely()" it makes the test
    | "likely()". That is, if we added an intermediate step, it would have
    | been:
    |
    | if (!likely(sched_clock_running))
    |
    | which would have prevented the mistake that this patch fixes.

    [ mingo: Edited the changelog. ]

    Signed-off-by: Zhenzhong Duan
    Reviewed-by: Steven Rostedt (VMware)
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: bsegall@google.com
    Cc: dietmar.eggemann@arm.com
    Cc: juri.lelli@redhat.com
    Cc: mgorman@suse.de
    Cc: vincent.guittot@linaro.org
    Link: https://lkml.kernel.org/r/1574843848-26825-1-git-send-email-zhenzhong.duan@oracle.com
    Signed-off-by: Ingo Molnar

    Zhenzhong Duan
     

21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have EXPORT_.*_SYMBOL_GPL inside which was used in the
    initial scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

31 Jul, 2018

1 commit

  • sched_clock_init() used be called early during boot when interrupts were
    still disabled. After the recent changes to utilize sched clock early the
    sched_clock_init() call happens when interrupts are already enabled, which
    triggers the following warning:

    WARNING: CPU: 0 PID: 0 at kernel/time/sched_clock.c:180 sched_clock_register+0x44/0x278
    [] (warn_slowpath_null) from [] (sched_clock_register+0x44/0x278)
    [] (sched_clock_register) from [] (generic_sched_clock_init+0x28/0x88)
    [] (generic_sched_clock_init) from [] (sched_clock_init+0x54/0x74)
    [] (sched_clock_init) from [] (start_kernel+0x310/0x3e4)
    [] (start_kernel) from [] ( (null))

    Disable IRQs for the duration of generic_sched_clock_init().

    Fixes: 857baa87b642 ("sched/clock: Enable sched clock early")
    Signed-off-by: Pavel Tatashin
    Reported-by: Guenter Roeck
    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: steven.sistare@oracle.com
    Cc: daniel.m.jordan@oracle.com
    Link: https://lkml.kernel.org/r/20180730135252.24599-1-pasha.tatashin@oracle.com

    Pavel Tatashin
     

20 Jul, 2018

4 commits

  • All data required for the 'unstable' sched_clock must be set-up _before_
    enabling it -- setting sched_clock_running. This includes the
    __gtod_offset but also a recent scd stamp.

    Make the gtod-offset update also set the csd stamp -- it requires the
    same two clock reads _anyway_. This doesn't hurt in the
    sched_clock_tick_stable() case and ensures sched_clock_init() gets
    everything set-up before use.

    Also switch to unconditional IRQ-disable/enable because the static key
    stuff already requires this is not ran with IRQs disabled.

    Fixes: 857baa87b642 ("sched/clock: Enable sched clock early")
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Thomas Gleixner
    Cc: Pavel Tatashin
    Cc: steven.sistare@oracle.com
    Cc: daniel.m.jordan@oracle.com
    Cc: linux@armlinux.org.uk
    Cc: schwidefsky@de.ibm.com
    Cc: heiko.carstens@de.ibm.com
    Cc: john.stultz@linaro.org
    Cc: sboyd@codeaurora.org
    Cc: hpa@zytor.com
    Cc: douly.fnst@cn.fujitsu.com
    Cc: prarit@redhat.com
    Cc: feng.tang@intel.com
    Cc: pmladek@suse.com
    Cc: gnomes@lxorguk.ukuu.org.uk
    Cc: linux-s390@vger.kernel.org
    Cc: boris.ostrovsky@oracle.com
    Cc: jgross@suse.com
    Cc: pbonzini@redhat.com
    Link: https://lkml.kernel.org/r/20180720080911.GM2494@hirez.programming.kicks-ass.net

    Peter Zijlstra
     
  • sched_clock_running may be read every time sched_clock_cpu() is called.
    Yet, this variable is updated only twice during boot, and never changes
    again, therefore it is better to make it a static key.

    Signed-off-by: Pavel Tatashin
    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Cc: steven.sistare@oracle.com
    Cc: daniel.m.jordan@oracle.com
    Cc: linux@armlinux.org.uk
    Cc: schwidefsky@de.ibm.com
    Cc: heiko.carstens@de.ibm.com
    Cc: john.stultz@linaro.org
    Cc: sboyd@codeaurora.org
    Cc: hpa@zytor.com
    Cc: douly.fnst@cn.fujitsu.com
    Cc: prarit@redhat.com
    Cc: feng.tang@intel.com
    Cc: pmladek@suse.com
    Cc: gnomes@lxorguk.ukuu.org.uk
    Cc: linux-s390@vger.kernel.org
    Cc: boris.ostrovsky@oracle.com
    Cc: jgross@suse.com
    Cc: pbonzini@redhat.com
    Link: https://lkml.kernel.org/r/20180719205545.16512-25-pasha.tatashin@oracle.com

    Pavel Tatashin
     
  • Allow sched_clock() to be used before schec_clock_init() is called. This
    provides a way to get early boot timestamps on machines with unstable
    clocks.

    Signed-off-by: Pavel Tatashin
    Signed-off-by: Thomas Gleixner
    Cc: steven.sistare@oracle.com
    Cc: daniel.m.jordan@oracle.com
    Cc: linux@armlinux.org.uk
    Cc: schwidefsky@de.ibm.com
    Cc: heiko.carstens@de.ibm.com
    Cc: john.stultz@linaro.org
    Cc: sboyd@codeaurora.org
    Cc: hpa@zytor.com
    Cc: douly.fnst@cn.fujitsu.com
    Cc: peterz@infradead.org
    Cc: prarit@redhat.com
    Cc: feng.tang@intel.com
    Cc: pmladek@suse.com
    Cc: gnomes@lxorguk.ukuu.org.uk
    Cc: linux-s390@vger.kernel.org
    Cc: boris.ostrovsky@oracle.com
    Cc: jgross@suse.com
    Cc: pbonzini@redhat.com
    Link: https://lkml.kernel.org/r/20180719205545.16512-24-pasha.tatashin@oracle.com

    Pavel Tatashin
     
  • sched_clock_postinit() initializes a generic clock on systems where no
    other clock is provided. This function may be called only after
    timekeeping_init().

    Rename sched_clock_postinit to generic_clock_inti() and call it from
    sched_clock_init(). Move the call for sched_clock_init() until after
    time_init().

    Suggested-by: Peter Zijlstra
    Signed-off-by: Pavel Tatashin
    Signed-off-by: Thomas Gleixner
    Cc: steven.sistare@oracle.com
    Cc: daniel.m.jordan@oracle.com
    Cc: linux@armlinux.org.uk
    Cc: schwidefsky@de.ibm.com
    Cc: heiko.carstens@de.ibm.com
    Cc: john.stultz@linaro.org
    Cc: sboyd@codeaurora.org
    Cc: hpa@zytor.com
    Cc: douly.fnst@cn.fujitsu.com
    Cc: prarit@redhat.com
    Cc: feng.tang@intel.com
    Cc: pmladek@suse.com
    Cc: gnomes@lxorguk.ukuu.org.uk
    Cc: linux-s390@vger.kernel.org
    Cc: boris.ostrovsky@oracle.com
    Cc: jgross@suse.com
    Cc: pbonzini@redhat.com
    Link: https://lkml.kernel.org/r/20180719205545.16512-23-pasha.tatashin@oracle.com

    Pavel Tatashin
     

04 Mar, 2018

1 commit

  • Do the following cleanups and simplifications:

    - sched/sched.h already includes , so no need to
    include it in sched/core.c again.

    - order the headers alphabetically

    - add all headers to kernel/sched/sched.h

    - remove all unnecessary includes from the .c files that
    are already included in kernel/sched/sched.h.

    Finally, make all scheduler .c files use a single common header:

    #include "sched.h"

    ... which now contains a union of the relied upon headers.

    This makes the various .c files easier to read and easier to handle.

    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

03 Mar, 2018

1 commit

  • A good number of small style inconsistencies have accumulated
    in the scheduler core, so do a pass over them to harmonize
    all these details:

    - fix speling in comments,

    - use curly braces for multi-line statements,

    - remove unnecessary parentheses from integer literals,

    - capitalize consistently,

    - remove stray newlines,

    - add comments where necessary,

    - remove invalid/unnecessary comments,

    - align structure definitions and other data types vertically,

    - add missing newlines for increased readability,

    - fix vertical tabulation where it's misaligned,

    - harmonize preprocessor conditional block labeling
    and vertical alignment,

    - remove line-breaks where they uglify the code,

    - add newline after local variable definitions,

    No change in functionality:

    md5:
    1191fa0a890cfa8132156d2959d7e9e2 built-in.o.before.asm
    1191fa0a890cfa8132156d2959d7e9e2 built-in.o.after.asm

    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

08 Nov, 2017

1 commit

  • Use lockdep to check that IRQs are enabled or disabled as expected. This
    way the sanity check only shows overhead when concurrency correctness
    debug code is enabled.

    Signed-off-by: Frederic Weisbecker
    Acked-by: Thomas Gleixner
    Cc: David S . Miller
    Cc: Lai Jiangshan
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Tejun Heo
    Link: http://lkml.kernel.org/r/1509980490-4285-12-git-send-email-frederic@kernel.org
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

24 May, 2017

1 commit

  • The more strict early boot preemption warnings found that
    __set_sched_clock_stable() was incorrectly assuming we'd still be
    running on a single CPU:

    BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
    caller is debug_smp_processor_id+0x1c/0x1e
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc2-00108-g1c3c5ea #1
    Call Trace:
    dump_stack+0x110/0x192
    check_preemption_disabled+0x10c/0x128
    ? set_debug_rodata+0x25/0x25
    debug_smp_processor_id+0x1c/0x1e
    sched_clock_init_late+0x27/0x87
    [...]

    Fix it by disabling IRQs.

    Reported-by: kernel test robot
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Thomas Gleixner
    Cc: Greg Kroah-Hartman
    Cc: Linus Torvalds
    Cc: Mark Rutland
    Cc: Peter Zijlstra
    Cc: Steven Rostedt
    Cc: lkp@01.org
    Cc: tipbuild@zytor.com
    Link: http://lkml.kernel.org/r/20170524065202.v25vyu7pvba5mhpd@hirez.programming.kicks-ass.net
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

15 May, 2017

7 commits

  • With our switch to stable delayed until late_initcall(), the most
    likely cause of hitting mark_tsc_unstable() is the watchdog. The
    watchdog typically only triggers when creative BIOS'es fiddle with the
    TSC to hide SMI latency.

    Since the watchdog can only detect TSC fiddling after the fact all TSC
    clocks (including userspace GTOD) can already have reported funny
    values.

    The only way to fully avoid this, is manually marking the TSC unstable
    at boot. Suggest people do this on their broken systems.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Core2 marks its TSC unstable in ACPI Processor Idle, which is probed
    after sched_init_smp(). Luckily it appears both acpi_processor and
    intel_idle (which has a similar check) are mandatory built-in.

    This means we can delay switching to stable until after these drivers
    have ran (if they were modules, this would be impossible).

    Delay the stable switch to late_initcall() to allow these drivers to
    mark TSC unstable and avoid difficult stable->unstable transitions.

    Reported-by: Lofstedt, Marta
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Rafael J . Wysocki
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Ville reported that on his Core2, which has TSC stop in idle, we would
    always report very short idle durations. He tracked this down to
    commit:

    e93e59ce5b85 ("cpuidle: Replace ktime_get() with local_clock()")

    which replaces ktime_get() with local_clock().

    Add a sched_clock_idle_wakeup_event() call, which will re-sync the
    clock with ktime_get_ns() when TSC is unstable and no-op otherwise.

    Reported-by: Ville Syrjälä
    Tested-by: Ville Syrjälä
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Daniel Lezcano
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Rafael J . Wysocki
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Fixes: e93e59ce5b85 ("cpuidle: Replace ktime_get() with local_clock()")
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Commit:

    2bacec8c318c ("sched: touch softlockup watchdog after idling")

    introduced the touch_softlockup_watchdog_sched() call without
    justification and I feel sched_clock management is not the right
    place, it should only be concerned with producing semi coherent time.

    If this causes watchdog thingies, we can find a better place.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • The argument to sched_clock_idle_wakeup_event() has not been used in a
    long time. Remove it.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Currently we keep sched_clock_tick() active for stable TSC in order to
    keep the per-CPU state semi up-to-date. The (obvious) problem is that
    by the time we detect TSC is borked, our per-CPU state is also borked.

    So hook into the clocksource watchdog and call a method after we've
    found it to still be stable.

    There's the obvious race where the TSC goes wonky between finding it
    stable and us running the callback, but closing that is too much work
    and not really worth it, since we're already detecting TSC wobbles
    after the fact, so we cannot, per definition, fully avoid funny clock
    values.

    And since the watchdog runs less often than the tick, this is also an
    optimization.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • In preparation for not keeping the sched_clock_tick() active for
    stable TSC, we need to explicitly initialize all per-CPU state
    before switching back to unstable.

    Note: this patch looses the __gtod_offset calculation; it will be
    restored in the next one.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

27 Mar, 2017

1 commit

  • When it is determined that the clock is actually unstable, and
    we switch from stable to unstable, the __clear_sched_clock_stable()
    function is eventually called.

    In this function we set gtod_offset so the following holds true:

    sched_clock() + raw_offset == ktime_get_ns() + gtod_offset

    But instead of getting the latest timestamps, we use the last values
    from scd, so instead of sched_clock() we use scd->tick_raw, and
    instead of ktime_get_ns() we use scd->tick_gtod.

    However, later, when we use gtod_offset sched_clock_local() we do not
    add it to scd->tick_gtod to calculate the correct clock value when we
    determine the boundaries for min/max clocks.

    This can result in tick granularity sched_clock() values, so fix it.

    Signed-off-by: Pavel Tatashin
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: hpa@zytor.com
    Fixes: 5680d8094ffa ("sched/clock: Provide better clock continuity")
    Link: http://lkml.kernel.org/r/1490214265-899964-2-git-send-email-pasha.tatashin@oracle.com
    Signed-off-by: Ingo Molnar

    Pavel Tatashin
     

23 Mar, 2017

2 commits

  • People reported that commit:

    5680d8094ffa ("sched/clock: Provide better clock continuity")

    broke "perf test tsc".

    That commit added another offset to the reported clock value; so
    take that into account when computing the provided offset values.

    Reported-by: Adrian Hunter
    Reported-by: Arnaldo Carvalho de Melo
    Tested-by: Alexander Shishkin
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: 5680d8094ffa ("sched/clock: Provide better clock continuity")
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Paul reported a problems with clear_sched_clock_stable(). Since we run
    all of __clear_sched_clock_stable() from workqueue context, there's a
    preempt problem.

    Solve it by only running the static_key_disable() from workqueue.

    Reported-by: Paul E. McKenney
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: fweisbec@gmail.com
    Link: http://lkml.kernel.org/r/20170313124621.GA3328@twins.programming.kicks-ass.net
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

02 Mar, 2017

2 commits


20 Jan, 2017

1 commit

  • Mike reported that he could trigger the WARN_ON_ONCE() in
    set_sched_clock_stable() using hotplug.

    This exposed a fundamental problem with the interface, we should never
    mark the TSC stable if we ever find it to be unstable. Therefore
    set_sched_clock_stable() is a broken interface.

    The reason it existed is that not having it is a pain, it means all
    relevant architecture code needs to call clear_sched_clock_stable()
    where appropriate.

    Of the three architectures that select HAVE_UNSTABLE_SCHED_CLOCK ia64
    and parisc are trivial in that they never called
    set_sched_clock_stable(), so add an unconditional call to
    clear_sched_clock_stable() to them.

    For x86 the story is a lot more involved, and what this patch tries to
    do is ensure we preserve the status quo. So even is Cyrix or Transmeta
    have usable TSC they never called set_sched_clock_stable() so they now
    get an explicit mark unstable.

    Reported-by: Mike Galbraith
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: 9881b024b7d7 ("sched/clock: Delay switching sched_clock to stable")
    Link: http://lkml.kernel.org/r/20170119133633.GB6536@twins.programming.kicks-ass.net
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

14 Jan, 2017

3 commits

  • When switching between the unstable and stable variants it is
    currently possible that clock discontinuities occur.

    And while these will mostly be 'small', attempt to do better.

    As observed on my IVB-EP, the sched_clock() is ~1.5s ahead of the
    ktime_get_ns() based timeline at the point of switchover
    (sched_clock_init_late()) after SMP bringup.

    Equally, when the TSC is later found to be unstable -- typically
    because SMM tries to hide its SMI latencies by mucking with the TSC --
    we want to avoid large jumps.

    Since the clocksource watchdog reports the issue after the fact we
    cannot exactly fix up time, but since SMI latencies are typically
    small (~10ns range), the discontinuity is mainly due to drift between
    sched_clock() and ktime_get_ns() (which on my desktop is ~79s over
    24days).

    I dislike this patch because it adds overhead to the good case in
    favour of dealing with badness. But given the widespread failure of
    TSC stability this is worth it.

    Note that in case the TSC makes drastic jumps after SMP bringup we're
    still hosed. There's just not much we can do in that case without
    stupid overhead.

    If we were to somehow expose tsc_clocksource_reliable (which is hard
    because this code is also used on ia64 and parisc) we could avoid some
    of the newly introduced overhead.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Currently we switch to the stable sched_clock if we guess the TSC is
    usable, and then switch back to the unstable path if it turns out TSC
    isn't stable during SMP bringup after all.

    Delay switching to the stable path until after SMP bringup is
    complete. This way we'll avoid switching during the time we detect the
    worst of the TSC offences.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • sched_clock was still using the deprecated static_key interface.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

13 Apr, 2016

2 commits

  • The local_clock/cpu_clock functions were changed to prevent a double
    identical test with sched_clock_cpu() when HAVE_UNSTABLE_SCHED_CLOCK
    is set. That resulted in one line functions.

    As these functions are in all the cases one line functions and in the
    hot path, it is useful to specify them as static inline in order to
    give a strong hint to the compiler.

    After verification, it appears the compiler does not inline them
    without this hint. Change those functions to static inline.

    sched_clock_cpu() is called via the inlined local_clock()/cpu_clock()
    functions from sched.h. So any module code including sched.h will
    reference sched_clock_cpu(). Thus it must be exported with the
    EXPORT_SYMBOL_GPL macro.

    Signed-off-by: Daniel Lezcano
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1460385514-14700-2-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Daniel Lezcano
     
  • In case the HAVE_UNSTABLE_SCHED_CLOCK config is set, the cpu_clock() version
    checks if sched_clock_stable() is not set and calls sched_clock_cpu(),
    otherwise it calls sched_clock().

    sched_clock_cpu() checks also if sched_clock_stable() is set and, if true,
    calls sched_clock().

    sched_clock() will be called in sched_clock_cpu() if sched_clock_stable() is
    true.

    Remove the duplicate test by directly calling sched_clock_cpu() and let the
    static key act in this function instead.

    Signed-off-by: Daniel Lezcano
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1460385514-14700-1-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Daniel Lezcano
     

02 Mar, 2016

1 commit

  • Instead of checking sched_clock_stable from the nohz subsystem to verify
    its tick dependency, migrate it to the new mask in order to include it
    to the all-in-one check.

    Reviewed-by: Chris Metcalf
    Cc: Christoph Lameter
    Cc: Chris Metcalf
    Cc: Ingo Molnar
    Cc: Luiz Capitulino
    Cc: Peter Zijlstra
    Cc: Rik van Riel
    Cc: Thomas Gleixner
    Cc: Viresh Kumar
    Signed-off-by: Frederic Weisbecker

    Frederic Weisbecker
     

12 Jan, 2016

1 commit

  • Pull workqueue update from Tejun Heo:
    "Workqueue changes for v4.5. One cleanup patch and three to improve
    the debuggability.

    Workqueue now has a stall detector which dumps workqueue state if any
    worker pool hasn't made forward progress over a certain amount of time
    (30s by default) and also triggers a warning if a workqueue which can
    be used in memory reclaim path tries to wait on something which can't
    be.

    These should make workqueue hangs a lot easier to debug."

    * 'for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
    workqueue: simplify the apply_workqueue_attrs_locked()
    workqueue: implement lockup detector
    watchdog: introduce touch_softlockup_watchdog_sched()
    workqueue: warn if memory reclaim tries to flush !WQ_MEM_RECLAIM workqueue

    Linus Torvalds
     

09 Dec, 2015

1 commit

  • touch_softlockup_watchdog() is used to tell watchdog that scheduler
    stall is expected. One group of usage is from paths where the task
    may not be able to yield for a long time such as performing slow PIO
    to finicky device and coming out of suspend. The other is to account
    for scheduler and timer going idle.

    For scheduler softlockup detection, there's no reason to distinguish
    the two cases; however, workqueue lockup detector is planned and it
    can use the same signals from the former group while the latter would
    spuriously prevent detection. This patch introduces a new function
    touch_softlockup_watchdog_sched() and convert the latter group to call
    it instead. For now, it just calls touch_softlockup_watchdog() and
    there's no functional difference.

    Signed-off-by: Tejun Heo
    Cc: Ulrich Obergfell
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Andrew Morton

    Tejun Heo
     

23 Nov, 2015

1 commit

  • There were still a number of references to my old Red Hat email
    address in the kernel source. Remove these while keeping the
    Red Hat copyright notices intact.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

13 Feb, 2015

1 commit

  • When the hypervisor pauses a virtualised kernel the kernel will observe a
    jump in timebase, this can cause spurious messages from the softlockup
    detector.

    Whilst these messages are harmless, they are accompanied with a stack
    trace which causes undue concern and more problematically the stack trace
    in the guest has nothing to do with the observed problem and can only be
    misleading.

    Futhermore, on POWER8 this is completely avoidable with the introduction
    of the Virtual Time Base (VTB) register.

    This patch (of 2):

    This permits the use of arch specific clocks for which virtualised kernels
    can use their notion of 'running' time, not the elpased wall time which
    will include host execution time.

    Signed-off-by: Cyril Bur
    Cc: Michael Ellerman
    Cc: Andrew Jones
    Acked-by: Don Zickus
    Cc: Ingo Molnar
    Cc: Ulrich Obergfell
    Cc: chai wen
    Cc: Fabian Frederick
    Cc: Aaron Tomlin
    Cc: Ben Zhang
    Cc: Martin Schwidefsky
    Cc: John Stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cyril Bur
     

27 Aug, 2014

1 commit

  • Convert uses of __get_cpu_var for creating a address from a percpu
    offset to this_cpu_ptr.

    The two cases where get_cpu_var is used to actually access a percpu
    variable are changed to use this_cpu_read/raw_cpu_read.

    Reviewed-by: Thomas Gleixner
    Signed-off-by: Christoph Lameter
    Signed-off-by: Tejun Heo

    Christoph Lameter
     

08 Apr, 2014

1 commit


11 Mar, 2014

1 commit

  • Prevent tracing of preempt_disable/enable() in sched_clock_cpu().
    When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are
    traced and this causes trace_clock() users (and probably others) to
    go into an infinite recursion. Systems with a stable sched_clock()
    are not affected.

    This problem is similar to that fixed by upstream commit 95ef1e52922
    ("KVM guest: prevent tracing recursion with kvmclock").

    Signed-off-by: Fernando Luis Vazquez Cao
    Signed-off-by: Peter Zijlstra
    Acked-by: Steven Rostedt
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Link: http://lkml.kernel.org/r/1394083528.4524.3.camel@nexus
    Signed-off-by: Ingo Molnar

    Fernando Luis Vazquez Cao
     

23 Jan, 2014

1 commit

  • The code would assume sched_clock_stable() and switch to !stable
    later, this switch brings a discontinuity in time.

    The discontinuity on switching from stable to unstable was always
    present, but previously we would set stable/unstable before
    initializing TSC and usually stick to the one we start out with.

    So the static_key bits brought an extra switch where there previously
    wasn't one.

    Things are further complicated by the fact that we cannot use
    static_key as early as we usually call set_sched_clock_stable().

    Fix things by tracking the stable state in a regular variable and only
    set the static_key to the right state on sched_clock_init(), which is
    ran right after late_time_init->tsc_init().

    Before this we would not be using the TSC anyway.

    Reported-and-Tested-by: Sasha Levin
    Reported-by: dyoung@redhat.com
    Fixes: 35af99e646c7 ("sched/clock, x86: Use a static_key for sched_clock_stable")
    Cc: jacob.jun.pan@linux.intel.com
    Cc: Mike Galbraith
    Cc: hpa@zytor.com
    Cc: paulmck@linux.vnet.ibm.com
    Cc: John Stultz
    Cc: Andy Lutomirski
    Cc: Arjan van de Ven
    Cc: lenb@kernel.org
    Cc: rjw@rjwysocki.net
    Cc: Eliezer Tamir
    Cc: rui.zhang@intel.com
    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20140122115918.GG3694@twins.programming.kicks-ass.net
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

13 Jan, 2014

2 commits

  • The below tells us the static_key conversion has a problem; since the
    exact point of clearing that flag isn't too important, delay the flip
    and use a workqueue to process it.

    [ ] TSC synchronization [CPU#0 -> CPU#22]:
    [ ] Measured 8 cycles TSC warp between CPUs, turning off TSC clock.
    [ ]
    [ ] ======================================================
    [ ] [ INFO: possible circular locking dependency detected ]
    [ ] 3.13.0-rc3-01745-g848b0d0322cb-dirty #637 Not tainted
    [ ] -------------------------------------------------------
    [ ] swapper/0/1 is trying to acquire lock:
    [ ] (jump_label_mutex){+.+...}, at: [] jump_label_lock+0x17/0x20
    [ ]
    [ ] but task is already holding lock:
    [ ] (cpu_hotplug.lock){+.+.+.}, at: [] cpu_hotplug_begin+0x2b/0x60
    [ ]
    [ ] which lock already depends on the new lock.
    [ ]
    [ ]
    [ ] the existing dependency chain (in reverse order) is:
    [ ]
    [ ] -> #1 (cpu_hotplug.lock){+.+.+.}:
    [ ] [] lock_acquire+0x90/0x130
    [ ] [] mutex_lock_nested+0x63/0x3e0
    [ ] [] get_online_cpus+0x3c/0x60
    [ ] [] arch_jump_label_transform+0x37/0x130
    [ ] [] __jump_label_update+0x5f/0x80
    [ ] [] jump_label_update+0x9d/0xb0
    [ ] [] static_key_slow_inc+0x9d/0xb0
    [ ] [] sched_feat_set+0xf5/0x100
    [ ] [] set_numabalancing_state+0x2c/0x30
    [ ] [] numa_policy_init+0x1af/0x1b7
    [ ] [] start_kernel+0x35d/0x41f
    [ ] [] x86_64_start_reservations+0x2a/0x2c
    [ ] [] x86_64_start_kernel+0xfb/0xfe
    [ ]
    [ ] -> #0 (jump_label_mutex){+.+...}:
    [ ] [] __lock_acquire+0x1701/0x1eb0
    [ ] [] lock_acquire+0x90/0x130
    [ ] [] mutex_lock_nested+0x63/0x3e0
    [ ] [] jump_label_lock+0x17/0x20
    [ ] [] static_key_slow_inc+0x6b/0xb0
    [ ] [] clear_sched_clock_stable+0x15/0x20
    [ ] [] mark_tsc_unstable+0x23/0x70
    [ ] [] check_tsc_sync_source+0x14b/0x150
    [ ] [] native_cpu_up+0x3a2/0x890
    [ ] [] _cpu_up+0xdb/0x160
    [ ] [] cpu_up+0x79/0x90
    [ ] [] smp_init+0x60/0x8c
    [ ] [] kernel_init_freeable+0x8c/0x197
    [ ] [] kernel_init+0xe/0x130
    [ ] [] ret_from_fork+0x7c/0xb0
    [ ]
    [ ] other info that might help us debug this:
    [ ]
    [ ] Possible unsafe locking scenario:
    [ ]
    [ ] CPU0 CPU1
    [ ] ---- ----
    [ ] lock(cpu_hotplug.lock);
    [ ] lock(jump_label_mutex);
    [ ] lock(cpu_hotplug.lock);
    [ ] lock(jump_label_mutex);
    [ ]
    [ ] *** DEADLOCK ***
    [ ]
    [ ] 2 locks held by swapper/0/1:
    [ ] #0: (cpu_add_remove_lock){+.+.+.}, at: [] cpu_maps_update_begin+0x17/0x20
    [ ] #1: (cpu_hotplug.lock){+.+.+.}, at: [] cpu_hotplug_begin+0x2b/0x60
    [ ]
    [ ] stack backtrace:
    [ ] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc3-01745-g848b0d0322cb-dirty #637
    [ ] Hardware name: Supermicro X8DTN/X8DTN, BIOS 4.6.3 01/08/2010
    [ ] ffffffff82c9c270 ffff880236843bb8 ffffffff8165c5f5 ffffffff82c9c270
    [ ] ffff880236843bf8 ffffffff81658c02 ffff880236843c80 ffff8802368586a0
    [ ] ffff880236858678 0000000000000001 0000000000000002 ffff880236858000
    [ ] Call Trace:
    [ ] [] dump_stack+0x4e/0x7a
    [ ] [] print_circular_bug+0x1f9/0x207
    [ ] [] __lock_acquire+0x1701/0x1eb0
    [ ] [] ? __atomic_notifier_call_chain+0x8f/0xb0
    [ ] [] lock_acquire+0x90/0x130
    [ ] [] ? jump_label_lock+0x17/0x20
    [ ] [] ? jump_label_lock+0x17/0x20
    [ ] [] mutex_lock_nested+0x63/0x3e0
    [ ] [] ? jump_label_lock+0x17/0x20
    [ ] [] jump_label_lock+0x17/0x20
    [ ] [] static_key_slow_inc+0x6b/0xb0
    [ ] [] clear_sched_clock_stable+0x15/0x20
    [ ] [] mark_tsc_unstable+0x23/0x70
    [ ] [] check_tsc_sync_source+0x14b/0x150
    [ ] [] native_cpu_up+0x3a2/0x890
    [ ] [] _cpu_up+0xdb/0x160
    [ ] [] cpu_up+0x79/0x90
    [ ] [] smp_init+0x60/0x8c
    [ ] [] kernel_init_freeable+0x8c/0x197
    [ ] [] ? rest_init+0xd0/0xd0
    [ ] [] kernel_init+0xe/0x130
    [ ] [] ret_from_fork+0x7c/0xb0
    [ ] [] ? rest_init+0xd0/0xd0
    [ ] ------------[ cut here ]------------
    [ ] WARNING: CPU: 0 PID: 1 at /usr/src/linux-2.6/kernel/smp.c:374 smp_call_function_many+0xad/0x300()
    [ ] Modules linked in:
    [ ] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc3-01745-g848b0d0322cb-dirty #637
    [ ] Hardware name: Supermicro X8DTN/X8DTN, BIOS 4.6.3 01/08/2010
    [ ] 0000000000000009 ffff880236843be0 ffffffff8165c5f5 0000000000000000
    [ ] ffff880236843c18 ffffffff81093d8c 0000000000000000 0000000000000000
    [ ] ffffffff81ccd1a0 ffffffff810ca951 0000000000000000 ffff880236843c28
    [ ] Call Trace:
    [ ] [] dump_stack+0x4e/0x7a
    [ ] [] warn_slowpath_common+0x8c/0xc0
    [ ] [] ? sched_clock_tick+0x1/0xa0
    [ ] [] warn_slowpath_null+0x1a/0x20
    [ ] [] smp_call_function_many+0xad/0x300
    [ ] [] ? arch_unregister_cpu+0x30/0x30
    [ ] [] ? arch_unregister_cpu+0x30/0x30
    [ ] [] ? sched_clock_tick+0x1/0xa0
    [ ] [] smp_call_function+0x46/0x80
    [ ] [] ? arch_unregister_cpu+0x30/0x30
    [ ] [] on_each_cpu+0x3c/0xa0
    [ ] [] ? sched_clock_idle_sleep_event+0x20/0x20
    [ ] [] ? sched_clock_tick+0x1/0xa0
    [ ] [] text_poke_bp+0x64/0xd0
    [ ] [] ? sched_clock_idle_sleep_event+0x20/0x20
    [ ] [] arch_jump_label_transform+0xae/0x130
    [ ] [] __jump_label_update+0x5f/0x80
    [ ] [] jump_label_update+0x9d/0xb0
    [ ] [] static_key_slow_inc+0x9d/0xb0
    [ ] [] clear_sched_clock_stable+0x15/0x20
    [ ] [] mark_tsc_unstable+0x23/0x70
    [ ] [] check_tsc_sync_source+0x14b/0x150
    [ ] [] native_cpu_up+0x3a2/0x890
    [ ] [] _cpu_up+0xdb/0x160
    [ ] [] cpu_up+0x79/0x90
    [ ] [] smp_init+0x60/0x8c
    [ ] [] kernel_init_freeable+0x8c/0x197
    [ ] [] ? rest_init+0xd0/0xd0
    [ ] [] kernel_init+0xe/0x130
    [ ] [] ret_from_fork+0x7c/0xb0
    [ ] [] ? rest_init+0xd0/0xd0
    [ ] ---[ end trace 6ff1df5620c49d26 ]---
    [ ] tsc: Marking TSC unstable due to check_tsc_sync_source failed

    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/n/tip-v55fgqj3nnyqnngmvuu8ep6h@git.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • In order to avoid the runtime condition and variable load turn
    sched_clock_stable into a static_key.

    Also provide a shorter implementation of local_clock() and
    cpu_clock(int) when sched_clock_stable==1.

    MAINLINE PRE POST

    sched_clock_stable: 1 1 1
    (cold) sched_clock: 329841 221876 215295
    (cold) local_clock: 301773 234692 220773
    (warm) sched_clock: 38375 25602 25659
    (warm) local_clock: 100371 33265 27242
    (warm) rdtsc: 27340 24214 24208
    sched_clock_stable: 0 0 0
    (cold) sched_clock: 382634 235941 237019
    (cold) local_clock: 396890 297017 294819
    (warm) sched_clock: 38194 25233 25609
    (warm) local_clock: 143452 71234 71232
    (warm) rdtsc: 27345 24245 24243

    Signed-off-by: Peter Zijlstra
    Cc: Linus Torvalds
    Cc: Andrew Morton
    Link: http://lkml.kernel.org/n/tip-eummbdechzz37mwmpags1gjr@git.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra