Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp630971pxk; Thu, 24 Sep 2020 14:23:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz075VlENtpkgSLP14eSnCdm6m9Tq6cdHtQa4ekm5cFbeTihU/58E7Zso0F6CkEQgWDqLjV X-Received: by 2002:a05:6402:1d93:: with SMTP id dk19mr791295edb.198.1600982602868; Thu, 24 Sep 2020 14:23:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600982602; cv=none; d=google.com; s=arc-20160816; b=oKw2F9SubfVAKC/ZdYnpEahsF0iwYTpjK8NKhynndLmk8GxFdpiQPNq6cO1gQCsA9e zSJOnG3N20ZT1YSeN+KapTOIToyk2CuhAvI79nks3pydH0T9OTvC3+s/6jKUYEyiDbDT jgzHg/+60wlNqDwJLLz5sPwktisi5y1q3MEtmaAnxIMS2XSK7Wz9OAmY8c+6vAMpD2gy ZNlQLheo6RjnDvZaMYFJmh2ZNlI8HmXZ4ufhscjk3ZNmTcsmmdzAe+fPw8VXB1H25YZG zGXGCNBi6dAcuIvjOCzOiVsrbUijxlkHEGD3NE73m5yBn7IuzetIHhyph8h+TWPvfoEq 34LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:to:dkim-signature:dkim-signature:from; bh=/f2519A4FFfEiLO37RE5G/56UlC68vOhs3kQ5xBftDs=; b=iLJY+4h8KxASPnK9uR/Qe0WXO2xiGBigHmoj/NQICw+aKI3OX4/I7MteHD92jKj06x rbjdWf13Mi9qRKW//g4AeHfIaE3ZS4QgP0Qjnx2j1kfx8uBlWHDsaul6nff/HNn0sOiV tv4HbNsyF7NloFY98VXxzFrE5VtBzx4WpFVUMPTU0vOyU4BhNeDBn1cnRPkm7OWHMYru qS9PRxGLsF6BSQkKBPt2IZZBSak/Hp0fgeDseTy79Y76TcAjY5JOtqBkHN7jvUH6Cf+5 N7HzIjMV7CjGg5Qd/Gvuvl1zh5DFI0++BX9sjZqJYTSNpsKwRCT0XtRIdj/8C4Qa7pMs eOKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zGWGGczc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0j6xC2UC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si539933ejk.73.2020.09.24.14.22.59; Thu, 24 Sep 2020 14:23:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zGWGGczc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0j6xC2UC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726604AbgIXVTz (ORCPT + 99 others); Thu, 24 Sep 2020 17:19:55 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:51380 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgIXVTz (ORCPT ); Thu, 24 Sep 2020 17:19:55 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1600982393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/f2519A4FFfEiLO37RE5G/56UlC68vOhs3kQ5xBftDs=; b=zGWGGczcrPtzNvrC1XAax8sFAbJb/azuMPygmdZ24MAMzrc/rjxqzfXFcjpF+RO/Vrl/1e +FVzQkuP0EXtYU0GQJ1REFUeX1JdMrFC3EmQKMfjWwK/KINl3+NfNG58Ti5k2MkHtHSwmK m8PJx0ZQ0s/YMLaz5m3riFBqlfyDUeS5UyK7erdiU9EkoPsCZg6UpOI/6arxw8KNo6FbST j5kafCPdBC/8OSgIuNU0jnMUHqYnw9SCCluodEsuv/u/I81efcup1XxxD/RFex8cKksjD2 L5ZPgFpCAZazHE3udxArK3sXCTaK+lvEtzNV3euIuwyrCZyvE4ASCMDLU2QnlA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1600982393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/f2519A4FFfEiLO37RE5G/56UlC68vOhs3kQ5xBftDs=; b=0j6xC2UCjpscBk8+SqseCoV0zxI+5wS2N+WGzn1FbjiK2tzMmySjJ9H6+QqcJ4GLVGCvQp Y5V37dIH/PgeasCw== To: Tom Hromatka , tom.hromatka@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, fweisbec@gmail.com, mingo@kernel.org, adobriyan@gmail.com Subject: Re: [PATCH v2 2/2] /proc/stat: Simplify iowait and idle calculations when cpu is offline In-Reply-To: <20200915193627.85423-3-tom.hromatka@oracle.com> References: <20200915193627.85423-1-tom.hromatka@oracle.com> <20200915193627.85423-3-tom.hromatka@oracle.com> Date: Thu, 24 Sep 2020 23:19:53 +0200 Message-ID: <87h7rm7tza.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15 2020 at 13:36, Tom Hromatka wrote: > Prior to this commit, the cpu idle and iowait data in /proc/stat used > different data sources based upon whether the CPU was online or not. > This would cause spikes in the cpu idle and iowait data. This would not cause spikes. It _causes_ these times to go backwards and start over from 0. That's something completely different than a spike. Please describe problems precisely. > This patch uses the same data source, get_cpu_{idle,iowait}_time_us(), > whether the CPU is online or not. > > This patch and the preceding patch, "tick-sched: Do not clear the > iowait and idle times", ensure that the cpu idle and iowait data > are always increasing. So now you have a mixture of 'This commit and this patch'. Oh well. Aside of that the ordering of your changelog is backwards. Something like this: The CPU idle and iowait times in /proc/stats are inconsistent accross CPU hotplug. The reason is that for NOHZ active systems the core accounting of CPU idle and iowait times used to be reset when a CPU was unplugged. The /proc/stat code tries to work around that by using the corresponding member of kernel_cpustat when the CPU is offline. This works as long as the CPU stays offline, but when it is onlined again then the accounting is taken from the NOHZ core data again which started over from 0 causing both times to go backwards. The HOHZ core has been fixed to preserve idle and iowait times accross CPU unplug, so the broken workaround is not longer required. Hmm? But... > --- a/fs/proc/stat.c > +++ b/fs/proc/stat.c > @@ -47,34 +47,12 @@ static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu) > > static u64 get_idle_time(struct kernel_cpustat *kcs, int cpu) > { > - u64 idle, idle_usecs = -1ULL; > - > - if (cpu_online(cpu)) > - idle_usecs = get_cpu_idle_time_us(cpu, NULL); > - > - if (idle_usecs == -1ULL) > - /* !NO_HZ or cpu offline so we can rely on cpustat.idle */ > - idle = kcs->cpustat[CPUTIME_IDLE]; > - else > - idle = idle_usecs * NSEC_PER_USEC; > - > - return idle; > + return get_cpu_idle_time_us(cpu, NULL) * NSEC_PER_USEC; Q: How is this supposed to work on !NO_HZ systems or in case that NOHZ has been disabled at boot time via command line option or lack of hardware? A: Not at all. Hint #1: You removed the following comment: /* !NO_HZ or cpu offline so we can rely on cpustat.idle */ Hint #2: There is more than one valid kernel configuration. ' Hint #3: Command line options and hardware features have side effects Hint #4: git grep 'get_cpu_.*_time_us' Thanks, tglx