[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <F6B47DBD-0350-4966-9C82-3B252A6D8224@zytor.com>
Date: Fri, 17 Jan 2025 20:09:22 -0800
From: "H. Peter Anvin" <hpa@...or.com>
To: Ethan Zhao <etzhao@...look.com>, Ethan Zhao <haifeng.zhao@...ux.intel.com>,
Xin Li <xin@...or.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 January 17, 2025 8:06:27 PM PST, Ethan Zhao <etzhao@...look.com> wrote:
>On 1/18/2025 11:41 AM, H. Peter Anvin wrote:
>> On January 17, 2025 7:29:36 PM PST, Ethan Zhao <etzhao@...look.com> wrote:
>>> On 1/18/2025 12:24 AM, H. Peter Anvin wrote:
>>>>> In short, seems that __builtin_expect not work with switch(), at least for
>>>>> gcc version 8.5.0 20210514(RHEL).
>>>>>
>>>> For forward-facing optimizations, please don't use an ancient version of gcc as the benchmark.
>>> Even there is a latest Gcc built-in feature could work for this case, it is highly unlikely that Linus would adopt such trick into upstream kernel (only works for specific ver compiler). the same resultto those downstream vendors/LTS kernels. thus, making an optimization with latest only Gcc would construct an impractical benchmark-only performance barrier. As to the __builtin_expect(), my understanding, it was designed to only work for if(bool value) {
>>> }
>>> else if(bool value) {
>>> } The value of the condition expression returned by __builtin_expect() is a bool const. while switch(variable) expects a variable. so it is normal for Gcc that it doesn't work with it.
>>>
>>> If I got something wrong, please let me know.
>>>
>>> Thanks,
>>> Ethan
>>>
>>>> -hpa
>>>>
>> That is not true at all; we do that pretty much *all the time*. The reason is that the new compiler versions will become mainstream on a much shorter time scale than the lifespan of kernel code.
>
>Yup, time walks forward...
>But it is very painful to backporting like jobs to make those things in position for eager/no-waiting customers.
>
>Thanks,
>Ethan
>
>>
>> We do care about not making the code for the current mainstream compilers *worse* in the process, and we care about not *breaking* the backrev compilers.
As I said, it is OK for an ancient compiler (gcc 8 is the oldest compiler still supported) to *not have an improvement* as long as it doesn't make it worse.
Powered by blists - more mailing lists