1. 13 9月, 2013 1 次提交
    • W
      seqlock: Add a new locking reader type · 1370e97b
      Waiman Long 提交于
      The sequence lock (seqlock) was originally designed for the cases where
      the readers do not need to block the writers by making the readers retry
      the read operation when the data change.
      
      Since then, the use cases have been expanded to include situations where
      a thread does not need to change the data (effectively a reader) at all
      but have to take the writer lock because it can't tolerate changes to
      the protected structure.  Some examples are the d_path() function and
      the getcwd() syscall in fs/dcache.c where the functions take the writer
      lock on rename_lock even though they don't need to change anything in
      the protected data structure at all.  This is inefficient as a reader is
      now blocking other sequence number reading readers from moving forward
      by pretending to be a writer.
      
      This patch tries to eliminate this inefficiency by introducing a new
      type of locking reader to the seqlock locking mechanism.  This new
      locking reader will try to take an exclusive lock preventing other
      writers and locking readers from going forward.  However, it won't
      affect the progress of the other sequence number reading readers as the
      sequence number won't be changed.
      Signed-off-by: NWaiman Long <Waiman.Long@hp.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1370e97b
  2. 19 2月, 2013 2 次提交
  3. 05 5月, 2012 2 次提交
    • L
      seqlock: add 'raw_seqcount_begin()' function · 4f988f15
      Linus Torvalds 提交于
      The normal read_seqcount_begin() function will wait for any current
      writers to exit their critical region by looping until the sequence
      count is even.
      
      That "wait for sequence count to stabilize" is the right thing to do if
      the read-locker will just retry the whole operation on contention: no
      point in doing a potentially expensive reader sequence if we know at the
      beginning that we'll just end up re-doing it all.
      
      HOWEVER.  Some users don't actually retry the operation, but instead
      will abort and do the operation with proper locking.  So the sequence
      count case may be the optimistic quick case, but in the presense of
      writers you may want to do full locking in order to guarantee forward
      progress.  The prime example of this would be the RCU name lookup.
      
      And in that case, you may well be better off without the "retry early",
      and are in a rush to instead get to the failure handling.  Thus this
      "raw" interface that just returns the sequence number without testing it
      - it just forces the low bit to zero so that read_seqcount_retry() will
      always fail such a "active concurrent writer" scenario.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4f988f15
    • L
      Fix __read_seqcount_begin() to use ACCESS_ONCE for sequence value read · 2f624278
      Linus Torvalds 提交于
      We really need to use a ACCESS_ONCE() on the sequence value read in
      __read_seqcount_begin(), because otherwise the compiler might end up
      reloading the value in between the test and the return of it.  As a
      result, it might end up returning an odd value (which means that a write
      is in progress).
      
      If the reader is then fast enough that that odd value is still the
      current one when the read_seqcount_retry() is done, we might end up with
      a "successful" read sequence, even despite the concurrent write being
      active.
      
      In practice this probably never really happens - there just isn't
      anything else going on around the read of the sequence count, and the
      common case is that we end up having a read barrier immediately
      afterwards.
      
      So the code sequence in which gcc might decide to reaload from memory is
      small, and there's no reason to believe it would ever actually do the
      reload.  But if the compiler ever were to decide to do so, it would be
      incredibly annoying to debug.  Let's just make sure.
      
      Cc: stable@kernel.org
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2f624278
  4. 12 6月, 2011 1 次提交
  5. 24 5月, 2011 1 次提交
  6. 12 5月, 2011 1 次提交
    • M
      seqlock: Don't smp_rmb in seqlock reader spin loop · 5db1256a
      Milton Miller 提交于
      Move the smp_rmb after cpu_relax loop in read_seqlock and add
      ACCESS_ONCE to make sure the test and return are consistent.
      
      A multi-threaded core in the lab didn't like the update
      from 2.6.35 to 2.6.36, to the point it would hang during
      boot when multiple threads were active.  Bisection showed
      af5ab277 (clockevents:
      Remove the per cpu tick skew) as the culprit and it is
      supported with stack traces showing xtime_lock waits including
      tick_do_update_jiffies64 and/or update_vsyscall.
      
      Experimentation showed the combination of cpu_relax and smp_rmb
      was significantly slowing the progress of other threads sharing
      the core, and this patch is effective in avoiding the hang.
      
      A theory is the rmb is affecting the whole core while the
      cpu_relax is causing a resource rebalance flush, together they
      cause an interfernce cadance that is unbroken when the seqlock
      reader has interrupts disabled.
      
      At first I was confused why the refactor in
      3c22cd57 (kernel: optimise
      seqlock) didn't affect this patch application, but after some
      study that affected seqcount not seqlock. The new seqcount was
      not factored back into the seqlock.  I defer that the future.
      
      While the removal of the timer interrupt offset created
      contention for the xtime lock while a cpu does the
      additonal work to update the system clock, the seqlock
      implementation with the tight rmb spin loop goes back much
      further, and is just waiting for the right trigger.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMilton Miller <miltonm@bga.com>
      Cc: <linuxppc-dev@lists.ozlabs.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Nick Piggin <npiggin@kernel.dk>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Anton Blanchard <anton@samba.org>
      Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
      Acked-by: NEric Dumazet <eric.dumazet@gmail.com>
      Link: http://lkml.kernel.org/r/%3Cseqlock-rmb%40mdm.bga.com%3ESigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      5db1256a
  7. 07 1月, 2011 1 次提交
    • N
      kernel: optimise seqlock · 3c22cd57
      Nick Piggin 提交于
      Add branch annotations for seqlock read fastpath, and introduce
      __read_seqcount_begin and __read_seqcount_end functions, that can avoid the
      smp_rmb() if used carefully. These will be used by store-free path walking
      algorithm performance is critical and seqlocks are in use.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      3c22cd57
  8. 25 4月, 2008 1 次提交
    • I
      seqlock: livelock fix · 88a411c0
      Ingo Molnar 提交于
      Thomas Gleixner debugged a particularly ugly seqlock related livelock:
      do not process the seq-read section if we know it beforehand that the
      test at the end of the section will fail ...
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      88a411c0
  9. 28 4月, 2007 1 次提交
  10. 18 2月, 2007 1 次提交
  11. 13 12月, 2006 1 次提交
    • I
      [PATCH] lockdep: fix seqlock_init() · 99a3eb38
      Ingo Molnar 提交于
      seqlock_init() needs to use spin_lock_init() for dynamic locks, so that
      lockdep is notified about the presence of a new lock.
      
      (this is a fallout of the recent networking merge, which started using
      the so-far unused seqlock_init() API.)
      
      This fix solves the following lockdep-internal warning on current -git:
      
       INFO: trying to register non-static key.
       the code is fine but needs lockdep annotation.
       turning off the locking correctness validator.
           __lock_acquire+0x10c/0x9f9
           lock_acquire+0x56/0x72
           _spin_lock+0x35/0x42
           neigh_destroy+0x9d/0x12e
           neigh_periodic_timer+0x10a/0x15c
           run_timer_softirq+0x126/0x18e
           __do_softirq+0x6b/0xe6
           do_softirq+0x64/0xd2
           ksoftirqd+0x82/0x138
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      99a3eb38
  12. 04 7月, 2006 1 次提交
  13. 26 4月, 2006 1 次提交
  14. 11 4月, 2006 1 次提交
  15. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4