[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YuJlLK4x9aUuqHQZ@worktop.programming.kicks-ass.net>
Date: Thu, 28 Jul 2022 12:30:04 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Yu Zhe <yuzhe@...china.com>
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
liqiong@...china.com
Subject: Re: [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...
Powered by blists - more mailing lists