Re: [PATCH vfs 1/2] lib: implement ptrset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Tue, Nov 18, 2014 at 06:56:29PM +0300, Azat Khuzhin wrote:
> On Thu, Nov 13, 2014 at 05:09:27PM -0500, Tejun Heo wrote:
> > +int ptrset_add(void *ptr, struct ptrset *set, gfp_t gfp)
> > +{
> > +	struct ptrset_elem *elem;
> > +	struct rb_node *parent, **slot;
> > +
> > +	elem = kmalloc(sizeof(*elem), gfp);
> > +	if (!elem && !in_interrupt())	/* see ptrset_preload() */
> > +		elem = this_cpu_xchg(ptrset_preload_elem, NULL);
> > +	if (!elem)
> > +		return -ENOMEM;
> > +	elem->ptr = ptr;
> > +
> > +	if (ptrset_find_slot(elem->ptr, set, &slot, &parent)) {
> > +		kfree(elem);
> > +		return -EEXIST;
> > +	}
> 
> Maybe allocation *after* ptrset_find_slot() will be better?
> This will avoid extra kmalloc/kfree if such ptr already exist (and also
> will avoid ENOMEM for such cases).

Sure thing.  Will post an updated version soon.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux