Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp734458img; Fri, 22 Mar 2019 07:30:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSuv1ciwBOcRf3rlSReQkYnuK3F0BanQg+cWYEjsr0aWCJQ3/s/EooFXp310N1044LB3Vp X-Received: by 2002:a63:f541:: with SMTP id e1mr9144925pgk.388.1553265040533; Fri, 22 Mar 2019 07:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553265040; cv=none; d=google.com; s=arc-20160816; b=fGCYvf2bemegw36wCIU9CW8NEYV1Zb7mEkm6aYzEeif4BBeLcftrNDWNLDtIpCvDrM Hhx7EhhnCr5pwvq2WnN3w46xwHQnE//nKDtJpOcMzqPW3YNqt40LmfwAWmHvpu0J8giX hOUDx4xSv8lxmS1pAmJLGICgJYdp6wdCcJi5gsfPBELkYdeFUiJ1DdzTE5jfpAFcSx36 H2GRzX+bj8159Fx14Tzrjmt2R/V95zE/UHp1BgyrKFnYZwPD75+kJESuBjpI6U4ObGzI hbgEuzw95712OvEYf5YJh0gmOENEd4jvbS+Fd4wzI6512bf8SWt+djWPoIOxVmcCpqoP dcJQ== 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=xROtQ3lPB34jz8QZgjrxqlObnm92aodmjQzoFMjYC7M=; b=riiSaKWGXP1Uh/SEf1oky6oOi/ZQx0cNsFs0Idw7I4euy0Rc9mLScOHR4eBd8nS/d0 iD/qMDB9Ykkyy60lKcTubZXzZWG1+PQotakvxAX+4orSqDsuJ2Ar3lbDlQWjWFsL+Dai 8ssuRF6skor+fFczpAx277dTC1VXv3ptTLwyup6Kon6IdQdPszeStvZSbGgyUO5vT0zZ pNFc4QU/Ivv6XnSQjfHmEemw2OU4fqcjNZ3RiYzezM9NrynH2hL5Nm77eeo3gXBeUGZ3 blzRK53UIJb86nYI6opq9NZFnpEjYCuprlqO8GYRwGjE6r78YhQ6INvrVEsENoC1Ga+b cLLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=b6bLss9l; 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 q64si6993087pga.492.2019.03.22.07.30.24; Fri, 22 Mar 2019 07:30:40 -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=b6bLss9l; 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 S1728773AbfCVO20 (ORCPT + 99 others); Fri, 22 Mar 2019 10:28:26 -0400 Received: from mail.skyhub.de ([5.9.137.197]:36922 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727996AbfCVO2Z (ORCPT ); Fri, 22 Mar 2019 10:28:25 -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 35C441EC00FF; Fri, 22 Mar 2019 15:28:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1553264904; 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=xROtQ3lPB34jz8QZgjrxqlObnm92aodmjQzoFMjYC7M=; b=b6bLss9lHSosC9ZX5ABsBjMDCXuViAaXiCOAELSagxAFG0F0Qs4B5PappTlmXKUHzNHhrI GfpLmzRw83WKWB+nVGKYlDAGFLYJMX1n8ka2u8u2j/ObR6zCW4sKSEtd1AfghYKMVvIT85 ZIqNkFq1l1N5xhO2HlcesDAd2T4Pba8= Date: Fri, 22 Mar 2019 15:28:28 +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: <20190322142828.GA12472@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) One more reason to control MSR accesses from userspace. I'm working on a series to even completely forbid accesses to some MSRs over /dev/msr so I think accessing MSR_IA32_ENERGY_PERF_BIAS solely over the new interface in patch 2 would be much better. So, you're carrying those and you'd like to have an ACK from me? Btw, a couple of nitpicks below. > Index: linux-pm/arch/x86/kernel/cpu/intel_epb.c > =================================================================== > --- /dev/null > +++ linux-pm/arch/x86/kernel/cpu/intel_epb.c > @@ -0,0 +1,131 @@ > +// SPDX-License-Identifier: GPL-2.0 ... > +static DEFINE_PER_CPU(u8, saved_epb); > + > +#define EPB_MASK 0x0fULL > +#define EPB_SAVED 0x10ULL > + > +static int intel_epb_save(void) I'd drop that "intel_epb_" prefix from those static functions, but your call... > +{ > + u64 epb; > + > + rdmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb); > + /* > + * Ensure that saved_epb will always be nonzero after this write even if > + * the EPB value read from the MSR is 0. > + */ > + this_cpu_write(saved_epb, (epb & EPB_MASK) | EPB_SAVED); > + > + return 0; > +} ... > Index: linux-pm/Documentation/admin-guide/pm/intel_epb.rst > =================================================================== > --- /dev/null > +++ linux-pm/Documentation/admin-guide/pm/intel_epb.rst WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 #345: FILE: Documentation/admin-guide/pm/intel_epb.rst:1: +====================================== > @@ -0,0 +1,6 @@ > +====================================== > +Intel Performance and Energy Bias Hint > +====================================== > + > +.. kernel-doc:: arch/x86/kernel/cpu/intel_epb.c > + :doc: overview > Index: linux-pm/Documentation/admin-guide/pm/working-state.rst > =================================================================== > --- linux-pm.orig/Documentation/admin-guide/pm/working-state.rst > +++ linux-pm/Documentation/admin-guide/pm/working-state.rst > @@ -8,3 +8,4 @@ Working-State Power Management > cpuidle > cpufreq > intel_pstate > + intel_epb > -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.