Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3132274img; Mon, 25 Mar 2019 04:32:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXW42bymIGd3FG/u0ADKNpef+A7IzKIlSrzBW1u8q8iiGFT1axG7ruWPpHJ0XqNRZsjl2Z X-Received: by 2002:a62:bd09:: with SMTP id a9mr23329321pff.61.1553513568586; Mon, 25 Mar 2019 04:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553513568; cv=none; d=google.com; s=arc-20160816; b=L9CXyYfw1AfoUUPpQ4t33numZekwkeb8Wi1/vQI5dyfePmswzRquyAqI8co+Oz87cT EnEaB6kBREXxv2aIIJJ5MSVBVf9Du5j2X5ouUTKSZZFzWUt4m3ERFjyIXuJNqFlzPEeL x/NAe6Jx7Gez1J7NUFvoev9coB3Kbh/IBrsIH037uufSZjBA5MUyJOt1DOaSt0HPXAVp +FRBa88O8Ete5Vmht2xTswz1ic3W0q8gN5/vTJBzxNNoiNCzWFvsuG+bPZh9bw31T8J5 cTvb906sZgG7a8eAnd9L9QgMaipEToa84HKv3a4F/Qm/ZcRGyG61Icl4ojAitUX+nsDC SRGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zPNHNJzzrCYQq1d7EtTW+RAp59xLlj7afJzzPP5UHlo=; b=dy7+ApiwuiE0qzPOfextOvvphy0l+7zYFeRvw+uEMplEjmD+FFMEnnpEMF9CwYbarb TsbJa9vpnnyaQSzHFOplpg0QWkaKxu3Og+XGR/WbpgyfGWHA7fZVvmFGWX1z3xwmm3r2 cn3MYyqzc6LYdjl3H2QpW5DUGfGk7D6d+ELeGJmMQU3MT8kjxLuWM9YYwZzf8LV+DOQF 0uhiQB2DuZlDFB+a3E6Sym9oR8h/ykpqxOsthjLtwXEXgGS6Xc9BArN79zxt5SukCyfY TC9K/vbAgMBt0+wzTkE4ds/sImkoQEFfhlachb14f/m+h0tpb4HTrhYAvCAd72t7utwK kxFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="BD/yLuGI"; 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=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 139si13186975pga.219.2019.03.25.04.32.33; Mon, 25 Mar 2019 04:32:48 -0700 (PDT) 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=@alien8.de header.s=dkim header.b="BD/yLuGI"; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730856AbfCYLbV (ORCPT + 99 others); Mon, 25 Mar 2019 07:31:21 -0400 Received: from mail.skyhub.de ([5.9.137.197]:38842 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728869AbfCYLbV (ORCPT ); Mon, 25 Mar 2019 07:31:21 -0400 Received: from zn.tnic (p200300EC2F098000329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:8000:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id F05941EC0987; Mon, 25 Mar 2019 12:31:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1553513480; h=from:from: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:in-reply-to:in-reply-to: references:references; bh=zPNHNJzzrCYQq1d7EtTW+RAp59xLlj7afJzzPP5UHlo=; b=BD/yLuGIu/jeF711f70oitT8LxEsLIwixeWvWeaRTRLZLH62qaj0wnaWcAVrN2rCIG1Aot T5Yr5OaHm3HpiwD4xVcjKPmzsuxbkdFZk1hXgRLHXfj/6fgQp9slHis0CKwcbh38SkL79d Iv+mwcDf/B3sXoMypAGz6YSdJ5Fi7T4= Date: Mon, 25 Mar 2019 12:31:23 +0100 From: Borislav Petkov To: "Rafael J. Wysocki" Cc: x86 , LKML , Len Brown , Linux PM , Srinivas Pandruvada , Laura Abbott , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Simon Schricker , Hannes Reinecke Subject: Re: [PATCH 1/2] PM / arch: x86: Rework the MSR_IA32_ENERGY_PERF_BIAS handling Message-ID: <20190325113123.GF12016@zn.tnic> References: <1637073.gl2OfxWTjI@aspire.rjw.lan> <1605148.8jT99SsvVP@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1605148.8jT99SsvVP@aspire.rjw.lan> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 11:18:01PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > The current handling of MSR_IA32_ENERGY_PERF_BIAS in the kernel is > problematic, because it may cause changes made by user space to that > MSR (with the help of the x86_energy_perf_policy tool, for example) > to be lost every time a CPU goes offline and then back online as well > as during system-wide power management transitions into sleep states > and back into the working state. > > The first problem is that if the current EPB value for a CPU going > online is 0 ('performance'), the kernel will change it to 6 ('normal') > regardless of whether or not this is the first bring-up of that CPU. > That also happens during system-wide resume from sleep states > (including, but not limited to, hibernation). However, the EPB may > have been adjusted by user space this way and the kernel should not > blindly override that setting. > > The second problem is that if the platform firmware resets the EPB > values for any CPUs during system-wide resume from a sleep state, > the kernel will not restore their previous EPB values that may > have been set by user space before the preceding system-wide > suspend transition. Again, that behavior may at least be confusing > from the user space perspective. > > In order to address these issues, rework the handling of > MSR_IA32_ENERGY_PERF_BIAS so that the EPB value is saved on CPU > offline and restored on CPU online as well as (for the boot CPU) > during the syscore stages of system-wide suspend and resume > transitions, respectively. > > However, retain the policy by which the EPB is set to 6 ('normal') > on the first bring-up of each CPU if its initial value is 0, based > on the observation that 0 may mean 'not initialized' just as well as > 'performance' in that case. > > While at it, move the MSR_IA32_ENERGY_PERF_BIAS handling code into > a separate file and document it in Documentation/admin-guide. > > Fixes: abe48b108247 (x86, intel, power: Initialize MSR_IA32_ENERGY_PERF_BIAS) > Fixes: b51ef52df71c (x86/cpu: Restore MSR_IA32_ENERGY_PERF_BIAS after resume) > Reported-by: Thomas Renninger > Signed-off-by: Rafael J. Wysocki Acked-by: Borislav Petkov -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.