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

Re: [PATCH 1/2] x86/msi: passthrough all MSI-X vector ctrl writes to device model


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 15 Nov 2022 14:54:51 +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=WPeNs0adUYM5IX3QijtNNjDpvZ4xtF52CHiCnGvQ0+s=; b=Ql1s68bhLo5V3u+PAw9+4oYeRmt+pmrhuq4qXdLUaneWO8nd7PLlBr6zFwnJWjJV3HV+doG6O16M1leTJcqMIXx0iD6vY7ckzFUwhEuQIMTC4Z7hztegTfs13RnO8MUowK2Y/Pocm4LfEYIszGtjnIvTENODk19V7A8NA6nRanmkLDJuzRuxQQ/dS4HJDHk716RGAfeHPy2jgoH9aeMSL6dfyGefHsTEHPE1KLrjKH8KsmQv1fCdKgyxKPEa/pY7HicVxDCyVybOTCh7AFXEVSXfQeXqtAfFrPk5XJsD5u5ajOW3jHP/B5qcXquJHujOsN7I7JANXDF92tENU9fr2g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Za0UdlBAnpBQH3LEmDEeRo+OpbwAdp+bA6vRszx3U+Kp6oBeDGWfF2N4/ER7xBqREi++9sd4O1STFrGhe/3lu3inuTlqHeITutgNg+BaUap74edmEu3aY+qFVYIsSIUFRlE1S9FzPRbsreBFgooTzWtyOEt0TnguZvB7ue7M0wFoNXrdbPxarfhjnD+9sNLzVxaHl8xixsDXX213al+rzP5Z7fLlQhyxEIY+BrdBuWYieMFwNCAZkXHIgZPa+uoS0JPqUHJ3poSTXUDrAFyjaqWC3dD46MblGdbBicAl90FRU68LGT3sU/R16MJc9Zm0AiKKoyeZFpkflh3vlfPWGw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 15 Nov 2022 13:55:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15.11.2022 12:37, Marek Marczykowski-Górecki wrote:
> On Tue, Nov 15, 2022 at 10:36:32AM +0100, Jan Beulich wrote:
>> On 14.11.2022 20:20, Marek Marczykowski-Górecki wrote:
>>> Give all necessary information to QEMU by passing all ctrl writes,
>>> including masking a vector.
>>
>> Can we perhaps still avoid sending dword writes which don't change
>> the mask bit?
> 
> Is it worth it? I don't think such writes are common (which I confirm
> observing debug log - every single write to maskbit Linux did was
> changing the value). The old value isn't readily available here.

For one a 2nd aspect would be Windows behavior. As you've seen in
the hypervisor code somebody back at the time even thought
accelerating reads was useful. I'm going from that rather than
knowing for sure that such an optimization would help anywhere.

>>> --- a/xen/arch/x86/hvm/vmsi.c
>>> +++ b/xen/arch/x86/hvm/vmsi.c
>>> @@ -271,7 +271,8 @@ out:
>>>  }
>>>  
>>>  static int msixtbl_write(struct vcpu *v, unsigned long address,
>>> -                         unsigned int len, unsigned long val)
>>> +                         unsigned int len, unsigned long val,
>>> +                         bool completion)
>>>  {
>>
>> I'd like to propose an alternative approach without an extra parameter:
>> Have msix_write_completion() pass 0 for "len" and move the initial
>> check
>>
>>     if ( (len != 4 && len != 8) || (address & (len - 1)) )
>>         return r;
>>
>> into _msixtbl_write(). Then ...
>>
>>> @@ -343,7 +344,7 @@ static int msixtbl_write(struct vcpu *v, unsigned long 
>>> address,
>>>  
>>>  unlock:
>>>      spin_unlock_irqrestore(&desc->lock, flags);
>>> -    if ( len == 4 )
>>> +    if ( len == 4 && completion )
>>>          r = X86EMUL_OKAY;
>>
>> ... this could simply be "if ( !len )", seeing that even with your
>> approach it could simply be "if ( completion )".
> 
> I find such usage of magic len=0 confusing. It would change the meaning
> of "len" from "write length" to "write length, unless it's 0 - then
> write length is 4 and it's called from msix_write_completion.
> Is there any real value from avoiding extra parameter?

Perhaps a matter of taste, but to me redundant parameters are odd
at times as well - often I end up wondering in such cases why an
extra parameter was introduced when things could easily be done
with what was there. In the specific case here there's also the
further aspect of you moving the function across the boundary of
all arguments fitting in registers available for parameter passing
(which of course only matters if the compiler decides to not
inline the function at all call sites).

Jan



 


Rackspace

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