Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2673370ybc; Wed, 20 Nov 2019 18:46:26 -0800 (PST) X-Google-Smtp-Source: APXvYqyOAgt9mazP1aX0bPNEtFEtPDVYUv0gkZmXA6i/aTAKEV6UNkyEHiD4gryLe2TD11ibTHwI X-Received: by 2002:a17:906:bce5:: with SMTP id op5mr10208175ejb.325.1574304386267; Wed, 20 Nov 2019 18:46:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574304386; cv=none; d=google.com; s=arc-20160816; b=IKBrdgoa2voRepYzX7bHZaSAfy05LHv9jAeO+IS5MSRwWOu/VLcy1fg5B2Q0WqCjYc uf31x+bQINcMAbzfzqx7Vdm8kwiFcPtOQAABsJGCwqw1atZBIcPxQmGKCxpM/SWC+5/G 4JyJWjb8mt2fhDSIwyJKCX2zmOmwN6VGsdkIibHVuHAovpaB2JmAFoHDPkvg7fGApGOh X8Ej36EceSEhBJQHW0UcxlxTwOBCOaBnHwRw+mWWLOfPB7mZhw56r8v8EARzQDcS1Uv7 lN4ZaL2Wlc7sA8PO+1cLnwAXpMFU943vzPSDep/EY2veS57pyGC9H+D4F4J1IV2kOXsU DxHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PIGU2/Eboetf976UGpa2vkvVzBabd71ls5KDpPmNglg=; b=udPpB4yWkrdCirjSscoEOkyzTMjcLBvXDIOnEQmKQ2Qbi2MXtWKshpckH2IabHUmP6 TYfH93zPNCBFSVpIYKLp2tFgSdt4AaKCOEJMaawBO4vN+Ofz2mvD7VXq4L3NiDX/imxE CIiekW1EQdpvmMLPQGbdUNp1H8vgYffbBcb1/uiLVfdZDVvZkeYXCoBAJs5yFpUIx7BR WN25RF7LS6x/VxDSzW5r7O1pA083tIQ5eMQLjKC0HBGH7K1csypUdHaimQTrhk2MPm0j TMr5fUiHRwpWx2Ptq5SjQlFSEhCbV4SqILCcxX8XXl+mFTMHXY+ZOxyHgGRVE0MoZdxe b5IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bLPkw3Ir; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si755457ejz.344.2019.11.20.18.46.01; Wed, 20 Nov 2019 18:46:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bLPkw3Ir; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbfKUCor (ORCPT + 99 others); Wed, 20 Nov 2019 21:44:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:54318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726840AbfKUCop (ORCPT ); Wed, 20 Nov 2019 21:44:45 -0500 Received: from lenoir.home (lfbn-ncy-1-150-155.w83-194.abo.wanadoo.fr [83.194.232.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A42532089D; Thu, 21 Nov 2019 02:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574304285; bh=bVTtftvy/497ZG5CBfJ+tdQkUTY2Eip4rA9yqOgTedc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bLPkw3IrS8wi7V+ItSmG0FlnLfYxSpzZQm44Oi3df/1wpCJBeweCO/W4PrHjugR84 ezxljgQQhJdHK3/HZO3L2tCMP2lH/eV0u7irndM0pGGV/FnHmjplf7tQb/GjLt6Gfr fzglAYtPjYqaazgkZOkrY2S6a4cGFX7Tsj6qmaDg= From: Frederic Weisbecker To: Peter Zijlstra , Ingo Molnar Cc: LKML , Frederic Weisbecker , Jacek Anaszewski , Wanpeng Li , "Rafael J . Wysocki" , Benjamin Herrenschmidt , Rik van Riel , Thomas Gleixner , Yauheni Kaliuta , Viresh Kumar , Pavel Machek Subject: [PATCH 3/6] procfs: Use all-in-one vtime aware kcpustat accessor Date: Thu, 21 Nov 2019 03:44:27 +0100 Message-Id: <20191121024430.19938-4-frederic@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191121024430.19938-1-frederic@kernel.org> References: <20191121024430.19938-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we can read also user and guest time safely under vtime, use the relevant accessor to fix frozen kcpustat values on nohz_full CPUs. Reported-by: Yauheni Kaliuta Signed-off-by: Frederic Weisbecker Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- fs/proc/stat.c | 54 ++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 5c6bd0ae3802..37bdbec5b402 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -120,20 +120,23 @@ static int show_stat(struct seq_file *p, void *v) getboottime64(&boottime); for_each_possible_cpu(i) { - struct kernel_cpustat *kcs = &kcpustat_cpu(i); + struct kernel_cpustat kcpustat; + u64 *cpustat = kcpustat.cpustat; - user += kcs->cpustat[CPUTIME_USER]; - nice += kcs->cpustat[CPUTIME_NICE]; - system += kcpustat_field(kcs, CPUTIME_SYSTEM, i); - idle += get_idle_time(kcs, i); - iowait += get_iowait_time(kcs, i); - irq += kcs->cpustat[CPUTIME_IRQ]; - softirq += kcs->cpustat[CPUTIME_SOFTIRQ]; - steal += kcs->cpustat[CPUTIME_STEAL]; - guest += kcs->cpustat[CPUTIME_GUEST]; - guest_nice += kcs->cpustat[CPUTIME_GUEST_NICE]; - sum += kstat_cpu_irqs_sum(i); - sum += arch_irq_stat_cpu(i); + kcpustat_cpu_fetch(&kcpustat, i); + + user += cpustat[CPUTIME_USER]; + nice += cpustat[CPUTIME_NICE]; + system += cpustat[CPUTIME_SYSTEM]; + idle += get_idle_time(&kcpustat, i); + iowait += get_iowait_time(&kcpustat, i); + irq += cpustat[CPUTIME_IRQ]; + softirq += cpustat[CPUTIME_SOFTIRQ]; + steal += cpustat[CPUTIME_STEAL]; + guest += cpustat[CPUTIME_GUEST]; + guest_nice += cpustat[CPUTIME_USER]; + sum += kstat_cpu_irqs_sum(i); + sum += arch_irq_stat_cpu(i); for (j = 0; j < NR_SOFTIRQS; j++) { unsigned int softirq_stat = kstat_softirqs_cpu(j, i); @@ -157,19 +160,22 @@ static int show_stat(struct seq_file *p, void *v) seq_putc(p, '\n'); for_each_online_cpu(i) { - struct kernel_cpustat *kcs = &kcpustat_cpu(i); + struct kernel_cpustat kcpustat; + u64 *cpustat = kcpustat.cpustat; + + kcpustat_cpu_fetch(&kcpustat, i); /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ - user = kcs->cpustat[CPUTIME_USER]; - nice = kcs->cpustat[CPUTIME_NICE]; - system = kcpustat_field(kcs, CPUTIME_SYSTEM, i); - idle = get_idle_time(kcs, i); - iowait = get_iowait_time(kcs, i); - irq = kcs->cpustat[CPUTIME_IRQ]; - softirq = kcs->cpustat[CPUTIME_SOFTIRQ]; - steal = kcs->cpustat[CPUTIME_STEAL]; - guest = kcs->cpustat[CPUTIME_GUEST]; - guest_nice = kcs->cpustat[CPUTIME_GUEST_NICE]; + user = cpustat[CPUTIME_USER]; + nice = cpustat[CPUTIME_NICE]; + system = cpustat[CPUTIME_SYSTEM]; + idle = get_idle_time(&kcpustat, i); + iowait = get_iowait_time(&kcpustat, i); + irq = cpustat[CPUTIME_IRQ]; + softirq = cpustat[CPUTIME_SOFTIRQ]; + steal = cpustat[CPUTIME_STEAL]; + guest = cpustat[CPUTIME_GUEST]; + guest_nice = cpustat[CPUTIME_USER]; seq_printf(p, "cpu%d", i); seq_put_decimal_ull(p, " ", nsec_to_clock_t(user)); seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice)); -- 2.23.0