Re: [PATCH v2 1/4] ida: Add ida_get_lowest()

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

 



On 2024/4/19 01:12, Jason Gunthorpe wrote:
On Thu, Apr 18, 2024 at 10:23:14AM -0600, Alex Williamson wrote:
yep. maybe we can start with the below code, no need for ida_for_each()
today.


   	int id = 0;

   	while (!ida_is_empty(&pasid_ida)) {
   		id = ida_find_first_range(pasid_ida, id, INT_MAX);

You've actually already justified the _min function here:

static inline int ida_find_first_min(struct ida *ida, unsigned int min)
{
	return ida_find_first_range(ida, min, ~0);
}

It should also always start from 0..

any special reason to always start from 0? Here we want to loop all the
IDs, and remove them. In this usage, it should be more efficient if we
start from the last found ID.

Ideally written more like:

while ((id = ida_find_first(pasid_ida)) != EMPTY_IDA) {
   ida_remove(id);
}

--
Regards,
Yi Liu




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux