Re: [PATCH] x86/fred: Optimize the FRED entry by prioritizing high-probability event dispatching

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

 




在 2025/1/17 9:21, H. Peter Anvin 写道:
On 1/16/25 16:37, Ethan Zhao wrote:

hpa suggested to introduce "switch_likely" for this kind of optimization on a switch statement, which is also easier to read.  I measured it with a user space focus test, it does improve performance a lot. But obviously there are still a lot of work to do.

Find a way to instruct compiler to pick the right hot branch meanwhile make folks
reading happy... yup, a lot of work.


It's not that complicated, believe it or not.

/*
 * switch(v) biased for speed in the case v == l
 *
 * Note: gcc is quite sensitive to the exact form of this
 * expression.
 */
#define switch_likely(v,l) \
    switch((__typeof__(v))__builtin_expect((v),(l)))

I know we could play such trick for one branch, never think of there are 2-3 branches are expected among 7 branches. :) , --- external interrupts, syscall, page fault.

Thanks,
Ethan
    -hpa

--
"firm, enduring, strong, and long-lived"





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux