Re: [PATCH 10/32] uverbs: Convert idr to XArray

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

 



On Thu, Feb 21, 2019 at 12:12:58PM -0700, Jason Gunthorpe wrote:
> On Thu, Feb 21, 2019 at 11:06:58AM -0800, Matthew Wilcox wrote:
> > On Thu, Feb 21, 2019 at 11:37:02AM -0700, Jason Gunthorpe wrote:
> > > What does the GFP flags == 0 do? I've seen you use this as a marker
> > > for stores that cannot fail?
> > 
> > It's for stores which we know we're just overwriting, so there won't
> > be any need to allocate memory.  But I've started to move away from
> > this idea -- it's a quirk of the current implementation that it won't
> > need to allocate memory, and not even guaranteed true by the current
> > implementation (if you try to store a 2-byte aligned pointer in index 0,
> > it will have to allocate memory).
> > 
> > So I think I'm actually going to replace this 0 with a GFP_KERNEL (I just
> > checked the calling context, and it can absolutely sleep to allocate
> > memory).
> 
> In that case the error code has to be returned here..
> 
> But, IMHO, a major reason to use xa_reserve is to create a situation
> where store can't fail, so it is disappointing to hear that isn't
> possible anymore.

You're right.  This is just a bug, and I've fixed it (see the head of the
xarray tree).

But I still want to pass in GFP_KERNEL here.  For the replacement data
structure I'm working on to replace the radix tree, there will be times
when being able to reallocate nodes will be advantageous.  It'll never
be necessary, so it can't return an error, but it may lead to a more
balanced tree.




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux