On Tue, Jan 15, 2019 at 08:17:37PM +0200, Leon Romanovsky wrote: > On Tue, Jan 15, 2019 at 09:53:13AM -0700, Jason Gunthorpe wrote: > > On Tue, Jan 15, 2019 at 12:56:10PM +0200, Leon Romanovsky wrote: > > > > > - ret = xa_insert(xa, res_to_id(res), res, GFP_KERNEL); > > > > > - WARN_ONCE(ret == -EEXIST, "Tried to add non-unique type %d entry\n", > > > > > - res->type); > > > > > + if (rt[res->type].max) { > > > > > + /* Not HW-capable device */ > > > > > + res->id = rt[res->type].reserved; > > > > > + ret = xa_alloc(xa, &res->id, rt[res->type].max, res, > > > > > + GFP_KERNEL); > > > > > > > > I feel like the SW ids should by allocated cyclicly? > > > > > > It was my initial thought too, but after I saw that most of the drivers > > > are using find_first_bit()/find_first_zero_bit() in various bitmap, > > > I realized that adding complexity for cycling allocation doesn't worth it. > > > > Those drivers didn't contemplate exposing these numbers of net link to > > an agent that isn't part of the create/destroy cycle. > > > > Using cyclic is the best way to avoid various races and confusion for > > the netlink side, and it is straightforward to do. > > No problem, I'll change it and will drop that patch with "user" field. Actually after thinking more, in order to implement this cyclic allocator, I will need to store next index and update it after every xa_alloc call and it means that we will need to add lock to maintain that index. Are you sure that we really need it? Thanks > > > > > Jason
Attachment:
signature.asc
Description: PGP signature