1. 15 Sep, 2009 2 commits
    • Ashwin Chaugule's avatar
      hrtimer: Eliminate needless reprogramming of clock events device · 7403f41f
      Ashwin Chaugule authored
      On NOHZ systems the following timers,
      
      -  tick_nohz_restart_sched_tick (tick_sched_timer)
      -  hrtimer_start (tick_sched_timer)
      
      are reprogramming the clock events device far more often than needed.
      No specific test case was required to observe this effect. This
      occurres because there was no check to see if the currently removed or
      restarted hrtimer was:
      
      1) the one which previously armed the clock events device.
      2) going to be replaced by another timer which has the same expiry time.
      
      Avoid the reprogramming in hrtimer_force_reprogram when the new expiry
      value which is evaluated from the clock bases is equal to
      cpu_base->expires_next. This results in faster application startup
      time by ~4%.
      
      [ tglx: simplified initial solution ]
      Signed-off-by: default avatarAshwin Chaugule <ashwinc@quicinc.com>
      LKML-Reference: <4AA00165.90609@codeaurora.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      7403f41f
    • Thomas Gleixner's avatar
      time: Prevent 32 bit overflow with set_normalized_timespec() · 12e09337
      Thomas Gleixner authored
      set_normalized_timespec() nsec argument is of type long. The recent
      timekeeping changes of ktime_get_ts() feed 
      
      	ts->tv_nsec + tomono.tv_nsec + nsecs
      
      to set_normalized_timespec(). On 32 bit machines that sum can be
      larger than (1 << 31) and therefor result in a negative value which
      screws up the result completely.
      
      Make the nsec argument of set_normalized_timespec() s64 to fix the
      problem at hand. This also prevents similar problems for future users
      of set_normalized_timespec().
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarCarsten Emde <carsten.emde@osadl.org>
      LKML-Reference: <new-submission>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: John Stultz <johnstul@us.ibm.com>
      12e09337
  2. 14 Sep, 2009 2 commits
  3. 11 Sep, 2009 1 commit
    • Martin Schwidefsky's avatar
      clocksource: Resolve cpu hotplug dead lock with TSC unstable, fix crash · f79e0258
      Martin Schwidefsky authored
      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: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Cc: John Stultz <johnstul@us.ibm.com>
      LKML-Reference: <20090911153305.3fe9a361@skybase>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      f79e0258
  4. 30 Aug, 2009 1 commit
  5. 28 Aug, 2009 1 commit
    • Thomas Gleixner's avatar
      clocksource: Resolve cpu hotplug dead lock with TSC unstable · 7285dd7f
      Thomas Gleixner authored
      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: default avatarThomas Gleixner <tglx@linutronix.de>
      LKML-Reference: <new-submission>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: John Stultz <johnstul@us.ibm.com>
      7285dd7f
  6. 26 Aug, 2009 1 commit
  7. 25 Aug, 2009 2 commits
    • Hiroshi Shimamoto's avatar
      timekeeping: Fix invalid getboottime() value · 36d47481
      Hiroshi Shimamoto authored
      Don't use timespec_add_safe() with wall_to_monotonic, because
      wall_to_monotonic has negative values which will cause overflow
      in timespec_add_safe(). That makes btime in /proc/stat invalid.
      Signed-off-by: default avatarHiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: John Stultz <johnstul@us.ibm.com>
      Cc: Daniel Walker <dwalker@fifo99.com>
      LKML-Reference: <4A937FDE.4050506@ct.jp.nec.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      36d47481
    • Paul Mundt's avatar
      timekeeping: Fix up read_persistent_clock() breakage on sh · 0ceb4c3e
      Paul Mundt authored
      The recent commit "timekeeping: Increase granularity of
      read_persistent_clock()" introduced read_persistent_clock()
      rework which inadvertently broke the sh conversion:
      
      	arch/sh/kernel/time.c:45: error: passing argument 1 of 'rtc_sh_get_time' from incompatible pointer type
      	distcc[13470] ERROR: compile arch/sh/kernel/time.c on sprygo/32 failed
      	make[2]: *** [arch/sh/kernel/time.o] Error 1
      
      This trivial fix gets it working again.
      Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      LKML-Reference: <20090824223239.GB20832@linux-sh.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      0ceb4c3e
  8. 23 Aug, 2009 1 commit
  9. 21 Aug, 2009 2 commits
    • john stultz's avatar
      time: Introduce CLOCK_REALTIME_COARSE · da15cfda
      john stultz authored
      After talking with some application writers who want very fast, but not
      fine-grained timestamps, I decided to try to implement new clock_ids
      to clock_gettime(): CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE
      which returns the time at the last tick. This is very fast as we don't
      have to access any hardware (which can be very painful if you're using
      something like the acpi_pm clocksource), and we can even use the vdso
      clock_gettime() method to avoid the syscall. The only trade off is you
      only get low-res tick grained time resolution.
      
      This isn't a new idea, I know Ingo has a patch in the -rt tree that made
      the vsyscall gettimeofday() return coarse grained time when the
      vsyscall64 sysctrl was set to 2. However this affects all applications
      on a system.
      
      With this method, applications can choose the proper speed/granularity
      trade-off for themselves.
      Signed-off-by: default avatarJohn Stultz <johnstul@us.ibm.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: nikolag@ca.ibm.com
      Cc: Darren Hart <dvhltc@us.ibm.com>
      Cc: arjan@infradead.org
      Cc: jonathan@jonmasters.org
      LKML-Reference: <1250734414.6897.5.camel@localhost.localdomain>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      da15cfda
    • Thomas Gleixner's avatar
      x86: Do not unregister PIT clocksource on PIT oneshot setup/shutdown · 8cab02dc
      Thomas Gleixner authored
      This basically reverts commit 1a0c009a (x86: unregister PIT
      clocksource when PIT is disabled) because the problem which was tried
      to address with that patch has been solved by commit 3f68535a
      (clocksource: sanity check sysfs clocksource changes).
      
      The problem addressed by the original patch is that PIT could be
      selected as clocksource after the system switched the PIT off or set
      the PIT into one shot mode which would result in complete timekeeping
      wreckage.
      
      Now with the sysfs sanity check in place PIT cannot be selected again
      when the system is in oneshot mode. The system will not switch to one
      shot mode as long as PIT is installed because PIT is not suitable for
      one shot.
      
      The shutdown case which happens when the lapic timer is installed is
      covered by the fact that init_pit_clocksource() is called after the
      lapic timer take over and then does not install the PIT clocksource
      at all.
      
      We should have done the sanity checks back then, but ...
      
      This also solves the locking problem which was reported vs. the
      clocksource rework.
      
      LKML-Reference: <new-submission>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: john stultz <johnstul@us.ibm.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      8cab02dc
  10. 19 Aug, 2009 2 commits
    • Martin Schwidefsky's avatar
      clocksource: Avoid clocksource watchdog circular locking dependency · 01548f4d
      Martin Schwidefsky authored
      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: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: john stultz <johnstul@us.ibm.com>
      LKML-Reference: <20090818170942.3ab80c91@skybase>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      01548f4d
    • Thomas Gleixner's avatar
      clocksource: Protect the watchdog rating changes with clocksource_mutex · d0981a1b
      Thomas Gleixner authored
      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: <alpine.LFD.2.00.0908171038420.2782@localhost.localdomain>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      d0981a1b
  11. 15 Aug, 2009 16 commits
  12. 14 Aug, 2009 1 commit
  13. 13 Aug, 2009 8 commits