Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2673480ybc; Wed, 20 Nov 2019 18:46:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyB/Xxw6WnMzXCu/q5AKAQwzTZlBaeBGhJwexPLm84viCcxDVqU58hs7CneIbluPK84+yxu X-Received: by 2002:a17:906:1da1:: with SMTP id u1mr10287539ejh.275.1574304393120; Wed, 20 Nov 2019 18:46:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574304393; cv=none; d=google.com; s=arc-20160816; b=HdEyDkZNDGKktpUwufZ7oOCE7ammJO+KrpU4frRKoCKn1Xi93MVAtXQkGDMcP4do44 6zSG3VYc6/IX4Bj4qPhgNoBK7/cbjOAtrbHYjuPTUOWsS94Ldmf/sGLygFrjDNFnW1Wt swGLYPJyc+vIW9ljaP4+GscsofZDT4FMwEEL+KUNIbWmNEKpjhJ2n+0cCIAY8UDejwG3 b/hX3md74l7A+u+OgLJzqwrH7HHGrs0R+M/+157ERbOXDRnXMdq5Knfk9K73OPMRuos1 obb8rZCOVaLY4epfPm2U5TjbwC6nVZRXbBFH69l40aIgp+GETzW/ZnouB5Y/KH1o5MmI SXMQ== 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=8TW6efxQP5v1poP1wqoA1zCm4MdPAiJLP/46HMFxXQY=; b=r+/m0RUBBAVsjyp11Z+IDOabc2CDTqYCpNzf3zEaIqbIbd60LiS2PElclQn21wzB61 WK+wyFicHJyA1xItxYusUu+wkUyrVisDT58mRlqmH/ybrlPOAea3fFkMowlUf/IPy9N8 BGkp4zHfuYGiTgNbaFRn5Dx3YbecAxX5p+YxpxaEG1iuRZ7DzTbh8/88DFEi32z6rzJz /+ubwVC5LUrbOgkwusgOaIcwGPYHaULVqjYUGW/b1Qch+TVk6KL2e5MZBeChZRWuLkgW x8dLhFtrxh6MP2oFTQuRa3IWiIUqiRiEfv99njHOUfngIz1A6SVT15BFexl4jW8AvmAm 3OAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oFjAcHXi; 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 cc4si1049919edb.237.2019.11.20.18.46.08; Wed, 20 Nov 2019 18:46:33 -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=oFjAcHXi; 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 S1726927AbfKUCov (ORCPT + 99 others); Wed, 20 Nov 2019 21:44:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:54384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbfKUCot (ORCPT ); Wed, 20 Nov 2019 21:44:49 -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 93E09208A3; Thu, 21 Nov 2019 02:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574304288; bh=dFaoUL/kjZQEWQ6Iam/kl52aRoyIpykAOKG/LDr/kZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFjAcHXiE4gPg9y6z3F+zaBAHpmR2cqOUAzK6GlyTf2M0/RtNu3KstyT+0fT3zq1A /DpdBnFr0tR+xtECXtRzkEln3oVPGagFYXiarq8xVWKGTGP0rGQCHmhtR0shWkONae x5AbZuvW0KCnzrYU9F3HwVehqltUKF+HB+XYOmSo= 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 4/6] cpufreq: Use vtime aware kcpustat accessors for user time Date: Thu, 21 Nov 2019 03:44:28 +0100 Message-Id: <20191121024430.19938-5-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 We can now safely read user and guest kcpustat fields on nohz_full CPUs. Use the appropriate accessors. Reported-by: Yauheni Kaliuta Signed-off-by: Frederic Weisbecker Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar Cc: Viresh Kumar Cc: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 17 ++++++++++------- drivers/cpufreq/cpufreq_governor.c | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 527fd068dc12..ee23eaf20f35 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -113,18 +113,21 @@ EXPORT_SYMBOL_GPL(get_governor_parent_kobj); static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) { - u64 idle_time; + struct kernel_cpustat kcpustat; u64 cur_wall_time; + u64 idle_time; u64 busy_time; cur_wall_time = jiffies64_to_nsecs(get_jiffies_64()); - busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; - busy_time += kcpustat_field(&kcpustat_cpu(cpu), CPUTIME_SYSTEM, cpu); - busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; - busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; - busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; - busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; + kcpustat_cpu_fetch(&kcpustat, cpu); + + busy_time = kcpustat.cpustat[CPUTIME_USER]; + busy_time += kcpustat.cpustat[CPUTIME_SYSTEM]; + busy_time += kcpustat.cpustat[CPUTIME_IRQ]; + busy_time += kcpustat.cpustat[CPUTIME_SOFTIRQ]; + busy_time += kcpustat.cpustat[CPUTIME_STEAL]; + busy_time += kcpustat.cpustat[CPUTIME_NICE]; idle_time = cur_wall_time - busy_time; if (wall) diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 4bb054d0cb43..f99ae45efaea 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -105,7 +105,7 @@ void gov_update_cpu_data(struct dbs_data *dbs_data) j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, &j_cdbs->prev_update_time, dbs_data->io_is_busy); if (dbs_data->ignore_nice_load) - j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; + j_cdbs->prev_cpu_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j); } } } @@ -149,7 +149,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy) j_cdbs->prev_cpu_idle = cur_idle_time; if (ignore_nice) { - u64 cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; + u64 cur_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j); idle_time += div_u64(cur_nice - j_cdbs->prev_cpu_nice, NSEC_PER_USEC); j_cdbs->prev_cpu_nice = cur_nice; @@ -530,7 +530,7 @@ int cpufreq_dbs_governor_start(struct cpufreq_policy *policy) j_cdbs->prev_load = 0; if (ignore_nice) - j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; + j_cdbs->prev_cpu_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j); } gov->start(policy); -- 2.23.0