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

Re: [XEN PATCH v11 4/8] x86/physdev: Return pirq that irq was already mapped to


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Mon, 8 Jul 2024 02:17:25 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.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=4G2kJG1ubey1prHGg9S3gq7Kbltp9rBYFy6FIa7H78I=; b=fFwX6LYV3yg9LdqpdVo7IWKR9aXr2dp1F1XvdmwDRhKJ/HH4EE9NQE9LuX6g87svHxFjPSgpIKbfxNVa6n880nWMR3C1aDMHggeWWPpo9YHRVR87MScrmmeQmVTimlu7ILbdiKx788KT0ftxmsw7zi+6bttJ1Em7IqJmdUFQJrLjivC+AEeZx0zpmmQJ9uOXxvXdvsxcqF6sMjVd9TActxMwyknjZeb3UuQyDS5XhvVLojhOwbPvz65UsNR04ccDkloqlSVH04l0yvpRaE2Pn841ZWcvJM/Th8volSa/os8uIVgku/ILGuLotENjeZPhs0gVskpqI5PFHDrJMcVLAA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jXxx0m7RQziMm9UXW42/3e7WWwOUs0+TD3rZY1vDD4Q0tLDkBvCY4Ng8f7BChN1pu+9lujqgVDTP3lH7v5xVP1mzjLk/M3Z8E/5gonSxxUHLfVu9epQpCFc16eht+xXat9QZgj9jRhccO1IRb0kSDSZl74O/rYqXNPnJ1leBOTgBskQV2Mcd0TCLkTYYQIKeT5bnpyz4pZ+WZc5G4OZo+wFdkWJ4PPoK88Y2V3ZbwM9UjUO3VM7ee5eTTXK/pFHEJXTNiCRmfyE3VOdAB0bKAXWWjL/lwzqnLUdDhIwEfj405RkRxZue1FPavgh0gncsmOOvy0Cb0Cr21e0cJaUizA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "Daniel P . Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, "Hildebrand, Stewart" <Stewart.Hildebrand@xxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Mon, 08 Jul 2024 02:17:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHayunUrYgDYrs6yUuu722r8ryT1LHmiusAgAYeu4A=
  • Thread-topic: [XEN PATCH v11 4/8] x86/physdev: Return pirq that irq was already mapped to

On 2024/7/4 20:47, Jan Beulich wrote:
> On 30.06.2024 14:33, Jiqian Chen wrote:
>> allocate_pirq is to allocate a pirq for a irq, and it supports to
>> allocate a free pirq(pirq parameter is <0) or a specific pirq (pirq
>> parameter is > 0).
>>
>> For current code, it has four usecases.
>>
>> First, pirq>0 and current_pirq>0, (current_pirq means if irq already
>> has a mapped pirq), if pirq==current_pirq means the irq already has
>> mapped to the pirq expected by the caller, it successes, if
>> pirq!=current_pirq means the pirq expected by the caller has been
>> mapped into other irq, it fails.
>>
>> Second, pirq>0 and current_pirq<0, it means pirq expected by the
>> caller has not been allocated to any irqs, so it can be allocated to
>> caller, it successes.
>>
>> Third, pirq<0 and current_pirq<0, it means caller want to allocate a
>> free pirq for irq and irq has no mapped pirq, it successes.
>>
>> Fourth, pirq<0 and current_pirq>0, it means caller want to allocate
>> a free pirq for irq but irq has a mapped pirq, then it returns the
>> negative pirq, so it fails.
>>
>> The problem is in Fourth, since the irq has a mapped pirq(current_pirq),
>> and the caller doesn't want to allocate a specified pirq to the irq, so
>> the current_pirq should be returned directly in this case, indicating
>> that the allocation is successful. That can help caller to success when
>> caller just want to allocate a free pirq but doesn't know if the irq
>> already has a mapped pirq or not.
>>
>> Signed-off-by: Jiqian Chen <Jiqian.Chen@xxxxxxx>
>> Signed-off-by: Huang Rui <ray.huang@xxxxxxx>
>> Signed-off-by: Jiqian Chen <Jiqian.Chen@xxxxxxx>
> 
> I think the change is correct, and actually fixes a regression. You want
> 
> Fixes: 0762e2502f1f ("x86/physdev: factor out the code to allocate and map a 
> pirq")
> 
> which would also have helped reviewing quite a bit. And it likely would
> also have helped you write a description which is easier to follow.
> Enumerating all the cases isn't really needed here; what is needed is
> an explanation of what went wrong in that re-factoring.
> 
>> --- a/xen/arch/x86/irq.c
>> +++ b/xen/arch/x86/irq.c
>> @@ -2897,6 +2897,8 @@ static int allocate_pirq(struct domain *d, int index, 
>> int pirq, int irq,
>>                      d->domain_id, index, pirq, current_pirq);
>>              if ( current_pirq < 0 )
>>                  return -EBUSY;
>> +            else
>> +                return current_pirq;
> 
> Please can this be simply
> 
>             pirq = current_pirq;
> 
> without any "else", and then taking the normal return path. That again is
> (imo) closer to what was there before.
> 
> I would further suggest that you split this fix out of this series and
> re-submit soon with a for-4.19 tag and with Oleksii Cc-ed, so that this
> can be considered for inclusion in 4.19.
Thanks, will split and send today.

> 
> Jan

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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