lkml.org 
[lkml]   [2014]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH vfs 1/2] lib: implement ptrset
On Thu, 13 Nov 2014 17:27:36 -0500 Tejun Heo <tj@kernel.org> wrote:

> Hello, Andrew.
>
> On Thu, Nov 13, 2014 at 02:23:33PM -0800, Andrew Morton wrote:
> > This seems rather slow and bloaty. Why not
> >
> > struct tjpointer {
> > struct list_head list;
> > void *pointer;
> > };
> >
> > And then callers do things like
> >
> > struct tjpointer *tjp;
> >
> > lock();
> >
> > for_each_tjpointer(tjp, &my_tjpointer_list) {
> > foo(tjp->ptr);
> > }
> >
> > tjpointer_del(tjp);
> >
> > unlock();
> >
> > That's less storage, vastly less support code, insertion and removal
> > are O(1) and it doesn't need the ghastly preload thing.
>
> The goal is moving the memory necessary for indexing to the indexer
> instead of the indexees. In the above case, the indexee would have to
> either embed tjpointer inside it or at least have a pointer pointing
> at it.

In that case tjpointer_add() would need to do a kmalloc() for each inode
which is added to the bdev/cdev, just as ptrset_add() is doing.

That might require a nasty preload thing. But really, for just two
known callers it would be better to require the caller to create the
storage.


struct tjpointer *new_tpj;

new_tpj = kmalloc(...);
lock();
tjpointer_add(&my_tjp_list, new_tjp, my_pointer);
unlock();

Basically what I'm saying is nuke the rbtree and use lists.


\
 
 \ /
  Last update: 2014-11-14 00:21    [W:0.107 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site