From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932159AbcEKXC4 (ORCPT ); Wed, 11 May 2016 19:02:56 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:33035 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932076AbcEKXCv (ORCPT ); Wed, 11 May 2016 19:02:51 -0400 From: David Carrillo-Cisneros To: Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Ingo Molnar Cc: Vikas Shivappa , Matt Fleming , Tony Luck , Stephane Eranian , Paul Turner , David Carrillo-Cisneros , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 08/32] perf/x86/intel/cqm: add pmu sysfs attribute Date: Wed, 11 May 2016 16:02:08 -0700 Message-Id: <1463007752-116802-9-git-send-email-davidcc@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1463007752-116802-1-git-send-email-davidcc@google.com> References: <1463007752-116802-1-git-send-email-davidcc@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); + + 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); + if (ret) + return ret; + + /* Mutex waits for rotation logic in all packages to complete. */ + monr_hrchy_acquire_mutexes(); + + __intel_cqm_max_threshold = bytes; + + monr_hrchy_release_mutexes(); + + return count; +} + +static DEVICE_ATTR_RW(max_recycle_threshold); + +static struct attribute *intel_cqm_attrs[] = { + &dev_attr_max_recycle_threshold.attr, + NULL, +}; + +static const struct attribute_group intel_cqm_group = { + .attrs = intel_cqm_attrs, +}; + static const struct attribute_group *intel_cqm_attr_groups[] = { &intel_cqm_events_group, &intel_cqm_format_group, + &intel_cqm_group, NULL, }; -- 2.8.0.rc3.226.g39d4020