Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751666Ab3HUI2P (ORCPT ); Wed, 21 Aug 2013 04:28:15 -0400 Received: from merlin.infradead.org ([205.233.59.134]:50458 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751391Ab3HUI2O (ORCPT ); Wed, 21 Aug 2013 04:28:14 -0400 Date: Wed, 21 Aug 2013 10:28:01 +0200 From: Peter Zijlstra To: Oleg Nesterov Cc: Frederic Weisbecker , LKML , Fernando Luis Vazquez Cao , Tetsuo Handa , Thomas Gleixner , Ingo Molnar , Andrew Morton , Arjan van de Ven Subject: Re: [PATCH RESEND 0/4] nohz: Fix racy sleeptime stats Message-ID: <20130821082801.GL3258@twins.programming.kicks-ass.net> References: <1376667753-29014-1-git-send-email-fweisbec@gmail.com> <20130820181500.GA22287@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130820181500.GA22287@redhat.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1866 Lines: 48 On Tue, Aug 20, 2013 at 08:15:00PM +0200, Oleg Nesterov wrote: > While at it. > > I do not also understand the cpu_online() checks in fs/proc/stat.c. > > OK, I agree, if cpu is offline it should not participate in cpu > summary. But if it goes offline, why it should switch from > ->iowait_sleeptime + cpustat[CPUTIME_IDLE] as it seen by /proc/stat? > > This can be another source of "idle goes backward", no? > > IOW. Ignoring the other problems we have, perhaps something like > below makes sense? Agreed, however > > +++ x/kernel/time/tick-sched.c > @@ -477,7 +477,7 @@ u64 get_cpu_idle_time_us(int cpu, u64 *l > update_ts_time_stats(cpu, ts, now, last_update_time); > idle = ts->idle_sleeptime; > } else { > - if (ts->idle_active && !nr_iowait_cpu(cpu)) { > + if (ts->idle_active && cpu_online(cpu) && !nr_iowait_cpu(cpu)) { > ktime_t delta = ktime_sub(now, ts->idle_entrytime); > > idle = ktime_add(ts->idle_sleeptime, delta); > @@ -518,7 +518,7 @@ u64 get_cpu_iowait_time_us(int cpu, u64 > update_ts_time_stats(cpu, ts, now, last_update_time); > iowait = ts->iowait_sleeptime; > } else { > - if (ts->idle_active && nr_iowait_cpu(cpu) > 0) { > + if (ts->idle_active && cpu_online(cpu) && nr_iowait_cpu(cpu)) { > ktime_t delta = ktime_sub(now, ts->idle_entrytime); > > iowait = ktime_add(ts->iowait_sleeptime, delta); > That's still mighty odd, but I guess that's in part due to the whacky semantics. We could simply transfer any open nr_iowait to the cpu doing the hotplug and then we have offline cpus that have nr_iowait == 0 and the above becomes simpler again. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/