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

Re: [PATCH] x86/irq: Improve local_irq_restore() code generation and performance


  • To: Andrew Cooper <amc96@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 6 Dec 2021 15:07:14 +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=X/ijlGOwIXpRo8SfXahGIkGaSLFMOXDD/vSOr8ascyo=; b=RjbkohPMXwBrkl3tFfGTRYs2E0GKCF4IO94/rEGj3UrsbwGqNtW7wUK9B8SH+JzLHrYvIQ1tkKB+wlH35PqIcE0FlFelGRdt9YObceyG7q22EOjhxkvIGuHDcwCNVJKoE1CrnnOZK+2zjatKwwCXeDJIWfjCu20AFZ2IThMQWpjxL6CuyqJ7sj7miNVpon4InHaYsp7GWe573hk1cFcQpzJ+e5uz/UVlz3RwmZD2+M6tFWD0kchFm7ZcV1n5lv72Bh77mAPtafXVnw2LjKgo5jf725H0kUw0moHsbQoY/riHZpUyZDhrArFT8IZG6UssFnHy5HzWAan4Nu6B85Hojg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RYr6YGJ2S0m/vPxn1hY2OrPy19kMnw33YEX6woQxu+DB+BORfyIXRMWSQI1K3YCGcZX8yCAb2iuz5MBepDknzYkAG/DOTfU8/8/g+RviUnC0rhjRb+q5mm72BjgFzW0Pvd4x9Eh+mMp0gf/lMojdmRv4RTrjgCI/e4bRKRCCYmM4+eez4tdlbHBt4A5/GliBroWsI9XeW4W/ipgkfmbCyBARk4iNHvPz/CjSvWnzcXfI81gu4n1hxbNVa4IzAHdCnbrjIpNLUExt/vYwcSu/pqUEo1yiTiPrdtUy1BjvhptJbYxJBF9HAfb/jDOX3/Iu00UHeuVVibRCONHjDYYq5w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 06 Dec 2021 14:07:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.12.2021 14:55, Andrew Cooper wrote:
> On 06/12/2021 13:38, Andrew Cooper wrote:
>> popf is a horribly expensive instruction, while sti is an optimised fastpath.
>> Switching popf for a conditional branch and sti caused an 8% perf improvement
>> in various linux measurements.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>> ---
>> CC: Jan Beulich <JBeulich@xxxxxxxx>
>> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>> CC: Wei Liu <wl@xxxxxxx>
>> ---
>>  xen/include/asm-x86/system.h | 9 ++-------
>>  1 file changed, 2 insertions(+), 7 deletions(-)
>>
>> diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h
>> index 65e63de69a67..4be235472ecd 100644
>> --- a/xen/include/asm-x86/system.h
>> +++ b/xen/include/asm-x86/system.h
>> @@ -267,13 +267,8 @@ static inline unsigned long 
>> array_index_mask_nospec(unsigned long index,
>>  })
>>  #define local_irq_restore(x)                                     \
>>  ({                                                               \
>> -    BUILD_BUG_ON(sizeof(x) != sizeof(long));                     \
>> -    asm volatile ( "pushfq\n\t"                                  \
>> -                   "andq %0, (%%rsp)\n\t"                        \
>> -                   "orq  %1, (%%rsp)\n\t"                        \
>> -                   "popfq"                                       \
>> -                   : : "i?r" ( ~X86_EFLAGS_IF ),                 \
>> -                       "ri" ( (x) & X86_EFLAGS_IF ) );           \
>> +    if ( (x) & X86_EFLAGS_IF )                                   \
>> +        local_irq_enable();                                      \
>>  })
> 
> Bah.  There's still the one total abuse of local_irq_restore() to
> disable interrupts.

Question is whether that's really to be considered an abuse: To me
"restore" doesn't mean only "maybe re-enable", but also "maybe
re-disable". And a conditional STI-or-CLI is likely still be better
than POPF.

Jan




 


Rackspace

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