mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 20:58:14 -04:00
ion: index client->handles rbtree by buffer
The only remaining users of the client->handles rbtree are iterating through it like a list. Keep the rbtree, but change its index to be the buffer address instead of the handle address, which makes ion_handle_lookup a fast rbtree search. Signed-off-by: Colin Cross <ccross@android.com> [jstultz: modified patch to apply to staging directory] Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
47b404580b
commit
e1cf368234
@@ -388,13 +388,16 @@ static int ion_handle_put(struct ion_handle *handle)
|
||||
static struct ion_handle *ion_handle_lookup(struct ion_client *client,
|
||||
struct ion_buffer *buffer)
|
||||
{
|
||||
struct rb_node *n;
|
||||
struct rb_node *n = client->handles.rb_node;
|
||||
|
||||
for (n = rb_first(&client->handles); n; n = rb_next(n)) {
|
||||
struct ion_handle *handle = rb_entry(n, struct ion_handle,
|
||||
node);
|
||||
if (handle->buffer == buffer)
|
||||
return handle;
|
||||
while (n) {
|
||||
struct ion_handle *entry = rb_entry(n, struct ion_handle, node);
|
||||
if (buffer < entry->buffer)
|
||||
n = n->rb_left;
|
||||
else if (buffer > entry->buffer)
|
||||
n = n->rb_right;
|
||||
else
|
||||
return entry;
|
||||
}
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
@@ -432,9 +435,9 @@ static int ion_handle_add(struct ion_client *client, struct ion_handle *handle)
|
||||
parent = *p;
|
||||
entry = rb_entry(parent, struct ion_handle, node);
|
||||
|
||||
if (handle < entry)
|
||||
if (handle->buffer < entry->buffer)
|
||||
p = &(*p)->rb_left;
|
||||
else if (handle > entry)
|
||||
else if (handle->buffer > entry->buffer)
|
||||
p = &(*p)->rb_right;
|
||||
else
|
||||
WARN(1, "%s: buffer already found.", __func__);
|
||||
|
||||
Reference in New Issue
Block a user