|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v10 1/3] xen/domain: unify domain ID allocation
On 23.06.2025 20:28, dmkhn@xxxxxxxxx wrote:
> @@ -2433,6 +2443,71 @@ void thaw_domains(void)
> rcu_read_unlock(&domlist_read_lock);
> }
>
> +domid_t domid_alloc(domid_t domid)
> +{
> + static domid_t domid_last;
> +
> + spin_lock(&domid_lock);
> +
> + /* Exact match. */
> + if ( domid < DOMID_FIRST_RESERVED )
> + {
> + if ( __test_and_set_bit(domid, domid_bitmap) )
> + domid = DOMID_INVALID;
> + }
> + /*
> + * Exhaustive search.
> + *
> + * Domain ID#0 is reserved for the first boot domain (e.g. control
> domain)
> + * and excluded from allocation.
> + *
> + * In dom0less build, domains are not dynamically destroyed, so there's
> no
> + * need to do a wraparound of the IDs.
> + */
> +#ifdef CONFIG_DOM0LESS_BOOT
> + else if ( domid_last + 1 >= DOMID_FIRST_RESERVED )
> + {
> + domid = DOMID_INVALID;
> + }
> +#endif
With this, ...
> + else
> + {
> + domid = find_next_zero_bit(domid_bitmap,
> + DOMID_FIRST_RESERVED,
> + domid_last + 1);
> +#ifdef CONFIG_DOM0LESS_BOOT
... was this meant to be #ifndef?
> + if ( domid == DOMID_FIRST_RESERVED )
This needs to be >=.
> + domid = find_next_zero_bit(domid_bitmap,
> + DOMID_FIRST_RESERVED,
> + 1);
> +#endif
> +
> + if ( domid < DOMID_FIRST_RESERVED )
> + {
> + __set_bit(domid, domid_bitmap);
> + domid_last = domid;
> + }
> + else
> + {
> + domid = DOMID_INVALID;
> + }
> + }
> +
> + spin_unlock(&domid_lock);
> +
> + return domid;
> +}
> +
> +void domid_free(domid_t domid)
> +{
> + if ( domid < DOMID_FIRST_RESERVED )
Is this legitimate to happen? IOW doesn't this want to be some kind of
assertion?
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |