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


Groups > linux.kernel > #1300678 > unrolled thread

[PATCH v5 08/11] arm-cci: Provide hook for writing to PMU counters

Started by"Suzuki K. Poulose" <suzuki.poulose@arm.com>
First post2016-01-04 13:00 +0100
Last post2016-01-11 13:20 +0100
Articles 3 — 3 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 v5 08/11] arm-cci: Provide hook for writing to PMU counters "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2016-01-04 13:00 +0100
    Re: [PATCH v5 08/11] arm-cci: Provide hook for writing to PMU  counters Mark Rutland <mark.rutland@arm.com> - 2016-01-11 12:00 +0100
      Re: [PATCH v5 08/11] arm-cci: Provide hook for writing to PMU  counters "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> - 2016-01-11 13:20 +0100

#1300678 — [PATCH v5 08/11] arm-cci: Provide hook for writing to PMU counters

From"Suzuki K. Poulose" <suzuki.poulose@arm.com>
Date2016-01-04 13:00 +0100
Subject[PATCH v5 08/11] arm-cci: Provide hook for writing to PMU counters
Message-ID<qNbXS-2ZX-49@gated-at.bofh.it>
Add a hook for writing to CCI PMU counters. This callback
can be used for CCI models which requires some extra work
to program the PMU counter values. To accommodate group writes
and single counter writes, the call back accepts a bitmask
of the counter indices which need to be programmed with the
given value.

Cc: Punit Agrawal <punit.agrawal@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
---
 drivers/bus/arm-cci.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index 2f1fcf0..47c9581 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -134,6 +134,7 @@ struct cci_pmu_model {
 	struct event_range event_ranges[CCI_IF_MAX];
 	int (*validate_hw_event)(struct cci_pmu *, unsigned long);
 	int (*get_event_idx)(struct cci_pmu *, struct cci_pmu_hw_events *, unsigned long);
+	void (*write_counters)(struct cci_pmu *, unsigned long *, u32 val);
 };
 
 static struct cci_pmu_model cci_pmu_models[];
@@ -846,7 +847,15 @@ static void pmu_write_counter(struct perf_event *event, u32 value)
 		dev_err(&cci_pmu->plat_device->dev, "Invalid CCI PMU counter %d\n", idx);
 		return;
 	}
-	__pmu_write_counter(cci_pmu, value, idx);
+
+	if (cci_pmu->model->write_counters) {
+		unsigned long mask[BITS_TO_LONGS(cci_pmu->num_cntrs)];
+
+		memset(mask, 0, BITS_TO_LONGS(cci_pmu->num_cntrs) * sizeof(unsigned long));
+		set_bit(idx, mask);
+		cci_pmu->model->write_counters(cci_pmu, mask, value);
+	} else
+		__pmu_write_counter(cci_pmu, value, idx);
 }
 
 /* Write a value to a given set of counters */
@@ -861,7 +870,10 @@ static void __pmu_write_counters(struct cci_pmu *cci_pmu, unsigned long *mask, u
 static void __maybe_unused
 pmu_write_counters(struct cci_pmu *cci_pmu, unsigned long *mask, u32 value)
 {
-	__pmu_write_counters(cci_pmu, mask, value);
+	if (cci_pmu->model->write_counters)
+		cci_pmu->model->write_counters(cci_pmu, mask, value);
+	else
+		__pmu_write_counters(cci_pmu, mask, value);
 }
 
 static u64 pmu_event_update(struct perf_event *event)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1306059 — Re: [PATCH v5 08/11] arm-cci: Provide hook for writing to PMU counters

FromMark Rutland <mark.rutland@arm.com>
Date2016-01-11 12:00 +0100
SubjectRe: [PATCH v5 08/11] arm-cci: Provide hook for writing to PMU counters
Message-ID<qPImD-1cN-17@gated-at.bofh.it>
In reply to#1300678
On Mon, Jan 04, 2016 at 11:54:47AM +0000, Suzuki K. Poulose wrote:
> Add a hook for writing to CCI PMU counters. This callback
> can be used for CCI models which requires some extra work
> to program the PMU counter values. To accommodate group writes
> and single counter writes, the call back accepts a bitmask
> of the counter indices which need to be programmed with the
> given value.
> 
> Cc: Punit Agrawal <punit.agrawal@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/bus/arm-cci.c |   16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
> index 2f1fcf0..47c9581 100644
> --- a/drivers/bus/arm-cci.c
> +++ b/drivers/bus/arm-cci.c
> @@ -134,6 +134,7 @@ struct cci_pmu_model {
>  	struct event_range event_ranges[CCI_IF_MAX];
>  	int (*validate_hw_event)(struct cci_pmu *, unsigned long);
>  	int (*get_event_idx)(struct cci_pmu *, struct cci_pmu_hw_events *, unsigned long);
> +	void (*write_counters)(struct cci_pmu *, unsigned long *, u32 val);
>  };
>  
>  static struct cci_pmu_model cci_pmu_models[];
> @@ -846,7 +847,15 @@ static void pmu_write_counter(struct perf_event *event, u32 value)
>  		dev_err(&cci_pmu->plat_device->dev, "Invalid CCI PMU counter %d\n", idx);
>  		return;
>  	}
> -	__pmu_write_counter(cci_pmu, value, idx);
> +
> +	if (cci_pmu->model->write_counters) {
> +		unsigned long mask[BITS_TO_LONGS(cci_pmu->num_cntrs)];
> +
> +		memset(mask, 0, BITS_TO_LONGS(cci_pmu->num_cntrs) * sizeof(unsigned long));
> +		set_bit(idx, mask);
> +		cci_pmu->model->write_counters(cci_pmu, mask, value);
> +	} else
> +		__pmu_write_counter(cci_pmu, value, idx);
>  }

It would be much simpler to always log writes here, and only do the real
wirtes in batches when we re-enable the PMU (with appropriate
disable/enable calls in the IRQ handler).

We'd still need special hooks for CCIs which require a special dance to
program them, but all the logic to handle the writes would be in one
place.

This should work, regardless.

Thanks,
Mark.

>  
>  /* Write a value to a given set of counters */
> @@ -861,7 +870,10 @@ static void __pmu_write_counters(struct cci_pmu *cci_pmu, unsigned long *mask, u
>  static void __maybe_unused
>  pmu_write_counters(struct cci_pmu *cci_pmu, unsigned long *mask, u32 value)
>  {
> -	__pmu_write_counters(cci_pmu, mask, value);
> +	if (cci_pmu->model->write_counters)
> +		cci_pmu->model->write_counters(cci_pmu, mask, value);
> +	else
> +		__pmu_write_counters(cci_pmu, mask, value);
>  }
>  
>  static u64 pmu_event_update(struct perf_event *event)
> -- 
> 1.7.9.5
> 

[toc] | [prev] | [next] | [standalone]


#1306123 — Re: [PATCH v5 08/11] arm-cci: Provide hook for writing to PMU counters

From"Suzuki K. Poulose" <Suzuki.Poulose@arm.com>
Date2016-01-11 13:20 +0100
SubjectRe: [PATCH v5 08/11] arm-cci: Provide hook for writing to PMU counters
Message-ID<qPJC2-2eG-11@gated-at.bofh.it>
In reply to#1306059
On 11/01/16 10:54, Mark Rutland wrote:
> On Mon, Jan 04, 2016 at 11:54:47AM +0000, Suzuki K. Poulose wrote:

>>   static struct cci_pmu_model cci_pmu_models[];
>> @@ -846,7 +847,15 @@ static void pmu_write_counter(struct perf_event *event, u32 value)
>>   		dev_err(&cci_pmu->plat_device->dev, "Invalid CCI PMU counter %d\n", idx);
>>   		return;
>>   	}
>> -	__pmu_write_counter(cci_pmu, value, idx);
>> +
>> +	if (cci_pmu->model->write_counters) {
>> +		unsigned long mask[BITS_TO_LONGS(cci_pmu->num_cntrs)];
>> +
>> +		memset(mask, 0, BITS_TO_LONGS(cci_pmu->num_cntrs) * sizeof(unsigned long));
>> +		set_bit(idx, mask);
>> +		cci_pmu->model->write_counters(cci_pmu, mask, value);
>> +	} else
>> +		__pmu_write_counter(cci_pmu, value, idx);
>>   }
>
> It would be much simpler to always log writes here, and only do the real
> wirtes in batches when we re-enable the PMU (with appropriate
> disable/enable calls in the IRQ handler).
>
> We'd still need special hooks for CCIs which require a special dance to
> program them, but all the logic to handle the writes would be in one
> place.

This one is only there for the writes from the irq handler. Now that
we have decided to disable pmu there, we could batch this one too.

Cheers
Suzuki

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web