29 Oct, 2014

1 commit


24 Jul, 2014

1 commit

  • We want to move the TSC sanity check into core code to make NMI safe
    accessors to clock monotonic[_raw] possible. For this we need to
    sanity check the delta calculation. Create a helper function and
    convert all sites to use it.

    [ Build fix from jstultz ]

    Signed-off-by: Thomas Gleixner
    Signed-off-by: John Stultz

    Thomas Gleixner
     

19 Oct, 2013

1 commit

  • sysfs_get_uname() is erroneously declared as returning size_t even
    though it may return a negative value, specifically -EINVAL. Its
    callers then check whether its return value is less than zero and indeed
    that is never the case for size_t.

    This patch changes sysfs_get_uname() to return ssize_t and makes sure
    its callers use ssize_t accordingly.

    Signed-off-by: Patrick Palka
    [jstultz: Didn't apply cleanly, as a similar partial fix was also applied
    so had to resolve the collisions]
    Signed-off-by: John Stultz

    Patrick Palka
     

18 Sep, 2013

1 commit


17 Sep, 2013

1 commit


31 Jul, 2013

1 commit


23 Jul, 2013

1 commit


05 Jul, 2013

1 commit

  • Up to commit 5d33b883a (clocksource: Always verify highres capability)
    we had no sanity check when selecting a clocksource, which prevented
    that a non highres capable clocksource is used when the system already
    switched to highres/nohz mode.

    The new sanity check works as Alex and Tim found out. It prevents the
    TSC from being used. This happens because on x86 the boot process
    looks like this:

    tsc_start_freqency_validation(TSC);
    clocksource_register(HPET);
    clocksource_done_booting();
    clocksource_select()
    Selects HPET which is valid for high-res

    switch_to_highres();

    clocksource_register(TSC);
    TSC is not selected, because it is not yet
    flagged as VALID_HIGH_RES

    clocksource_watchdog()
    Validates TSC for highres, but that does not make TSC
    the current clocksource.

    Before the sanity check was added, we installed TSC unvalidated which
    worked most of the time. If the TSC was really detected as unstable,
    then the unstable logic removed it and installed HPET again.

    The sanity check is correct and needed. So the watchdog needs to kick
    a reselection of the clocksource, when it qualifies TSC as a valid
    high res clocksource.

    To solve this, we mark the clocksource which got the flag
    CLOCK_SOURCE_VALID_FOR_HRES set by the watchdog with an new flag
    CLOCK_SOURCE_RESELECT and trigger the watchdog thread. The watchdog
    thread evaluates the flag and invokes clocksource_select() when set.

    To avoid that the clocksource_done_booting() code, which is about to
    install the first real clocksource anyway, needs to go through
    clocksource_select and tick_oneshot_notify() pointlessly, split out
    the clocksource_watchdog_kthread() list walk code and invoke the
    select/notify only when called from clocksource_watchdog_kthread().

    So clocksource_done_booting() can utilize the same splitout code
    without the select/notify invocation and the clocksource_mutex
    unlock/relock dance.

    Reported-and-tested-by: Alex Shi
    Cc: Hans Peter Anvin
    Cc: Tim Chen
    Cc: Andi Kleen
    Tested-by: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Davidlohr Bueso
    Cc: John Stultz
    Link: http://lkml.kernel.org/r/alpine.DEB.2.02.1307042239150.11637@ionos.tec.linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

28 May, 2013

1 commit


16 May, 2013

7 commits

  • Provide a sysfs interface to allow unbinding of clockevent
    devices. The device is unbound if it is unused or if there is a
    replacement device available. Unbinding of broadcast devices is not
    supported as we don't want to foster that nonsense. If no replacement
    device is available the unbind returns -EBUSY. Unbind is available
    from the kernel and through sysfs, which is necessary to drop the
    module refcount.

    Signed-off-by: Thomas Gleixner
    Cc: John Stultz
    Cc: Magnus Damm
    Link: http://lkml.kernel.org/r/20130425143436.499216659@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • The unregister call can fail, if the clocksource is the current one
    and there is no replacement clocksource available. It can also fail,
    if the clocksource is the watchdog clocksource and I'm not going to
    provide support for this.

    Signed-off-by: Thomas Gleixner
    Cc: John Stultz
    Cc: Magnus Damm
    Link: http://lkml.kernel.org/r/20130425143436.029915527@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • With the module refcount held for the current clocksource there is no
    way to unload the module.

    Provide a sysfs interface which allows to unbind the clocksource. One
    could argue that the clocksource override could be (ab)used to do so,
    but the clocksource override cannot be used from the kernel itself,
    while an unbind function can be used to programmatically check whether
    a clocksource can be shutdown or not.

    The unbind functionality uses the new skip current feature of
    clocksource_select and verifies that a fallback clocksource has been
    installed. If the clocksource which should be unbound is the current
    clocksource and no fallback can be found, unbind returns -EBUSY.

    This does not support the unbinding of a clocksource which is used as
    the watchdog clocksource. No point in fostering crappy hardware.

    Signed-off-by: Thomas Gleixner
    Cc: John Stultz
    Cc: Magnus Damm
    Link: http://lkml.kernel.org/r/20130425143435.964218245@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • Split out the user string input for clocksource override. Preparatory
    patch for unbind.

    [ jstultz: Fix an off by one error ]

    Signed-off-by: Thomas Gleixner
    Cc: John Stultz
    Cc: Magnus Damm
    Link: http://lkml.kernel.org/r/20130425143435.895851338@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • Preparatory patch for clocksource unbind support.

    Split out code from clocksource_select and modify it, so it skips the
    current clocksource on request and tries to find a fallback
    clocksource. Convert all existing users. No functional change.

    Signed-off-by: Thomas Gleixner
    Cc: John Stultz
    Cc: Magnus Damm
    Link: http://lkml.kernel.org/r/20130425143435.834965397@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • timekeeping_notify() can fail due cs->enable() failure. Though the
    caller does not notice and happily keeps the wrong clocksource as the
    current one.

    Let the caller know about failure, so the current clocksource will be
    shown correctly in sysfs.

    Signed-off-by: Thomas Gleixner
    Acked-by: John Stultz
    Cc: Magnus Damm
    Link: http://lkml.kernel.org/r/20130425143435.696321912@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • If a clocksource has a (wrong) high rating, but can't be used as a
    timebase for oneshot tick mode, it is unconditionally selected even
    when the system is already in oneshot tick mode. This causes full
    system failure.

    Verify the clocksource selection against the oneshot mode.

    Signed-off-by: Thomas Gleixner
    Acked-by: John Stultz
    Cc: Magnus Damm
    Link: http://lkml.kernel.org/r/20130425143435.635040849@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

24 Mar, 2012

1 commit


07 Jan, 2012

1 commit

  • This resolves the conflict in the arch/arm/mach-s3c64xx/s3c6400.c file,
    and it fixes the build error in the arch/x86/kernel/microcode_core.c
    file, that the merge did not catch.

    The microcode_core.c patch was provided by Stephen Rothwell
    who was invaluable in the merge issues involved
    with the large sysdev removal process in the driver-core tree.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

19 Dec, 2011

1 commit


15 Dec, 2011

1 commit


02 Dec, 2011

1 commit


11 Nov, 2011

1 commit

  • For some frequencies, the clocks_calc_mult_shift() function will
    unfortunately select mult values very close to 0xffffffff. This
    has the potential to overflow when NTP adjusts the clock, adding
    to the mult value.

    This patch adds a clocksource.maxadj value, which provides
    an approximation of an 11% adjustment(NTP limits adjustments to
    500ppm and the tick adjustment is limited to 10%), which could
    be made to the clocksource.mult value. This is then used to both
    check that the current mult value won't overflow/underflow, as
    well as warning us if the timekeeping_adjust() code pushes over
    that 11% boundary.

    v2: Fix max_adjustment calculation, and improve WARN_ONCE
    messages.

    v3: Don't warn before maxadj has actually been set

    CC: Yong Zhang
    CC: David Daney
    CC: Thomas Gleixner
    CC: Chen Jie
    CC: zhangfx
    CC: stable@kernel.org
    Reported-by: Chen Jie
    Reported-by: zhangfx
    Tested-by: Yong Zhang
    Signed-off-by: John Stultz

    John Stultz
     

13 Sep, 2011

1 commit

  • KGDB needs to trylock watchdog_lock when trying to reset the
    clocksource watchdog after the system has been stopped to avoid a
    potential deadlock. When the trylock fails TSC usually becomes
    unstable.

    We can be more clever by using an atomic counter and checking it in
    the clocksource_watchdog callback. We restart the watchdog whenever
    the counter is > 0 and only decrement the counter when we ran through
    a full update cycle.

    Signed-off-by: Thomas Gleixner
    Cc: John Stultz
    Acked-by: Jason Wessel
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1109121326280.2723@ionos
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

17 Jun, 2011

1 commit

  • The clocksource watchdog code is interruptible and it has been
    observed that this can trigger false positives which disable the TSC.

    The reason is that an interrupt storm or a long running interrupt
    handler between the read of the watchdog source and the read of the
    TSC brings the two far enough apart that the delta is larger than the
    unstable treshold. Move both reads into a short interrupt disabled
    region to avoid that.

    Reported-and-tested-by: Vernon Mauery
    Signed-off-by: Thomas Gleixner
    Cc: stable@kernel.org

    Thomas Gleixner
     

20 May, 2011

2 commits


19 May, 2011

1 commit


05 May, 2011

1 commit

  • Christian Hoffmann reported that the command line clocksource override
    with acpi_pm timer fails:

    Kernel command line: clocksource=acpi_pm
    hpet clockevent registered
    Switching to clocksource hpet
    Override clocksource acpi_pm is not HRT compatible.
    Cannot switch while in HRT/NOHZ mode.

    The watchdog code is what enables CLOCK_SOURCE_VALID_FOR_HRES, but we
    actually end up selecting the clocksource before we enqueue it into
    the watchdog list, so that's why we see the warning and fail to switch
    to acpi_pm timer as requested. That's particularly bad when we want to
    debug timekeeping related problems in early boot.

    Put the selection call last.

    Reported-by: Christian Hoffmann
    Signed-off-by: John Stultz
    Cc: stable@kernel.org # 32...
    Link: http://lkml.kernel.org/r/%3C1304558210.2943.24.camel%40work-vm%3E
    Signed-off-by: Thomas Gleixner

    john stultz
     

16 Jan, 2011

1 commit

  • …linus' and 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

    * 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    rcu: avoid pointless blocked-task warnings
    rcu: demote SRCU_SYNCHRONIZE_DELAY from kernel-parameter status
    rtmutex: Fix comment about why new_owner can be NULL in wake_futex_pi()

    * 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    x86, olpc: Add missing Kconfig dependencies
    x86, mrst: Set correct APB timer IRQ affinity for secondary cpu
    x86: tsc: Fix calibration refinement conditionals to avoid divide by zero
    x86, ia64, acpi: Clean up x86-ism in drivers/acpi/numa.c

    * 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    timekeeping: Make local variables static
    time: Rename misnamed minsec argument of clocks_calc_mult_shift()

    * 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    tracing: Remove syscall_exit_fields
    tracing: Only process module tracepoints once
    perf record: Add "nodelay" mode, disabled by default
    perf sched: Fix list of events, dropping unsupported ':r' modifier
    Revert "perf tools: Emit clearer message for sys_perf_event_open ENOENT return"
    perf top: Fix annotate segv
    perf evsel: Fix order of event list deletion

    Linus Torvalds
     

14 Jan, 2011

1 commit

  • * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (43 commits)
    Documentation/trace/events.txt: Remove obsolete sched_signal_send.
    writeback: fix global_dirty_limits comment runtime -> real-time
    ppc: fix comment typo singal -> signal
    drivers: fix comment typo diable -> disable.
    m68k: fix comment typo diable -> disable.
    wireless: comment typo fix diable -> disable.
    media: comment typo fix diable -> disable.
    remove doc for obsolete dynamic-printk kernel-parameter
    remove extraneous 'is' from Documentation/iostats.txt
    Fix spelling milisec -> ms in snd_ps3 module parameter description
    Fix spelling mistakes in comments
    Revert conflicting V4L changes
    i7core_edac: fix typos in comments
    mm/rmap.c: fix comment
    sound, ca0106: Fix assignment to 'channel'.
    hrtimer: fix a typo in comment
    init/Kconfig: fix typo
    anon_inodes: fix wrong function name in comment
    fix comment typos concerning "consistent"
    poll: fix a typo in comment
    ...

    Fix up trivial conflicts in:
    - drivers/net/wireless/iwlwifi/iwl-core.c (moved to iwl-legacy.c)
    - fs/ext4/ext4.h

    Also fix missed 'diabled' typo in drivers/net/bnx2x/bnx2x.h while at it.

    Linus Torvalds
     

12 Jan, 2011

1 commit

  • The minsec argument to clocks_calc_mult_shift() is misnamed. It is used
    to clamp the magnitude of the mult factor so that a multiplication with
    any value in the given range won't overflow a 64 bit result. Let's
    rename it to match the actual usage.

    Signed-off-by: Nicolas Pitre
    Acked-by: John Stultz
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Nicolas Pitre
     

23 Dec, 2010

1 commit

  • Russell King reports:
    | On the ARM dev boards, we have a 32-bit counter running at 24MHz. Calling
    | clocks_calc_mult_shift(&mult, &shift, 24MHz, NSEC_PER_SEC, 60) gives
    | us a multiplier of 2796202666 and a shift of 26.
    |
    | Over a large counter delta, this produces an error - lets take a count
    | from 362976315 to 4280663372:
    |
    | (4280663372-362976315) * 2796202666 / 2^26 - (4280663372-362976315) * (1000/24)
    | => -38.91872422891230269990
    |
    | Can we do better?
    |
    | (4280663372-362976315) * 2796202667 / 2^26 - (4280663372-362976315) * (1000/24)
    | 19.45936211449532822051
    |
    | which is about twice as good as the 2796202666 multiplier.
    |
    | Looking at the equivalent divisions obtained, 2796202666 / 2^26 gives
    | 41.66666665673255920410ns per tick, whereas 2796202667 / 2^26 gives
    | 41.66666667163372039794ns. The actual value wanted is 1000/24 =
    | 41.66666666666666666666ns.

    Fix this by ensuring we round to nearest when calculating the
    multiplier.

    Signed-off-by: John Stultz
    Tested-by: Santosh Shilimkar
    Tested-by: Will Deacon
    Tested-by: Mikael Pettersson
    Tested-by: Eric Miao
    Tested-by: Olof Johansson
    Tested-by: Jamie Iles
    Signed-off-by: Russell King

    john stultz
     

02 Nov, 2010

1 commit

  • "gadget", "through", "command", "maintain", "maintain", "controller", "address",
    "between", "initiali[zs]e", "instead", "function", "select", "already",
    "equal", "access", "management", "hierarchy", "registration", "interest",
    "relative", "memory", "offset", "already",

    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Jiri Kosina

    Uwe Kleine-König
     

27 Jul, 2010

2 commits


10 May, 2010

1 commit

  • How to pick good mult/shift pairs has always been difficult to
    describe to folks writing clocksource drivers, since it requires
    careful tradeoffs in adjustment accuracy vs overflow limits.

    Now, with the clocks_calc_mult_shift function, its much
    easier. However, not many clocksources have converted to using that
    function, and there is still the issue of the max interval length
    assumption being made by each clocksource driver independently.

    So this patch simplifies the registration process by having
    clocksources be registered with a hz/khz value and the registration
    function taking care of setting mult/shift.

    This should take most of the confusion out of writing a clocksource
    driver.

    Additionally it also keeps the shift size tradeoff (more accuracy vs
    longer possible nohz times) centralized so the timekeeping core can
    keep track of the assumptions being made.

    [ tglx: Coding style and comments fixed ]

    Signed-off-by: John Stultz
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    John Stultz
     

02 Mar, 2010

2 commits

  • Aaro Koskinen reported an issue in kernel.org bugzilla #15366, where
    on non-GENERIC_TIME systems, accessing
    /sys/devices/system/clocksource/clocksource0/current_clocksource
    results in an oops.

    It seems the timekeeper/clocksource rework missed initializing the
    curr_clocksource value in the !GENERIC_TIME case.

    Thanks to Aaro for reporting and diagnosing the issue as well as
    testing the fix!

    Reported-by: Aaro Koskinen
    Signed-off-by: John Stultz
    Cc: Martin Schwidefsky
    Cc: stable@kernel.org
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    john stultz
     
  • * 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    posix-timers.c: Don't export local functions
    clocksource: start CMT at clocksource resume
    clocksource: add suspend callback
    clocksource: add argument to resume callback
    ntp: Cleanup xtime references in ntp.c
    ntp: Make time_esterror and time_maxerror static

    Linus Torvalds
     

05 Feb, 2010

2 commits

  • Add a clocksource suspend callback. This callback can be used by the
    clocksource driver to shutdown and perform any kind of late suspend
    activities even though the clocksource driver itself is a non-sysdev
    driver.

    One example where this is useful is to fix the sh_cmt.c platform driver
    that today suspends using the platform bus and shuts down the clocksource
    too early.

    With this callback in place the sh_cmt driver will suspend using the
    clocksource and clockevent hooks and leave the platform device pm
    callbacks unused.

    Signed-off-by: Magnus Damm
    Cc: Paul Mundt
    Cc: john stultz
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Magnus Damm
     
  • Pass the clocksource as an argument to the clocksource resume callback.
    Needed so we can point out which CMT channel the sh_cmt.c driver shall
    resume.

    Signed-off-by: Magnus Damm
    Cc: john stultz
    Cc: Paul Mundt
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Magnus Damm