From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932914AbcERRk2 (ORCPT ); Wed, 18 May 2016 13:40:28 -0400 Received: from www.linutronix.de ([62.245.132.108]:43614 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751967AbcERRk1 (ORCPT ); Wed, 18 May 2016 13:40:27 -0400 Date: Wed, 18 May 2016 19:38:33 +0200 (CEST) From: Thomas Gleixner To: David Carrillo-Cisneros cc: Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Ingo Molnar , Vikas Shivappa , Matt Fleming , Tony Luck , Stephane Eranian , Paul Turner , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 08/32] perf/x86/intel/cqm: add pmu sysfs attribute In-Reply-To: <1463007752-116802-9-git-send-email-davidcc@google.com> Message-ID: References: <1463007752-116802-1-git-send-email-davidcc@google.com> <1463007752-116802-9-git-send-email-davidcc@google.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 May 2016, David Carrillo-Cisneros wrote: > Expose max_recycle_threshold pmu attribute to user-space. > > Reviewed-by: Stephane Eranian > Signed-off-by: David Carrillo-Cisneros > --- > arch/x86/events/intel/cqm.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > > diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c > index 54f219f..225b0c8 100644 > --- a/arch/x86/events/intel/cqm.c > +++ b/arch/x86/events/intel/cqm.c > @@ -393,9 +393,57 @@ static struct attribute_group intel_cqm_format_group = { > .attrs = intel_cqm_formats_attr, > }; > > +static ssize_t > +max_recycle_threshold_show( > + struct device *dev, struct device_attribute *attr, char *page) > +{ > + ssize_t rv; > + > + monr_hrchy_acquire_mutexes(); > + rv = snprintf(page, PAGE_SIZE - 1, "%u\n", > + __intel_cqm_max_threshold); > + monr_hrchy_release_mutexes(); So we acquire a gazillion of mutexes to read a single variable? > + > + return rv; > +} > + > +static ssize_t > +max_recycle_threshold_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + unsigned int bytes; > + int ret; > + > + ret = kstrtouint(buf, 0, &bytes); That number is not limited by any means. So 0 ... UINT_MAX is valid, correct? > + if (ret) > + return ret; > + > + /* Mutex waits for rotation logic in all packages to complete. */ What's wrong with just setting the variable and let it take effect on the next rotation? That locking here is just pointless. It does not protect anything. > + monr_hrchy_acquire_mutexes(); > + > + __intel_cqm_max_threshold = bytes; > + > + monr_hrchy_release_mutexes(); Thanks, tglx