Re: [PATCH] x86/aperfmperf: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"

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

 



On Thu, Jul 28, 2022 at 10:55:51AM +0800, Yu Zhe wrote:
> 在 2022年07月28日 00:00, Peter Zijlstra 写道:
> 
> > On Wed, Jul 27, 2022 at 11:14:05AM +0800, Yu Zhe wrote:
> > > time_is_before_jiffies deals with timer wrapping correctly.
> > Please explain how the current code does not.
> 
> 1. If the timer wrap changes in the future you won't have to alter your code.
> 
> 2. unsigned long ut;
> 
>    ut = ULONG_MAX + 4;
> 
>    printf("time_after(ut, ULONG_MAX), ut:%d, %d --> %d\n", ut,
>              time_after(ut, ULONG_MAX), (ULONG_MAX - ut) < 0);
> 
> 
>    In this case, time_after returns true, it's correct.

Now try the same with the existing code...



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux