From patchwork Tue Aug 8 21:12:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 9889115 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E67EF601EB for ; Tue, 8 Aug 2017 21:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D935C28857 for ; Tue, 8 Aug 2017 21:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE0B928956; Tue, 8 Aug 2017 21:13:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 812AF28857 for ; Tue, 8 Aug 2017 21:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752412AbdHHVNO (ORCPT ); Tue, 8 Aug 2017 17:13:14 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38668 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752145AbdHHVNL (ORCPT ); Tue, 8 Aug 2017 17:13:11 -0400 Received: by mail-pg0-f68.google.com with SMTP id 123so4082308pga.5; Tue, 08 Aug 2017 14:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5wX9qeWrDozvZIhcffnh3NEwMNKw5wqcaQI0MWLhMac=; b=dcj2yY3lJrksZVURNb5303jDuN3q5lSoIzrQ3tMnrYzqCLXiWhGpJKG4tBClcUVoYq Rxovk9Dt8Q6jf3SrYLPZ4f1HuRvTx/jAuWIdV2TOhq486Dr1gdVsoWckoyAp4ndw/HLL Gi04/Ccbrv1MPhUcIAHutT3LifmvutWFmImYtyyX5vI/X8ZHoOR8DeeEyzcuI1YYaprD rMtMn58x5bfEk5sTza1s7l5YuKzOS9i3cyxZg8hyQhgSWvg8EHvjvmZeQ0ccExgkx3FG 2nDlzpR/R3NNijE/Ii19wK/VhfrDKF3PpPs4Wr21/4TTHhFdjQixmnu6eT4CeP0jbuPf w30A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5wX9qeWrDozvZIhcffnh3NEwMNKw5wqcaQI0MWLhMac=; b=py9A23OKR7X0LQQxofXqoxGZOHg21u6eMRjLXU5aJp4omEllFwzmKI6r5O5ll4c5lM 7TAQgyB9PJxqPidKvvda/S4m0KTJjcr0Jm3fZWKOIDQY03/oFi7g194b7RmCPjS+hHbT 5LFwLs1AhbbhHnFudvcW5Nr/C241SHuY7qclc5Cn6ipK1aC3uK5fI+5iwVnsS5VjXc0K BQJwjvUgzTGpJhqiR7HwUTLXKECGUZW0uGh3TZJe7pHuyOM5ksaNMcJ7AWz7lA/poIpF FP4CFEeHERIj12WqKyEykpS4kZPxLHAaOyrP5mTkwuLg+399uNn94W1I7QAMkeLt7KRd YiCw== X-Gm-Message-State: AHYfb5idYrcP9Uz0hUasLPOoI0zU9MBJJ8ptEg6JznVafD8DAd/RkI0O Qv+MlQ10fKakIA== X-Received: by 10.98.166.153 with SMTP id r25mr5784878pfl.155.1502226791434; Tue, 08 Aug 2017 14:13:11 -0700 (PDT) Received: from s15.smythies.com (mail.smythies.com. [173.180.45.4]) by smtp.gmail.com with ESMTPSA id h20sm6368626pfk.175.2017.08.08.14.13.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Aug 2017 14:13:10 -0700 (PDT) From: Doug Smythies X-Google-Original-From: Doug Smythies To: x86@kernel.org, linux-pm@vger.kernel.org, len.brown@intel.com Cc: dsmythies@telus.net, rafael@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: x86: Disable interrupts during MSRs reading Date: Tue, 8 Aug 2017 14:12:49 -0700 Message-Id: <1502226769-5670-1-git-send-email-dsmythies@telus.net> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to Intel 64 and IA-32 Architectures SDM, Volume 3, Chapter 14.2, "Software needs to exercise care to avoid delays between the two RDMSRs (for example interrupts)". So, disable interrupts during reading MSRs IA32_APERF and IA32_MPERF. See also: commit 4ab60c3f32c721e46217e762bcd3e55a8f659c04 cpufreq: intel_pstate: Disable interrupts during MSRs reading Signed-off-by: Doug Smythies Reviewed-by: Len Brown --- arch/x86/kernel/cpu/aperfmperf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c index 7cf7c70..0ee8332 100644 --- a/arch/x86/kernel/cpu/aperfmperf.c +++ b/arch/x86/kernel/cpu/aperfmperf.c @@ -40,13 +40,16 @@ static void aperfmperf_snapshot_khz(void *dummy) struct aperfmperf_sample *s = this_cpu_ptr(&samples); ktime_t now = ktime_get(); s64 time_delta = ktime_ms_delta(now, s->time); + unsigned long flags; /* Don't bother re-computing within the cache threshold time. */ if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS) return; + local_irq_save(flags); rdmsrl(MSR_IA32_APERF, aperf); rdmsrl(MSR_IA32_MPERF, mperf); + local_irq_restore(flags); aperf_delta = aperf - s->aperf; mperf_delta = mperf - s->mperf;