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


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
     

26 Jan, 2010

1 commit

  • commit 0f8e8ef7 (clocksource: Simplify clocksource watchdog resume
    logic) introduced a potential kgdb dead lock. When the kernel is
    stopped by kgdb inside code which holds watchdog_lock then kgdb dead
    locks in clocksource_resume_watchdog().

    clocksource_resume_watchdog() is called from kbdg via
    clocksource_touch_watchdog() to avoid that the clock source watchdog
    marks TSC unstable after the kernel has been stopped.

    Solve this by replacing spin_lock with a spin_trylock and just return
    in case the lock is held. Not resetting the watchdog might result in
    TSC becoming marked unstable, but that's an acceptable penalty for
    using kgdb.

    The timekeeping is anyway easily screwed up by kgdb when the system
    uses either jiffies or a clock source which wraps in short intervals
    (e.g. pm_timer wraps about every 4.6s), so we really do not have to
    worry about that occasional TSC marked unstable side effect.

    The second caller of clocksource_resume_watchdog() is
    clocksource_resume(). The trylock is safe here as well because the
    system is UP at this point, interrupts are disabled and nothing else
    can hold watchdog_lock().

    Reported-by: Jason Wessel
    LKML-Reference:
    Cc: kgdb-bugreport@lists.sourceforge.net
    Cc: Martin Schwidefsky
    Cc: John Stultz
    Cc: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

10 Dec, 2009

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (42 commits)
    tree-wide: fix misspelling of "definition" in comments
    reiserfs: fix misspelling of "journaled"
    doc: Fix a typo in slub.txt.
    inotify: remove superfluous return code check
    hdlc: spelling fix in find_pvc() comment
    doc: fix regulator docs cut-and-pasteism
    mtd: Fix comment in Kconfig
    doc: Fix IRQ chip docs
    tree-wide: fix assorted typos all over the place
    drivers/ata/libata-sff.c: comment spelling fixes
    fix typos/grammos in Documentation/edac.txt
    sysctl: add missing comments
    fs/debugfs/inode.c: fix comment typos
    sgivwfb: Make use of ARRAY_SIZE.
    sky2: fix sky2_link_down copy/paste comment error
    tree-wide: fix typos "couter" -> "counter"
    tree-wide: fix typos "offest" -> "offset"
    fix kerneldoc for set_irq_msi()
    spidev: fix double "of of" in comment
    comment typo fix: sybsystem -> subsystem
    ...

    Linus Torvalds
     

09 Dec, 2009

1 commit

  • * 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    timers, init: Limit the number of per cpu calibration bootup messages
    posix-cpu-timers: optimize and document timer_create callback
    clockevents: Add missing include to pacify sparse
    x86: vmiclock: Fix printk format
    x86: Fix printk format due to variable type change
    sparc: fix printk for change of variable type
    clocksource/events: Fix fallout of generic code changes
    nohz: Allow 32-bit machines to sleep for more than 2.15 seconds
    nohz: Track last do_timer() cpu
    nohz: Prevent clocksource wrapping during idle
    nohz: Type cast printk argument
    mips: Use generic mult/shift factor calculation for clocks
    clocksource: Provide a generic mult/shift factor calculation
    clockevents: Use u32 for mult and shift factors
    nohz: Introduce arch_needs_cpu
    nohz: Reuse ktime in sub-functions of tick_check_idle.
    time: Remove xtime_cache
    time: Implement logarithmic time accumulation

    Linus Torvalds
     

14 Nov, 2009

3 commits

  • powerpc grew a new warning due to the type change of clockevent->mult.

    The architectures which use parts of the generic time keeping
    infrastructure tripped over my wrong assumption that
    clocksource_register is only used when GENERIC_TIME=y.

    I should have looked and also I should have known better. These
    renitent Gaul villages are racking my nerves. Some serious deprecating
    is due.

    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • 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
     

12 Nov, 2009

1 commit


09 Nov, 2009

1 commit


25 Sep, 2009

1 commit

  • git commit 75c5158f70c065b9 converted the clocksource spinlock to a
    mutex. This causes the following BUG:

    BUG: sleeping function called from invalid context at
    kernel/mutex.c:280 in_atomic(): 0, irqs_disabled(): 1, pid: 2473,
    name: pm-suspend 2 locks held by pm-suspend/2473:
    #0: (&buffer->mutex){......}, at: []
    sysfs_write_file+0x3c/0x137
    #1: (pm_mutex){......}, at: []
    enter_state+0x39/0x130 Pid: 2473, comm: pm-suspend Not tainted 2.6.31
    #1 Call Trace:
    [] ? __debug_show_held_locks+0x22/0x24
    [] __might_sleep+0x107/0x10b
    [] mutex_lock_nested+0x25/0x43
    [] clocksource_resume+0x1c/0x60
    [] timekeeping_resume+0x1e/0x1c8
    [] __sysdev_resume+0x25/0xcf
    [] sysdev_resume+0x6d/0xae
    [] suspend_devices_and_enter+0x12b/0x1af
    [] enter_state+0xdf/0x130
    [] state_store+0xb6/0xd3
    [] kobj_attr_store+0x17/0x19
    [] sysfs_write_file+0xfb/0x137
    [] vfs_write+0xae/0x10b
    [] ? __up_read+0x1a/0x7f
    [] sys_write+0x4a/0x6e
    [] system_call_fastpath+0x16/0x1b

    clocksource_resume is called early in the resume process, there is
    only one cpu, no processes are running and the interrupts are
    disabled. It is therefore possible to resume the clocksources
    without taking the clocksource mutex.

    Reported-by: Xiaotian Feng
    Signed-off-by: Martin Schwidefsky
    Tested-by: Michal Schmidt
    Cc: Xiaotian Feng
    Cc: John Stultz
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Martin Schwidefsky
     

15 Sep, 2009

2 commits


12 Sep, 2009

1 commit

  • The watchdog timer is started after the watchdog clocksource
    and at least one watched clocksource have been registered. The
    clocksource work element watchdog_work is initialized just
    before the clocksource timer is started. This is too late for
    the clocksource_mark_unstable call from native_cpu_up. To fix
    this use a static initializer for watchdog_work.

    This resolves a boot crash reported by multiple people.

    Signed-off-by: Martin Schwidefsky
    Cc: Jens Axboe
    Cc: John Stultz
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Martin Schwidefsky
     

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
     

19 Aug, 2009

2 commits

  • stop_machine from a multithreaded workqueue is not allowed because
    of a circular locking dependency between cpu_down and the workqueue
    execution. Use a kernel thread to do the clocksource downgrade.

    Signed-off-by: Martin Schwidefsky
    Cc: Peter Zijlstra
    Cc: john stultz
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Martin pointed out that commit 6ea41d2529 (clocksource: Call
    clocksource_change_rating() outside of watchdog_lock) has a
    theoretical reference count problem. The calls to
    clocksource_change_rating() are now done outside of the clocksource
    mutex and outside of the watchdog lock. A concurrent
    clocksource_unregister() could remove the clock.

    Split out the code which changes the rating from
    clocksource_change_rating() into __clocksource_change_rating().

    Protect the clocksource_watchdog_work() code sequence with the
    clocksource_mutex() and call __clocksource_change_rating().

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

    Thomas Gleixner
     

15 Aug, 2009

2 commits