mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -tip] perf_counter tools: check for valid cache operations
@ 2009-06-25 11:46 Jaswinder Singh Rajput
  2009-06-25 12:10 ` Ingo Molnar
  2009-06-25 12:12 ` [tip:perfcounters/urgent] perf_counter tools: Check " tip-bot for Jaswinder Singh Rajput
  0 siblings, 2 replies; 3+ messages in thread
From: Jaswinder Singh Rajput @ 2009-06-25 11:46 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, Peter Zijlstra, LKML


Made new table for cache operartion stat 'hw_cache_stat' as :
 L1I : Read and prefetch only
 ITLB and BPU : Read-only

introduce is_cache_op_valid() for cache operation validity

And checks for valid cache operations.

Reported-by : Ingo Molnar <mingo@elte.hu>
Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
 tools/perf/util/parse-events.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 06af2fa..7939a21 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -90,6 +90,34 @@ static char *hw_cache_result[][MAX_ALIASES] = {
 	{ "Miss"							},
 };
 
+#define C(x)		PERF_COUNT_HW_CACHE_##x
+#define CACHE_READ	(1 << C(OP_READ))
+#define CACHE_WRITE	(1 << C(OP_WRITE))
+#define CACHE_PREFETCH	(1 << C(OP_PREFETCH))
+#define COP(x)		(1 << x)
+
+/*
+ * cache operartion stat
+ * L1I : Read and prefetch only
+ * ITLB and BPU : Read-only
+ */
+static unsigned long hw_cache_stat[C(MAX)] = {
+ [C(L1D)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
+ [C(L1I)]	= (CACHE_READ | CACHE_PREFETCH),
+ [C(LL)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
+ [C(DTLB)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
+ [C(ITLB)]	= (CACHE_READ),
+ [C(BPU)]	= (CACHE_READ),
+};
+
+static int is_cache_op_valid(u8 cache_type, u8 cache_op)
+{
+	if (hw_cache_stat[cache_type] & COP(cache_op))
+		return 1;	/* valid */
+	else
+		return 0;	/* invalid */
+}
+
 char *event_name(int counter)
 {
 	u64 config = attrs[counter].config;
@@ -123,6 +151,8 @@ char *event_name(int counter)
 		if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX)
 			return "unknown-ext-hardware-cache-result";
 
+		if (!is_cache_op_valid(cache_type, cache_op))
+			return "invalid-cache";
 		sprintf(name, "%s-Cache-%s-%ses",
 			hw_cache[cache_type][0],
 			hw_cache_op[cache_op][0],
@@ -179,6 +209,9 @@ parse_generic_hw_symbols(const char *str, struct perf_counter_attr *attr)
 	if (cache_op == -1)
 		cache_op = PERF_COUNT_HW_CACHE_OP_READ;
 
+	if (!is_cache_op_valid(cache_type, cache_op))
+		return -EINVAL;
+
 	cache_result = parse_aliases(str, hw_cache_result,
 					PERF_COUNT_HW_CACHE_RESULT_MAX);
 	/*
-- 
1.6.0.6




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -tip] perf_counter tools: check for valid cache operations
  2009-06-25 11:46 [PATCH -tip] perf_counter tools: check for valid cache operations Jaswinder Singh Rajput
@ 2009-06-25 12:10 ` Ingo Molnar
  2009-06-25 12:12 ` [tip:perfcounters/urgent] perf_counter tools: Check " tip-bot for Jaswinder Singh Rajput
  1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2009-06-25 12:10 UTC (permalink / raw)
  To: Jaswinder Singh Rajput; +Cc: Thomas Gleixner, Peter Zijlstra, LKML


* Jaswinder Singh Rajput <jaswinder@kernel.org> wrote:

> Made new table for cache operartion stat 'hw_cache_stat' as :
>  L1I : Read and prefetch only
>  ITLB and BPU : Read-only
> 
> introduce is_cache_op_valid() for cache operation validity
> 
> And checks for valid cache operations.
> 
> Reported-by : Ingo Molnar <mingo@elte.hu>
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> ---
>  tools/perf/util/parse-events.c |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 06af2fa..7939a21 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -90,6 +90,34 @@ static char *hw_cache_result[][MAX_ALIASES] = {
>  	{ "Miss"							},
>  };
>  
> +#define C(x)		PERF_COUNT_HW_CACHE_##x
> +#define CACHE_READ	(1 << C(OP_READ))
> +#define CACHE_WRITE	(1 << C(OP_WRITE))
> +#define CACHE_PREFETCH	(1 << C(OP_PREFETCH))
> +#define COP(x)		(1 << x)
> +
> +/*
> + * cache operartion stat
> + * L1I : Read and prefetch only
> + * ITLB and BPU : Read-only
> + */
> +static unsigned long hw_cache_stat[C(MAX)] = {
> + [C(L1D)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
> + [C(L1I)]	= (CACHE_READ | CACHE_PREFETCH),
> + [C(LL)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
> + [C(DTLB)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
> + [C(ITLB)]	= (CACHE_READ),
> + [C(BPU)]	= (CACHE_READ),
> +};
> +
> +static int is_cache_op_valid(u8 cache_type, u8 cache_op)
> +{
> +	if (hw_cache_stat[cache_type] & COP(cache_op))
> +		return 1;	/* valid */
> +	else
> +		return 0;	/* invalid */
> +}
> +
>  char *event_name(int counter)
>  {
>  	u64 config = attrs[counter].config;
> @@ -123,6 +151,8 @@ char *event_name(int counter)
>  		if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX)
>  			return "unknown-ext-hardware-cache-result";
>  
> +		if (!is_cache_op_valid(cache_type, cache_op))
> +			return "invalid-cache";
>  		sprintf(name, "%s-Cache-%s-%ses",
>  			hw_cache[cache_type][0],
>  			hw_cache_op[cache_op][0],
> @@ -179,6 +209,9 @@ parse_generic_hw_symbols(const char *str, struct perf_counter_attr *attr)
>  	if (cache_op == -1)
>  		cache_op = PERF_COUNT_HW_CACHE_OP_READ;
>  
> +	if (!is_cache_op_valid(cache_type, cache_op))
> +		return -EINVAL;
> +
>  	cache_result = parse_aliases(str, hw_cache_result,
>  					PERF_COUNT_HW_CACHE_RESULT_MAX);

Yes, this looks better - applied. The names-shortening patch now 
doesnt apply but i guess that's expected.

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perfcounters/urgent] perf_counter tools: Check for valid cache operations
  2009-06-25 11:46 [PATCH -tip] perf_counter tools: check for valid cache operations Jaswinder Singh Rajput
  2009-06-25 12:10 ` Ingo Molnar
@ 2009-06-25 12:12 ` tip-bot for Jaswinder Singh Rajput
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Jaswinder Singh Rajput @ 2009-06-25 12:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, peterz, jaswinder, jaswinderrajput,
	tglx, mingo

Commit-ID:  06813f6c743420c16f9248ab59bd2e68a2de57ba
Gitweb:     http://git.kernel.org/tip/06813f6c743420c16f9248ab59bd2e68a2de57ba
Author:     Jaswinder Singh Rajput <jaswinder@kernel.org>
AuthorDate: Thu, 25 Jun 2009 17:16:07 +0530
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 25 Jun 2009 14:08:49 +0200

perf_counter tools: Check for valid cache operations

Made new table for cache operartion stat 'hw_cache_stat' as:

 L1I : Read and prefetch only
 ITLB and BPU : Read-only

introduce is_cache_op_valid() for cache operation validity

And checks for valid cache operations.

Reported-by : Ingo Molnar <mingo@elte.hu>
Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1245930367.5308.33.camel@localhost.localdomain>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 tools/perf/util/parse-events.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 06af2fa..7939a21 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -90,6 +90,34 @@ static char *hw_cache_result[][MAX_ALIASES] = {
 	{ "Miss"							},
 };
 
+#define C(x)		PERF_COUNT_HW_CACHE_##x
+#define CACHE_READ	(1 << C(OP_READ))
+#define CACHE_WRITE	(1 << C(OP_WRITE))
+#define CACHE_PREFETCH	(1 << C(OP_PREFETCH))
+#define COP(x)		(1 << x)
+
+/*
+ * cache operartion stat
+ * L1I : Read and prefetch only
+ * ITLB and BPU : Read-only
+ */
+static unsigned long hw_cache_stat[C(MAX)] = {
+ [C(L1D)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
+ [C(L1I)]	= (CACHE_READ | CACHE_PREFETCH),
+ [C(LL)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
+ [C(DTLB)]	= (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
+ [C(ITLB)]	= (CACHE_READ),
+ [C(BPU)]	= (CACHE_READ),
+};
+
+static int is_cache_op_valid(u8 cache_type, u8 cache_op)
+{
+	if (hw_cache_stat[cache_type] & COP(cache_op))
+		return 1;	/* valid */
+	else
+		return 0;	/* invalid */
+}
+
 char *event_name(int counter)
 {
 	u64 config = attrs[counter].config;
@@ -123,6 +151,8 @@ char *event_name(int counter)
 		if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX)
 			return "unknown-ext-hardware-cache-result";
 
+		if (!is_cache_op_valid(cache_type, cache_op))
+			return "invalid-cache";
 		sprintf(name, "%s-Cache-%s-%ses",
 			hw_cache[cache_type][0],
 			hw_cache_op[cache_op][0],
@@ -179,6 +209,9 @@ parse_generic_hw_symbols(const char *str, struct perf_counter_attr *attr)
 	if (cache_op == -1)
 		cache_op = PERF_COUNT_HW_CACHE_OP_READ;
 
+	if (!is_cache_op_valid(cache_type, cache_op))
+		return -EINVAL;
+
 	cache_result = parse_aliases(str, hw_cache_result,
 					PERF_COUNT_HW_CACHE_RESULT_MAX);
 	/*

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-06-25 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-25 11:46 [PATCH -tip] perf_counter tools: check for valid cache operations Jaswinder Singh Rajput
2009-06-25 12:10 ` Ingo Molnar
2009-06-25 12:12 ` [tip:perfcounters/urgent] perf_counter tools: Check " tip-bot for Jaswinder Singh Rajput

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome