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

Re: [PATCH v3] xen/console: Skip switching serial input to non existing domains


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 20 Mar 2023 13:07:14 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BcJfHW7V7WCx4Bghj5Ua12hi3VvRDijDqJLLw2enHlE=; b=BknAOm16mkaedBkNVqG0dCPQCfKT6KjfKiwuSU/BJv+KBAuSq/19pbjsbgsOCsjhUPxnpyMwi4SK01PwFpOSbOBgVSmaofg59y72d4emH+Z+mA7Li91KwC5uId6AML9cO/grCccwCYjiNxeIdsUOJtCEp15vdH4c4zrsaVkycv3zoG97iObASBrLQYlfRsfybK+ncgtmkoNNMxvxdmy955a1M/7wV01v4RR01QacLWDv+c0PGWCyguckL9VsC5CRqNhL65bC/DGulwm2Nuec4oBexEut11Q2Gch44J4eNfCt6u8OzNOlxSTv/FQKWk8TzleT0ovyARsTcK0qkpTRLA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aKRHfmNwe/ShABzLw4YKDHoWFC4X0lGxdsTmpsJxx3cCratyaal9vTlndRfsw7DYB0Nr5k/8OuZJWZmO7tg5opn2v5z4fShYoKMpxVCIduujgR0AziWxcxrP/6pjVK+2H3XgkBOPYO67NW4M2r0ogSQalT31syBsyG4eH/xBsaPe2UIVPt+y8nWhFJDnaawQn/DbYXlimaAaRS9EvZQXH4ckJ1W9eRQg3HbtyKv7/ozdiElVWj5tMIJD+uPxUnfEdwYzX3iwWU01qQZXRT3uq6bLwXSGbPS0OteJaL3Ota3s0zs8Y6PshKzqSfjN9xu7bA2yPq4ZegPXo2lWErpxLg==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 20 Mar 2023 12:08:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 20/03/2023 12:17, Jan Beulich wrote:
> 
> 
> On 20.03.2023 09:19, Michal Orzel wrote:
>> @@ -483,15 +485,34 @@ struct domain *console_input_domain(void)
>>
>>  static void switch_serial_input(void)
>>  {
>> -    if ( console_rx == max_init_domid + 1 )
>> -    {
>> -        console_rx = 0;
>> -        printk("*** Serial input to Xen");
>> -    }
>> -    else
>> +    unsigned int next_rx = console_rx + 1;
>> +
>> +    /*
>> +     * Rotate among Xen, dom0 and boot-time created domUs while skipping
>> +     * switching serial input to non existing domains.
>> +     */
>> +    while ( next_rx <= max_console_rx + 1 )
>>      {
>> -        console_rx++;
>> -        printk("*** Serial input to DOM%d", console_rx - 1);
>> +        if ( next_rx == max_console_rx + 1 )
> 
> Part of the earlier problems stemmed from the comparison being == here.
> Could I talk you into using >= instead?
With the loop condition unmodified it would not make sense as it would be 
impossible.
However, because of what you wrote below, I will do this together with other 
modifications.

> 
>> +        {
>> +            console_rx = 0;
>> +            printk("*** Serial input to Xen");
>> +            break;
>> +        }
>> +        else
> 
> No need for "else" after "break" (or alike). Omitting it will not only
> decrease indentation, but also make more visible that the earlier if()
> won't "fall through".
> 
ok.

>> +        {
>> +            struct domain *d = rcu_lock_domain_by_id(next_rx - 1);
>> +
>> +            if ( d )
>> +            {
>> +                rcu_unlock_domain(d);
>> +                console_rx = next_rx;
>> +                printk("*** Serial input to DOM%d", console_rx - 1);
> 
> While I expect the compiler will transform this to using "next_rx"
> here anyway, I think it would be nice if it was written like this
> right away.
ok.

> 
> Since you touch the printk() anyway, please also switch to using the
> more applicable %u.
ok.

> 
> With the adjustments
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> One other transformation for you to consider is to switch to a base
> layout like
> 
>     unsigned int next_rx = console_rx;
>     while ( next_rx++ <= max_console_rx )
>     {
>         ...
>     }
> 
> i.e. without a separate increment at the bottom of the loop. Which,
> now that I've spelled it out, raises the question of why the outer
> loop needs a condition in the first place (because as written above
> it clearly is always true). So perhaps better (and more directly
> showing what's going on)
> 
>     unsigned int next_rx = console_rx;
>     for ( ; ; )
>     {
>         if ( next_rx++ >= max_console_rx )
>         ...
>     }
Makes sense to me so I will do this assuming that you agree on adding your Rb 
tag also
for this approach.

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.