19 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
     

23 Jul, 2011

1 commit

  • * 'x86-vdso-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    x86-64, vdso: Do not allocate memory for the vDSO
    clocksource: Change __ARCH_HAS_CLOCKSOURCE_DATA to a CONFIG option
    x86, vdso: Drop now wrong comment
    Document the vDSO and add a reference parser
    ia64: Replace clocksource.fsys_mmio with generic arch data
    x86-64: Move vread_tsc and vread_hpet into the vDSO
    clocksource: Replace vread with generic arch data
    x86-64: Add --no-undefined to vDSO build
    x86-64: Allow alternative patching in the vDSO
    x86: Make alternative instruction pointers relative
    x86-64: Improve vsyscall emulation CS and RIP handling
    x86-64: Emulate legacy vsyscalls
    x86-64: Fill unused parts of the vsyscall page with 0xcc
    x86-64: Remove vsyscall number 3 (venosys)
    x86-64: Map the HPET NX
    x86-64: Remove kernel.vsyscall64 sysctl
    x86-64: Give vvars their own page
    x86-64: Document some of entry_64.S
    x86-64: Fix alignment of jiffies variable

    Linus Torvalds
     

22 Jul, 2011

1 commit

  • The machinery for __ARCH_HAS_CLOCKSOURCE_DATA assumed a file in
    asm-generic would be the default for architectures without their own
    file in asm/, but that is not how it works.

    Replace it with a Kconfig option instead.

    Link: http://lkml.kernel.org/r/4E288AA6.7090804@zytor.com
    Signed-off-by: H. Peter Anvin
    Cc: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: Tony Luck

    H. Peter Anvin
     

15 Jul, 2011

1 commit

  • Now that clocksource.archdata is available, use it for ia64-specific
    code.

    Cc: Clemens Ladisch
    Cc: linux-ia64@vger.kernel.org
    Cc: Tony Luck
    Cc: Fenghua Yu
    Cc: John Stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andy Lutomirski
    Link: http://lkml.kernel.org/r/d31de0ee0842a0e322fb6441571c2b0adb323fa2.1310563276.git.luto@mit.edu
    Signed-off-by: H. Peter Anvin

    Andy Lutomirski
     

14 Jul, 2011

1 commit

  • The vread field was bloating struct clocksource everywhere except
    x86_64, and I want to change the way this works on x86_64, so let's
    split it out into per-arch data.

    Cc: x86@kernel.org
    Cc: Clemens Ladisch
    Cc: linux-ia64@vger.kernel.org
    Cc: Tony Luck
    Cc: Fenghua Yu
    Cc: John Stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andy Lutomirski
    Link: http://lkml.kernel.org/r/3ae5ec76a168eaaae63f08a2a1060b91aa0b7759.1310563276.git.luto@mit.edu
    Signed-off-by: H. Peter Anvin

    Andy Lutomirski
     

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
     

24 May, 2011

1 commit

  • Add a generic mmio clocksource, covering both 32-bit and 16-bit register
    access sizes, for up or down counters. This can be used to easily
    create clocksources for simple counter-based implementations.

    Cc: Alessandro Rubini
    Cc: Colin Cross
    Cc: Eric Miao
    Cc: Erik Gilling
    Acked-by: "Hans J. Koch"
    Cc: Imre Kaloz
    Cc: Krzysztof Halasa
    Cc: Kukjin Kim
    Cc: Lennert Buytenhek
    Cc: Linus Walleij
    Cc: linux-omap@vger.kernel.org
    Acked-by: Nicolas Pitre
    Cc: Olof Johansson
    Tested-by: Sascha Hauer
    Reviewed-by: Thomas Gleixner
    Tested-by: Tony Lindgren
    Reviewed-by: Viresh Kumar
    Cc: Wan ZongShun
    Signed-off-by: Russell King

    Russell King
     

19 May, 2011

1 commit


14 May, 2011

2 commits


22 Feb, 2011

1 commit


27 Jul, 2010

2 commits

  • To properly handle clocksources that change frequencies
    at the clocksource->enable() point, this patch adds
    a method that will update the clocksource's mult/shift and
    max_idle_ns values.

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

    John Stultz
     
  • update_vsyscall() did not provide the wall_to_monotoinc offset,
    so arch specific implementations tend to reference wall_to_monotonic
    directly. This limits future cleanups in the timekeeping core, so
    this patch fixes the update_vsyscall interface to provide
    wall_to_monotonic, allowing wall_to_monotonic to be made static
    as planned in Documentation/feature-removal-schedule.txt

    Signed-off-by: John Stultz
    Cc: Martin Schwidefsky
    Cc: Anton Blanchard
    Cc: Paul Mackerras
    Cc: Tony Luck
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    John Stultz
     

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
     

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
     

09 Dec, 2009

1 commit


17 Nov, 2009

1 commit

  • Since commit 0a544198 "timekeeping: Move NTP adjusted clock multiplier
    to struct timekeeper" the clock multiplier of vsyscall is updated with
    the unmodified clock multiplier of the clock source and not with the
    NTP adjusted multiplier of the timekeeper.

    This causes user space observerable time warps:
    new CLOCK-warp maximum: 120 nsecs, 00000025c337c537 -> 00000025c337c4bf

    Add a new argument "mult" to update_vsyscall() and hand in the
    timekeeping internal NTP adjusted multiplier.

    Signed-off-by: Lin Ming
    Cc: "Zhang Yanmin"
    Cc: Martin Schwidefsky
    Cc: Benjamin Herrenschmidt
    Cc: Tony Luck
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Lin Ming
     

14 Nov, 2009

2 commits

  • The dynamic tick allows the kernel to sleep for periods longer than a
    single tick, but it does not limit the sleep time currently. In the
    worst case the kernel could sleep longer than the wrap around time of
    the time keeping clock source which would result in losing track of
    time.

    Prevent this by limiting it to the safe maximum sleep time of the
    current time keeping clock source. The value is calculated when the
    clock source is registered.

    [ tglx: simplified the code a bit and massaged the commit msg ]

    Signed-off-by: Jon Hunter
    Cc: John Stultz
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Jon Hunter
     
  • MIPS has two functions to calculcate the mult/shift factors for clock
    sources and clock events at run time. ARM needs such functions as
    well.

    Implement a function which calculates the mult/shift factors based on
    the frequencies to which and from which is converted. The function
    also has a parameter to specify the minimum conversion range in
    seconds. This range is guaranteed not to produce a 64bit overflow when
    a value is multiplied with the calculated mult factor. The larger the
    conversion range the less becomes the conversion accuracy.

    Provide two inline wrappers which handle clock events and clock
    sources. For clock events the "from" frequency is nano seconds per
    second which corresponds to 1GHz and "to" is the device frequency. For
    clock sources "from" is the device frequency and "to" is nano seconds
    per second.

    Signed-off-by: Thomas Gleixner
    Tested-by: Mikael Pettersson
    Acked-by: Ralf Baechle
    Acked-by: Linus Walleij
    Cc: John Stultz
    LKML-Reference:

    Thomas Gleixner
     

29 Aug, 2009

1 commit

  • Martin Schwidefsky analyzed it:
    To register a clocksource the clocksource_mutex is acquired and if
    necessary timekeeping_notify is called to install the clocksource as
    the timekeeper clock. timekeeping_notify uses stop_machine which needs
    to take cpu_add_remove_lock mutex.
    Starting a new cpu is done with the cpu_add_remove_lock mutex held.
    native_cpu_up checks the tsc of the new cpu and if the tsc is no good
    clocksource_change_rating is called. Which needs the clocksource_mutex
    and the deadlock is complete.

    The solution is to replace the TSC via the clocksource watchdog
    mechanism. Mark the TSC as unstable and schedule the watchdog work so
    it gets removed in the watchdog thread context.

    Signed-off-by: Thomas Gleixner
    LKML-Reference:
    Cc: Martin Schwidefsky
    Cc: John Stultz

    Thomas Gleixner
     

15 Aug, 2009

6 commits

  • update_wall_time calls change_clocksource HZ times per second to check
    if a new clock source is available. In close to 100% of all calls
    there is no new clock. Replace the tick based check by an update done
    with stop_machine.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • The clocksource structure has two multipliers, the unmodified multiplier
    clock->mult_orig and the NTP corrected multiplier clock->mult. The NTP
    multiplier is misplaced in the struct clocksource, this is private
    information of the timekeeping code. Add the mult field to the struct
    timekeeper to contain the NTP corrected value, keep the unmodifed
    multiplier in clock->mult and remove clock->mult_orig.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Add struct timekeeper to keep the internal values timekeeping.c needs
    in regard to the currently selected clock source. This moves the
    timekeeping intervals, xtime_nsec and the ntp error value from struct
    clocksource to struct timekeeper. The raw_time is removed from the
    clocksource as well. It gets treated like xtime as a global variable.
    Eventually xtime raw_time should be moved to struct timekeeper.

    [ tglx: minor cleanup ]

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Move the downgrade of an unstable clocksource from the timer interrupt
    context into the process context of a work queue thread. This is
    needed to be able to do the clocksource switch with stop_machine.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • If a non high-resolution clocksource is first set as override clock
    and then registered it becomes active even if the system is in one-shot
    mode. Move the override check from sysfs_override_clocksource to the
    clocksource selection. That fixes the bug and simplifies the code. The
    check in clocksource_register for double registration of the same
    clocksource is removed without replacement.

    To find the initial clocksource a new weak function in jiffies.c is
    defined that returns the jiffies clocksource. The architecture code
    can then override the weak function with a more suitable clocksource,
    e.g. the TOD clock on s390.

    [ tglx: Folded in a fix from John Stultz ]

    Signed-off-by: Martin Schwidefsky
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • The three inline functions clocksource_read, clocksource_enable and
    clocksource_disable are simple wrappers of an indirect call plus the
    copy from and to the mult_orig value. The functions are exclusively
    used by the timekeeping code which has intimate knowledge of the
    clocksource anyway. Therefore remove the inline functions. No
    functional change.

    Signed-off-by: Martin Schwidefsky
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     

31 Jul, 2009

1 commit

  • To fix the common case where ->enable() does not set up
    mult, make sure mult_orig is saved in mult on disable.

    Also add comments to explain why we do this.

    Signed-off-by: Magnus Damm
    Cc: johnstul@us.ibm.com
    Cc: lethal@linux-sh.org
    Cc: akpm@linux-foundation.org
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Magnus Damm
     

02 May, 2009

1 commit

  • Setup clocksource mult_orig in clocksource_enable().

    Clocksource drivers can save power by using keeping the
    device clock disabled while the clocksource is unused.

    In practice this means that the enable() and disable()
    callbacks perform clk_enable() and clk_disable().

    The enable() callback may also use clk_get_rate() to get
    the clock rate from the clock framework. This information
    can then be used to calculate the shift and mult variables.

    Currently the mult_orig variable is setup from mult at
    registration time only. This is conflicting with the above
    case since the clock is disabled and the mult variable is
    not yet calculated at the time of registration.

    Moving the mult_orig setup code to clocksource_enable()
    allows us to both handle the common case with no enable()
    callback and the mult-changed-after-enable() case.

    [ Impact: allow dynamic clock source usage ]

    Signed-off-by: Magnus Damm
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Magnus Damm
     

22 Apr, 2009

2 commits

  • Add enable() and disable() callbacks for clocksources.

    This allows us to put unused clocksources in power save mode. The
    functions clocksource_enable() and clocksource_disable() wrap the
    callbacks and are inserted in the timekeeping code to enable before use
    and disable after switching to a new clocksource.

    Signed-off-by: Magnus Damm
    Acked-by: John Stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Magnus Damm
     
  • Pass clocksource pointer to the read() callback for clocksources. This
    allows us to share the callback between multiple instances.

    [hugh@veritas.com: fix powerpc build of clocksource pass clocksource mods]
    [akpm@linux-foundation.org: cleanup]
    Signed-off-by: Magnus Damm
    Acked-by: John Stultz
    Cc: Thomas Gleixner
    Signed-off-by: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Magnus Damm
     

16 Feb, 2009

1 commit

  • So far struct clocksource acted as the interface between time/timekeeping.c
    and hardware. This patch generalizes the concept so that a similar
    interface can also be used in other contexts. For that it introduces
    new structures and related functions *without* touching the existing
    struct clocksource.

    The reasons for adding these new structures to clocksource.[ch] are
    * the APIs are clearly related
    * struct clocksource could be cleaned up to use the new structs
    * avoids proliferation of files with similar names (timesource.h?
    timecounter.h?)

    As outlined in the discussion with John Stultz, this patch adds
    * struct cyclecounter: stateless API to hardware which counts clock cycles
    * struct timecounter: stateful utility code built on a cyclecounter which
    provides a nanosecond counter
    * only the function to read the nanosecond counter; deltas are used internally
    and not exposed to users of timecounter

    The code does no locking of the shared state. It must be called at least
    as often as the cycle counter wraps around to detect these wrap arounds.
    Both is the responsibility of the timecounter user.

    Acked-by: John Stultz
    Signed-off-by: Patrick Ohly
    Signed-off-by: David S. Miller

    Patrick Ohly
     

21 Aug, 2008

2 commits

  • In talking with Josip Loncaric, and his work on clock synchronization (see
    btime.sf.net), he mentioned that for really close synchronization, it is
    useful to have access to "hardware time", that is a notion of time that is
    not in any way adjusted by the clock slewing done to keep close time sync.

    Part of the issue is if we are using the kernel's ntp adjusted
    representation of time in order to measure how we should correct time, we
    can run into what Paul McKenney aptly described as "Painting a road using
    the lines we're painting as the guide".

    I had been thinking of a similar problem, and was trying to come up with a
    way to give users access to a purely hardware based time representation
    that avoided users having to know the underlying frequency and mask values
    needed to deal with the wide variety of possible underlying hardware
    counters.

    My solution is to introduce CLOCK_MONOTONIC_RAW. This exposes a
    nanosecond based time value, that increments starting at bootup and has no
    frequency adjustments made to it what so ever.

    The time is accessed from userspace via the posix_clock_gettime() syscall,
    passing CLOCK_MONOTONIC_RAW as the clock_id.

    Signed-off-by: John Stultz
    Signed-off-by: Roman Zippel
    Signed-off-by: Andrew Morton
    Signed-off-by: Ingo Molnar

    John Stultz
     
  • The clocksource frequency is represented by
    clocksource->mult/2^(clocksource->shift). Currently, when NTP makes
    adjustments to the clock frequency, they are made directly to the mult
    value.

    This has the drawback that once changed, we cannot know what the orignal
    mult value was, or how much adjustment has been applied.

    This property causes problems in calculating proper ntp intervals when
    switching back and forth between clocksources.

    This patch separates the current mult value into a mult and mult_orig
    pair. The mult_orig value stays constant, while the ntp clocksource
    adjustments are done only to the mult value.

    This allows for correct ntp interval calculation and additionally lays the
    groundwork for a new notion of time, what I'm calling the monotonic-raw
    time, which is introduced in a following patch.

    Signed-off-by: John Stultz
    Signed-off-by: Roman Zippel
    Signed-off-by: Andrew Morton
    Signed-off-by: Ingo Molnar

    John Stultz
     

01 May, 2008

1 commit

  • Remove the leap second handling from second_overflow(), which doesn't have to
    check for it every second anymore. With CONFIG_NO_HZ this also makes sure the
    leap second is handled close to the full second. Additionally this makes it
    possible to abort a leap second properly by resetting the STA_INS/STA_DEL
    status bits.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     

18 Apr, 2008

1 commit


30 Jan, 2008

2 commits


19 Oct, 2007

1 commit

  • On platforms that copy sys_tz into the vdso (currently only x86_64, soon to
    include powerpc), it is possible for the vdso to get out of sync if a user
    calls (admittedly unusual) settimeofday(NULL, ptr).

    This patch adds a hook for architectures that set
    CONFIG_GENERIC_TIME_VSYSCALL to ensure when sys_tz is updated they can also
    updatee their copy in the vdso.

    Signed-off-by: Tony Breeds
    Cc: Andi Kleen
    Cc: Tony Luck
    Acked-by: John Stultz
    Cc: Paul Mackerras
    Cc: Benjamin Herrenschmidt
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tony Breeds