All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>, Avi Kivity <avi@redhat.com>,
	Ingo Molnar <mingo@elte.hu>,
	john@jfloren.net, kvm@vger.kernel.org, asias.hejun@gmail.com,
	gorcunov@gmail.com, prasadjoshi124@gmail.com,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Phil Howard <csbetterthanjava@gmail.com>,
	rp@svcs.cs.pdx.edu
Subject: Re: RCU red-black tree (was: Re: [PATCH 4/6] kvm tools: Add rwlock wrapper)
Date: Mon, 30 May 2011 14:57:57 -0400	[thread overview]
Message-ID: <20110530185757.GA13903@Krystal> (raw)
In-Reply-To: <1306777969.15912.3.camel@lappy>

* Sasha Levin (levinsasha928@gmail.com) wrote:
> On Mon, 2011-05-30 at 13:38 -0400, Mathieu Desnoyers wrote:
> > * Sasha Levin (levinsasha928@gmail.com) wrote:
> > > On Sun, 2011-05-29 at 22:54 -0400, Mathieu Desnoyers wrote:
> > > > Please note that what I currently have is a normal rbtree, not an
> > > > interval rbtree. Can you elaborate on your use-case so I can try to
> > > > figure out how we could augment it to support the interval rbtree you
> > > > need ?
> > > 
> > > We don't need anything specific for interval rbtree. The rbtree used in
> > > the kernel provides augmentation functions for insert and erase (see
> > > rb_augment_insert() and rb_augment_erase_begin() +
> > > rb_augment_erase_end()).
> > > What they basically do is call a user-provided callback for each node
> > > from the newly inserted (or deepest after deletion) node up to the root
> > > of the tree. You can see our code at 'tools/kvm/util/rbtree-interval.c',
> > > basically all we need are the 2 augmentation functions I've mentioned
> > > above.
> > 
> > Just a little question about Documentation/rbtree.txt:
> > 
> > I see that find_lowest_match(lo, hi, node) seems to use ">" and "<" to
> > compare the lo value with the max_hi and node->lo. I think it would be
> > more natural to do range comparison functions with inclusive ranges (>=
> > and <=). Or maybe I am missing something about the way find_lowest_match
> > works ?
> 
> It's just an implementation of an interval search() function. Since
> kernel rbtree users implement their own search() and insert() functions
> (look in our util/rbtree-interval.c) it shouldn't be a consideration in
> designing the tree - we (the users of urcu/rbtree) want to control the
> search code anyway.

The reason why I provide this facility as part of the RCU rbtree is
because, unlike the kernel rbtree where every user is free to use
"inheritance" to put their object in the same cache-line as the rbtree
node, the RCU implementation needs to do copies of its inner nodes, so
the rbtree user cannot expect the node pointer to stay valid. Therefore,
I use a more usual scheme where the pointer to the user-provided data
structure is kept as a "void *key" in the node. So basically, the rbtree
user don't have to provide the search, next and prev functions: this is
all done within the rbtree code, especially because these have to be
RCU-aware, and because the code that augments the rbtree with ranges
needs to be RCU-aware too.

Finally, my tests showed up that the "<= and >=" need to have the equal
for the ranges to be inclusive. I tested this by using the same
test-case as the search, duplicating the key value as both lower and
upper bound of the range searched for. (see updated rbtree2 branch for
tested range search).

My stress-test now tests the range lookups, and it passes fine so far:

e.g.   test_urcu_rbtree 6 2 200 -g 40  (on a 8-core machine)

Thanks,

Mathieu

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2011-05-30 18:58 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26 14:25 [PATCH 1/6] kvm tools: Prevent double assignment of guest memory info Sasha Levin
2011-05-26 14:25 ` [PATCH 2/6] kvm tools: Exit VCPU thread only when SIGKVMEXIT is received Sasha Levin
2011-05-26 14:25 ` [PATCH 3/6] kvm tools: Protect IRQ allocations by a mutex Sasha Levin
2011-05-26 14:25 ` [PATCH 4/6] kvm tools: Add rwlock wrapper Sasha Levin
2011-05-26 16:02   ` Pekka Enberg
2011-05-26 16:19     ` Sasha Levin
2011-05-26 18:05       ` Ingo Molnar
2011-05-26 18:11         ` Avi Kivity
2011-05-26 18:21           ` Pekka Enberg
2011-05-26 18:57             ` Sasha Levin
2011-05-26 23:09               ` Mathieu Desnoyers
2011-05-27 10:19                 ` Sasha Levin
2011-05-27 10:36                   ` Ingo Molnar
2011-05-27 15:52                     ` Sasha Levin
2011-05-27 17:10                       ` Ingo Molnar
2011-05-27 20:19                         ` Sasha Levin
2011-05-28 15:24                           ` Ingo Molnar
2011-05-28 16:44                             ` Paul E. McKenney
2011-05-28 19:45                             ` Sasha Levin
2011-05-29  6:47                               ` Avi Kivity
2011-05-29  7:19                                 ` Ingo Molnar
2011-05-29 15:31                                   ` Paul E. McKenney
2011-05-29 15:51                                     ` Paul E. McKenney
2011-05-29 19:54                                       ` Ingo Molnar
2011-05-30  3:12                                         ` Paul E. McKenney
2011-05-29 16:22                                     ` Sasha Levin
2011-05-27 13:14                   ` Mathieu Desnoyers
2011-05-29 17:01                     ` RCU red-black tree (was: Re: [PATCH 4/6] kvm tools: Add rwlock wrapper) Mathieu Desnoyers
2011-05-29 17:48                       ` Sasha Levin
2011-05-30  2:54                         ` Mathieu Desnoyers
2011-05-30  6:07                           ` Sasha Levin
2011-05-30 11:30                             ` Mathieu Desnoyers
2011-05-30 17:38                             ` Mathieu Desnoyers
2011-05-30 17:50                               ` Mathieu Desnoyers
2011-05-30 17:52                               ` Sasha Levin
2011-05-30 18:57                                 ` Mathieu Desnoyers [this message]
2011-05-30 19:11                                   ` Sasha Levin
2011-05-31 13:05                                   ` Sasha Levin
2011-05-31 13:09                                     ` Ingo Molnar
2011-05-31 13:20                                       ` Sasha Levin
2011-05-31 15:25                                         ` Ingo Molnar
2011-05-31 19:09                                           ` Prasad Joshi
2011-05-31 19:31                                             ` Ingo Molnar
2011-06-02 14:55                                     ` Mathieu Desnoyers
2011-05-30  3:38                       ` Paul E. McKenney
2011-05-30 11:18                         ` Mathieu Desnoyers
2011-05-26 20:25             ` [PATCH 4/6] kvm tools: Add rwlock wrapper Ingo Molnar
2011-05-26 23:05               ` Mathieu Desnoyers
2011-05-27  0:58                 ` Paul E. McKenney
2011-05-27  9:12                   ` Ingo Molnar
2011-05-27 12:48                     ` Mathieu Desnoyers
2011-05-27 13:19                       ` Ingo Molnar
2011-05-27 13:29                         ` Mathieu Desnoyers
2011-05-27 13:36                           ` Ingo Molnar
2011-05-27 17:22                     ` Paul E. McKenney
2011-05-27 10:25                 ` Ingo Molnar
2011-05-27 11:07                   ` Ingo Molnar
2011-05-27 11:10                     ` Ingo Molnar
2011-05-27 11:24                       ` Ingo Molnar
2011-05-27 14:18                         ` Mathieu Desnoyers
2011-05-27 14:11                     ` Mathieu Desnoyers
2011-05-28 18:12                     ` Avi Kivity
2011-05-28 18:32                       ` Ingo Molnar
2011-05-29  6:41                         ` Avi Kivity
2011-05-29  7:35                           ` Ingo Molnar
2011-05-29  7:54                             ` Avi Kivity
2011-05-29 12:37                               ` Ingo Molnar
2011-05-29 12:48                                 ` Avi Kivity
2011-05-29 14:27                                   ` Ingo Molnar
2011-05-29 15:00                                     ` Avi Kivity
2011-05-29 15:38                                       ` Paul E. McKenney
2011-05-29 19:33                                         ` Ingo Molnar
2011-05-30  3:07                                           ` Paul E. McKenney
2011-05-30  8:12                                             ` Ingo Molnar
2011-05-27 13:22                   ` Mathieu Desnoyers
2011-05-27 13:31                     ` Ingo Molnar
2011-05-28 18:14                       ` Avi Kivity
2011-05-27 13:07                 ` Ingo Molnar
2011-05-26 14:25 ` [PATCH 5/6] kvm tools: Protect MMIO tree by rwsem Sasha Levin
2011-05-26 14:25 ` [PATCH 6/6] kvm tools: Protect IOPORT " Sasha Levin
2011-05-26 16:01   ` Pekka Enberg
2011-05-26 16:19     ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110530185757.GA13903@Krystal \
    --to=mathieu.desnoyers@efficios.com \
    --cc=asias.hejun@gmail.com \
    --cc=avi@redhat.com \
    --cc=csbetterthanjava@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=john@jfloren.net \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mingo@elte.hu \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    --cc=rp@svcs.cs.pdx.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.