Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp358278ybz; Wed, 29 Apr 2020 01:19:43 -0700 (PDT) X-Google-Smtp-Source: APiQypKPUgQxv/O4CK4qmhJp91tz6sdYbbyb1O5cn2hn5tVT0NU28sN9jQ+GSVsu+C7N4r8mzbJP X-Received: by 2002:a17:906:90c1:: with SMTP id v1mr1421231ejw.322.1588148383419; Wed, 29 Apr 2020 01:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588148383; cv=none; d=google.com; s=arc-20160816; b=fu1bpNbEkHHC5Ugwdb1XOXoX4JPIScyKWPXQcySo1wNMeDTZ3mEI3dSd9yYEMv3WcU vPPHS7ISbCo3VKDMQiXoOEuaW0WNRg+i/mV31SwN1dAPk51KgiggWkD+UpZILK/6CIGC L/mcosB6XpniAcdSF1XRLSc0glvBx0MreBFLpu3PsVktVUfoDLYe6e9N7Hke2HDdl9KL IhGoqB26+Bz1pwFgA5imba38iizIa5X35DeAjP/VfIA3HTzPZVHJbimoDpAQ6R2Xezb8 es3dgS/ewAdxlpegoCo/lxmU5qM5VuopUJD544wiEGkrBgPq6CSJqrwBoD3HtRkiLJqr 3DRA== 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:date:to:from:subject:message-id; bh=zCt/fvSP11aGz26/WgHcomC20JTQE4Ujl1lfmjPCCog=; b=u71LkgJBYkcam5DgrLGSq50u7DAQsWrIGs/+KQH2z+YFw+ot2+8JFfKmQm/hzCs1th kZtw+TddsTYjQtOQg2fP+W2vjYGQwH5l/BqaUq75vz0Eu2HnVQ2U/ewdeyvbDD2/J0Tw 9j5x9YiYVIjDiq6ksrbX27H9WR4kpiHla0dJTi/Gwai5g4Ov83ZDuaU2Ntzg305uXG/Z Y6weK0MX5UpMkFnyeaS3R+7qvglwYUsu/NjepkaDyPK/JYH5VZ49AiFxEsTyAh79mCFq nfNAEZrlBm0Y/qBKnRtBYJF1jx2yzFZjKaDarV/ByYBYdXhzfJmPwck21Pbqwxr4+qqU PlDQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw27si2999082edb.289.2020.04.29.01.19.19; Wed, 29 Apr 2020 01:19:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726621AbgD2IPO (ORCPT + 99 others); Wed, 29 Apr 2020 04:15:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:50174 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbgD2IPO (ORCPT ); Wed, 29 Apr 2020 04:15:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5DA56AB8F; Wed, 29 Apr 2020 08:15:11 +0000 (UTC) Message-ID: <1588148110.21179.63.camel@suse.cz> Subject: Re: [PATCH] x86: move turbo_disabled() out of intel_set_max_freq_ratio From: Giovanni Gherdovich To: Li RongQing , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, rafael.j.wysocki@intel.com Date: Wed, 29 Apr 2020 10:15:10 +0200 In-Reply-To: <1588125007-8799-1-git-send-email-lirongqing@baidu.com> References: <1588125007-8799-1-git-send-email-lirongqing@baidu.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-04-29 at 09:50 +0800, Li RongQing wrote: > move the turbo_disabled before intel_set_max_freq_ratio, > when turbo is disabled, the max frequency ratio is a const > value, it is unnecessary to read MSR_TURBO_RATIO* msr to > compute > > Signed-off-by: Li RongQing > --- > arch/x86/kernel/smpboot.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index fe3ab9632f3b..8979c459df2f 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -1987,7 +1987,7 @@ static bool intel_set_max_freq_ratio(void) > out: > arch_turbo_freq_ratio = div_u64(turbo_freq * SCHED_CAPACITY_SCALE, > base_freq); > - arch_set_max_freq_ratio(turbo_disabled()); > + arch_set_max_freq_ratio(false); > return true; > } > > @@ -2009,6 +2009,9 @@ static void init_freq_invariance(void) > if (smp_processor_id() != 0 || !boot_cpu_has(X86_FEATURE_APERFMPERF)) > return; > > + if (turbo_disabled()) > + return; > + > if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) > ret = intel_set_max_freq_ratio(); > Hello, the problem is that turbo can be enabled/disabled by the firmware at runtime, after the machine has booted. This happens for example with the Dell XPS 13, where turbo gets disabled by the firmware if the machine is disconnected from AC power and runs on battery. The laptop could boot on battery (turbo disabled), then after some time the user connects the AC power supply, turbo gets enabled, and with your patch we wouldn't know what is the turbo_freq/base_freq ratio to do frequency invariance (we skipped reading MSR_TURBO_RATIO_LIMIT at boot because turbo was disabled at that timed). This behavior was requested by reviewers in this thread: https://lore.kernel.org/lkml/1906426.HDqaVa71mF@kreacher/ and implemented with 918229cdd5ab ("x86/intel_pstate: Handle runtime turbo disablement/enablement in frequency invariance"). Thanks, Giovanni Gherdovich