On Thu, Sep 12, 2024 at 06:17:26AM -0700, Yi Liu wrote: > There is no helpers for user to check if a given ID is allocated or not, > neither a helper to loop all the allocated IDs in an IDA and do something > for cleanup. With the two needs, a helper to get the lowest allocated ID > of a range and two variants based on it. > > Caller can check if a given ID is allocated or not by: > > bool ida_exists(struct ida *ida, unsigned int id) > > Caller can iterate all allocated IDs by: > > int id; > while ((id = ida_find_first(&pasid_ida)) > 0) { > //anything to do with the allocated ID > ida_free(pasid_ida, pasid); > } > > Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> > Suggested-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > Signed-off-by: Yi Liu <yi.l.liu@xxxxxxxxx> > --- > include/linux/idr.h | 11 ++++++++ > lib/idr.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 78 insertions(+) No test cases for the test suite? ;-(