xarray reserve/release?

From: Jason Gunthorpe
Date: Tue Feb 19 2019 - 18:53:56 EST


Hey Matt,

Did you intend that xa_release doesn't work on allocating arrays:

xa_init_flags(&xa, XA_FLAGS_ALLOC);
xa_reserve(&xa, 0, GFP_KERNEL);
WARN_ON(xa_empty(&xa));
xa_release(&xa, 0);
WARN_ON(!xa_empty(&xa));

Triggers the second WARN_ON.

If FLAGS_ALLOC is removed this passes

This creates kind of a confusing / super unexpected situation where

xa_for_each (xa, id)
xa_erase(xa, id);
WARN_ON(!xa_empty(&xa))

Is not safe with XA_FLAGS_ALLOC??

Seems like at least deserves a documentation note.. Or maybe ALLOC
xa_empty should do something different?

Thanks,
Jason