1. 29 4月, 2008 1 次提交
    • T
      hrtimer: raise softirq unlocked to avoid circular lock dependency · 0c96c597
      Thomas Gleixner 提交于
      The scheduler hrtimer bits in 2.6.25 introduced a circular lock
      dependency in a rare code path:
      
      =======================================================
      [ INFO: possible circular locking dependency detected ]
      2.6.25-sched-devel.git-x86-latest.git #19
      -------------------------------------------------------
      X/2980 is trying to acquire lock:
       (&rq->rq_lock_key#2){++..}, at: [<ffffffff80230146>] task_rq_lock+0x56/0xa0
      
      but task is already holding lock:
       (&cpu_base->lock){++..}, at: [<ffffffff80257ae1>] lock_hrtimer_base+0x31/0x60
      
      which lock already depends on the new lock.
      
      The scenario which leads to this is:
      
      posix-timer signal is delivered
       -> posix-timer is rearmed
          timer is already expired in hrtimer_enqueue()
           -> softirq is raised
      
      To prevent this we need to move the raise of the softirq out of the
      base->lock protected code path.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: stable@kernel.org
      Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      0c96c597
  2. 28 4月, 2008 1 次提交
    • B
      hrtimer: timeout too long when using HRTIMER_CB_SOFTIRQ · d7b41a24
      Bodo Stroesser 提交于
      When using hrtimer with timer->cb_mode == HRTIMER_CB_SOFTIRQ
      in some cases the clockevent is not programmed.
      This happens, if:
       - a timer is rearmed while it's state is HRTIMER_STATE_CALLBACK
       - hrtimer_reprogram() returns -ETIME, when it is called after
         CALLBACK is finished. This occurs if the new timer->expires
         is in the past when CALLBACK is done.
      In this case, the timer needs to be removed from the tree and put
      onto the pending list again.
      
      The patch is against 2.6.22.5, but AFAICS, it is relevant
      for 2.6.25 also (in run_hrtimer_pending()).
      Signed-off-by: NBodo Stroesser <bstroesser@fujitsu-siemens.com>
      Cc: stable@kernel.org
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      d7b41a24
  3. 21 4月, 2008 2 次提交
  4. 17 4月, 2008 2 次提交
  5. 15 2月, 2008 2 次提交
  6. 10 2月, 2008 2 次提交
    • O
      hrtimer: don't modify restart_block->fn in restart functions · c289b074
      Oleg Nesterov 提交于
      hrtimer_nanosleep_restart() clears/restores restart_block->fn. This is
      pointless and complicates its usage. Note that if sys_restart_syscall()
      doesn't actually happen, we have a bogus "pending" restart->fn anyway,
      this is harmless.
      Signed-off-by: NOleg Nesterov <oleg@tv-sign.ru>
      Cc: Alexey Dobriyan <adobriyan@sw.ru>
      Cc: Pavel Emelyanov <xemul@sw.ru>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Toyo Abe <toyoa@mvista.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      c289b074
    • O
      hrtimer: fix *rmtp handling in hrtimer_nanosleep() · 080344b9
      Oleg Nesterov 提交于
      Spotted by Pavel Emelyanov and Alexey Dobriyan.
      
      hrtimer_nanosleep() sets restart_block->arg1 = rmtp, but this rmtp points to
      the local variable which lives in the caller's stack frame. This means that
      if sys_restart_syscall() actually happens and it is interrupted as well, we
      don't update the user-space variable, but write into the already dead stack
      frame.
      
      Introduced by commit 04c22714
      hrtimer: Rework hrtimer_nanosleep to make sys_compat_nanosleep easier
      
      Change the callers to pass "__user *rmtp" to hrtimer_nanosleep(), and change
      hrtimer_nanosleep() to use copy_to_user() to actually update *rmtp.
      
      Small problem remains. man 2 nanosleep states that *rtmp should be written if
      nanosleep() was interrupted (it says nothing whether it is OK to update *rmtp
      if nanosleep returns 0), but (with or without this patch) we can dirty *rem
      even if nanosleep() returns 0.
      
      NOTE: this patch doesn't change compat_sys_nanosleep(), because it has other
      bugs. Fixed by the next patch.
      Signed-off-by: NOleg Nesterov <oleg@tv-sign.ru>
      Cc: Alexey Dobriyan <adobriyan@sw.ru>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Cc: Pavel Emelyanov <xemul@sw.ru>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Toyo Abe <toyoa@mvista.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      
       include/linux/hrtimer.h |    2 -
       kernel/hrtimer.c        |   51 +++++++++++++++++++++++++-----------------------
       kernel/posix-timers.c   |   14 +------------
       3 files changed, 30 insertions(+), 37 deletions(-)
      080344b9
  7. 06 2月, 2008 1 次提交
    • D
      timerfd: new timerfd API · 4d672e7a
      Davide Libenzi 提交于
      This is the new timerfd API as it is implemented by the following patch:
      
      int timerfd_create(int clockid, int flags);
      int timerfd_settime(int ufd, int flags,
      		    const struct itimerspec *utmr,
      		    struct itimerspec *otmr);
      int timerfd_gettime(int ufd, struct itimerspec *otmr);
      
      The timerfd_create() API creates an un-programmed timerfd fd.  The "clockid"
      parameter can be either CLOCK_MONOTONIC or CLOCK_REALTIME.
      
      The timerfd_settime() API give new settings by the timerfd fd, by optionally
      retrieving the previous expiration time (in case the "otmr" parameter is not
      NULL).
      
      The time value specified in "utmr" is absolute, if the TFD_TIMER_ABSTIME bit
      is set in the "flags" parameter.  Otherwise it's a relative time.
      
      The timerfd_gettime() API returns the next expiration time of the timer, or
      {0, 0} if the timerfd has not been set yet.
      
      Like the previous timerfd API implementation, read(2) and poll(2) are
      supported (with the same interface).  Here's a simple test program I used to
      exercise the new timerfd APIs:
      
      http://www.xmailserver.org/timerfd-test2.c
      
      [akpm@linux-foundation.org: coding-style cleanups]
      [akpm@linux-foundation.org: fix ia64 build]
      [akpm@linux-foundation.org: fix m68k build]
      [akpm@linux-foundation.org: fix mips build]
      [akpm@linux-foundation.org: fix alpha, arm, blackfin, cris, m68k, s390, sparc and sparc64 builds]
      [heiko.carstens@de.ibm.com: fix s390]
      [akpm@linux-foundation.org: fix powerpc build]
      [akpm@linux-foundation.org: fix sparc64 more]
      Signed-off-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk-manpages@gmx.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Davide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk-manpages@gmx.net>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Michael Kerrisk <mtk.manpages@gmail.com>
      Cc: Davide Libenzi <davidel@xmailserver.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4d672e7a
  8. 02 2月, 2008 1 次提交
  9. 26 1月, 2008 3 次提交
  10. 22 1月, 2008 1 次提交
    • R
      hrtimer: fix section mismatch · 0ec160dd
      Randy Dunlap 提交于
      Fix section mismatch in hrtimer.c:
      
      WARNING: vmlinux.o(.text+0x50c61): Section mismatch: reference to .init.text: (between 'hrtimer_cpu_notify' and 'down_read_trylock')
      
      Noticed by Johannes Berg and confirmed by Sam Ravnborg.
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: Linus Torvalds <torvalds@akpm@linux-foundation.org>
      0ec160dd
  11. 08 12月, 2007 1 次提交
    • T
      hrtimers: avoid overflow for large relative timeouts · 62f0f61e
      Thomas Gleixner 提交于
      Relative hrtimers with a large timeout value might end up as negative
      timer values, when the current time is added in hrtimer_start().
      
      This in turn is causing the clockevents_set_next() function to set an
      huge timeout and sleep for quite a long time when we have a clock
      source which is capable of long sleeps like HPET. With PIT this almost
      goes unnoticed as the maximum delta is ~27ms. The non-hrt/nohz code
      sorts this out in the next timer interrupt, so we never noticed that
      problem which has been there since the first day of hrtimers.
      
      This bug became more apparent in 2.6.24 which activates HPET on more
      hardware.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      62f0f61e
  12. 29 10月, 2007 1 次提交
  13. 20 10月, 2007 2 次提交
  14. 19 10月, 2007 1 次提交
  15. 11 10月, 2007 1 次提交
  16. 26 7月, 2007 2 次提交
    • J
      Cache xtime every call to update_wall_time · 17c38b74
      john stultz 提交于
      This avoids xtime lag seen with dynticks, because while 'xtime' itself
      is still not updated often, we keep a 'xtime_cache' variable around that
      contains the approximate real-time that _is_ updated each time we do a
      'update_wall_time()', and is thus never off by more than one tick.
      
      IOW, this restores the original semantics for 'xtime' users, as long as
      you use the proper abstraction functions (ie 'current_kernel_time()' or
      'get_seconds()' depending on whether you want a timespec or just the
      seconds field).
      
      [ Updated Patch.  As penance for my sins I've also yanked another #ifdef
        that was added to avoid the xtime lag w/ hrtimers.  ]
      Signed-off-by: NJohn Stultz <johnstul@us.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      17c38b74
    • J
      Cleanup non-arch xtime uses, use get_seconds() or current_kernel_time(). · 2c6b47de
      john stultz 提交于
      This avoids use of the kernel-internal "xtime" variable directly outside
      of the actual time-related functions.  Instead, use the helper functions
      that we already have available to us.
      
      This doesn't actually change any behaviour, but this will allow us to
      fix the fact that "xtime" isn't updated very often with CONFIG_NO_HZ
      (because much of the realtime information is maintained as separate
      offsets to 'xtime'), which has caused interfaces that use xtime directly
      to get a time that is out of sync with the real-time clock by up to a
      third of a second or so.
      Signed-off-by: NJohn Stultz <johnstul@us.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2c6b47de
  17. 22 7月, 2007 2 次提交
  18. 17 7月, 2007 1 次提交
  19. 10 5月, 2007 1 次提交
    • R
      Add suspend-related notifications for CPU hotplug · 8bb78442
      Rafael J. Wysocki 提交于
      Since nonboot CPUs are now disabled after tasks and devices have been
      frozen and the CPU hotplug infrastructure is used for this purpose, we need
      special CPU hotplug notifications that will help the CPU-hotplug-aware
      subsystems distinguish normal CPU hotplug events from CPU hotplug events
      related to a system-wide suspend or resume operation in progress.  This
      patch introduces such notifications and causes them to be used during
      suspend and resume transitions.  It also changes all of the
      CPU-hotplug-aware subsystems to take these notifications into consideration
      (for now they are handled in the same way as the corresponding "normal"
      ones).
      
      [oleg@tv-sign.ru: cleanups]
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Signed-off-by: NOleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8bb78442
  20. 09 5月, 2007 1 次提交
  21. 28 4月, 2007 1 次提交
  22. 26 4月, 2007 1 次提交
  23. 08 4月, 2007 1 次提交
    • I
      [PATCH] high-res timers: resume fix · 995f054f
      Ingo Molnar 提交于
      Soeren Sonnenburg reported that upon resume he is getting
      this backtrace:
      
       [<c0119637>] smp_apic_timer_interrupt+0x57/0x90
       [<c0142d30>] retrigger_next_event+0x0/0xb0
       [<c0104d30>] apic_timer_interrupt+0x28/0x30
       [<c0142d30>] retrigger_next_event+0x0/0xb0
       [<c0140068>] __kfifo_put+0x8/0x90
       [<c0130fe5>] on_each_cpu+0x35/0x60
       [<c0143538>] clock_was_set+0x18/0x20
       [<c0135cdc>] timekeeping_resume+0x7c/0xa0
       [<c02aabe1>] __sysdev_resume+0x11/0x80
       [<c02ab0c7>] sysdev_resume+0x47/0x80
       [<c02b0b05>] device_power_up+0x5/0x10
      
      it turns out that on resume we mistakenly re-enable interrupts too
      early.  Do the timer retrigger only on the current CPU.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NSoeren Sonnenburg <kernel@nn7.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      995f054f
  24. 29 3月, 2007 1 次提交
  25. 17 3月, 2007 2 次提交
  26. 07 3月, 2007 1 次提交
  27. 05 3月, 2007 1 次提交
    • H
      [PATCH] timer/hrtimer: take per cpu locks in sane order · e81ce1f7
      Heiko Carstens 提交于
      Doing something like this on a two cpu system
      
        # echo 0 > /sys/devices/system/cpu/cpu0/online
        # echo 1 > /sys/devices/system/cpu/cpu0/online
        # echo 0 > /sys/devices/system/cpu/cpu1/online
      
      will give me this:
      
        =======================================================
        [ INFO: possible circular locking dependency detected ]
        2.6.21-rc2-g562aa1d4-dirty #7
        -------------------------------------------------------
        bash/1282 is trying to acquire lock:
         (&cpu_base->lock_key){.+..}, at: [<000000000005f17e>] hrtimer_cpu_notify+0xc6/0x240
      
        but task is already holding lock:
         (&cpu_base->lock_key#2){.+..}, at: [<000000000005f174>] hrtimer_cpu_notify+0xbc/0x240
      
        which lock already depends on the new lock.
      
      This happens because we have the following code in kernel/hrtimer.c:
      
        migrate_hrtimers(int cpu)
        [...]
        old_base = &per_cpu(hrtimer_bases, cpu);
        new_base = &get_cpu_var(hrtimer_bases);
        [...]
        spin_lock(&new_base->lock);
        spin_lock(&old_base->lock);
      
      Which means the spinlocks are taken in an order which depends on which cpu
      gets shut down from which other cpu. Therefore lockdep complains that there
      might be an ABBA deadlock. Since migrate_hrtimers() gets only called on
      cpu hotplug it's safe to assume that it isn't executed concurrently on a
      
      The same problem exists in kernel/timer.c: migrate_timers().
      
      As pointed out by Christian Borntraeger one possible solution to avoid
      the locking order complaints would be to make sure that the locks are
      always taken in the same order. E.g. by taking the lock of the cpu with
      the lower number first.
      
      To achieve this we introduce two new spinlock functions double_spin_lock
      and double_spin_unlock which lock or unlock two locks in a given order.
      
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Cc: John Stultz <johnstul@us.ibm.com>
      Cc: Christian Borntraeger <cborntra@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e81ce1f7
  28. 17 2月, 2007 3 次提交