lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YJP6fWhwg95JZ1Kg@hirez.programming.kicks-ass.net>
Date:   Thu, 6 May 2021 16:17:33 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Johannes Weiner <hannes@...xchg.org>
Cc:     tglx@...utronix.de, mingo@...nel.org, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com, bsingharora@...il.com, pbonzini@...hat.com,
        maz@...nel.org, linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
        riel@...riel.com
Subject: Re: [PATCH 1/6] delayacct: Use sched_clock()

On Thu, May 06, 2021 at 09:59:11AM -0400, Johannes Weiner wrote:
> On Wed, May 05, 2021 at 12:59:41PM +0200, Peter Zijlstra wrote:
> > @@ -42,10 +42,9 @@ void __delayacct_tsk_init(struct task_st
> >   * Finish delay accounting for a statistic using its timestamps (@start),
> >   * accumalator (@total) and @count
> >   */
> > -static void delayacct_end(raw_spinlock_t *lock, u64 *start, u64 *total,
> > -			  u32 *count)
> > +static void delayacct_end(raw_spinlock_t *lock, u64 *start, u64 *total, u32 *count)
> >  {
> > -	s64 ns = ktime_get_ns() - *start;
> > +	s64 ns = local_clock() - *start;
> 
> I don't think this is safe. These time sections that have preemption
> and migration enabled and so might span multiple CPUs. local_clock()
> could end up behind *start, AFAICS.

Only if you have really crummy hardware, and in that case the drift is
bounded by around 1 tick. Also, this function actually checks: ns > 0.

And if you do have crummy hardware like that, ktime_get_ns() is the very
last thing you want to call at any frequency because it'll be the HPET.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ