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

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


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 17 Mar 2023 09:36:00 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; 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=oVfivTb6ESZPZFA4yEzEv6+i/Vdza1OGnc4z3izec7g=; b=GN05g5VcI/og18/9uHCx/SVHNyQwF/lfIZogidYtIugU8ZF0hWb++sVYdzrgnstbSOxaq8+wOk90/WRH1zG/YTcHK2ZeTQ9iAB7X1xgb2VJAWLbhsqT8SDpaaMUl+TbLzwClLDgBzaIaeKGh4H/oDh5+nHAzaZWj/EFZIGFVnE9a+gXnaG6+n/w1ks/tUIZ6ySwIUDm098GAHkhx5dwxzePdzCPDBcncgQBOLYjkqJuKlo3ruXCEAebFSYARzrK/LFYSmmiSUbcI7/jmJSLV/BXEMlHdEbsKcSYI4i7Iu3R78NZXgaVGzoKpBs7AUZN/gpElXFZs63P35lBdLVWlyg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MvLDgmJ6Fvr0v1qjkk0yh9Mog3PLgC4vCRH8ffWwrIKjjh08dXicWiUImD9OX74TUXN0vCall5A+f9Dwd88R+aP8pux3lSV9EcXgt15+9TBNIXZ4Zx6YmS41gM0N08jU6mKO352Yv4Ru2z5YBH2WVdY3eucGDtw0CNZ9ibEqeu3QFhvagxZIJ+nLThmQ5NYSHpAko9JwB7VShYQlQHxN+9JeEWG3RvxEZCseZLmD0FMAd23mBnYJQ7yQ4xh49Q/mZw0wb3p7Sn17fxJOwY4gSZRzn1JM3qdUCnhMQoHCF2vNIvq3s2UWqT0YFsLWIuasJevBZXf/tH/nD6KGH8y6Rw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 17 Mar 2023 08:36:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.03.2023 23:59, Stefano Stabellini wrote:
> On Thu, 16 Mar 2023, Jan Beulich wrote:
>> On 16.03.2023 11:26, Michal Orzel wrote:
>>> --- a/xen/drivers/char/console.c
>>> +++ b/xen/drivers/char/console.c
>>> @@ -490,7 +490,24 @@ static void switch_serial_input(void)
>>>      }
>>>      else
>>>      {
>>> -        console_rx++;
>>> +        unsigned int next_rx = console_rx + 1;
>>> +
>>> +        /* Skip switching serial input to non existing domains */
>>> +        while ( next_rx < max_init_domid + 1 )
>>> +        {
>>> +            struct domain *d = rcu_lock_domain_by_id(next_rx - 1);
>>> +
>>> +            if ( d )
>>> +            {
>>> +                rcu_unlock_domain(d);
>>> +                break;
>>> +            }
>>> +
>>> +            next_rx++;
>>> +        }
>>> +
>>> +        console_rx = next_rx;
>>> +
>>>          printk("*** Serial input to DOM%d", console_rx - 1);
>>>      }
>>
>> While at the first glance (when you sent it in reply to v1) it looked okay,
>> I'm afraid it really isn't: Please consider what happens when the last of
>> the DomU-s doesn't exist anymore. (You don't really check whether it still
>> exists, because the range check comes ahead of the existence one.) In that
>> case you want to move from second-to-last to Xen. I expect the entire
>> if/else construct wants to be inside the loop.
> 
> I don't think we need another loop, just a check if we found a domain or

I didn't say "another loop", but I suggested that the loop needs to be
around the if/else. Of course this can be transformed into equivalent
forms, like ...

> not. E.g.:
> 
> 
>     unsigned int next_rx = console_rx + 1;
> 
>     /* Skip switching serial input to non existing domains */
>     while ( next_rx < max_init_domid + 1 )
>     {
>         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);
>             break;
>         }
> 
>         next_rx++;
>     }
> 
>     /* no domain found */
>     console_rx = 0;
>     printk("*** Serial input to Xen");

... what you suggest (or at least almost, because the way it's written
we'd always switch to Xen).

Jan



 


Rackspace

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