Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935279AbdDFOgX (ORCPT ); Thu, 6 Apr 2017 10:36:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40322 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935188AbdDFOgH (ORCPT ); Thu, 6 Apr 2017 10:36:07 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 271CA2EF17C Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=riel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 271CA2EF17C Message-ID: <1491489361.8850.151.camel@redhat.com> Subject: Re: [PATCH] tick/nohz: Fix wrong user and system time accouting against vtime sampling From: Rik van Riel To: Wanpeng Li , linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Wanpeng Li , Frederic Weisbecker , Mike Galbraith , Luiz Capitulino , Thomas Gleixner Date: Thu, 06 Apr 2017 10:36:01 -0400 In-Reply-To: <1491460584-4908-1-git-send-email-wanpeng.li@hotmail.com> References: <1491460584-4908-1-git-send-email-wanpeng.li@hotmail.com> Organization: Red Hat, Inc Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 06 Apr 2017 14:36:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1504 Lines: 42 On Wed, 2017-04-05 at 23:36 -0700, Wanpeng Li wrote: > This patch offsets the tick to avert all ticks alignment in order  > that the vtime sampling does not end up "in phase" with the jiffies  > incrementing. > > Reported-by: Luiz Capitulino > Suggested-by: Rik van Riel > Cc: Frederic Weisbecker > Cc: Rik van Riel > Cc: Mike Galbraith > Cc: Luiz Capitulino > Cc: Thomas Gleixner > Cc: Peter Zijlstra > Signed-off-by: Wanpeng Li Reviewed-by: Rik van Riel > +++ b/kernel/time/tick-sched.c > @@ -1197,8 +1197,12 @@ void tick_setup_sched_timer(void) >   /* Get the next period (per-CPU) */ >   hrtimer_set_expires(&ts->sched_timer, > tick_init_jiffy_update()); >   > - /* Offset the tick to avert jiffies_lock contention. */ > - if (sched_skew_tick) { > + /* > +  * 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. > +  */ I feel like part of the explanation is missing from this comment, but I am not sure how to make it better without making it way too long :) > + 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();