lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9315ac61-f617-4449-ae23-72ad23eb668a@zytor.com>
Date: Fri, 17 Jan 2025 08:23:35 -0800
From: "H. Peter Anvin" <hpa@...or.com>
To: Xin Li <xin@...or.com>, Ethan Zhao <haifeng.zhao@...ux.intel.com>,
        Ethan Zhao <etzhao@...look.com>, linux-kernel@...r.kernel.org,
        stable@...r.kernel.org
Cc: tglx@...utronix.de, dave.hansen@...ux.intel.com, x86@...nel.org,
        andrew.cooper3@...rix.com, mingo@...hat.com, bp@...en8.de
Subject: Re: [PATCH] x86/fred: Optimize the FRED entry by prioritizing
 high-probability event dispatching

On 1/17/25 08:17, H. Peter Anvin wrote:
>>>
>>> -       switch (regs->fred_ss.type) {
>>> +       switch_likely (etype, (EVENT_TYPE_EXTINT == etype || 
>>> EVENT_TYPE_OTHER == etype)) {
>>
>> This is not what I suggested, the (l) argument should be only one
>> constant; __builtin_expect() doesn't allow 2 different constants.
>>
> 
> The (l) argument is not a boolean expression! It is the *expected value* 
> of (v).
> 

Also, EVENT_TYPE_EXTINT == etype is not Linux style.

More fundamentally, though, I have to question this unless based on 
profiling, because it isn't at all clear that EXTINT is more important 
than FAULT (page faults, to be specific.)

To optimize syscalls, you want to do a one-shot comparison of the entire 
syscall64 signature (event type, 64-bit flag, and vector) as a mask and 
compare. For that you want to make sure the compiler loads the high 32 
bits into a register so that your mask and compare values can be 
immediates. In other words, you don't actually want it to be part of the 
switch at all, and you want *other* EVENT_TYPE_OTHER to fall back to the 
switch with regular (low) priority.

	-hpa


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ