Re: prio_tree generalization

From: Andrea Arcangeli
Date: Sun Jul 04 2004 - 21:08:59 EST


On Sun, Jul 04, 2004 at 10:24:38PM -0300, Werner Almesberger wrote:
> Hi Rajesh,
>
> I'm currently experimenting with the prio_tree code in an elevator
> ("IO scheduler"), and I'm thinking about a way to avoid code
> duplication.

that's a nice effort, I agree prio_tree.c is better suited for lib/ than
mm/ but the code already looks quite generic and well written.

>
> The most straightforward approach seems to be to put everything
> after prio_tree_init and before vma_prio_tree_add into a new file,
> and #include that file. (And prio_tree_init should be shared.)
>
> #including a .c file normally isn't exactly considered an epitome
> of elegance, but in this case, there doesn't seem to be much of a
> choice.

why don't you move the shared code to lib/prio_tree.c instead of
duplicating it in every object?
prio_tree_insert/prio_tree_remove/prio_tree_replace needs to be
exported etc..

> There's another issue: in the elevator, entries overlap only
> rarely if at all, and it is sometimes useful to walk the tree in
> sort order. As far as I can tell, RPSTs can be walked just like
> RB trees if there are no overlaps on the path from the current to
> the respective adjacent node.
>
> Unfortunately, "prio_tree_next" is already taken. It would be nice
> to follow the same naming scheme as RB trees, so perhaps
> prio_tree_next could become prio_tree_more, or such ?

I thought prio_tree_next was already the equivalent of rb_next for
prio-trees. The API is slightly different because you need an iterator
object, but I'm not sure how you want to change it to make it more
symmetric with rb_next.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/