[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANN689EUC26UjmGSAhsmZD5iPjmzTPPgGsZ9ZyPfy0RHFBp06g@mail.gmail.com>
Date: Fri, 22 Jun 2012 00:06:00 -0700
From: Michel Lespinasse <walken@...gle.com>
To: John Stultz <john.stultz@...aro.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Android Kernel Team <kernel-team@...roid.com>,
Robert Love <rlove@...gle.com>, Mel Gorman <mel@....ul.ie>,
Hugh Dickins <hughd@...gle.com>,
Dave Hansen <dave@...ux.vnet.ibm.com>,
Rik van Riel <riel@...hat.com>,
Dmitry Adamushko <dmitry.adamushko@...il.com>,
Dave Chinner <david@...morbit.com>, Neil Brown <neilb@...e.de>,
Andrea Righi <andrea@...terlinux.com>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>,
Taras Glek <tgek@...illa.com>, Mike Hommey <mh@...ndium.org>,
Jan Kara <jack@...e.cz>,
KOSAKI Motohiro <kosaki.motohiro@...il.com>
Subject: Re: [PATCH 1/6] [RFC] Interval tree implementation
On Tue, Jun 12, 2012 at 6:10 PM, John Stultz <john.stultz@...aro.org> wrote:
> After Andrew suggested something like his mumbletree idea
> to better store a list of intervals, I worked on a few different
> approaches, and this is what I've finally managed to get working.
>
> The idea of storing intervals in a tree is nice, but has a number
> of complications. When adding an interval, its possible that a
> large interval will consume and merge a number of smaller intervals.
> When removing a interval, its possible you may end up splitting an
> existing interval, causing one interval to become two. This makes it
> very difficult to provide generic list_head like behavior, as
> the parent structures would need to be duplicated and removed,
> and that has lots of memory ownership issues.
>
> So, this is a much simplified and more list_head like
> implementation. You can add a node to a tree, or remove a node
> to a tree, but the generic implementation doesn't do the
> merging or splitting for you. But it does provide helpers to
> find overlapping and adjacent intervals.
>
> Andrew also really wanted this interval-tree implementation to be
> resuable so we don't duplicate the file locking logic. I'm not
> totally convinced that the requirements between the volatile
> intervals and file locking are really equivelent, but this reduced
> impelementation may make it possible.
Well, we already have several implementations of interval trees:
* lib/prio_tree.c seems to do what you want. It's often used with
VMAs, but there is also a 'raw' node structure, as used in
mm/kmemleak.c, which supports all the operations you are proposing.
* lib/rb_tree.c has some support for the "augmented tree" structure,
with which you can implement interval trees as is done in
arch/x86/mm/pat_rbtree.c
I don't think it makes sense to have two implementations already, and
I am looking into possibly collapsing these into one. Please don't add
a third one :)
Also, the name "interval tree" typically implies a data structure that
is capable of representing overlapping intervals. Since your
implementation does not support that (it requires its callers to make
sure the intervals are non-overlapping), I think calling it "interval
tree" could cause confusion.
--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists