Thread (13 messages) 13 messages, 3 authors, 2012-05-31

Re: [PATCH 0/3] Generic rb tree code

From: Jan Kara <hidden>
Date: 2012-05-31 21:03:40
Also in: lkml

On Fri 25-05-12 13:57:38, Kent Overstreet wrote:
Right now, users of the rb tree code have to open code their own search and
insert functions. This provides generic versions that you pass a comparison
function to.

I highly doubt the extra function calls are going to have a measurable
performance impact in practice - the pointer chasing is going to dominate. I
did provide inline versions just in case, though - it's modelled after the
spinlock code.

The inline version of rb_search() is important for another reason, though - you
have to pass rb_search a pointer to your struct for it to compare against,
which has to be allocated on the stack. For most users I think that'll be fine,
but for the elevator code struct rb_node is embedded in struct request, which
is rather large. By using the inline version that stack allocation goes away.

(I looked at the generated assembly of elv_rb_find() before and after, and if
I'm reading it right it's not using any extra stack. Code is a bit worse, but
IMO removing code duplication is worth it).

Kent Overstreet (3):
  rbtree: Add rb_insert(), rb_search(), etc.
  timerqueue: convert to generic rb tree code
  block: convert elevator to generic rb tree code
  Hum, are you aware of another generic rb-tree attempt -
 https://lkml.org/lkml/2012/4/30/132 ?

								Honza
-- 
Jan Kara [off-list ref]
SUSE Labs, CR
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help