Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752791AbdDJSBx (ORCPT ); Mon, 10 Apr 2017 14:01:53 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33961 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751442AbdDJSBv (ORCPT ); Mon, 10 Apr 2017 14:01:51 -0400 Date: Mon, 10 Apr 2017 20:01:46 +0200 From: Frederic Weisbecker To: Thomas Gleixner Cc: Wanpeng Li , linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Wanpeng Li , Rik van Riel , Mike Galbraith , Luiz Capitulino Subject: Re: [PATCH] tick/nohz: Fix wrong user and system time accouting against vtime sampling Message-ID: <20170410180143.GA18098@lerouge> References: <1491460584-4908-1-git-send-email-wanpeng.li@hotmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1003 Lines: 26 On Mon, Apr 10, 2017 at 05:45:56PM +0200, Thomas Gleixner wrote: > On Wed, 5 Apr 2017, Wanpeng Li wrote: > > + /* > > + * Offset the tick to avert jiffies_lock contention, and all ticks > > + * alignment in order that the vtime sampling does not end up "in > > + * phase" with the jiffies incrementing. > > + */ > > + if (sched_skew_tick || tick_nohz_full_enabled()) { > > u64 offset = ktime_to_ns(tick_period) >> 1; > > do_div(offset, num_possible_cpus()); > > offset *= smp_processor_id(); > > That's not a fix, that's just papering over the problem. > > offset = 1ms / 2 = 500us = 500000ns; > offset /= 144 = 3472ns > > So CPU0 and CPU1 ticks are ~3 microseconds apart. That merily reduces the > probability of the issue, but does not prevent it. I worried about it but didn't realize it could be that tight. So the alternative is the solution involving sched_clock() as the source for cputime. Wanpeng Li could you please resubmit your patch that does that? Thanks.