From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932424AbcFOKXG (ORCPT ); Wed, 15 Jun 2016 06:23:06 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34133 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753285AbcFOKXB (ORCPT ); Wed, 15 Jun 2016 06:23:01 -0400 MIME-Version: 1.0 In-Reply-To: <20160615100029.GB32588@pd.tnic> References: <20160615100029.GB32588@pd.tnic> From: chenyu Date: Wed, 15 Jun 2016 18:22:59 +0800 Message-ID: Subject: Re: [RFC PATCH] x86: Move away from /dev/cpu/*/msr To: Borislav Petkov Cc: lkml , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Greg Kroah-Hartman , Thomas Renninger , Kan Liang , "Peter Zijlstra (Intel)" , "Rafael J. Wysocki" , Len Brown , Linux PM list Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 15, 2016 at 6:00 PM, Borislav Petkov wrote: > Comments are, as always, appreciated. > > --- > From: Borislav Petkov > Date: Wed, 15 Jun 2016 11:20:41 +0200 > Subject: [PATCH] Move away from msr.ko > > Take care of MSR_IA32_ENERGY_PERF_BIAS. > > Not-yet-signed-off-by: Borislav Petkov [cut] > +static ssize_t > +energy_policy_pref_hint_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + u64 epb; > + > + rdmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb); MSR_IA32_ENERGY_PERF_BIAS is of core scope, should we use rdmsr_on_cpu? > + > + return sprintf(buf, "%d\n", (unsigned int)(epb & 0xFULL)); > +} > + > +static ssize_t > +energy_policy_pref_hint_store(struct device *dev, struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + u32 val; > + u64 epb; > + > + if (kstrtou32(buf, 10, &val) < 0) > + return -EINVAL; > + > + if (val > 15) > + return -EINVAL; > + > + rdmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb); rdmsr_on_cpu? > + > + if ((epb & 0xf) == val) > + return count; > + > + wrmsrl(MSR_IA32_ENERGY_PERF_BIAS, (epb & ~0xFULL) | val); wrmsr_on_cpu? thanks, Yu