Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp477433img; Fri, 22 Mar 2019 02:04:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtFL70AOy5J0ALLcj1HmQvWnQnJkIErm022MFesgU0qYbSy235FpS6EA9FIcsdCV6yJpxn X-Received: by 2002:a62:b40b:: with SMTP id h11mr8028933pfn.108.1553245477248; Fri, 22 Mar 2019 02:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553245477; cv=none; d=google.com; s=arc-20160816; b=WNt2+8vu2N4JrFdvXj5JgeMhMuHR2CZ4X4SBk20wi2BXKQ9y5IfL9pnQqhyte2aytD pSL6mkNcuCIeLlUjZmqLHUqdIk4XHnRWvKO+MSViRontdDxF+IzVOx3Wg9p1Q+3kU0eR mCvQ5f4IQFX78Baz1bz3RZM6lbJMx4vVogyxWEDDrua2rxoKtIPU+zt2OyeaS+jjrtS1 LCgUNvudDpK3VdLRyF0KlyFusojMAgYakJoTN4hBgrFFv97Yf5C39arxnkFdaL626dAe wyKbE0zfYCUMLmDeiobTbcJJ2vqG28Iq07HeXukWRQE4hN296QhhO8xCbG+NzdOUVGVb H3Wg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=4MA1vCySRHfShJ0A3UpigxXo+bQX5YVOXHe1tl2aiZk=; b=tTdx5qYo9ZPNgNebSfE1E7qVJIDUCDwP/s+Z6EQzXmPkJQrVxUPLA+WoCCYEaTs7Z8 TSyvNQnVHeAAPkahUazJ50hAFjdr1CS3gXh/lSDTms2yq9UtKkP0N3jiReLvxtLD9qtn EFc7TdXgsQax49QDZ266UUqNQW+ecw7AXK+Bofv6L1b73urCpx6YUhYpm8q7NYc/Ks9o fRBkDU86Ve4q1HddVgKdVm/9OCO5d0rPjihILJ/7GTMPOQZhxu+C+3mGu7VDhNSKIEoU qX2avi9oFYlILU1kNa88xr++Zgq4/dXfDxYbjXr/wl+ovSj8WX6qNTnLdWygaG2cEAxV ybCg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si6764446plb.407.2019.03.22.02.04.22; Fri, 22 Mar 2019 02:04:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727798AbfCVJDe (ORCPT + 99 others); Fri, 22 Mar 2019 05:03:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:55028 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725981AbfCVJDe (ORCPT ); Fri, 22 Mar 2019 05:03:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1ECEAB00B; Fri, 22 Mar 2019 09:03:33 +0000 (UTC) Subject: Re: [PATCH 1/2] PM / arch: x86: Rework the MSR_IA32_ENERGY_PERF_BIAS handling To: "Rafael J. Wysocki" , x86 Cc: LKML , Len Brown , Linux PM , Srinivas Pandruvada , Laura Abbott , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Simon Schricker , Borislav Petkov References: <1637073.gl2OfxWTjI@aspire.rjw.lan> <1605148.8jT99SsvVP@aspire.rjw.lan> From: Hannes Reinecke Message-ID: <0754bf38-319e-f1a7-1ae6-fe2de548b882@suse.de> Date: Fri, 22 Mar 2019 10:03:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <1605148.8jT99SsvVP@aspire.rjw.lan> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/21/19 11:18 PM, 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 > --- > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)