From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932702AbcFOOAd (ORCPT ); Wed, 15 Jun 2016 10:00:33 -0400 Received: from mail.skyhub.de ([78.46.96.112]:40396 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753161AbcFOOAc (ORCPT ); Wed, 15 Jun 2016 10:00:32 -0400 Date: Wed, 15 Jun 2016 16:00:28 +0200 From: Borislav Petkov To: chenyu 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 Subject: Re: [RFC PATCH] x86: Move away from /dev/cpu/*/msr Message-ID: <20160615140028.GD32588@pd.tnic> References: <20160615100029.GB32588@pd.tnic> <20160615103622.GA19822@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160615103622.GA19822@pd.tnic> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 15, 2016 at 12:36:22PM +0200, Borislav Petkov wrote: > Ah, yes, good point. Will change. Ok, got a bit more involved - I also need to disable preemption around smp_call_function_single(). Here's what I have now. It seems to work too. static ssize_t energy_policy_pref_hint_show(struct device *dev, struct device_attribute *attr, char *buf) { u64 epb; preempt_disable(); if (rdmsrl_on_cpu(dev->id, MSR_IA32_ENERGY_PERF_BIAS, &epb)) epb = -1; preempt_enable(); 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; preempt_disable(); if (rdmsrl_on_cpu(dev->id, MSR_IA32_ENERGY_PERF_BIAS, &epb)) { count = -EINVAL; goto out; } if ((epb & 0xf) == val) goto out; if (wrmsrl_on_cpu(dev->id, MSR_IA32_ENERGY_PERF_BIAS, (epb & ~0xFULL) | val)) count = -EINVAL; out: preempt_enable(); return count; } -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.