1. 28 5月, 2015 1 次提交
    • P
      rbtree: Make lockless searches non-fatal · d72da4a4
      Peter Zijlstra 提交于
      Change the insert and erase code such that lockless searches are
      non-fatal.
      
      In and of itself an rbtree cannot be correctly searched while
      in-modification, we can however provide weaker guarantees that will
      allow the rbtree to be used in conjunction with other techniques, such
      as latches; see 9b0fd802 ("seqcount: Add raw_write_seqcount_latch()").
      
      For this to work we need the following guarantees from the rbtree
      code:
      
       1) a lockless reader must not see partial stores, this would allow it
          to observe nodes that are invalid memory.
      
       2) there must not be (temporary) loops in the tree structure in the
          modifier's program order, this would cause a lookup which
          interrupts the modifier to get stuck indefinitely.
      
      For 1) we must use WRITE_ONCE() for all updates to the tree structure;
      in particular this patch only does rb_{left,right} as those are the
      only element required for simple searches.
      
      It generates slightly worse code, probably because volatile. But in
      pointer chasing heavy code a few instructions more should not matter.
      
      For 2) I have carefully audited the code and drawn every intermediate
      link state and not found a loop.
      
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: David Woodhouse <David.Woodhouse@intel.com>
      Cc: Rik van Riel <riel@redhat.com>
      Reviewed-by: NMichel Lespinasse <walken@google.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      d72da4a4
  2. 09 8月, 2014 1 次提交
  3. 12 9月, 2013 1 次提交
    • C
      rbtree: add postorder iteration functions · 9dee5c51
      Cody P Schafer 提交于
      Postorder iteration yields all of a node's children prior to yielding the
      node itself, and this particular implementation also avoids examining the
      leaf links in a node after that node has been yielded.
      
      In what I expect will be its most common usage, postorder iteration allows
      the deletion of every node in an rbtree without modifying the rbtree nodes
      (no _requirement_ that they be nulled) while avoiding referencing child
      nodes after they have been "deleted" (most commonly, freed).
      
      I have only updated zswap to use this functionality at this point, but
      numerous bits of code (most notably in the filesystem drivers) use a hand
      rolled postorder iteration that NULLs child links as it traverses the
      tree.  Each of those instances could be replaced with this common
      implementation.
      
      1 & 2 add rbtree postorder iteration functions.
      3 adds testing of the iteration to the rbtree runtime tests
      4 allows building the rbtree runtime tests as builtins
      5 updates zswap.
      
      This patch:
      
      Add postorder iteration functions for rbtree.  These are useful for safely
      freeing an entire rbtree without modifying the tree at all.
      Signed-off-by: NCody P Schafer <cody@linux.vnet.ibm.com>
      Reviewed-by: NSeth Jennings <sjenning@linux.vnet.ibm.com>
      Cc: David Woodhouse <David.Woodhouse@intel.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Michel Lespinasse <walken@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9dee5c51
  4. 12 1月, 2013 1 次提交
  5. 09 10月, 2012 17 次提交
  6. 08 3月, 2012 1 次提交
  7. 28 1月, 2011 1 次提交
  8. 05 7月, 2010 1 次提交
    • P
      rbtree: Undo augmented trees performance damage and regression · b945d6b2
      Peter Zijlstra 提交于
      Reimplement augmented RB-trees without sprinkling extra branches
      all over the RB-tree code (which lives in the scheduler hot path).
      
      This approach is 'borrowed' from Fabio's BFQ implementation and
      relies on traversing the rebalance path after the RB-tree-op to
      correct the heap property for insertion/removal and make up for
      the damage done by the tree rotations.
      
      For insertion the rebalance path is trivially that from the new
      node upwards to the root, for removal it is that from the deepest
      node in the path from the to be removed node that will still
      be around after the removal.
      
      [ This patch also fixes a video driver regression reported by
        Ali Gholami Rudi - the memtype->subtree_max_end was updated
        incorrectly. ]
      Acked-by: NSuresh Siddha <suresh.b.siddha@intel.com>
      Acked-by: NVenkatesh Pallipadi <venki@google.com>
      Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Tested-by: NAli Gholami Rudi <ali@rudi.ir>
      Cc: Fabio Checconi <fabio@gandalf.sssup.it>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      LKML-Reference: <1275414172.27810.27961.camel@twins>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b945d6b2
  9. 19 2月, 2010 1 次提交
  10. 17 6月, 2009 3 次提交
  11. 01 4月, 2009 1 次提交
  12. 10 1月, 2009 1 次提交
  13. 01 10月, 2006 1 次提交
  14. 06 6月, 2006 1 次提交
  15. 21 4月, 2006 2 次提交
    • D
      [RBTREE] Merge colour and parent fields of struct rb_node. · 55a98102
      David Woodhouse 提交于
      We only used a single bit for colour information, so having a whole
      machine word of space allocated for it was a bit wasteful. Instead,
      store it in the lowest bit of the 'parent' pointer, since that was
      always going to be aligned anyway.
      Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
      55a98102
    • D
      [RBTREE] Remove dead code in rb_erase() · 1975e593
      David Woodhouse 提交于
      Observe rb_erase(), when the victim node 'old' has two children so
      neither of the simple cases at the beginning are taken.
      
      Observe that it effectively does an 'rb_next()' operation to find the
      next (by value) node in the tree. That is; we go to the victim's
      right-hand child and then follow left-hand pointers all the way
      down the tree as far as we can until we find the next node 'node'. We
      end up with 'node' being either the same immediate right-hand child of
      'old', or one of its descendants on the far left-hand side.
      
      For a start, we _know_ that 'node' has a parent. We can drop that check.
      
      We also know that if 'node's parent is 'old', then 'node' is the
      right-hand child of its parent. And that if 'node's parent is _not_
      'old', then 'node' is the left-hand child of its parent.
      
      So instead of checking for 'node->rb_parent == old' in one place and
      also checking 'node's heritage separately when we're trying to change
      its link from its parent, we can shuffle things around a bit and do
      it like this...
      Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
      1975e593
  16. 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