Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2878908pxb; Tue, 19 Jan 2021 08:13:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGwrRJNTI7ktY1opwFAgdccJoJO6LZFKqTPUNnMcqhzJOkgnh4SySGO6lfcxCEnw9wNh4c X-Received: by 2002:a17:906:6693:: with SMTP id z19mr3430924ejo.376.1611072812782; Tue, 19 Jan 2021 08:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611072812; cv=none; d=google.com; s=arc-20160816; b=eyNovYnFCQ6Mryt4HxhCVWEhW9ow0A9wNgZm4NIs1ugDT4V+RlGn/in/7oxfU8qfJu AeGDhclHSBr4BRmKXTUrdPyx5TqQZDLK8cAY9/v+sLKxglkDAaqoYiGDc+SJt4tzg83l zv+utxFY6o95icZiWWGDnGFYXow/pKc6sJHm75ycRSgYcTwyv763K7C+mN2tyekxzm1d jg5++m8wrGz7KwNlgiq28yn2tpvnnbE4cEpK3QuVFImV5nkFGwEqgeD8/b5r1MxvWNRC wIKSLpb3sQTBXJaJDg2Y2AQVyYmvr31jtnl4c3Yp5BPoGkoztRYuXF+M/+QdvT7tQuvL Eseg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=J/X7bnT0Fs4sPITr8k9z7TTU0AiLMBMoPoDOqNqcWbo=; b=kfQsODNzddCHAiYYrdYYiKhUA+DUAoqfJYVeOMJ8JOumVn25XuJPEp8b31IrfDZjKT joRdt5lZr7hIiNSUEjQEbV4zlzFKYzGJMUdnrWLT1WQL7RQEVUzobLVlIrub84sRoWIH rVHMUTMpPP1TtpZS5q7Fm3/GC9JYwaISYHXk5mhdbEWjod4CbpVnPU2ezzDwG9xXRO5F zP6ukGVWk0jqykde9ieOQ1R+mHj1ScYMDxxzC6i2au5yeai4re7SxGXLWLD/2HDkAtO9 8lT+3+TkUHUHcZYBttj3KNbBR9bN76mzel6zrwQ+d+IZmCOcj15v69nlEjnzvmenWtFz e4gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0qXiEm+w; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 q8si8076141ejj.24.2021.01.19.08.13.09; Tue, 19 Jan 2021 08:13:32 -0800 (PST) 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=0qXiEm+w; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S2391467AbhASQLZ (ORCPT + 99 others); Tue, 19 Jan 2021 11:11:25 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:35072 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391775AbhASQKl (ORCPT ); Tue, 19 Jan 2021 11:10:41 -0500 Date: Tue, 19 Jan 2021 16:09:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1611072596; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J/X7bnT0Fs4sPITr8k9z7TTU0AiLMBMoPoDOqNqcWbo=; b=0qXiEm+wwysMZJk8AGANYIvbLP8kledYnojIUmXol+1AVeFYXbTCDKBg7apquWozUXkg28 omvL9MYUixAxbborLr3/B2jgojwtqSa7Xrrdc2Bpm56fTzrjUfLAQdkGTVLJkKcdlcvAeu +ETt411VByiwsZ9E6kJs7dihVERI8wWTInVvxTgXgaPXbS0glWjxGNJwQs/mLhmtgwDsDw sWMQ0RRDIIGPIv2Gn5e3l1UC1RysLc1OaT+5bWHrq/1GLkWXY33Fh5nuKbEV8gdbOL3LmM mgQ6jaPzXDsEoBriK6sOUYHsVml0Gv9QTmver//pv9ATm8xj+H32iuIKppMxYg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1611072596; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J/X7bnT0Fs4sPITr8k9z7TTU0AiLMBMoPoDOqNqcWbo=; b=+nMZrqv/PnClTnwLGYweWpXVEMuclFPJDv60inTobhnnFx+0pFp90Rgar0E9x10bAGrZy1 MUFG6wFOf667sRBA== From: "tip-bot2 for Rafael J. Wysocki" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] x86: PM: Register syscore_ops for scale invariance Cc: "Rafael J. Wysocki" , "Peter Zijlstra (Intel)" , Giovanni Gherdovich , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1803209.Mvru99baaF@kreacher> References: <1803209.Mvru99baaF@kreacher> MIME-Version: 1.0 Message-ID: <161107259553.414.4642815387021919631.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 9c7d9017a49fb8516c13b7bff59b7da2abed23e1 Gitweb: https://git.kernel.org/tip/9c7d9017a49fb8516c13b7bff59b7da2abed23e1 Author: Rafael J. Wysocki AuthorDate: Fri, 08 Jan 2021 19:05:59 +01:00 Committer: Peter Zijlstra CommitterDate: Tue, 19 Jan 2021 17:04:03 +01:00 x86: PM: Register syscore_ops for scale invariance On x86 scale invariace tends to be disabled during resume from suspend-to-RAM, because the MPERF or APERF MSR values are not as expected then due to updates taking place after the platform firmware has been invoked to complete the suspend transition. That, of course, is not desirable, especially if the schedutil scaling governor is in use, because the lack of scale invariance causes it to be less reliable. To counter that effect, modify init_freq_invariance() to register a syscore_ops object for scale invariance with the ->resume callback pointing to init_counter_refs() which will run on the CPU starting the resume transition (the other CPUs will be taken care of the "online" operations taking place later). Fixes: e2b0d619b400 ("x86, sched: check for counters overflow in frequency invariant accounting") Signed-off-by: Rafael J. Wysocki Signed-off-by: Peter Zijlstra (Intel) Acked-by: Giovanni Gherdovich Link: https://lkml.kernel.org/r/1803209.Mvru99baaF@kreacher --- arch/x86/kernel/smpboot.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 8ca66af..117e24f 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -2083,6 +2084,23 @@ static void init_counter_refs(void) this_cpu_write(arch_prev_mperf, mperf); } +#ifdef CONFIG_PM_SLEEP +static struct syscore_ops freq_invariance_syscore_ops = { + .resume = init_counter_refs, +}; + +static void register_freq_invariance_syscore_ops(void) +{ + /* Bail out if registered already. */ + if (freq_invariance_syscore_ops.node.prev) + return; + + register_syscore_ops(&freq_invariance_syscore_ops); +} +#else +static inline void register_freq_invariance_syscore_ops(void) {} +#endif + static void init_freq_invariance(bool secondary, bool cppc_ready) { bool ret = false; @@ -2109,6 +2127,7 @@ static void init_freq_invariance(bool secondary, bool cppc_ready) if (ret) { init_counter_refs(); static_branch_enable(&arch_scale_freq_key); + register_freq_invariance_syscore_ops(); pr_info("Estimated ratio of average max frequency by base frequency (times 1024): %llu\n", arch_max_freq_ratio); } else { pr_debug("Couldn't determine max cpu frequency, necessary for scale-invariant accounting.\n");