public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Generic rb tree code
@ 2012-05-25 20:57 Kent Overstreet
  2012-05-25 20:57 ` [PATCH 1/3] rbtree: Add rb_insert(), rb_search(), etc Kent Overstreet
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Kent Overstreet @ 2012-05-25 20:57 UTC (permalink / raw)
  To: linux-kernel, linux-bcache; +Cc: Kent Overstreet, tj, axboe, paul.gortmaker

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

 block/elevator.c       |   42 ++++++------------
 include/linux/rbtree.h |  110 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/rbtree.c           |   28 ++++++++++++
 lib/timerqueue.c       |   23 ++++------
 4 files changed, 159 insertions(+), 44 deletions(-)

-- 
1.7.9.3.327.g2980b


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-05-31 21:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-25 20:57 [PATCH 0/3] Generic rb tree code Kent Overstreet
2012-05-25 20:57 ` [PATCH 1/3] rbtree: Add rb_insert(), rb_search(), etc Kent Overstreet
2012-05-28 23:35   ` Tejun Heo
2012-05-25 20:57 ` [PATCH 2/3] timerqueue: convert to generic rb tree code Kent Overstreet
2012-05-25 20:57 ` [PATCH 3/3] block: convert elevator " Kent Overstreet
2012-05-28 23:17   ` Tejun Heo
2012-05-29  3:25     ` Kent Overstreet
2012-05-29  5:24       ` Tejun Heo
2012-05-29  6:57         ` Kent Overstreet
2012-05-28 23:22 ` [PATCH 0/3] Generic " Tejun Heo
2012-05-29  3:30   ` Kent Overstreet
2012-05-29  5:28     ` Tejun Heo
2012-05-31 21:03 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox