On 01.04.2025 01:05, dm...@proton.me wrote:
> From: Denis Mukhin <dmuk...@ford.com>
> 
> Introduce domid_top() in architecture-independent location to retrieve
> the highest non-system domain ID for use in console input switch logic.
> 
> Replace max_init_domid with domid_top(), which obsoletes max_init_domid
> in the code base.
> 
> Signed-off-by: Denis Mukhin <dmuk...@ford.com>
> ---
> Changes since v1:
> - promote domid_top to a function which walks through the list of domains
>   to identify the highest non-system domain ID which should be considered
>   for console input rotation
> - elimitate use of max_init_domid

I still don't get how this is functionally identical to what we had so far.
In principle imo this change should come with a "No functional change"
statement. Provided of course that's true in the first place.

> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -111,6 +111,29 @@ int domid_alloc(int hint)
>      return domid;
>  }
>  
> +/*
> + * Retrieve the highest known non-system domain ID.
> + */
> +domid_t domid_top(void)
> +{
> +    struct domain *d;

const?

> +    domid_t i = 0;

i is a pretty generic name for something of type domid_t.

> +
> +    spin_lock(&domlist_update_lock);
> +
> +    for ( d = domain_list;
> +          d && (d->domain_id < DOMID_FIRST_RESERVED);

May I ask which domains with ID >= DOMID_FIRST_RESERVED end up in this
list?

> +          d = d->next_in_list )
> +    {
> +        if ( i < d->domain_id )
> +            i = d->domain_id;

See the comment in domlist_insert() as to sorting of that list.

> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -472,7 +472,7 @@ static void cf_check dump_console_ring_key(unsigned char 
> key)
>   */
>  static unsigned int __read_mostly console_rx = 0;
>  
> -#define max_console_rx (max_init_domid + 1)
> +#define max_console_rx (domid_top() + 1)

This is becoming quite a bit more expensive now, without it becoming clear
whether it's really worth paying that price.

Jan

Reply via email to