Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1399591 > unrolled thread

[PATCH v2 08/32] perf/x86/intel/cqm: add pmu sysfs attribute

Started byDavid Carrillo-Cisneros <davidcc@google.com>
First post2016-05-12 01:10 +0200
Last post2016-05-18 19:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 08/32] perf/x86/intel/cqm: add pmu sysfs attribute David Carrillo-Cisneros <davidcc@google.com> - 2016-05-12 01:10 +0200
    Re: [PATCH v2 08/32] perf/x86/intel/cqm: add pmu sysfs attribute Thomas Gleixner <tglx@linutronix.de> - 2016-05-18 19:50 +0200

#1399591 — [PATCH v2 08/32] perf/x86/intel/cqm: add pmu sysfs attribute

FromDavid Carrillo-Cisneros <davidcc@google.com>
Date2016-05-12 01:10 +0200
Subject[PATCH v2 08/32] perf/x86/intel/cqm: add pmu sysfs attribute
Message-ID<rxLqs-1mv-61@gated-at.bofh.it>
Expose max_recycle_threshold pmu attribute to user-space.

Reviewed-by: Stephane Eranian <eranian@google.com>
Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
---
 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

[toc] | [next] | [standalone]


#1403195

FromThomas Gleixner <tglx@linutronix.de>
Date2016-05-18 19:50 +0200
Message-ID<rAdLA-5bb-15@gated-at.bofh.it>
In reply to#1399591
On Wed, 11 May 2016, David Carrillo-Cisneros wrote:

> Expose max_recycle_threshold pmu attribute to user-space.
> 
> Reviewed-by: Stephane Eranian <eranian@google.com>
> Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
> ---
>  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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web