lkml.org 
[lkml]   [2022]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86/aperfmperf: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
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...

\
 
 \ /
  Last update: 2022-07-28 12:31    [W:0.165 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site