[PATCH] media: cx25840: mark pad sig_types to fix cx231xx init

2019-01-14 Thread Cody P Schafer
Without this, we get failures like this when the kernel attempts to
initialize a cx231xx device:

[16046.153653] cx231xx 3-1.2:1.1: New device Hauppauge Hauppauge Device 
@ 480 Mbps (2040:c200) with 6 interfaces
[16046.153900] cx231xx 3-1.2:1.1: can't change interface 3 alt no. to 
3: Max. Pkt size = 0
[16046.153907] cx231xx 3-1.2:1.1: Identified as Hauppauge USB Live 2 
(card=9)
[16046.154350] i2c i2c-11: Added multiplexed i2c bus 13
[16046.154379] i2c i2c-11: Added multiplexed i2c bus 14
[16046.267194] cx25840 10-0044: cx23102 A/V decoder found @ 0x88 
(cx231xx #0-0)
[16048.424551] cx25840 10-0044: loaded v4l-cx231xx-avcore-01.fw 
firmware (16382 bytes)
[16048.463224] cx231xx 3-1.2:1.1: v4l2 driver version 0.0.3
[16048.567878] cx231xx 3-1.2:1.1: Registered video device video2 [v4l2]
[16048.568001] cx231xx 3-1.2:1.1: Registered VBI device vbi0
[16048.568419] cx231xx 3-1.2:1.1: audio EndPoint Addr 0x83, Alternate 
settings: 3
[16048.568425] cx231xx 3-1.2:1.1: video EndPoint Addr 0x84, Alternate 
settings: 5
[16048.568431] cx231xx 3-1.2:1.1: VBI EndPoint Addr 0x85, Alternate 
settings: 2
[16048.568436] cx231xx 3-1.2:1.1: sliced CC EndPoint Addr 0x86, 
Alternate settings: 2
[16048.568448] usb 3-1.2: couldn't get decoder output pad for V4L I/O
[16048.568453] cx231xx 3-1.2:1.1: V4L2 device vbi0 deregistered
[16048.568579] cx231xx 3-1.2:1.1: V4L2 device video2 deregistered
[16048.569001] cx231xx: probe of 3-1.2:1.1 failed with error -22

Likely a regession since Commit 9d6d20e652c0
("media: v4l2-mc: switch it to use the new approach to setup pipelines")
(v4.19-rc1-100-g9d6d20e652c0), which introduced the use of
PAD_SIGNAL_DV within v4l2_mc_create_media_graph().

This also modifies cx25840 to remove the VBI pad, matching the action
taken in Commit 092a37875a22 ("media: v4l2: remove VBI output pad").

Fixes: 9d6d20e652c0 ("media: v4l2-mc: switch it to use the new approach to 
setup pipelines")
Cc: sta...@vger.kernel.org
Signed-off-by: Cody P Schafer 
---
 drivers/media/i2c/cx25840/cx25840-core.c | 3 ++-
 drivers/media/i2c/cx25840/cx25840-core.h | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c 
b/drivers/media/i2c/cx25840/cx25840-core.c
index b168bf3635b6..8b0b8b5aa531 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5216,8 +5216,9 @@ static int cx25840_probe(struct i2c_client *client,
 * those extra inputs. So, let's add it only when needed.
 */
state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
+   state->pads[CX25840_PAD_INPUT].sig_type = PAD_SIGNAL_ANALOG;
state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
-   state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
+   state->pads[CX25840_PAD_VID_OUT].sig_type = PAD_SIGNAL_DV;
sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
ret = media_entity_pads_init(>entity, ARRAY_SIZE(state->pads),
diff --git a/drivers/media/i2c/cx25840/cx25840-core.h 
b/drivers/media/i2c/cx25840/cx25840-core.h
index c323b1af1f83..9efefa15d090 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.h
+++ b/drivers/media/i2c/cx25840/cx25840-core.h
@@ -40,7 +40,6 @@ enum cx25840_model {
 enum cx25840_media_pads {
CX25840_PAD_INPUT,
CX25840_PAD_VID_OUT,
-   CX25840_PAD_VBI_OUT,
 
CX25840_NUM_PADS
 };
-- 
2.20.1



[PATCH] rbtree: clarify documentation of rbtree_postorder_for_each_entry_safe()

2015-10-04 Thread Cody P Schafer
Noticed that commit a20135ffbc44 ("writeback: don't drain
bdi_writeback_congested on bdi destruction") added a usage of
rbtree_postorder_for_each_entry_safe() in mm/backing-dev.c which appears
to try to rb_erase() elements from an rbtree while iterating over it
using rbtree_postorder_for_each_entry_safe().

Doing this will cause random nodes to be missed by the iteration because
rb_erase() may rebalance the tree, changing the ordering that we're
trying to iterate over.

The previous documentation for rbtree_postorder_for_each_entry_safe()
wasn't clear that this wasn't allowed, it was taken from the docs for
list_for_each_entry_safe(), where erasing isn't a problem due to
list_del() not reordering.

Explicitly warn developers about this potential pit-fall.

Note that I haven't fixed the actual issue that (it appears) the commit
referenced above introduced (not familiar enough with that code).

In general (and in this case), the patterns to follow are:
 - switch to rb_first() + rb_erase(), don't use
   rbtree_postorder_for_each_entry_safe().
 - keep the postorder iteration and don't rb_erase() at all. Instead
   just clear the fields of rb_node & cgwb_congested_tree as required by
   other users of those structures.

CC: Tejun Heo 
Signed-off-by: Cody P Schafer 
---
 include/linux/rbtree.h | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 830c499..39de3df 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -101,13 +101,21 @@ static inline void rb_link_node_rcu(struct rb_node *node, 
struct rb_node *parent
})
 
 /**
- * rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of
- * given type safe against removal of rb_node entry
+ * rbtree_postorder_for_each_entry_safe - iterate in post-order over rb_root of
+ * given type allowing the backing memory of @pos to be invalidated
  *
  * @pos:   the 'type *' to use as a loop cursor.
  * @n: another 'type *' to use as temporary storage
  * @root:  'rb_root *' of the rbtree.
  * @field: the name of the rb_node field within 'type'.
+ *
+ * This function provides a similar guarantee as list_for_each_entry_safe() and
+ * allows the iteration to continue independent of changes to @pos by the body
+ * of the loop.
+ *
+ * Note, however, that it cannot handle other modifications that re-order the
+ * rbtree it is iterating over. This includes calling rb_erase() on @pos, as
+ * rb_erase() may rebalance the tree, causing us to miss some nodes.
  */
 #define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
for (pos = rb_entry_safe(rb_first_postorder(root), typeof(*pos), 
field); \
-- 
2.4.9

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


[PATCH] rbtree: clarify documentation of rbtree_postorder_for_each_entry_safe()

2015-10-04 Thread Cody P Schafer
Noticed that commit a20135ffbc44 ("writeback: don't drain
bdi_writeback_congested on bdi destruction") added a usage of
rbtree_postorder_for_each_entry_safe() in mm/backing-dev.c which appears
to try to rb_erase() elements from an rbtree while iterating over it
using rbtree_postorder_for_each_entry_safe().

Doing this will cause random nodes to be missed by the iteration because
rb_erase() may rebalance the tree, changing the ordering that we're
trying to iterate over.

The previous documentation for rbtree_postorder_for_each_entry_safe()
wasn't clear that this wasn't allowed, it was taken from the docs for
list_for_each_entry_safe(), where erasing isn't a problem due to
list_del() not reordering.

Explicitly warn developers about this potential pit-fall.

Note that I haven't fixed the actual issue that (it appears) the commit
referenced above introduced (not familiar enough with that code).

In general (and in this case), the patterns to follow are:
 - switch to rb_first() + rb_erase(), don't use
   rbtree_postorder_for_each_entry_safe().
 - keep the postorder iteration and don't rb_erase() at all. Instead
   just clear the fields of rb_node & cgwb_congested_tree as required by
   other users of those structures.

CC: Tejun Heo <t...@kernel.org>
Signed-off-by: Cody P Schafer <d...@codyps.com>
---
 include/linux/rbtree.h | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 830c499..39de3df 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -101,13 +101,21 @@ static inline void rb_link_node_rcu(struct rb_node *node, 
struct rb_node *parent
})
 
 /**
- * rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of
- * given type safe against removal of rb_node entry
+ * rbtree_postorder_for_each_entry_safe - iterate in post-order over rb_root of
+ * given type allowing the backing memory of @pos to be invalidated
  *
  * @pos:   the 'type *' to use as a loop cursor.
  * @n: another 'type *' to use as temporary storage
  * @root:  'rb_root *' of the rbtree.
  * @field: the name of the rb_node field within 'type'.
+ *
+ * This function provides a similar guarantee as list_for_each_entry_safe() and
+ * allows the iteration to continue independent of changes to @pos by the body
+ * of the loop.
+ *
+ * Note, however, that it cannot handle other modifications that re-order the
+ * rbtree it is iterating over. This includes calling rb_erase() on @pos, as
+ * rb_erase() may rebalance the tree, causing us to miss some nodes.
  */
 #define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
for (pos = rb_entry_safe(rb_first_postorder(root), typeof(*pos), 
field); \
-- 
2.4.9

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


Re: [PATCH v7 7/7] powerpc/perf/hv-24x7: Document sysfs event description entries

2015-02-22 Thread Cody P Schafer
On Fri, Jan 30, 2015 at 4:46 PM, Sukadev Bhattiprolu
 wrote:
> From: Cody P Schafer 
>
> Signed-off-by: Cody P Schafer 
> Signed-off-by: Sukadev Bhattiprolu 
> ---
> Changelog[v6]
> Update Contact info to Linux on Power Developer list
>
>  .../testing/sysfs-bus-event_source-devices-hv_24x7 | 22 
> ++
>  1 file changed, 22 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 
> b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> index 32f3f5f..f893337 100644
> --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> @@ -21,3 +21,25 @@ Contact: Linux on PowerPC Developer List 
> 
>  Description:
> Exposes the "version" field of the 24x7 catalog. This is also
> extractable from the provided binary "catalog" sysfs entry.
> +
> +What:  /sys/bus/event_source/devices/hv_24x7/event_descs/
> +Date:  February 2014
> +Contact:   Linux on PowerPC Developer List 
> 
> +Description:
> +   Provides the description of a particular event as provided by
> +   the firmware. If firmware does not provide a description, no
> +   file will be created.
> +
> +   Note that the event-name lacks the domain suffix appended for
> +   events in the events/ dir.

I'm probably a bit late on this, but:

Please consider removing the need for a user to know about the "domain
suffixes" (which, as far as I know are 24x7 specific).
If anyone else ever wants to add firmware/hardware/kernel provided
event descriptions, they'll need to special case these ones as they
don't match up with the actual event names.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH] perf: Implement read_group() PMU operation

2015-02-22 Thread Cody P Schafer
On Thu, Feb 5, 2015 at 9:59 PM, Sukadev Bhattiprolu
 wrote:
> From: Sukadev Bhattiprolu 
> Date: Thu Feb  5 20:56:20 EST 2015 -0300
> Subject: [RFC][PATCH] perf: Implement read_group() PMU operation
>
> This is a lightly tested, exploratory patch to allow PMUs to return
> several counters at once. Appreciate any comments :-)
>

Back when I was fiddling with this, I started looking into changing
the {start,commit,cancel}_txn to operate on (struct perf_event *)
rather than (struct pmu *), and commit_txn would generate the actual
request & reads based on the perf_event's group (sounds similar but
not identical to what Peter's proposed previously).

The key bit I was concerned about was that these "PMUs" aren't
actually physical hw, so it made a bit more sense to pin the grouping
to a group rather than a txn over a PMU.

[Of course, I never did confirm if that actually fit with how perf was
modeling txns]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v7 7/7] powerpc/perf/hv-24x7: Document sysfs event description entries

2015-02-22 Thread Cody P Schafer
On Fri, Jan 30, 2015 at 4:46 PM, Sukadev Bhattiprolu
suka...@linux.vnet.ibm.com wrote:
 From: Cody P Schafer c...@linux.vnet.ibm.com

 Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
 Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
 ---
 Changelog[v6]
 Update Contact info to Linux on Power Developer list

  .../testing/sysfs-bus-event_source-devices-hv_24x7 | 22 
 ++
  1 file changed, 22 insertions(+)

 diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 
 b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
 index 32f3f5f..f893337 100644
 --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
 +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
 @@ -21,3 +21,25 @@ Contact: Linux on PowerPC Developer List 
 linuxppc-...@lists.ozlabs.org
  Description:
 Exposes the version field of the 24x7 catalog. This is also
 extractable from the provided binary catalog sysfs entry.
 +
 +What:  /sys/bus/event_source/devices/hv_24x7/event_descs/event-name
 +Date:  February 2014
 +Contact:   Linux on PowerPC Developer List 
 linuxppc-...@lists.ozlabs.org
 +Description:
 +   Provides the description of a particular event as provided by
 +   the firmware. If firmware does not provide a description, no
 +   file will be created.
 +
 +   Note that the event-name lacks the domain suffix appended for
 +   events in the events/ dir.

I'm probably a bit late on this, but:

Please consider removing the need for a user to know about the domain
suffixes (which, as far as I know are 24x7 specific).
If anyone else ever wants to add firmware/hardware/kernel provided
event descriptions, they'll need to special case these ones as they
don't match up with the actual event names.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH] perf: Implement read_group() PMU operation

2015-02-22 Thread Cody P Schafer
On Thu, Feb 5, 2015 at 9:59 PM, Sukadev Bhattiprolu
suka...@linux.vnet.ibm.com wrote:
 From: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
 Date: Thu Feb  5 20:56:20 EST 2015 -0300
 Subject: [RFC][PATCH] perf: Implement read_group() PMU operation

 This is a lightly tested, exploratory patch to allow PMUs to return
 several counters at once. Appreciate any comments :-)


Back when I was fiddling with this, I started looking into changing
the {start,commit,cancel}_txn to operate on (struct perf_event *)
rather than (struct pmu *), and commit_txn would generate the actual
request  reads based on the perf_event's group (sounds similar but
not identical to what Peter's proposed previously).

The key bit I was concerned about was that these PMUs aren't
actually physical hw, so it made a bit more sense to pin the grouping
to a group rather than a txn over a PMU.

[Of course, I never did confirm if that actually fit with how perf was
modeling txns]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Support parsing parameterized events

2015-01-28 Thread tip-bot for Cody P Schafer
Commit-ID:  688d4dfcdd624192cbf03c08402e444d1d11f294
Gitweb: http://git.kernel.org/tip/688d4dfcdd624192cbf03c08402e444d1d11f294
Author: Cody P Schafer 
AuthorDate: Wed, 7 Jan 2015 17:13:50 -0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 21 Jan 2015 13:24:32 -0300

perf tools: Support parsing parameterized events

Enable event specification like:

pmu/event_name,param1=0x1,param2=0x4/

Assuming that

/sys/bus/event_source/devices/pmu/events/event_name

Contains something like

param2=?,bar=1,param1=?

Signed-off-by: Cody P Schafer 
Signed-off-by: Sukadev Bhattiprolu 
Acked-by: Jiri Olsa 
Cc: Cody P Schafer 
Cc: Haren Myneni 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1420679633-28856-2-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/parse-events.h |  1 +
 tools/perf/util/pmu.c  | 74 +++---
 2 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index db2cf78..ca226ce 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -71,6 +71,7 @@ struct parse_events_term {
int type_val;
int type_term;
struct list_head list;
+   bool used;
 };
 
 struct parse_events_evlist {
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 5c9c494..bfbecf7 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -551,31 +551,68 @@ static void pmu_format_value(unsigned long *format, __u64 
value, __u64 *v,
 }
 
 /*
+ * Term is a string term, and might be a param-term. Try to look up it's value
+ * in the remaining terms.
+ * - We have a term like "base-or-format-term=param-term",
+ * - We need to find the value supplied for "param-term" (with param-term named
+ *   in a config string) later on in the term list.
+ */
+static int pmu_resolve_param_term(struct parse_events_term *term,
+ struct list_head *head_terms,
+ __u64 *value)
+{
+   struct parse_events_term *t;
+
+   list_for_each_entry(t, head_terms, list) {
+   if (t->type_val == PARSE_EVENTS__TERM_TYPE_NUM) {
+   if (!strcmp(t->config, term->config)) {
+   t->used = true;
+   *value = t->val.num;
+   return 0;
+   }
+   }
+   }
+
+   if (verbose)
+   printf("Required parameter '%s' not specified\n", term->config);
+
+   return -1;
+}
+
+/*
  * Setup one of config[12] attr members based on the
  * user input data - term parameter.
  */
 static int pmu_config_term(struct list_head *formats,
   struct perf_event_attr *attr,
   struct parse_events_term *term,
+  struct list_head *head_terms,
   bool zero)
 {
struct perf_pmu_format *format;
__u64 *vp;
+   __u64 val;
+
+   /*
+* If this is a parameter we've already used for parameterized-eval,
+* skip it in normal eval.
+*/
+   if (term->used)
+   return 0;
 
/*
-* Support only for hardcoded and numnerial terms.
 * Hardcoded terms should be already in, so nothing
 * to be done for them.
 */
if (parse_events__is_hardcoded_term(term))
return 0;
 
-   if (term->type_val != PARSE_EVENTS__TERM_TYPE_NUM)
-   return -EINVAL;
-
format = pmu_find_format(formats, term->config);
-   if (!format)
+   if (!format) {
+   if (verbose)
+   printf("Invalid event/parameter '%s'\n", term->config);
return -EINVAL;
+   }
 
switch (format->value) {
case PERF_PMU_FORMAT_VALUE_CONFIG:
@@ -592,11 +629,25 @@ static int pmu_config_term(struct list_head *formats,
}
 
/*
-* XXX If we ever decide to go with string values for
-* non-hardcoded terms, here's the place to translate
-* them into value.
+* Either directly use a numeric term, or try to translate string terms
+* using event parameters.
 */
-   pmu_format_value(format->bits, term->val.num, vp, zero);
+   if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM)
+   val = term->val.num;
+   else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) {
+   if (strcmp(term->val.str, "?")) {
+   if (verbose)
+   pr_info("Invalid sysfs entry %s=%s\n",
+

[tip:perf/core] perf tools: Extend format_alias() to include event parameters

2015-01-28 Thread tip-bot for Cody P Schafer
Commit-ID:  aaea36174991ff39c7a18044660db86527100c55
Gitweb: http://git.kernel.org/tip/aaea36174991ff39c7a18044660db86527100c55
Author: Cody P Schafer 
AuthorDate: Wed, 7 Jan 2015 17:13:51 -0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 21 Jan 2015 13:24:33 -0300

perf tools: Extend format_alias() to include event parameters

This causes `perf list pmu` to show parameters for parameterized events
like:

  pmu/event_name,param1=?,param2=?/ [Kernel PMU event]

An example:

  hv_24x7/HPM_TLBIE__PHYS_CORE,core=?/ [Kernel PMU event]

Signed-off-by: Cody P Schafer 
Signed-off-by: Sukadev Bhattiprolu 
Acked-by: Jiri Olsa 
Cc: Cody P Schafer 
Cc: Haren Myneni 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1420679633-28856-3-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/pmu.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index bfbecf7..4841167 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -819,10 +819,36 @@ void perf_pmu__set_format(unsigned long *bits, long from, 
long to)
set_bit(b, bits);
 }
 
+static int sub_non_neg(int a, int b)
+{
+   if (b > a)
+   return 0;
+   return a - b;
+}
+
 static char *format_alias(char *buf, int len, struct perf_pmu *pmu,
  struct perf_pmu_alias *alias)
 {
-   snprintf(buf, len, "%s/%s/", pmu->name, alias->name);
+   struct parse_events_term *term;
+   int used = snprintf(buf, len, "%s/%s", pmu->name, alias->name);
+
+   list_for_each_entry(term, >terms, list) {
+   if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR)
+   used += snprintf(buf + used, sub_non_neg(len, used),
+   ",%s=%s", term->config,
+   term->val.str);
+   }
+
+   if (sub_non_neg(len, used) > 0) {
+   buf[used] = '/';
+   used++;
+   }
+   if (sub_non_neg(len, used) > 0) {
+   buf[used] = '\0';
+   used++;
+   } else
+   buf[len - 1] = '\0';
+
return buf;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Document parameterized and symbolic events

2015-01-28 Thread tip-bot for Cody P Schafer
Commit-ID:  f9ab9c196d015f3bd8f6bd1c30785c5a49542323
Gitweb: http://git.kernel.org/tip/f9ab9c196d015f3bd8f6bd1c30785c5a49542323
Author: Cody P Schafer 
AuthorDate: Wed, 7 Jan 2015 17:13:53 -0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 21 Jan 2015 13:24:33 -0300

perf tools: Document parameterized and symbolic events

Signed-off-by: Cody P Schafer 
Signed-off-by: Sukadev Bhattiprolu 
Acked-by: Jiri Olsa 
Cc: Cody P Schafer 
Cc: Haren Myneni 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1420679633-28856-5-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-list.txt   | 13 +
 tools/perf/Documentation/perf-record.txt | 12 
 tools/perf/Documentation/perf-stat.txt   | 20 
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-list.txt 
b/tools/perf/Documentation/perf-list.txt
index cbb4f74..3e2aec9 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -89,6 +89,19 @@ raw encoding of 0x1A8 can be used:
 You should refer to the processor specific documentation for getting these
 details. Some of them are referenced in the SEE ALSO section below.
 
+PARAMETERIZED EVENTS
+
+
+Some pmu events listed by 'perf-list' will be displayed with '?' in them. For
+example:
+
+  hv_gpci/dtbp_ptitc,phys_processor_idx=?/
+
+This means that when provided as an event, a value for '?' must
+also be supplied. For example:
+
+  perf stat -C 0 -e 'hv_gpci/dtbp_ptitc,phys_processor_idx=0x2/' ...
+
 OPTIONS
 ---
 
diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index af9a54e..7d8df2e 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -33,6 +33,18 @@ OPTIONS
 - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
  hexadecimal event descriptor.
 
+   - a symbolically formed PMU event like 'pmu/param1=0x3,param2/' where
+ 'param1', 'param2', etc are defined as formats for the PMU in
+ /sys/bus/event_sources/devices//format/*.
+
+   - a symbolically formed event like 'pmu/config=M,config1=N,config3=K/'
+
+  where M, N, K are numbers (in decimal, hex, octal format). Acceptable
+  values for each of 'config', 'config1' and 'config2' are defined by
+  corresponding entries in 
/sys/bus/event_sources/devices//format/*
+  param1 and param2 are defined as formats for the PMU in:
+  /sys/bus/event_sources/devices//format/*
+
 - a hardware breakpoint event in the form of '\mem:addr[:access]'
   where addr is the address in memory you want to break in.
   Access is the memory access type (read, write, execute) it can
diff --git a/tools/perf/Documentation/perf-stat.txt 
b/tools/perf/Documentation/perf-stat.txt
index 29ee857..04e150d 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -25,10 +25,22 @@ OPTIONS
 
 -e::
 --event=::
-   Select the PMU event. Selection can be a symbolic event name
-   (use 'perf list' to list all events) or a raw PMU
-   event (eventsel+umask) in the form of rNNN where NNN is a
-hexadecimal event descriptor.
+   Select the PMU event. Selection can be:
+
+   - a symbolic event name (use 'perf list' to list all events)
+
+   - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
+ hexadecimal event descriptor.
+
+   - a symbolically formed event like 'pmu/param1=0x3,param2/' where
+ param1 and param2 are defined as formats for the PMU in
+ /sys/bus/event_sources/devices//format/*
+
+   - a symbolically formed event like 'pmu/config=M,config1=N,config2=K/'
+ where M, N, K are numbers (in decimal, hex, octal format).
+ Acceptable values for each of 'config', 'config1' and 'config2'
+ parameters are defined by corresponding entries in
+ /sys/bus/event_sources/devices//format/*
 
 -i::
 --no-inherit::
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf Documentation: Add event parameters

2015-01-28 Thread tip-bot for Cody P Schafer
Commit-ID:  98a43e0e9917059da32db89829b0eb95453a11ee
Gitweb: http://git.kernel.org/tip/98a43e0e9917059da32db89829b0eb95453a11ee
Author: Cody P Schafer 
AuthorDate: Wed, 7 Jan 2015 17:13:52 -0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 21 Jan 2015 13:24:33 -0300

perf Documentation: Add event parameters

Event parameters are a basic way for partial events to be specified in
sysfs with per-event names given to the fields that need to be filled in
when using a particular event.

It is intended for supporting cases where the single 'cpu' parameter is
insufficient. For example, POWER 8 has events for physical
sockets/cores/cpus that are accessible from with virtual machines. To
keep using the single 'cpu' parameter we'd need to perform a mapping
between Linux's cpus and the physical machine's cpus (in this case Linux
is running under a hypervisor). This isn't possible because bindings
between our cpus and physical cpus may not be fixed, and we probably
won't have a "cpu" on each physical cpu.

Signed-off-by: Cody P Schafer 
Signed-off-by: Sukadev Bhattiprolu 
Acked-by: Jiri Olsa 
Cc: Cody P Schafer 
Cc: Haren Myneni 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Sukadev Bhattiprolu 
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1420679633-28856-4-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 Documentation/ABI/testing/sysfs-bus-event_source-devices-events | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index 20979f8..505f080 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -52,12 +52,18 @@ Description:Per-pmu performance monitoring events 
specific to the running syste
event=0x2abc
event=0x423,inv,cmask=0x3
domain=0x1,offset=0x8,starting_index=0x
+   domain=0x1,offset=0x8,core=?
 
Each of the assignments indicates a value to be assigned to a
particular set of bits (as defined by the format file
corresponding to the ) in the perf_event structure passed
to the perf_open syscall.
 
+   In the case of the last example, a value replacing "?" would
+   need to be provided by the user selecting the particular event.
+   This is referred to as "event parameterization". Event
+   parameters have the format 'param=?'.
+
 What: /sys/bus/event_source/devices//events/.unit
 Date: 2014/02/24
 Contact:   Linux kernel mailing list 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Document parameterized and symbolic events

2015-01-28 Thread tip-bot for Cody P Schafer
Commit-ID:  f9ab9c196d015f3bd8f6bd1c30785c5a49542323
Gitweb: http://git.kernel.org/tip/f9ab9c196d015f3bd8f6bd1c30785c5a49542323
Author: Cody P Schafer c...@linux.vnet.ibm.com
AuthorDate: Wed, 7 Jan 2015 17:13:53 -0800
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Wed, 21 Jan 2015 13:24:33 -0300

perf tools: Document parameterized and symbolic events

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Acked-by: Jiri Olsa jo...@kernel.org
Cc: Cody P Schafer d...@codyps.com
Cc: Haren Myneni hb...@us.ibm.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Michael Ellerman m...@ellerman.id.au
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1420679633-28856-5-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/Documentation/perf-list.txt   | 13 +
 tools/perf/Documentation/perf-record.txt | 12 
 tools/perf/Documentation/perf-stat.txt   | 20 
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-list.txt 
b/tools/perf/Documentation/perf-list.txt
index cbb4f74..3e2aec9 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -89,6 +89,19 @@ raw encoding of 0x1A8 can be used:
 You should refer to the processor specific documentation for getting these
 details. Some of them are referenced in the SEE ALSO section below.
 
+PARAMETERIZED EVENTS
+
+
+Some pmu events listed by 'perf-list' will be displayed with '?' in them. For
+example:
+
+  hv_gpci/dtbp_ptitc,phys_processor_idx=?/
+
+This means that when provided as an event, a value for '?' must
+also be supplied. For example:
+
+  perf stat -C 0 -e 'hv_gpci/dtbp_ptitc,phys_processor_idx=0x2/' ...
+
 OPTIONS
 ---
 
diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index af9a54e..7d8df2e 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -33,6 +33,18 @@ OPTIONS
 - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
  hexadecimal event descriptor.
 
+   - a symbolically formed PMU event like 'pmu/param1=0x3,param2/' where
+ 'param1', 'param2', etc are defined as formats for the PMU in
+ /sys/bus/event_sources/devices/pmu/format/*.
+
+   - a symbolically formed event like 'pmu/config=M,config1=N,config3=K/'
+
+  where M, N, K are numbers (in decimal, hex, octal format). Acceptable
+  values for each of 'config', 'config1' and 'config2' are defined by
+  corresponding entries in 
/sys/bus/event_sources/devices/pmu/format/*
+  param1 and param2 are defined as formats for the PMU in:
+  /sys/bus/event_sources/devices/pmu/format/*
+
 - a hardware breakpoint event in the form of '\mem:addr[:access]'
   where addr is the address in memory you want to break in.
   Access is the memory access type (read, write, execute) it can
diff --git a/tools/perf/Documentation/perf-stat.txt 
b/tools/perf/Documentation/perf-stat.txt
index 29ee857..04e150d 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -25,10 +25,22 @@ OPTIONS
 
 -e::
 --event=::
-   Select the PMU event. Selection can be a symbolic event name
-   (use 'perf list' to list all events) or a raw PMU
-   event (eventsel+umask) in the form of rNNN where NNN is a
-hexadecimal event descriptor.
+   Select the PMU event. Selection can be:
+
+   - a symbolic event name (use 'perf list' to list all events)
+
+   - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
+ hexadecimal event descriptor.
+
+   - a symbolically formed event like 'pmu/param1=0x3,param2/' where
+ param1 and param2 are defined as formats for the PMU in
+ /sys/bus/event_sources/devices/pmu/format/*
+
+   - a symbolically formed event like 'pmu/config=M,config1=N,config2=K/'
+ where M, N, K are numbers (in decimal, hex, octal format).
+ Acceptable values for each of 'config', 'config1' and 'config2'
+ parameters are defined by corresponding entries in
+ /sys/bus/event_sources/devices/pmu/format/*
 
 -i::
 --no-inherit::
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Support parsing parameterized events

2015-01-28 Thread tip-bot for Cody P Schafer
Commit-ID:  688d4dfcdd624192cbf03c08402e444d1d11f294
Gitweb: http://git.kernel.org/tip/688d4dfcdd624192cbf03c08402e444d1d11f294
Author: Cody P Schafer c...@linux.vnet.ibm.com
AuthorDate: Wed, 7 Jan 2015 17:13:50 -0800
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Wed, 21 Jan 2015 13:24:32 -0300

perf tools: Support parsing parameterized events

Enable event specification like:

pmu/event_name,param1=0x1,param2=0x4/

Assuming that

/sys/bus/event_source/devices/pmu/events/event_name

Contains something like

param2=?,bar=1,param1=?

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Acked-by: Jiri Olsa jo...@kernel.org
Cc: Cody P Schafer d...@codyps.com
Cc: Haren Myneni hb...@us.ibm.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Michael Ellerman m...@ellerman.id.au
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1420679633-28856-2-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/util/parse-events.h |  1 +
 tools/perf/util/pmu.c  | 74 +++---
 2 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index db2cf78..ca226ce 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -71,6 +71,7 @@ struct parse_events_term {
int type_val;
int type_term;
struct list_head list;
+   bool used;
 };
 
 struct parse_events_evlist {
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 5c9c494..bfbecf7 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -551,31 +551,68 @@ static void pmu_format_value(unsigned long *format, __u64 
value, __u64 *v,
 }
 
 /*
+ * Term is a string term, and might be a param-term. Try to look up it's value
+ * in the remaining terms.
+ * - We have a term like base-or-format-term=param-term,
+ * - We need to find the value supplied for param-term (with param-term named
+ *   in a config string) later on in the term list.
+ */
+static int pmu_resolve_param_term(struct parse_events_term *term,
+ struct list_head *head_terms,
+ __u64 *value)
+{
+   struct parse_events_term *t;
+
+   list_for_each_entry(t, head_terms, list) {
+   if (t-type_val == PARSE_EVENTS__TERM_TYPE_NUM) {
+   if (!strcmp(t-config, term-config)) {
+   t-used = true;
+   *value = t-val.num;
+   return 0;
+   }
+   }
+   }
+
+   if (verbose)
+   printf(Required parameter '%s' not specified\n, term-config);
+
+   return -1;
+}
+
+/*
  * Setup one of config[12] attr members based on the
  * user input data - term parameter.
  */
 static int pmu_config_term(struct list_head *formats,
   struct perf_event_attr *attr,
   struct parse_events_term *term,
+  struct list_head *head_terms,
   bool zero)
 {
struct perf_pmu_format *format;
__u64 *vp;
+   __u64 val;
+
+   /*
+* If this is a parameter we've already used for parameterized-eval,
+* skip it in normal eval.
+*/
+   if (term-used)
+   return 0;
 
/*
-* Support only for hardcoded and numnerial terms.
 * Hardcoded terms should be already in, so nothing
 * to be done for them.
 */
if (parse_events__is_hardcoded_term(term))
return 0;
 
-   if (term-type_val != PARSE_EVENTS__TERM_TYPE_NUM)
-   return -EINVAL;
-
format = pmu_find_format(formats, term-config);
-   if (!format)
+   if (!format) {
+   if (verbose)
+   printf(Invalid event/parameter '%s'\n, term-config);
return -EINVAL;
+   }
 
switch (format-value) {
case PERF_PMU_FORMAT_VALUE_CONFIG:
@@ -592,11 +629,25 @@ static int pmu_config_term(struct list_head *formats,
}
 
/*
-* XXX If we ever decide to go with string values for
-* non-hardcoded terms, here's the place to translate
-* them into value.
+* Either directly use a numeric term, or try to translate string terms
+* using event parameters.
 */
-   pmu_format_value(format-bits, term-val.num, vp, zero);
+   if (term-type_val == PARSE_EVENTS__TERM_TYPE_NUM)
+   val = term-val.num;
+   else if (term-type_val == PARSE_EVENTS__TERM_TYPE_STR) {
+   if (strcmp(term-val.str, ?)) {
+   if (verbose)
+   pr_info(Invalid sysfs

[tip:perf/core] perf tools: Extend format_alias() to include event parameters

2015-01-28 Thread tip-bot for Cody P Schafer
Commit-ID:  aaea36174991ff39c7a18044660db86527100c55
Gitweb: http://git.kernel.org/tip/aaea36174991ff39c7a18044660db86527100c55
Author: Cody P Schafer c...@linux.vnet.ibm.com
AuthorDate: Wed, 7 Jan 2015 17:13:51 -0800
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Wed, 21 Jan 2015 13:24:33 -0300

perf tools: Extend format_alias() to include event parameters

This causes `perf list pmu` to show parameters for parameterized events
like:

  pmu/event_name,param1=?,param2=?/ [Kernel PMU event]

An example:

  hv_24x7/HPM_TLBIE__PHYS_CORE,core=?/ [Kernel PMU event]

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Acked-by: Jiri Olsa jo...@kernel.org
Cc: Cody P Schafer d...@codyps.com
Cc: Haren Myneni hb...@us.ibm.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Michael Ellerman m...@ellerman.id.au
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1420679633-28856-3-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/util/pmu.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index bfbecf7..4841167 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -819,10 +819,36 @@ void perf_pmu__set_format(unsigned long *bits, long from, 
long to)
set_bit(b, bits);
 }
 
+static int sub_non_neg(int a, int b)
+{
+   if (b  a)
+   return 0;
+   return a - b;
+}
+
 static char *format_alias(char *buf, int len, struct perf_pmu *pmu,
  struct perf_pmu_alias *alias)
 {
-   snprintf(buf, len, %s/%s/, pmu-name, alias-name);
+   struct parse_events_term *term;
+   int used = snprintf(buf, len, %s/%s, pmu-name, alias-name);
+
+   list_for_each_entry(term, alias-terms, list) {
+   if (term-type_val == PARSE_EVENTS__TERM_TYPE_STR)
+   used += snprintf(buf + used, sub_non_neg(len, used),
+   ,%s=%s, term-config,
+   term-val.str);
+   }
+
+   if (sub_non_neg(len, used)  0) {
+   buf[used] = '/';
+   used++;
+   }
+   if (sub_non_neg(len, used)  0) {
+   buf[used] = '\0';
+   used++;
+   } else
+   buf[len - 1] = '\0';
+
return buf;
 }
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf Documentation: Add event parameters

2015-01-28 Thread tip-bot for Cody P Schafer
Commit-ID:  98a43e0e9917059da32db89829b0eb95453a11ee
Gitweb: http://git.kernel.org/tip/98a43e0e9917059da32db89829b0eb95453a11ee
Author: Cody P Schafer c...@linux.vnet.ibm.com
AuthorDate: Wed, 7 Jan 2015 17:13:52 -0800
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Wed, 21 Jan 2015 13:24:33 -0300

perf Documentation: Add event parameters

Event parameters are a basic way for partial events to be specified in
sysfs with per-event names given to the fields that need to be filled in
when using a particular event.

It is intended for supporting cases where the single 'cpu' parameter is
insufficient. For example, POWER 8 has events for physical
sockets/cores/cpus that are accessible from with virtual machines. To
keep using the single 'cpu' parameter we'd need to perform a mapping
between Linux's cpus and the physical machine's cpus (in this case Linux
is running under a hypervisor). This isn't possible because bindings
between our cpus and physical cpus may not be fixed, and we probably
won't have a cpu on each physical cpu.

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Acked-by: Jiri Olsa jo...@kernel.org
Cc: Cody P Schafer d...@codyps.com
Cc: Haren Myneni hb...@us.ibm.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Michael Ellerman m...@ellerman.id.au
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1420679633-28856-4-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 Documentation/ABI/testing/sysfs-bus-event_source-devices-events | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index 20979f8..505f080 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -52,12 +52,18 @@ Description:Per-pmu performance monitoring events 
specific to the running syste
event=0x2abc
event=0x423,inv,cmask=0x3
domain=0x1,offset=0x8,starting_index=0x
+   domain=0x1,offset=0x8,core=?
 
Each of the assignments indicates a value to be assigned to a
particular set of bits (as defined by the format file
corresponding to the term) in the perf_event structure passed
to the perf_open syscall.
 
+   In the case of the last example, a value replacing ? would
+   need to be provided by the user selecting the particular event.
+   This is referred to as event parameterization. Event
+   parameters have the format 'param=?'.
+
 What: /sys/bus/event_source/devices/pmu/events/event.unit
 Date: 2014/02/24
 Contact:   Linux kernel mailing list linux-kernel@vger.kernel.org
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 1/4] tools/perf: support parsing parameterized events

2014-12-05 Thread Cody P Schafer
On Thu, Dec 4, 2014 at 7:44 AM, Jiri Olsa  wrote:
> On Tue, Dec 02, 2014 at 06:09:35PM -0800, Sukadev Bhattiprolu wrote:
>> From: Cody P Schafer 
>>
>> Enable event specification like:
>>
>>   pmu/event_name,param1=0x1,param2=0x4/
>>
>> Assuming that
>>
>>   /sys/bus/event_source/devices/pmu/events/event_name
>>
>> Contains something like
>>
>>   param2=$foo,bar=1,param1=$baz
>
> oops.. sorry to be PITA on this one.. I might have missed something
> in the previous discussion but I guess I might have finally some
> opinion on this ;-)
>
> here's how I think your patchset works:
>
> in /sys/bus/event_source/devices/pmu/events/event_name you can actually have:
>
>param2=foo,bar=1,param1=baz
>
> notice no '$', thats what you add later in 'perf list' output, right?
>
> Moreover it actually does not matter whats in value 'param2=HERE',
> because it's not used in the config code at all apart from the
> 'perf list' display processing.
>
> So when we discussed the '$' name way, I thought it'd be like:
>
> in /sys/bus/event_source/devices/pmu/events/event_name you have:
>   param2=$foo,bar=1,param1=$baz
>
> and on command line you'd use:
>   pmu/event_name,foo=0x1,bar=0x4/
>
> to assign directly to the $var, which would justify the $var
> syntax I think..
>

Agreed, what you've described above sounds like a good idea.

Compared to monopolizing all strings (which is what I did when
initialy writing this), using a '$' prefix would allow less pain when
some events suddenly need non-integer parameters.

> anyway we could assign directly to the param term name as you do,
> but I think we just need to mark the term as parametrized, like:
>
> in /sys/bus/event_source/devices/pmu/events/event_name you have:
>   param2=?,bar=1,param1=?
>
> and on command line you'd use:
>   pmu/event_name,param2=0x1,param1=0x4/
>
> while the config code would check that the param substitution is
> done only for terms with '?' in value, like 'param2=?' and not
> for all PARSE_EVENTS__TERM_TYPE_STR type terms (as of now)

I prefer the `foo=0x1` as mentioned previously: it makes the user
interface much less painful as we can have event-specific names for
register/hcall fields.

I'm pretty sure the code used to do this, not sure when it was removed
(haven't been following this patchset closely).

That said: I haven't fiddled with this code in a while (it's Suka's at
this point), and there might be arguments the other way on both of
those.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 1/4] tools/perf: support parsing parameterized events

2014-12-05 Thread Cody P Schafer
On Thu, Dec 4, 2014 at 7:44 AM, Jiri Olsa jo...@redhat.com wrote:
 On Tue, Dec 02, 2014 at 06:09:35PM -0800, Sukadev Bhattiprolu wrote:
 From: Cody P Schafer c...@linux.vnet.ibm.com

 Enable event specification like:

   pmu/event_name,param1=0x1,param2=0x4/

 Assuming that

   /sys/bus/event_source/devices/pmu/events/event_name

 Contains something like

   param2=$foo,bar=1,param1=$baz

 oops.. sorry to be PITA on this one.. I might have missed something
 in the previous discussion but I guess I might have finally some
 opinion on this ;-)

 here's how I think your patchset works:

 in /sys/bus/event_source/devices/pmu/events/event_name you can actually have:

param2=foo,bar=1,param1=baz

 notice no '$', thats what you add later in 'perf list' output, right?

 Moreover it actually does not matter whats in value 'param2=HERE',
 because it's not used in the config code at all apart from the
 'perf list' display processing.

 So when we discussed the '$' name way, I thought it'd be like:

 in /sys/bus/event_source/devices/pmu/events/event_name you have:
   param2=$foo,bar=1,param1=$baz

 and on command line you'd use:
   pmu/event_name,foo=0x1,bar=0x4/

 to assign directly to the $var, which would justify the $var
 syntax I think..


Agreed, what you've described above sounds like a good idea.

Compared to monopolizing all strings (which is what I did when
initialy writing this), using a '$' prefix would allow less pain when
some events suddenly need non-integer parameters.

 anyway we could assign directly to the param term name as you do,
 but I think we just need to mark the term as parametrized, like:

 in /sys/bus/event_source/devices/pmu/events/event_name you have:
   param2=?,bar=1,param1=?

 and on command line you'd use:
   pmu/event_name,param2=0x1,param1=0x4/

 while the config code would check that the param substitution is
 done only for terms with '?' in value, like 'param2=?' and not
 for all PARSE_EVENTS__TERM_TYPE_STR type terms (as of now)

I prefer the `foo=0x1` as mentioned previously: it makes the user
interface much less painful as we can have event-specific names for
register/hcall fields.

I'm pretty sure the code used to do this, not sure when it was removed
(haven't been following this patchset closely).

That said: I haven't fiddled with this code in a while (it's Suka's at
this point), and there might be arguments the other way on both of
those.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 6/6] powerpc/perf/hv-24x7: Document sysfs event description entries

2014-12-03 Thread Cody P Schafer
> diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 
> b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> index 32f3f5f..cf70084 100644
> --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> @@ -21,3 +21,25 @@ Contact: Linux on PowerPC Developer List 
> 
> +Contact:   Cody P Schafer 

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


Re: [PATCH v5 6/6] powerpc/perf/hv-24x7: Document sysfs event description entries

2014-12-03 Thread Cody P Schafer
 diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 
 b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
 index 32f3f5f..cf70084 100644
 --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
 +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
 @@ -21,3 +21,25 @@ Contact: Linux on PowerPC Developer List 
 linuxppc-...@lists.ozlabs.org
 +Contact:   Cody P Schafer c...@linux.vnet.ibm.com

Probably want someone else to be the contact here.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf Documentation: Remove Ruplicated docs for powerpc cpu specific events

2014-10-15 Thread tip-bot for Cody P Schafer
Commit-ID:  b56d5beff4825f9f216f1fc4a54a5d07d4b68b71
Gitweb: http://git.kernel.org/tip/b56d5beff4825f9f216f1fc4a54a5d07d4b68b71
Author: Cody P Schafer 
AuthorDate: Tue, 30 Sep 2014 23:03:20 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 15 Oct 2014 16:00:37 -0300

perf Documentation: Remove Ruplicated docs for powerpc cpu specific events

Listing specific events doesn't actually help us at all here because:
 - these events actually vary between different ppc processors, they
   aren't garunteed to be present.
 - the documentation of the (generic) file contents is now superceded by the
   docs for arbitrary event file contents.

Signed-off-by: Cody P Schafer 
Signed-off-by: Sukadev Bhattiprolu 
Cc: Andi Kleen 
Cc: Anshuman Khandual 
Cc: Haren Myneni 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1412143402-26061-5-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 .../testing/sysfs-bus-event_source-devices-events  | 573 -
 1 file changed, 573 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index a5226f0..20979f8 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -27,579 +27,6 @@ Description:Generic performance monitoring events
"basename".
 
 
-What:  /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL
-   /sys/devices/cpu/events/PM_BRU_FIN
-   /sys/devices/cpu/events/PM_BR_MPRED
-   /sys/devices/cpu/events/PM_CMPLU_STALL
-   /sys/devices/cpu/events/PM_CMPLU_STALL_BRU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DFU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DIV
-   /sys/devices/cpu/events/PM_CMPLU_STALL_ERAT_MISS
-   /sys/devices/cpu/events/PM_CMPLU_STALL_FXU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_IFU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_LSU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_REJECT
-   /sys/devices/cpu/events/PM_CMPLU_STALL_SCALAR
-   /sys/devices/cpu/events/PM_CMPLU_STALL_SCALAR_LONG
-   /sys/devices/cpu/events/PM_CMPLU_STALL_STORE
-   /sys/devices/cpu/events/PM_CMPLU_STALL_THRD
-   /sys/devices/cpu/events/PM_CMPLU_STALL_VECTOR
-   /sys/devices/cpu/events/PM_CMPLU_STALL_VECTOR_LONG
-   /sys/devices/cpu/events/PM_CYC
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_BR_MPRED
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_BR_MPRED_IC_MISS
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_IC_MISS
-   /sys/devices/cpu/events/PM_GRP_CMPL
-   /sys/devices/cpu/events/PM_INST_CMPL
-   /sys/devices/cpu/events/PM_LD_MISS_L1
-   /sys/devices/cpu/events/PM_LD_REF_L1
-   /sys/devices/cpu/events/PM_RUN_CYC
-   /sys/devices/cpu/events/PM_RUN_INST_CMPL
-   /sys/devices/cpu/events/PM_IC_DEMAND_L2_BR_ALL
-   /sys/devices/cpu/events/PM_GCT_UTIL_7_TO_10_SLOTS
-   /sys/devices/cpu/events/PM_PMC2_SAVED
-   /sys/devices/cpu/events/PM_VSU0_16FLOP
-   /sys/devices/cpu/events/PM_MRK_LSU_DERAT_MISS
-   /sys/devices/cpu/events/PM_MRK_ST_CMPL
-   /sys/devices/cpu/events/PM_NEST_PAIR3_ADD
-   /sys/devices/cpu/events/PM_L2_ST_DISP
-   /sys/devices/cpu/events/PM_L2_CASTOUT_MOD
-   /sys/devices/cpu/events/PM_ISEG
-   /sys/devices/cpu/events/PM_MRK_INST_TIMEO
-   /sys/devices/cpu/events/PM_L2_RCST_DISP_FAIL_ADDR
-   /sys/devices/cpu/events/PM_LSU1_DC_PREF_STREAM_CONFIRM
-   /sys/devices/cpu/events/PM_IERAT_WR_64K
-   /sys/devices/cpu/events/PM_MRK_DTLB_MISS_16M
-   /sys/devices/cpu/events/PM_IERAT_MISS
-   /sys/devices/cpu/events/PM_MRK_PTEG_FROM_LMEM
-   /sys/devices/cpu/events/PM_FLOP
-   /sys/devices/cpu/events/PM_THRD_PRIO_4_5_CYC
-   /sys/devices/cpu/events/PM_BR_PRED_TA
-   /sys/devices/cpu/events/PM_EXT_INT
-   /sys/devices/cpu/events/PM_VSU_FSQRT_FDIV
-   /sys/devices/cpu/events/PM_MRK_LD_MISS_EXPOSED_CYC
-   /sys/devices/cpu/events/PM_LSU1_LDF
-   /sys/devices/cpu/events/PM_IC_WRITE_ALL
-   /sys/devices/cpu/events/PM_LSU0_SRQ_STFWD
-   /sys/devices/cpu/events/PM_PTEG_FROM_RL2L3_MOD
-   /sys/devices/cpu/events/PM_MRK_DATA_FR

[tip:perf/urgent] perf Documentation: sysfs events/ interfaces

2014-10-15 Thread tip-bot for Cody P Schafer
Commit-ID:  ed90a4466340e51699139ea83dbe0f4536360e6d
Gitweb: http://git.kernel.org/tip/ed90a4466340e51699139ea83dbe0f4536360e6d
Author: Cody P Schafer 
AuthorDate: Tue, 30 Sep 2014 23:03:19 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 15 Oct 2014 15:54:40 -0300

perf Documentation: sysfs events/ interfaces

Add documentation for the , .scale, and .unit
files in sysfs.

.scale and .unit were undocumented.
 was previously documented only for specific powerpc pmu events.

Signed-off-by: Cody P Schafer 
Signed-off-by: Sukadev Bhattiprolu 
Cc: Andi Kleen 
Cc: Anshuman Khandual 
Cc: Cody P Schafer 
Cc: Haren Myneni 
Cc: Haren Myneni 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1412143402-26061-4-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 .../testing/sysfs-bus-event_source-devices-events  | 60 ++
 1 file changed, 60 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index 7b40a3c..a5226f0 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -599,3 +599,63 @@ Description:   POWER-systems specific performance 
monitoring events
Further, multiple terms like 'event=0x' can be specified
and separated with comma. All available terms are defined in
the /sys/bus/event_source/devices//format file.
+
+What: /sys/bus/event_source/devices//events/
+Date: 2014/02/24
+Contact:   Linux kernel mailing list 
+Description:   Per-pmu performance monitoring events specific to the running 
system
+
+   Each file (except for some of those with a '.' in them, '.unit'
+   and '.scale') in the 'events' directory describes a single
+   performance monitoring event supported by the . The name
+   of the file is the name of the event.
+
+   File contents:
+
+   [=][,[=]]...
+
+   Where  is one of the terms listed under
+   /sys/bus/event_source/devices//format/ and  is
+   a number is base-16 format with a '0x' prefix (lowercase only).
+   If a  is specified alone (without an assigned value), it
+   is implied that 0x1 is assigned to that .
+
+   Examples (each of these lines would be in a seperate file):
+
+   event=0x2abc
+   event=0x423,inv,cmask=0x3
+   domain=0x1,offset=0x8,starting_index=0x
+
+   Each of the assignments indicates a value to be assigned to a
+   particular set of bits (as defined by the format file
+   corresponding to the ) in the perf_event structure passed
+   to the perf_open syscall.
+
+What: /sys/bus/event_source/devices//events/.unit
+Date: 2014/02/24
+Contact:   Linux kernel mailing list 
+Description:   Perf event units
+
+   A string specifying the English plural numerical unit that 

+   (once multiplied by .scale) represents.
+
+   Example:
+
+   Joules
+
+What: /sys/bus/event_source/devices//events/.scale
+Date: 2014/02/24
+Contact:   Linux kernel mailing list 
+Description:   Perf event scaling factors
+
+   A string representing a floating point value expressed in
+   scientific notation to be multiplied by the event count
+   recieved from the kernel to match the unit specified in the
+   .unit file.
+
+   Example:
+
+   2.3283064365386962890625e-10
+
+   This is provided to avoid performing floating point arithmetic
+   in the kernel.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf Documentation: sysfs events/ interfaces

2014-10-15 Thread tip-bot for Cody P Schafer
Commit-ID:  ed90a4466340e51699139ea83dbe0f4536360e6d
Gitweb: http://git.kernel.org/tip/ed90a4466340e51699139ea83dbe0f4536360e6d
Author: Cody P Schafer d...@codyps.com
AuthorDate: Tue, 30 Sep 2014 23:03:19 -0700
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Wed, 15 Oct 2014 15:54:40 -0300

perf Documentation: sysfs events/ interfaces

Add documentation for the event, event.scale, and event.unit
files in sysfs.

event.scale and event.unit were undocumented.
event was previously documented only for specific powerpc pmu events.

Signed-off-by: Cody P Schafer d...@codyps.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Cc: Andi Kleen a...@linux.intel.com
Cc: Anshuman Khandual khand...@linux.vnet.ibm.com
Cc: Cody P Schafer d...@codyps.com
Cc: Haren Myneni hb...@us.ibm.com
Cc: Haren Myneni hb...@us.ibm.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Michael Ellerman micha...@au1.ibm.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1412143402-26061-4-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 .../testing/sysfs-bus-event_source-devices-events  | 60 ++
 1 file changed, 60 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index 7b40a3c..a5226f0 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -599,3 +599,63 @@ Description:   POWER-systems specific performance 
monitoring events
Further, multiple terms like 'event=0x' can be specified
and separated with comma. All available terms are defined in
the /sys/bus/event_source/devices/dev/format file.
+
+What: /sys/bus/event_source/devices/pmu/events/event
+Date: 2014/02/24
+Contact:   Linux kernel mailing list linux-kernel@vger.kernel.org
+Description:   Per-pmu performance monitoring events specific to the running 
system
+
+   Each file (except for some of those with a '.' in them, '.unit'
+   and '.scale') in the 'events' directory describes a single
+   performance monitoring event supported by the pmu. The name
+   of the file is the name of the event.
+
+   File contents:
+
+   term[=value][,term[=value]]...
+
+   Where term is one of the terms listed under
+   /sys/bus/event_source/devices/pmu/format/ and value is
+   a number is base-16 format with a '0x' prefix (lowercase only).
+   If a term is specified alone (without an assigned value), it
+   is implied that 0x1 is assigned to that term.
+
+   Examples (each of these lines would be in a seperate file):
+
+   event=0x2abc
+   event=0x423,inv,cmask=0x3
+   domain=0x1,offset=0x8,starting_index=0x
+
+   Each of the assignments indicates a value to be assigned to a
+   particular set of bits (as defined by the format file
+   corresponding to the term) in the perf_event structure passed
+   to the perf_open syscall.
+
+What: /sys/bus/event_source/devices/pmu/events/event.unit
+Date: 2014/02/24
+Contact:   Linux kernel mailing list linux-kernel@vger.kernel.org
+Description:   Perf event units
+
+   A string specifying the English plural numerical unit that 
event
+   (once multiplied by event.scale) represents.
+
+   Example:
+
+   Joules
+
+What: /sys/bus/event_source/devices/pmu/events/event.scale
+Date: 2014/02/24
+Contact:   Linux kernel mailing list linux-kernel@vger.kernel.org
+Description:   Perf event scaling factors
+
+   A string representing a floating point value expressed in
+   scientific notation to be multiplied by the event count
+   recieved from the kernel to match the unit specified in the
+   event.unit file.
+
+   Example:
+
+   2.3283064365386962890625e-10
+
+   This is provided to avoid performing floating point arithmetic
+   in the kernel.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf Documentation: Remove Ruplicated docs for powerpc cpu specific events

2014-10-15 Thread tip-bot for Cody P Schafer
Commit-ID:  b56d5beff4825f9f216f1fc4a54a5d07d4b68b71
Gitweb: http://git.kernel.org/tip/b56d5beff4825f9f216f1fc4a54a5d07d4b68b71
Author: Cody P Schafer d...@codyps.com
AuthorDate: Tue, 30 Sep 2014 23:03:20 -0700
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Wed, 15 Oct 2014 16:00:37 -0300

perf Documentation: Remove Ruplicated docs for powerpc cpu specific events

Listing specific events doesn't actually help us at all here because:
 - these events actually vary between different ppc processors, they
   aren't garunteed to be present.
 - the documentation of the (generic) file contents is now superceded by the
   docs for arbitrary event file contents.

Signed-off-by: Cody P Schafer d...@codyps.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Cc: Andi Kleen a...@linux.intel.com
Cc: Anshuman Khandual khand...@linux.vnet.ibm.com
Cc: Haren Myneni hb...@us.ibm.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Michael Ellerman micha...@au1.ibm.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1412143402-26061-5-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 .../testing/sysfs-bus-event_source-devices-events  | 573 -
 1 file changed, 573 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index a5226f0..20979f8 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -27,579 +27,6 @@ Description:Generic performance monitoring events
basename.
 
 
-What:  /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL
-   /sys/devices/cpu/events/PM_BRU_FIN
-   /sys/devices/cpu/events/PM_BR_MPRED
-   /sys/devices/cpu/events/PM_CMPLU_STALL
-   /sys/devices/cpu/events/PM_CMPLU_STALL_BRU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DFU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DIV
-   /sys/devices/cpu/events/PM_CMPLU_STALL_ERAT_MISS
-   /sys/devices/cpu/events/PM_CMPLU_STALL_FXU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_IFU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_LSU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_REJECT
-   /sys/devices/cpu/events/PM_CMPLU_STALL_SCALAR
-   /sys/devices/cpu/events/PM_CMPLU_STALL_SCALAR_LONG
-   /sys/devices/cpu/events/PM_CMPLU_STALL_STORE
-   /sys/devices/cpu/events/PM_CMPLU_STALL_THRD
-   /sys/devices/cpu/events/PM_CMPLU_STALL_VECTOR
-   /sys/devices/cpu/events/PM_CMPLU_STALL_VECTOR_LONG
-   /sys/devices/cpu/events/PM_CYC
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_BR_MPRED
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_BR_MPRED_IC_MISS
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_IC_MISS
-   /sys/devices/cpu/events/PM_GRP_CMPL
-   /sys/devices/cpu/events/PM_INST_CMPL
-   /sys/devices/cpu/events/PM_LD_MISS_L1
-   /sys/devices/cpu/events/PM_LD_REF_L1
-   /sys/devices/cpu/events/PM_RUN_CYC
-   /sys/devices/cpu/events/PM_RUN_INST_CMPL
-   /sys/devices/cpu/events/PM_IC_DEMAND_L2_BR_ALL
-   /sys/devices/cpu/events/PM_GCT_UTIL_7_TO_10_SLOTS
-   /sys/devices/cpu/events/PM_PMC2_SAVED
-   /sys/devices/cpu/events/PM_VSU0_16FLOP
-   /sys/devices/cpu/events/PM_MRK_LSU_DERAT_MISS
-   /sys/devices/cpu/events/PM_MRK_ST_CMPL
-   /sys/devices/cpu/events/PM_NEST_PAIR3_ADD
-   /sys/devices/cpu/events/PM_L2_ST_DISP
-   /sys/devices/cpu/events/PM_L2_CASTOUT_MOD
-   /sys/devices/cpu/events/PM_ISEG
-   /sys/devices/cpu/events/PM_MRK_INST_TIMEO
-   /sys/devices/cpu/events/PM_L2_RCST_DISP_FAIL_ADDR
-   /sys/devices/cpu/events/PM_LSU1_DC_PREF_STREAM_CONFIRM
-   /sys/devices/cpu/events/PM_IERAT_WR_64K
-   /sys/devices/cpu/events/PM_MRK_DTLB_MISS_16M
-   /sys/devices/cpu/events/PM_IERAT_MISS
-   /sys/devices/cpu/events/PM_MRK_PTEG_FROM_LMEM
-   /sys/devices/cpu/events/PM_FLOP
-   /sys/devices/cpu/events/PM_THRD_PRIO_4_5_CYC
-   /sys/devices/cpu/events/PM_BR_PRED_TA
-   /sys/devices/cpu/events/PM_EXT_INT
-   /sys/devices/cpu/events/PM_VSU_FSQRT_FDIV
-   /sys/devices/cpu/events/PM_MRK_LD_MISS_EXPOSED_CYC
-   /sys/devices/cpu/events/PM_LSU1_LDF

Re: [PATCH v4 10/10] powerpc/perf/hv-24x7: Document sysfs event description entries

2014-09-30 Thread Cody P Schafer
> +What:  /sys/bus/event_source/devices/hv_24x7/event_descs/
> +Date:  February 2014
> +Contact:       Cody P Schafer 

May want to change this contact email to an address that still works
(perhaps the ppc devel list?)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 10/10] powerpc/perf/hv-24x7: Document sysfs event description entries

2014-09-30 Thread Cody P Schafer
 +What:  /sys/bus/event_source/devices/hv_24x7/event_descs/event-name
 +Date:  February 2014
 +Contact:   Cody P Schafer c...@linux.vnet.ibm.com

May want to change this contact email to an address that still works
(perhaps the ppc devel list?)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Annotate PMU related list_head members with type info

2014-08-18 Thread tip-bot for Cody P Schafer
Commit-ID:  885b5930d6632fc7df55445d9021b87d8bb17a9b
Gitweb: http://git.kernel.org/tip/885b5930d6632fc7df55445d9021b87d8bb17a9b
Author: Cody P Schafer 
AuthorDate: Fri, 15 Aug 2014 00:26:14 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 15 Aug 2014 10:42:40 -0300

perf tools: Annotate PMU related list_head members with type info

So that we can more readily understand in which list heads structs are
stored into.

Signed-off-by: Cody P Schafer 
Cc: Andi Kleen 
Cc: Anshuman Khandual 
Cc: Cody P Schafer 
Cc: Haren Myneni 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1408087583-32239-6-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Sukadev Bhattiprolu 
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/pmu.c | 4 ++--
 tools/perf/util/pmu.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 7a811eb..9bf5827 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -14,8 +14,8 @@
 
 struct perf_pmu_alias {
char *name;
-   struct list_head terms;
-   struct list_head list;
+   struct list_head terms; /* HEAD struct parse_events_term -> list */
+   struct list_head list;  /* ELEM */
char unit[UNIT_MAX_LEN+1];
double scale;
 };
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index c14a543..1c1e2ee 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -17,9 +17,9 @@ struct perf_pmu {
char *name;
__u32 type;
struct cpu_map *cpus;
-   struct list_head format;
-   struct list_head aliases;
-   struct list_head list;
+   struct list_head format;  /* HEAD struct perf_pmu_format -> list */
+   struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
+   struct list_head list;/* ELEM */
 };
 
 struct perf_pmu *perf_pmu__find(const char *name);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Annotate PMU related list_head members with type info

2014-08-18 Thread tip-bot for Cody P Schafer
Commit-ID:  885b5930d6632fc7df55445d9021b87d8bb17a9b
Gitweb: http://git.kernel.org/tip/885b5930d6632fc7df55445d9021b87d8bb17a9b
Author: Cody P Schafer d...@codyps.com
AuthorDate: Fri, 15 Aug 2014 00:26:14 -0700
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Fri, 15 Aug 2014 10:42:40 -0300

perf tools: Annotate PMU related list_head members with type info

So that we can more readily understand in which list heads structs are
stored into.

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
Cc: Andi Kleen a...@linux.intel.com
Cc: Anshuman Khandual khand...@linux.vnet.ibm.com
Cc: Cody P Schafer d...@codyps.com
Cc: Haren Myneni hb...@us.ibm.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Michael Ellerman micha...@au1.ibm.com
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Cc: linuxppc-...@lists.ozlabs.org
Link: 
http://lkml.kernel.org/r/1408087583-32239-6-git-send-email-suka...@linux.vnet.ibm.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/util/pmu.c | 4 ++--
 tools/perf/util/pmu.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 7a811eb..9bf5827 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -14,8 +14,8 @@
 
 struct perf_pmu_alias {
char *name;
-   struct list_head terms;
-   struct list_head list;
+   struct list_head terms; /* HEAD struct parse_events_term - list */
+   struct list_head list;  /* ELEM */
char unit[UNIT_MAX_LEN+1];
double scale;
 };
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index c14a543..1c1e2ee 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -17,9 +17,9 @@ struct perf_pmu {
char *name;
__u32 type;
struct cpu_map *cpus;
-   struct list_head format;
-   struct list_head aliases;
-   struct list_head list;
+   struct list_head format;  /* HEAD struct perf_pmu_format - list */
+   struct list_head aliases; /* HEAD struct perf_pmu_alias - list */
+   struct list_head list;/* ELEM */
 };
 
 struct perf_pmu *perf_pmu__find(const char *name);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Allow overriding sysfs and proc finding with env var

2014-06-05 Thread tip-bot for Cody P Schafer
Commit-ID:  f2d9627b2b31506204417bb6842a7ea88970b700
Gitweb: http://git.kernel.org/tip/f2d9627b2b31506204417bb6842a7ea88970b700
Author: Cody P Schafer 
AuthorDate: Tue, 27 May 2014 17:21:56 -0700
Committer:  Jiri Olsa 
CommitDate: Tue, 3 Jun 2014 21:34:29 +0200

perf tools: Allow overriding sysfs and proc finding with env var

SYSFS_PATH and PROC_PATH environment variables now let the user override
the detection of sysfs and proc locations for testing purposes.

Signed-off-by: Cody P Schafer 
Cc: Sukadev Bhattiprolu 
Link: http://lkml.kernel.org/r/1401236684-10579-2-git-send-email-...@codyps.com
Signed-off-by: Jiri Olsa 
---
 tools/lib/api/fs/fs.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb78..c1b49c3 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
 /* TODO merge/factor in debugfs.c here */
 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
 }
 
+static void mem_toupper(char *f, size_t len)
+{
+   while (len) {
+   *f = toupper(*f);
+   f++;
+   len--;
+   }
+}
+
+/*
+ * Check for "NAME_PATH" environment variable to override fs location (for
+ * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * for SYSFS_PATH.
+ */
+static bool fs__env_override(struct fs *fs)
+{
+   char *override_path;
+   size_t name_len = strlen(fs->name);
+   /* name + "_PATH" + '\0' */
+   char upper_name[name_len + 5 + 1];
+   memcpy(upper_name, fs->name, name_len);
+   mem_toupper(upper_name, name_len);
+   strcpy(_name[name_len], "_PATH");
+
+   override_path = getenv(upper_name);
+   if (!override_path)
+   return false;
+
+   fs->found = true;
+   strncpy(fs->path, override_path, sizeof(fs->path));
+   return true;
+}
+
 static const char *fs__get_mountpoint(struct fs *fs)
 {
+   if (fs__env_override(fs))
+   return fs->path;
+
if (fs__check_mounts(fs))
return fs->path;
 
-   return fs__read_mounts(fs) ? fs->path : NULL;
+   if (fs__read_mounts(fs))
+   return fs->path;
+
+   return NULL;
 }
 
 static const char *fs__mountpoint(int idx)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Allow overriding sysfs and proc finding with env var

2014-06-05 Thread tip-bot for Cody P Schafer
Commit-ID:  f2d9627b2b31506204417bb6842a7ea88970b700
Gitweb: http://git.kernel.org/tip/f2d9627b2b31506204417bb6842a7ea88970b700
Author: Cody P Schafer d...@codyps.com
AuthorDate: Tue, 27 May 2014 17:21:56 -0700
Committer:  Jiri Olsa jo...@kernel.org
CommitDate: Tue, 3 Jun 2014 21:34:29 +0200

perf tools: Allow overriding sysfs and proc finding with env var

SYSFS_PATH and PROC_PATH environment variables now let the user override
the detection of sysfs and proc locations for testing purposes.

Signed-off-by: Cody P Schafer d...@codyps.com
Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Link: http://lkml.kernel.org/r/1401236684-10579-2-git-send-email-...@codyps.com
Signed-off-by: Jiri Olsa jo...@kernel.org
---
 tools/lib/api/fs/fs.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb78..c1b49c3 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
 /* TODO merge/factor in debugfs.c here */
 
+#include ctype.h
 #include errno.h
 #include stdbool.h
 #include stdio.h
+#include stdlib.h
 #include string.h
 #include sys/vfs.h
 
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
 }
 
+static void mem_toupper(char *f, size_t len)
+{
+   while (len) {
+   *f = toupper(*f);
+   f++;
+   len--;
+   }
+}
+
+/*
+ * Check for NAME_PATH environment variable to override fs location (for
+ * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * for SYSFS_PATH.
+ */
+static bool fs__env_override(struct fs *fs)
+{
+   char *override_path;
+   size_t name_len = strlen(fs-name);
+   /* name + _PATH + '\0' */
+   char upper_name[name_len + 5 + 1];
+   memcpy(upper_name, fs-name, name_len);
+   mem_toupper(upper_name, name_len);
+   strcpy(upper_name[name_len], _PATH);
+
+   override_path = getenv(upper_name);
+   if (!override_path)
+   return false;
+
+   fs-found = true;
+   strncpy(fs-path, override_path, sizeof(fs-path));
+   return true;
+}
+
 static const char *fs__get_mountpoint(struct fs *fs)
 {
+   if (fs__env_override(fs))
+   return fs-path;
+
if (fs__check_mounts(fs))
return fs-path;
 
-   return fs__read_mounts(fs) ? fs-path : NULL;
+   if (fs__read_mounts(fs))
+   return fs-path;
+
+   return NULL;
 }
 
 static const char *fs__mountpoint(int idx)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be, le}_to_cpu() and cpu_to_{be, le}() macros

2014-05-28 Thread Cody P Schafer
On Wed, May 28, 2014 at 6:00 PM, Joe Perches  wrote:
> On Wed, 2014-05-28 at 17:11 -0500, Cody P Schafer wrote:
>> On Wed, May 28, 2014 at 5:05 PM, Cody P Schafer  wrote:
>> > On Wed, May 28, 2014 at 3:45 AM, David Laight  
>> > wrote:
>> >> From: Cody P Schafer
>> >>> Rather manually specifying the size of the integer to be converted, key
>> >>> off of the type size. Reduces duplicate size info and the occurance of
>> >>> certain types of bugs (using the wrong sized conversion).
>> >> ...
>> >>> +#define be_to_cpu(v) \
>> >>> + __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
>> >>> + __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), 
>> >>> be16_to_cpu(v), \
>> >>> + __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), 
>> >>> be32_to_cpu(v), \
>> >>> + __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), 
>> >>> be64_to_cpu(v), \
>> >>> + (void)0
>> >> ...
>> >>
>> >> I'm not at all sure that using the 'size' of the constant will reduce
>> >> the number of bugs - it just introduces a whole new category of bugs.
>> >
>> > Certainly, if you mis-size the argument (and thus have missized one of
>> > the variables containing the be value, probably a bug anyhow), there
>> > will be problems.
>> >
>> > I put this interface together because of an actual bug I wrote into
>> > the initial code of the hv_24x7 driver (resized a struct member
>> > without adjusting the be*_to_cpu() sizing).
>> > Having this "auto sizing" macro means I can avoid encoding the size of
>> > a struct field in multiple places.
>>
>> To clarify, the point I'm making here is that this simply cuts out 1
>> more place we can screw up endianness conversion sizing.
>
> It does screw up other types when you do things like:
>
> u8 foo = some_function();
>
> cpu_to_be(foo + 1);
>
> the return value is sizeof(int) not u8

Yep, that is a very good argument against the cpu_to_{be,le}()
variants. It might make sense to remove them and just have the
{be,le}_to_cpu() ones.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be, le}_to_cpu() and cpu_to_{be, le}() macros

2014-05-28 Thread Cody P Schafer
On Wed, May 28, 2014 at 5:05 PM, Cody P Schafer  wrote:
> On Wed, May 28, 2014 at 3:45 AM, David Laight  wrote:
>> From: Cody P Schafer
>>> Rather manually specifying the size of the integer to be converted, key
>>> off of the type size. Reduces duplicate size info and the occurance of
>>> certain types of bugs (using the wrong sized conversion).
>> ...
>>> +#define be_to_cpu(v) \
>>> + __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
>>> + __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
>>> + __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
>>> + __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
>>> + (void)0
>> ...
>>
>> I'm not at all sure that using the 'size' of the constant will reduce
>> the number of bugs - it just introduces a whole new category of bugs.
>
> Certainly, if you mis-size the argument (and thus have missized one of
> the variables containing the be value, probably a bug anyhow), there
> will be problems.
>
> I put this interface together because of an actual bug I wrote into
> the initial code of the hv_24x7 driver (resized a struct member
> without adjusting the be*_to_cpu() sizing).
> Having this "auto sizing" macro means I can avoid encoding the size of
> a struct field in multiple places.

To clarify, the point I'm making here is that this simply cuts out 1
more place we can screw up endianness conversion sizing.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be,le}_to_cpu() and cpu_to_{be,le}() macros

2014-05-28 Thread Cody P Schafer
On Tue, May 27, 2014 at 7:44 PM, Joe Perches  wrote:
> On Tue, 2014-05-27 at 17:22 -0700, Cody P Schafer wrote:
>> Rather manually specifying the size of the integer to be converted, key
>> off of the type size. Reduces duplicate size info and the occurance of
>> certain types of bugs (using the wrong sized conversion).
> []
>> diff --git a/include/linux/byteorder.h b/include/linux/byteorder.h
> []
>> @@ -0,0 +1,34 @@
>> +#ifndef LINUX_BYTEORDER_H_
>> +#define LINUX_BYTEORDER_H_
>> +
>> +#include 
>> +
>> +#define be_to_cpu(v) \
>> + __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
>> + __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
>> + __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
>> + __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
>> + (void)0
>
> probably better to use BUILD_BUG instead of these 0 returns
>

They aren't 0 returns.

$ echo "int main(void) { int x = (void)0; return x; }" | gcc -x c -
: In function ‘main’:
:1:26: error: void value not ignored as it ought to be
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be, le}_to_cpu() and cpu_to_{be, le}() macros

2014-05-28 Thread Cody P Schafer
On Wed, May 28, 2014 at 3:45 AM, David Laight  wrote:
> From: Cody P Schafer
>> Rather manually specifying the size of the integer to be converted, key
>> off of the type size. Reduces duplicate size info and the occurance of
>> certain types of bugs (using the wrong sized conversion).
> ...
>> +#define be_to_cpu(v) \
>> + __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
>> + __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
>> + __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
>> + __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
>> + (void)0
> ...
>
> I'm not at all sure that using the 'size' of the constant will reduce
> the number of bugs - it just introduces a whole new category of bugs.

Certainly, if you mis-size the argument (and thus have missized one of
the variables containing the be value, probably a bug anyhow), there
will be problems.

I put this interface together because of an actual bug I wrote into
the initial code of the hv_24x7 driver (resized a struct member
without adjusting the be*_to_cpu() sizing).
Having this "auto sizing" macro means I can avoid encoding the size of
a struct field in multiple places.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be, le}_to_cpu() and cpu_to_{be, le}() macros

2014-05-28 Thread Cody P Schafer
On Wed, May 28, 2014 at 3:45 AM, David Laight david.lai...@aculab.com wrote:
 From: Cody P Schafer
 Rather manually specifying the size of the integer to be converted, key
 off of the type size. Reduces duplicate size info and the occurance of
 certain types of bugs (using the wrong sized conversion).
 ...
 +#define be_to_cpu(v) \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
 + (void)0
 ...

 I'm not at all sure that using the 'size' of the constant will reduce
 the number of bugs - it just introduces a whole new category of bugs.

Certainly, if you mis-size the argument (and thus have missized one of
the variables containing the be value, probably a bug anyhow), there
will be problems.

I put this interface together because of an actual bug I wrote into
the initial code of the hv_24x7 driver (resized a struct member
without adjusting the be*_to_cpu() sizing).
Having this auto sizing macro means I can avoid encoding the size of
a struct field in multiple places.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be,le}_to_cpu() and cpu_to_{be,le}() macros

2014-05-28 Thread Cody P Schafer
On Tue, May 27, 2014 at 7:44 PM, Joe Perches j...@perches.com wrote:
 On Tue, 2014-05-27 at 17:22 -0700, Cody P Schafer wrote:
 Rather manually specifying the size of the integer to be converted, key
 off of the type size. Reduces duplicate size info and the occurance of
 certain types of bugs (using the wrong sized conversion).
 []
 diff --git a/include/linux/byteorder.h b/include/linux/byteorder.h
 []
 @@ -0,0 +1,34 @@
 +#ifndef LINUX_BYTEORDER_H_
 +#define LINUX_BYTEORDER_H_
 +
 +#include asm/byteorder.h
 +
 +#define be_to_cpu(v) \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
 + (void)0

 probably better to use BUILD_BUG instead of these 0 returns


They aren't 0 returns.

$ echo int main(void) { int x = (void)0; return x; } | gcc -x c -
stdin: In function ‘main’:
stdin:1:26: error: void value not ignored as it ought to be
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be, le}_to_cpu() and cpu_to_{be, le}() macros

2014-05-28 Thread Cody P Schafer
On Wed, May 28, 2014 at 5:05 PM, Cody P Schafer d...@codyps.com wrote:
 On Wed, May 28, 2014 at 3:45 AM, David Laight david.lai...@aculab.com wrote:
 From: Cody P Schafer
 Rather manually specifying the size of the integer to be converted, key
 off of the type size. Reduces duplicate size info and the occurance of
 certain types of bugs (using the wrong sized conversion).
 ...
 +#define be_to_cpu(v) \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
 + __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
 + (void)0
 ...

 I'm not at all sure that using the 'size' of the constant will reduce
 the number of bugs - it just introduces a whole new category of bugs.

 Certainly, if you mis-size the argument (and thus have missized one of
 the variables containing the be value, probably a bug anyhow), there
 will be problems.

 I put this interface together because of an actual bug I wrote into
 the initial code of the hv_24x7 driver (resized a struct member
 without adjusting the be*_to_cpu() sizing).
 Having this auto sizing macro means I can avoid encoding the size of
 a struct field in multiple places.

To clarify, the point I'm making here is that this simply cuts out 1
more place we can screw up endianness conversion sizing.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be, le}_to_cpu() and cpu_to_{be, le}() macros

2014-05-28 Thread Cody P Schafer
On Wed, May 28, 2014 at 6:00 PM, Joe Perches j...@perches.com wrote:
 On Wed, 2014-05-28 at 17:11 -0500, Cody P Schafer wrote:
 On Wed, May 28, 2014 at 5:05 PM, Cody P Schafer d...@codyps.com wrote:
  On Wed, May 28, 2014 at 3:45 AM, David Laight david.lai...@aculab.com 
  wrote:
  From: Cody P Schafer
  Rather manually specifying the size of the integer to be converted, key
  off of the type size. Reduces duplicate size info and the occurance of
  certain types of bugs (using the wrong sized conversion).
  ...
  +#define be_to_cpu(v) \
  + __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
  + __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), 
  be16_to_cpu(v), \
  + __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), 
  be32_to_cpu(v), \
  + __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), 
  be64_to_cpu(v), \
  + (void)0
  ...
 
  I'm not at all sure that using the 'size' of the constant will reduce
  the number of bugs - it just introduces a whole new category of bugs.
 
  Certainly, if you mis-size the argument (and thus have missized one of
  the variables containing the be value, probably a bug anyhow), there
  will be problems.
 
  I put this interface together because of an actual bug I wrote into
  the initial code of the hv_24x7 driver (resized a struct member
  without adjusting the be*_to_cpu() sizing).
  Having this auto sizing macro means I can avoid encoding the size of
  a struct field in multiple places.

 To clarify, the point I'm making here is that this simply cuts out 1
 more place we can screw up endianness conversion sizing.

 It does screw up other types when you do things like:

 u8 foo = some_function();

 cpu_to_be(foo + 1);

 the return value is sizeof(int) not u8

Yep, that is a very good argument against the cpu_to_{be,le}()
variants. It might make sense to remove them and just have the
{be,le}_to_cpu() ones.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/16] perf: add PMU_EVENT_ATTR_STRING() helper

2014-05-27 Thread Cody P Schafer
Helper for constructing static struct perf_pmu_events_attr s.

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 include/linux/perf_event.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 6c1d6dd..1313171 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -876,6 +876,13 @@ static struct perf_pmu_events_attr _var = {
\
.id   =  _id,   \
 };
 
+#define PMU_EVENT_ATTR_STRING(_name, _var, _value) \
+static struct perf_pmu_events_attr _var = {\
+   .attr = __ATTR(_name, 0444, perf_event_sysfs_show, NULL),   \
+   .event_str = _value,\
+};
+
+
 #define PMU_FORMAT_ATTR(_name, _format)
\
 static ssize_t \
 _name##_show(struct device *dev,   \
-- 
1.9.3

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


[PATCH 15/16] powerpc/perf/{hv-gpci,hv-common}: generate requests with counters annotated

2014-05-27 Thread Cody P Schafer
This adds (in req-gen/) a framework for defining gpci counter requests.
It uses macro magic similar to ftrace.

Also convert the existing hv-gpci request structures and enum values to
use the new framework (and adjust old users of the structs and enum
values to cope with changes in naming).

In exchange for this macro disaster, we get autogenerated event listing
for GPCI in sysfs, build time field offset checking, and zero
duplication of information about GPCI requests.

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-common.c  |  10 +-
 arch/powerpc/perf/hv-gpci-requests.h   |  79 +++
 arch/powerpc/perf/hv-gpci.c|   8 ++
 arch/powerpc/perf/hv-gpci.h|  37 +++
 arch/powerpc/perf/req-gen/_begin.h |  13 +++
 arch/powerpc/perf/req-gen/_clear.h |   5 +
 arch/powerpc/perf/req-gen/_end.h   |   4 +
 arch/powerpc/perf/req-gen/_request-begin.h |  15 +++
 arch/powerpc/perf/req-gen/_request-end.h   |   8 ++
 arch/powerpc/perf/req-gen/perf.h   | 155 +
 10 files changed, 304 insertions(+), 30 deletions(-)
 create mode 100644 arch/powerpc/perf/hv-gpci-requests.h
 create mode 100644 arch/powerpc/perf/req-gen/_begin.h
 create mode 100644 arch/powerpc/perf/req-gen/_clear.h
 create mode 100644 arch/powerpc/perf/req-gen/_end.h
 create mode 100644 arch/powerpc/perf/req-gen/_request-begin.h
 create mode 100644 arch/powerpc/perf/req-gen/_request-end.h
 create mode 100644 arch/powerpc/perf/req-gen/perf.h

diff --git a/arch/powerpc/perf/hv-common.c b/arch/powerpc/perf/hv-common.c
index 47e02b3..7dce8f10 100644
--- a/arch/powerpc/perf/hv-common.c
+++ b/arch/powerpc/perf/hv-common.c
@@ -9,13 +9,13 @@ unsigned long hv_perf_caps_get(struct hv_perf_caps *caps)
unsigned long r;
struct p {
struct hv_get_perf_counter_info_params params;
-   struct cv_system_performance_capabilities caps;
+   struct hv_gpci_system_performance_capabilities caps;
} __packed __aligned(sizeof(uint64_t));
 
struct p arg = {
.params = {
.counter_request = cpu_to_be32(
-   CIR_SYSTEM_PERFORMANCE_CAPABILITIES),
+   HV_GPCI_system_performance_capabilities),
.starting_index = cpu_to_be32(-1),
.counter_info_version_in = 0,
}
@@ -31,9 +31,9 @@ unsigned long hv_perf_caps_get(struct hv_perf_caps *caps)
 
caps->version = arg.params.counter_info_version_out;
caps->collect_privileged = !!arg.caps.perf_collect_privileged;
-   caps->ga = !!(arg.caps.capability_mask & CV_CM_GA);
-   caps->expanded = !!(arg.caps.capability_mask & CV_CM_EXPANDED);
-   caps->lab = !!(arg.caps.capability_mask & CV_CM_LAB);
+   caps->ga = !!(arg.caps.capability_mask & HV_GPCI_CM_GA);
+   caps->expanded = !!(arg.caps.capability_mask & HV_GPCI_CM_EXPANDED);
+   caps->lab = !!(arg.caps.capability_mask & HV_GPCI_CM_LAB);
 
return r;
 }
diff --git a/arch/powerpc/perf/hv-gpci-requests.h 
b/arch/powerpc/perf/hv-gpci-requests.h
new file mode 100644
index 000..0dfc4d9
--- /dev/null
+++ b/arch/powerpc/perf/hv-gpci-requests.h
@@ -0,0 +1,79 @@
+
+#include "req-gen/_begin.h"
+
+/*
+ * Based on the document "getPerfCountInfo v1.07"
+ */
+
+/* this needs to be -1 encoded in hex suitable for parsing by tools/perf. */
+#define M1 0x
+
+/*
+ * #define REQUEST_NAME counter_request_name
+ * #define REQUEST_NUM r_num
+ * #define REQUEST_IDX_KIND starting_index_kind
+ * #include I(REQUEST_BEGIN)
+ * REQUEST(
+ * __field(...)
+ * __field(...)
+ * __array(...)
+ * __count(...)
+ * )
+ * #include I(REQUEST_END)
+ *
+ * - starting_index_kind is one of:
+ *   M1: must be -1
+ *   chip_id: hardware chip id or -1 for current hw chip
+ *   phys_processor_idx:
+ *
+ * __count(offset, bytes, name):
+ * a counter that should be exposed via perf
+ * __field(offset, bytes, name)
+ * a normal field
+ * __array(offset, bytes, name)
+ * an array of bytes
+ *
+ *
+ * @bytes for __count, and __field _must_ be a numeral token
+ * in decimal, not an expression and not in hex.
+ *
+ *
+ * TODO:
+ * - expose secondary index (if any counter ever uses it, only 0xA0
+ *   appears to use it right now, and it doesn't have any counters)
+ * - embed versioning info
+ * - include counter descriptions
+ */
+#define REQUEST_NAME dispatch_timebase_by_processor
+#define REQUEST_NUM 0x10
+#define REQUEST_IDX_KIND phys_processor_idx
+#include I(REQUEST_BEGIN)
+REQUEST(__count(0, 8,  processor_time_in_timebase_cycles)
+   __field(0x8,4,  hw_processor_id)
+   __field(0xC,2,  owning_part_id)
+   __field(0xE,1,  processor_state

[PATCH 16/16] powerpc/perf/hv-gpci: add the remaining gpci requests

2014-05-27 Thread Cody P Schafer
Add the remaining gpci requests that contain counters suitable for use
by perf. Omit those that don't contain any counters (but note their
ommision).

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-gpci-requests.h | 179 +++
 1 file changed, 179 insertions(+)

diff --git a/arch/powerpc/perf/hv-gpci-requests.h 
b/arch/powerpc/perf/hv-gpci-requests.h
index 0dfc4d9..af3b73c 100644
--- a/arch/powerpc/perf/hv-gpci-requests.h
+++ b/arch/powerpc/perf/hv-gpci-requests.h
@@ -65,6 +65,33 @@ REQUEST(__count(0,   8,  
processor_time_in_timebase_cycles)
 )
 #include I(REQUEST_END)
 
+#define REQUEST_NAME 
entitled_capped_uncapped_donated_idle_timebase_by_partition
+#define REQUEST_NUM 0x20
+#define REQUEST_IDX_KIND sibling_part_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 8,  partition_id)
+   __count(0x8,8,  entitled_cycles)
+   __count(0x10,   8,  consumed_capped_cycles)
+   __count(0x18,   8,  consumed_uncapped_cycles)
+   __count(0x20,   8,  cycles_donated)
+   __count(0x28,   8,  purr_idle_cycles)
+)
+#include I(REQUEST_END)
+
+/*
+ * Not avaliable for counter_info_version >= 0x8, use
+ * run_instruction_cycles_by_partition(0x100) instead.
+ */
+#define REQUEST_NAME run_instructions_run_cycles_by_partition
+#define REQUEST_NUM 0x30
+#define REQUEST_IDX_KIND sibling_part_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 8,  partition_id)
+   __count(0x8,8,  instructions_completed)
+   __count(0x10,   8,  cycles)
+)
+#include I(REQUEST_END)
+
 #define REQUEST_NAME system_performance_capabilities
 #define REQUEST_NUM 0x40
 #define REQUEST_IDX_KIND M1
@@ -75,5 +102,157 @@ REQUEST(__field(0, 1,  perf_collect_privileged)
 )
 #include I(REQUEST_END)
 
+#define REQUEST_NAME processor_bus_utilization_abc_links
+#define REQUEST_NUM 0x50
+#define REQUEST_IDX_KIND hw_chip_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 4,  hw_chip_id)
+   __array(0x4,0xC,reserved1)
+   __count(0x10,   8,  total_link_cycles)
+   __count(0x18,   8,  idle_cycles_for_a_link)
+   __count(0x20,   8,  idle_cycles_for_b_link)
+   __count(0x28,   8,  idle_cycles_for_c_link)
+   __array(0x30,   0x20,   reserved2)
+)
+#include I(REQUEST_END)
+
+#define REQUEST_NAME processor_bus_utilization_wxyz_links
+#define REQUEST_NUM 0x60
+#define REQUEST_IDX_KIND hw_chip_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 4,  hw_chip_id)
+   __array(0x4,0xC,reserved1)
+   __count(0x10,   8,  total_link_cycles)
+   __count(0x18,   8,  idle_cycles_for_w_link)
+   __count(0x20,   8,  idle_cycles_for_x_link)
+   __count(0x28,   8,  idle_cycles_for_y_link)
+   __count(0x30,   8,  idle_cycles_for_z_link)
+   __array(0x38,   0x28,   reserved2)
+)
+#include I(REQUEST_END)
+
+#define REQUEST_NAME processor_bus_utilization_gx_links
+#define REQUEST_NUM 0x70
+#define REQUEST_IDX_KIND hw_chip_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 4,  hw_chip_id)
+   __array(0x4,0xC,reserved1)
+   __count(0x10,   8,  gx0_in_address_cycles)
+   __count(0x18,   8,  gx0_in_data_cycles)
+   __count(0x20,   8,  gx0_in_retries)
+   __count(0x28,   8,  gx0_in_bus_cycles)
+   __count(0x30,   8,  gx0_in_cycles_total)
+   __count(0x38,   8,  gx0_out_address_cycles)
+   __count(0x40,   8,  gx0_out_data_cycles)
+   __count(0x48,   8,  gx0_out_retries)
+   __count(0x50,   8,  gx0_out_bus_cycles)
+   __count(0x58,   8,  gx0_out_cycles_total)
+   __count(0x60,   8,  gx1_in_address_cycles)
+   __count(0x68,   8,  gx1_in_data_cycles)
+   __count(0x70,   8,  gx1_in_retries)
+   __count(0x78,   8,  gx1_in_bus_cycles)
+   __count(0x80,   8,  gx1_in_cycles_total)
+   __count(0x88,   8,  gx1_out_address_cycles)
+   __count(0x90,   8,  gx1_out_data_cycles)
+   __count(0x98,   8,  gx1_out_retries)
+   __count(0xA0,   8,  gx1_out_bus_cycles)
+   __count(0xA8,   8,  gx1_out_cycles_total)
+)
+#include I(REQUEST_END)
+
+#define REQUEST_NAME processor_bus_utilization_mc_links
+#define REQUEST_NUM 0x80
+#define REQUEST_IDX_KIND hw_chip_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 4,  hw_chip_id)
+   __array(0x4,0xC,reserved1)
+   __count(0x10,   8,  mc0_frames)
+   __count(0x18,   8,  mc0_reads)
+   __count(0x20,   8,  mc0_write)
+   __count(0x28,   8,  mc0_total_cycles)
+   __count(0x30,   8,  mc1_frames)
+   __count(0x38,   8,  mc1_reads)
+   __count(0x40,   8,  mc1_writes)
+   __count(0x48,   8,  mc1_total_cycles)
+)
+#include I(REQUEST_END)
+
+/* Processor_config (0x90) skipped, no counters */
+/* Current_processor_frequency (0x91) skipped, no counters */
+
+#def

[PATCH 12/16] powerpc/perf/hv-24x7: parse catalog and populate sysfs with events

2014-05-27 Thread Cody P Schafer
Retrieves and parses the 24x7 catalog on POWER systems that supply it
(right now, only POWER 8). Events are exposed via sysfs in the standard
fashion, and are all parameterized.

Catalog is (at the moment) only parsed on boot. It needs re-parsing
when a some hypervisor events occur. At that point we'll also need to
prevent old events from continuing to function (counter that is passed
in via spare space in the config values?).

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-24x7-catalog.h |  25 ++
 arch/powerpc/perf/hv-24x7-domains.h |  19 +
 arch/powerpc/perf/hv-24x7.c | 760 +++-
 arch/powerpc/perf/hv-24x7.h |  12 +-
 4 files changed, 804 insertions(+), 12 deletions(-)
 create mode 100644 arch/powerpc/perf/hv-24x7-domains.h

diff --git a/arch/powerpc/perf/hv-24x7-catalog.h 
b/arch/powerpc/perf/hv-24x7-catalog.h
index 21b19dd..69e2e1f 100644
--- a/arch/powerpc/perf/hv-24x7-catalog.h
+++ b/arch/powerpc/perf/hv-24x7-catalog.h
@@ -30,4 +30,29 @@ struct hv_24x7_catalog_page_0 {
__u8 reserved6[2];
 } __packed;
 
+struct hv_24x7_event_data {
+   __be16 length; /* in bytes, must be a multiple of 16 */
+   __u8 reserved1[2];
+   __u8 domain; /* Chip = 1, Core = 2 */
+   __u8 reserved2[1];
+   __be16 event_group_record_offs; /* in bytes, must be 8 byte aligned */
+   __be16 event_group_record_len; /* in bytes */
+
+   /* in bytes, offset from event_group_record */
+   __be16 event_counter_offs;
+
+   /* verified_state, unverified_state, caveat_state, broken_state, ... */
+   __be32 flags;
+
+   __be16 primary_group_ix;
+   __be16 group_count;
+   __be16 event_name_len;
+   __u8 remainder[];
+   /* __u8 event_name[event_name_len - 2]; */
+   /* __be16 event_description_len; */
+   /* __u8 event_desc[event_description_len - 2]; */
+   /* __be16 detailed_desc_len; */
+   /* __u8 detailed_desc[detailed_desc_len - 2]; */
+} __packed;
+
 #endif
diff --git a/arch/powerpc/perf/hv-24x7-domains.h 
b/arch/powerpc/perf/hv-24x7-domains.h
new file mode 100644
index 000..9c5c862
--- /dev/null
+++ b/arch/powerpc/perf/hv-24x7-domains.h
@@ -0,0 +1,19 @@
+
+/*
+ * DOMAIN(name, num, index_kind, is_physical)
+ *
+ * @name: an all caps token, suitable for use in generating an enum member and
+ *appending to an event name in sysfs.
+ * @num: the number corresponding to the domain as given in documentation. We
+ *   assume the catalog domain and the hcall domain have the same numbering
+ *   (so far they do), but this may need to be changed in the future.
+ * @index_kind: a stringifiable token describing the meaning of the index 
within the
+ *  given domain. Must fit the parsing rules of the perf sysfs api.
+ * @is_physical: true if the domain is physical, false otherwise (if virtual).
+ */
+DOMAIN(PHYSICAL_CHIP, 0x01, chip, true)
+DOMAIN(PHYSICAL_CORE, 0x02, core, true)
+DOMAIN(VIRTUAL_PROCESSOR_HOME_CORE, 0x03, vcpu, false)
+DOMAIN(VIRTUAL_PROCESSOR_HOME_CHIP, 0x04, vcpu, false)
+DOMAIN(VIRTUAL_PROCESSOR_HOME_NODE, 0x05, vcpu, false)
+DOMAIN(VIRTUAL_PROCESSOR_REMOTE_NODE, 0x06, vcpu, false)
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 9a7a830..c9b7c55 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -1,3 +1,4 @@
+#define DEBUG 1
 /*
  * Hypervisor supplied "24x7" performance counter support
  *
@@ -12,9 +13,13 @@
 
 #define pr_fmt(fmt) "hv-24x7: " fmt
 
+#include 
 #include 
+#include 
 #include 
 #include 
+#include 
+
 #include 
 #include 
 #include 
@@ -23,6 +28,66 @@
 #include "hv-24x7-catalog.h"
 #include "hv-common.h"
 
+static const char *domain_to_index_string(unsigned domain)
+{
+   switch (domain) {
+#define DOMAIN(n, v, x, c) \
+   case HV_PERF_DOMAIN_##n:\
+   return #x;
+#include "hv-24x7-domains.h"
+#undef DOMAIN
+   default:
+   WARN(1, "unknown domain %d\n", domain);
+   return "UNKNOWN_DOMAIN_INDEX_STRING";
+   }
+}
+
+static const char *event_domain_suffix(unsigned domain)
+{
+   switch (domain) {
+#define DOMAIN(n, v, x, c) \
+   case HV_PERF_DOMAIN_##n:\
+   return "__" #n;
+#include "hv-24x7-domains.h"
+#undef DOMAIN
+   default:
+   WARN(1, "unknown domain %d\n", domain);
+   return "__UNKNOWN_DOMAIN_SUFFIX";
+   }
+}
+
+static bool domain_is_valid(unsigned domain)
+{
+   switch (domain) {
+#define DOMAIN(n, v, x, c) \
+   case HV_PERF_DOMAIN_##n:\
+   /* fall through */
+#include "hv-24x7-domains.h"
+#undef DOMAIN
+   return true;
+   default:
+   return false;
+   }
+}
+
+static bool is_physical_domain

[PATCH 11/16] byteorder: provide a linux/byteorder.h with {be,le}_to_cpu() and cpu_to_{be,le}() macros

2014-05-27 Thread Cody P Schafer
Rather manually specifying the size of the integer to be converted, key
off of the type size. Reduces duplicate size info and the occurance of
certain types of bugs (using the wrong sized conversion).

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 include/linux/byteorder.h | 34 ++
 1 file changed, 34 insertions(+)
 create mode 100644 include/linux/byteorder.h

diff --git a/include/linux/byteorder.h b/include/linux/byteorder.h
new file mode 100644
index 000..c7ab8da
--- /dev/null
+++ b/include/linux/byteorder.h
@@ -0,0 +1,34 @@
+#ifndef LINUX_BYTEORDER_H_
+#define LINUX_BYTEORDER_H_
+
+#include 
+
+#define be_to_cpu(v) \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
+   (void)0
+
+#define le_to_cpu(v) \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), le16_to_cpu(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), le32_to_cpu(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), le64_to_cpu(v), \
+   (void)0
+
+#define cpu_to_le(v) \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), cpu_to_le16(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), cpu_to_le32(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), cpu_to_le64(v), \
+   (void)0
+
+#define cpu_to_be(v) \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), cpu_to_be16(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), cpu_to_be32(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), cpu_to_be64(v), \
+   (void)0
+
+#endif
-- 
1.9.3

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


[PATCH 13/16] powerpc/perf/hv-24x7: Documentaion for new sysfs entries which expose descriptions

2014-05-27 Thread Cody P Schafer
CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 .../testing/sysfs-bus-event_source-devices-hv_24x7 | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
index e78ee79..5b501d7 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
@@ -21,3 +21,25 @@ Contact: Cody P Schafer 
 Description:
Exposes the "version" field of the 24x7 catalog. This is also
extractable from the provided binary "catalog" sysfs entry.
+
+What:  /sys/bus/event_source/devices/hv_24x7/event_descs/
+Date:  February 2014
+Contact:   Cody P Schafer 
+Description:
+   Provides the description of a particular event as provided by
+   the firmware. If firmware does not provide a description, no
+   file will be created.
+
+   Note that the event-name lacks the domain suffix appended for
+   events in the events/ dir.
+
+What:  
/sys/bus/event_source/devices/hv_24x7/event_long_descs/
+Date:  February 2014
+Contact:   Cody P Schafer 
+Description:
+   Provides the "long" description of a particular event as
+   provided by the firmware. If firmware does not provide a
+   description, no file will be created.
+
+   Note that the event-name lacks the domain suffix appended for
+   events in the events/ dir.
-- 
1.9.3

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


[PATCH 07/16] tools/perf: support parsing parameterized events

2014-05-27 Thread Cody P Schafer
Enable event specification like:

pmu/event_name,param1=0x1,param2=0x4/

Assuming that

/sys/bus/event_source/devices/pmu/events/event_name

Contains something like

bar=param2,foo=1,baz=param1

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 tools/perf/util/parse-events.h |  1 +
 tools/perf/util/pmu.c  | 55 ++
 2 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index f1cb4c4..1147e87 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -60,6 +60,7 @@ struct parse_events_term {
int type_val;
int type_term;
struct list_head list;
+   bool used;
 };
 
 struct parse_events_evlist {
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 906ae40..db53fac 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -504,27 +504,57 @@ static __u64 pmu_format_value(unsigned long *format, 
__u64 value)
 }
 
 /*
+ * Term is a string term, and might be a param-term. Try to look up it's value
+ * in the remaining terms.
+ * - We have a term like "base-or-format-term=param-term",
+ * - We need to find the value supplied for "param-term" (with param-term named
+ *   in a config string) later on in the term list.
+ */
+static int pmu_resolve_param_term(struct parse_events_term *term,
+ struct list_head *head_terms,
+ __u64 *value)
+{
+   struct parse_events_term *t;
+
+   list_for_each_entry(t, head_terms, list)
+   if (t->type_val == PARSE_EVENTS__TERM_TYPE_NUM) {
+   if (!strcmp(t->config, term->val.str)) {
+   t->used = true;
+   *value = t->val.num;
+   return 0;
+   }
+   }
+
+   return -1;
+}
+
+/*
  * Setup one of config[12] attr members based on the
  * user input data - term parameter.
  */
 static int pmu_config_term(struct list_head *formats,
   struct perf_event_attr *attr,
-  struct parse_events_term *term)
+  struct parse_events_term *term,
+  struct list_head *head_terms)
 {
struct perf_pmu_format *format;
__u64 *vp;
+   __u64 val;
+
+   /*
+* If this is a parameter we've already used for parameterized-eval,
+* skip it in normal eval.
+*/
+   if (term->used)
+   return 0;
 
/*
-* Support only for hardcoded and numnerial terms.
 * Hardcoded terms should be already in, so nothing
 * to be done for them.
 */
if (parse_events__is_hardcoded_term(term))
return 0;
 
-   if (term->type_val != PARSE_EVENTS__TERM_TYPE_NUM)
-   return -EINVAL;
-
format = pmu_find_format(formats, term->config);
if (!format)
return -EINVAL;
@@ -544,11 +574,16 @@ static int pmu_config_term(struct list_head *formats,
}
 
/*
-* XXX If we ever decide to go with string values for
-* non-hardcoded terms, here's the place to translate
-* them into value.
+* Either directly use a numeric term, or try to translate string terms
+* using event parameters.
 */
-   *vp |= pmu_format_value(format->bits, term->val.num);
+   if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM)
+   val = term->val.num;
+   else
+   if (pmu_resolve_param_term(term, head_terms, ))
+   return -EINVAL;
+
+   *vp |= pmu_format_value(format->bits, val);
return 0;
 }
 
@@ -559,7 +594,7 @@ int perf_pmu__config_terms(struct list_head *formats,
struct parse_events_term *term;
 
list_for_each_entry(term, head_terms, list)
-   if (pmu_config_term(formats, attr, term))
+   if (pmu_config_term(formats, attr, term, head_terms))
return -EINVAL;
 
return 0;
-- 
1.9.3

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


[PATCH 09/16] tools/perf: document parameterized events and note symbolically formed events

2014-05-27 Thread Cody P Schafer
CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 tools/perf/Documentation/perf-list.txt   | 13 +
 tools/perf/Documentation/perf-record.txt |  5 +
 2 files changed, 18 insertions(+)

diff --git a/tools/perf/Documentation/perf-list.txt 
b/tools/perf/Documentation/perf-list.txt
index 6fce6a6..626818b 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -89,6 +89,19 @@ raw encoding of 0x1A8 can be used:
 You should refer to the processor specific documentation for getting these
 details. Some of them are referenced in the SEE ALSO section below.
 
+PARAMETERIZED EVENTS
+
+
+Some pmu events listed by 'perf-list' will be displayed with '?' in them. For
+example:
+
+  hv_gpci/dtbp_ptitc,phys_processor_idx=?/
+
+This means that when provided as an event, a value for phys_processor_idx must
+also be supplied. For example:
+
+  perf stat -e 'hv_gpci/dtbp_ptitc,phys_processor_idx=0x2/' ...
+
 OPTIONS
 ---
 
diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index c71b0f3..c005180 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -33,6 +33,11 @@ OPTIONS
 - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
  hexadecimal event descriptor.
 
+   - a symbolicly formed PMU event like 'pmu/value1=0x3,value2/' where
+ 'value1' and 'value2' are defined as formats in
+ /sys/bus/event_sources/devices/pmu/format/* OR are one of 'config',
+ 'config1', 'config2'.
+
 - a hardware breakpoint event in the form of '\mem:addr[:access]'
   where addr is the address in memory you want to break in.
   Access is the memory access type (read, write, execute) it can
-- 
1.9.3

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


[PATCH 05/16] perf Documentation: add event parameters

2014-05-27 Thread Cody P Schafer
Event parameters are a basic way for partial events to be specified in
sysfs with per-event names given to the fields that need to be filled in
when using a particular event.

It is intended for supporting cases where the single 'cpu' parameter is
insufficient. For example, POWER 8 has events for physical
sockets/cores/cpus that are accessible from with virtual machines. To
keep using the single 'cpu' parameter we'd need to perform a mapping
between Linux's cpus and the physical machine's cpus (in this case
Linux is running under a hypervisor). This isn't possible because
bindings between our cpus and physical cpus may not be fixed, and we
probably won't have a "cpu" on each physical cpu.

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 Documentation/ABI/testing/sysfs-bus-event_source-devices-events | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index 20979f8..c1f9850 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -52,12 +52,18 @@ Description:Per-pmu performance monitoring events 
specific to the running syste
event=0x2abc
event=0x423,inv,cmask=0x3
domain=0x1,offset=0x8,starting_index=0x
+   domain=0x1,offset=0x8,starting_index=phys_cpu
 
Each of the assignments indicates a value to be assigned to a
particular set of bits (as defined by the format file
corresponding to the ) in the perf_event structure passed
to the perf_open syscall.
 
+   In the case of the last example, a value replacing "phys_cpu"
+   would need to be provided by the user selecting the particular
+   event. This is refered to as "event parameterization". All
+   non-numerical values indicate an event parameter.
+
 What: /sys/bus/event_source/devices//events/.unit
 Date: 2014/02/24
 Contact:   Linux kernel mailing list 
-- 
1.9.3

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


[PATCH 08/16] tools/perf: extend format_alias() to include event parameters

2014-05-27 Thread Cody P Schafer
This causes `perf list pmu` to show parameters for parameterized events
like follows:

  pmu/event_name,param1=?,param2=?/ [Kernel PMU event]

An example:

  
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=?/
 [Kernel PMU event]

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 tools/perf/util/pmu.c | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index db53fac..7b8d067 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -741,10 +741,33 @@ void perf_pmu__set_format(unsigned long *bits, long from, 
long to)
set_bit(b, bits);
 }
 
+static int sub_non_neg(int a, int b)
+{
+   if (b > a)
+   return 0;
+   return a - b;
+}
+
 static char *format_alias(char *buf, int len, struct perf_pmu *pmu,
  struct perf_pmu_alias *alias)
 {
-   snprintf(buf, len, "%s/%s/", pmu->name, alias->name);
+   struct parse_events_term *term;
+   int used = snprintf(buf, len, "%s/%s", pmu->name, alias->name);
+
+   list_for_each_entry(term, >terms, list)
+   if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR)
+   used += snprintf(buf + used, sub_non_neg(len, used),
+   ",%s=?", term->val.str);
+
+   if (sub_non_neg(len, used) > 0) {
+   buf[used] = '/';
+   used++;
+   }
+   if (sub_non_neg(len, used) > 0) {
+   buf[used] = '\0';
+   used++;
+   } else
+   buf[len - 1] = '\0';
return buf;
 }
 
@@ -795,6 +818,7 @@ void print_pmu_events(const char *event_glob, bool 
name_only)
if (is_cpu && !name_only)
aliases[j] = format_alias_or(buf, sizeof(buf),
  pmu, alias);
+
aliases[j] = strdup(aliases[j]);
j++;
}
-- 
1.9.3

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


[PATCH 10/16] perf: provide sysfs_show for struct perf_pmu_events_attr

2014-05-27 Thread Cody P Schafer
(struct perf_pmu_events_attr) is defined in include/linux/perf_event.h,
but the only "show" for it is in x86 and contains x86 specific stuff.

Make a generic one for those of us who are just using the event_str.

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 include/linux/perf_event.h | 3 +++
 kernel/events/core.c   | 8 
 2 files changed, 11 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 3356abc..6c1d6dd 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -867,6 +867,9 @@ struct perf_pmu_events_attr {
const char *event_str;
 };
 
+ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute 
*attr,
+ char *page);
+
 #define PMU_EVENT_ATTR(_name, _var, _id, _show)
\
 static struct perf_pmu_events_attr _var = {\
.attr = __ATTR(_name, 0444, _show, NULL),   \
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f83a71a..6830e21 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7971,6 +7971,14 @@ void __init perf_event_init(void)
 != 1024);
 }
 
+ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute 
*attr,
+ char *page)
+{
+   struct perf_pmu_events_attr *pmu_attr =
+   container_of(attr, struct perf_pmu_events_attr, attr);
+   return sprintf(page, "%s\n", pmu_attr->event_str);
+}
+
 static int __init perf_event_sysfs_init(void)
 {
struct pmu *pmu;
-- 
1.9.3

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


[PATCH 06/16] tools/perf: annotate list_head with type info

2014-05-27 Thread Cody P Schafer
CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 tools/perf/util/pmu.c | 4 ++--
 tools/perf/util/pmu.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 00a7dcb..906ae40 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -14,8 +14,8 @@
 
 struct perf_pmu_alias {
char *name;
-   struct list_head terms;
-   struct list_head list;
+   struct list_head terms; /* HEAD struct parse_events_term -> list */
+   struct list_head list;  /* ELEM */
char unit[UNIT_MAX_LEN+1];
double scale;
 };
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 8b64125..4a85230 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -17,9 +17,9 @@ struct perf_pmu {
char *name;
__u32 type;
struct cpu_map *cpus;
-   struct list_head format;
-   struct list_head aliases;
-   struct list_head list;
+   struct list_head format;  /* HEAD struct perf_pmu_format -> list */
+   struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
+   struct list_head list;/* ELEM */
 };
 
 struct perf_pmu *perf_pmu__find(const char *name);
-- 
1.9.3

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


[PATCH 02/16] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-27 Thread Cody P Schafer
Ian pointed out the use of __aligned(4096) caused rather large stack
consumption in single_24x7_request(), so use the kmem_cache
hv_page_cache (which we've already got set up for other allocations)
insead of allocating locally.

CC: Sukadev Bhattiprolu 
Reported-by: Ian Munsie 
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-24x7.c | 52 -
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index e0766b8..9a7a830 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -294,7 +294,7 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
 u16 lpar, u64 *res,
 bool success_expected)
 {
-   unsigned long ret;
+   unsigned long ret = -ENOMEM;
 
/*
 * request_buffer and result_buffer are not required to be 4k aligned,
@@ -304,7 +304,27 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
struct reqb {
struct hv_24x7_request_buffer buf;
struct hv_24x7_request req;
-   } __packed __aligned(4096) request_buffer = {
+   } __packed *request_buffer;
+   struct resb {
+   struct hv_24x7_data_result_buffer buf;
+   struct hv_24x7_result res;
+   struct hv_24x7_result_element elem;
+   __be64 result;
+   } __packed *result_buffer;
+
+   BUILD_BUG_ON(sizeof(*request_buffer) > 4096);
+   BUILD_BUG_ON(sizeof(*result_buffer) > 4096);
+
+   request_buffer = kmem_cache_alloc(hv_page_cache, GFP_USER);
+
+   if (!request_buffer)
+   goto out_reqb;
+
+   result_buffer = kmem_cache_zalloc(hv_page_cache, GFP_USER);
+   if (!result_buffer)
+   goto out_resb;
+
+   *request_buffer = (struct reqb) {
.buf = {
.interface_version = HV_24X7_IF_VERSION_CURRENT,
.num_requests = 1,
@@ -320,28 +340,30 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
}
};
 
-   struct resb {
-   struct hv_24x7_data_result_buffer buf;
-   struct hv_24x7_result res;
-   struct hv_24x7_result_element elem;
-   __be64 result;
-   } __packed __aligned(4096) result_buffer = {};
-
ret = plpar_hcall_norets(H_GET_24X7_DATA,
-   virt_to_phys(_buffer), sizeof(request_buffer),
-   virt_to_phys(_buffer),  sizeof(result_buffer));
+   virt_to_phys(request_buffer), sizeof(*request_buffer),
+   virt_to_phys(result_buffer),  sizeof(*result_buffer));
 
if (ret) {
if (success_expected)
pr_err_ratelimited("hcall failed: %d %#x %#x %d => 
0x%lx (%ld) detail=0x%x failing ix=%x\n",
domain, offset, ix, lpar,
ret, ret,
-   result_buffer.buf.detailed_rc,
-   result_buffer.buf.failing_request_ix);
-   return ret;
+   result_buffer->buf.detailed_rc,
+   result_buffer->buf.failing_request_ix);
+   goto out_hcall;
}
 
-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer->result);
+   kfree(result_buffer);
+   kfree(request_buffer);
+   return ret;
+
+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
 }
 
-- 
1.9.3

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


[PATCH 03/16] perf Documentation: sysfs events/ interfaces

2014-05-27 Thread Cody P Schafer
Add documentation for the , .scale, and .unit
files in sysfs.

.scale and .unit were undocumented.
 was previously documented only for specific powerpc pmu events.

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 .../testing/sysfs-bus-event_source-devices-events  | 60 ++
 1 file changed, 60 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index 7b40a3c..a5226f0 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -599,3 +599,63 @@ Description:   POWER-systems specific performance 
monitoring events
Further, multiple terms like 'event=0x' can be specified
and separated with comma. All available terms are defined in
the /sys/bus/event_source/devices//format file.
+
+What: /sys/bus/event_source/devices//events/
+Date: 2014/02/24
+Contact:   Linux kernel mailing list 
+Description:   Per-pmu performance monitoring events specific to the running 
system
+
+   Each file (except for some of those with a '.' in them, '.unit'
+   and '.scale') in the 'events' directory describes a single
+   performance monitoring event supported by the . The name
+   of the file is the name of the event.
+
+   File contents:
+
+   [=][,[=]]...
+
+   Where  is one of the terms listed under
+   /sys/bus/event_source/devices//format/ and  is
+   a number is base-16 format with a '0x' prefix (lowercase only).
+   If a  is specified alone (without an assigned value), it
+   is implied that 0x1 is assigned to that .
+
+   Examples (each of these lines would be in a seperate file):
+
+   event=0x2abc
+   event=0x423,inv,cmask=0x3
+   domain=0x1,offset=0x8,starting_index=0x
+
+   Each of the assignments indicates a value to be assigned to a
+   particular set of bits (as defined by the format file
+   corresponding to the ) in the perf_event structure passed
+   to the perf_open syscall.
+
+What: /sys/bus/event_source/devices//events/.unit
+Date: 2014/02/24
+Contact:   Linux kernel mailing list 
+Description:   Perf event units
+
+   A string specifying the English plural numerical unit that 

+   (once multiplied by .scale) represents.
+
+   Example:
+
+   Joules
+
+What: /sys/bus/event_source/devices//events/.scale
+Date: 2014/02/24
+Contact:   Linux kernel mailing list 
+Description:   Perf event scaling factors
+
+   A string representing a floating point value expressed in
+   scientific notation to be multiplied by the event count
+   recieved from the kernel to match the unit specified in the
+   .unit file.
+
+   Example:
+
+   2.3283064365386962890625e-10
+
+   This is provided to avoid performing floating point arithmetic
+   in the kernel.
-- 
1.9.3

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


[PATCH 04/16] perf Documentation: remove duplicated docs for powerpc cpu specific events

2014-05-27 Thread Cody P Schafer
Listing specific events doesn't actually help us at all here because:
 - these events actually vary between different ppc processors, they
   aren't garunteed to be present.
 - the documentation of the (generic) file contents is now superceded by the
   docs for arbitrary event file contents.

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 .../testing/sysfs-bus-event_source-devices-events  | 573 -
 1 file changed, 573 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index a5226f0..20979f8 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -27,579 +27,6 @@ Description:Generic performance monitoring events
"basename".
 
 
-What:  /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL
-   /sys/devices/cpu/events/PM_BRU_FIN
-   /sys/devices/cpu/events/PM_BR_MPRED
-   /sys/devices/cpu/events/PM_CMPLU_STALL
-   /sys/devices/cpu/events/PM_CMPLU_STALL_BRU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DFU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DIV
-   /sys/devices/cpu/events/PM_CMPLU_STALL_ERAT_MISS
-   /sys/devices/cpu/events/PM_CMPLU_STALL_FXU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_IFU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_LSU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_REJECT
-   /sys/devices/cpu/events/PM_CMPLU_STALL_SCALAR
-   /sys/devices/cpu/events/PM_CMPLU_STALL_SCALAR_LONG
-   /sys/devices/cpu/events/PM_CMPLU_STALL_STORE
-   /sys/devices/cpu/events/PM_CMPLU_STALL_THRD
-   /sys/devices/cpu/events/PM_CMPLU_STALL_VECTOR
-   /sys/devices/cpu/events/PM_CMPLU_STALL_VECTOR_LONG
-   /sys/devices/cpu/events/PM_CYC
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_BR_MPRED
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_BR_MPRED_IC_MISS
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_IC_MISS
-   /sys/devices/cpu/events/PM_GRP_CMPL
-   /sys/devices/cpu/events/PM_INST_CMPL
-   /sys/devices/cpu/events/PM_LD_MISS_L1
-   /sys/devices/cpu/events/PM_LD_REF_L1
-   /sys/devices/cpu/events/PM_RUN_CYC
-   /sys/devices/cpu/events/PM_RUN_INST_CMPL
-   /sys/devices/cpu/events/PM_IC_DEMAND_L2_BR_ALL
-   /sys/devices/cpu/events/PM_GCT_UTIL_7_TO_10_SLOTS
-   /sys/devices/cpu/events/PM_PMC2_SAVED
-   /sys/devices/cpu/events/PM_VSU0_16FLOP
-   /sys/devices/cpu/events/PM_MRK_LSU_DERAT_MISS
-   /sys/devices/cpu/events/PM_MRK_ST_CMPL
-   /sys/devices/cpu/events/PM_NEST_PAIR3_ADD
-   /sys/devices/cpu/events/PM_L2_ST_DISP
-   /sys/devices/cpu/events/PM_L2_CASTOUT_MOD
-   /sys/devices/cpu/events/PM_ISEG
-   /sys/devices/cpu/events/PM_MRK_INST_TIMEO
-   /sys/devices/cpu/events/PM_L2_RCST_DISP_FAIL_ADDR
-   /sys/devices/cpu/events/PM_LSU1_DC_PREF_STREAM_CONFIRM
-   /sys/devices/cpu/events/PM_IERAT_WR_64K
-   /sys/devices/cpu/events/PM_MRK_DTLB_MISS_16M
-   /sys/devices/cpu/events/PM_IERAT_MISS
-   /sys/devices/cpu/events/PM_MRK_PTEG_FROM_LMEM
-   /sys/devices/cpu/events/PM_FLOP
-   /sys/devices/cpu/events/PM_THRD_PRIO_4_5_CYC
-   /sys/devices/cpu/events/PM_BR_PRED_TA
-   /sys/devices/cpu/events/PM_EXT_INT
-   /sys/devices/cpu/events/PM_VSU_FSQRT_FDIV
-   /sys/devices/cpu/events/PM_MRK_LD_MISS_EXPOSED_CYC
-   /sys/devices/cpu/events/PM_LSU1_LDF
-   /sys/devices/cpu/events/PM_IC_WRITE_ALL
-   /sys/devices/cpu/events/PM_LSU0_SRQ_STFWD
-   /sys/devices/cpu/events/PM_PTEG_FROM_RL2L3_MOD
-   /sys/devices/cpu/events/PM_MRK_DATA_FROM_L31_SHR
-   /sys/devices/cpu/events/PM_DATA_FROM_L21_MOD
-   /sys/devices/cpu/events/PM_VSU1_SCAL_DOUBLE_ISSUED
-   /sys/devices/cpu/events/PM_VSU0_8FLOP
-   /sys/devices/cpu/events/PM_POWER_EVENT1
-   /sys/devices/cpu/events/PM_DISP_CLB_HELD_BAL
-   /sys/devices/cpu/events/PM_VSU1_2FLOP
-   /sys/devices/cpu/events/PM_LWSYNC_HELD
-   /sys/devices/cpu/events/PM_PTEG_FROM_DL2L3_SHR
-   /sys/devices/cpu/events/PM_INST_FROM_L21_MOD
-   /sys/devices/cpu/events/PM_IERAT_XLATE_WR_16MPLUS
-   /sys/devices/cpu/events/PM_IC_REQ_ALL
-   /sys/devices/cpu/events/PM

[PATCH 01/16] tools/perf: allow overriding sysfs and proc finding with env var

2014-05-27 Thread Cody P Schafer
SYSFS_PATH and PROC_PATH environment variables now let the user override
the detection of sysfs and proc locations for testing purposes.

CC: Sukadev Bhattiprolu 
Signed-off-by: Cody P Schafer 
---
 tools/lib/api/fs/fs.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb78..c1b49c3 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
 /* TODO merge/factor in debugfs.c here */
 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
 }
 
+static void mem_toupper(char *f, size_t len)
+{
+   while (len) {
+   *f = toupper(*f);
+   f++;
+   len--;
+   }
+}
+
+/*
+ * Check for "NAME_PATH" environment variable to override fs location (for
+ * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * for SYSFS_PATH.
+ */
+static bool fs__env_override(struct fs *fs)
+{
+   char *override_path;
+   size_t name_len = strlen(fs->name);
+   /* name + "_PATH" + '\0' */
+   char upper_name[name_len + 5 + 1];
+   memcpy(upper_name, fs->name, name_len);
+   mem_toupper(upper_name, name_len);
+   strcpy(_name[name_len], "_PATH");
+
+   override_path = getenv(upper_name);
+   if (!override_path)
+   return false;
+
+   fs->found = true;
+   strncpy(fs->path, override_path, sizeof(fs->path));
+   return true;
+}
+
 static const char *fs__get_mountpoint(struct fs *fs)
 {
+   if (fs__env_override(fs))
+   return fs->path;
+
if (fs__check_mounts(fs))
return fs->path;
 
-   return fs__read_mounts(fs) ? fs->path : NULL;
+   if (fs__read_mounts(fs))
+   return fs->path;
+
+   return NULL;
 }
 
 static const char *fs__mountpoint(int idx)
-- 
1.9.3

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


[PATCH 00/16] perf: add support for parameterized events from sysfs (powerpc 24x7)

2014-05-27 Thread Cody P Schafer
What this patchset does:

 - the first patch (override sysfs in tools/perf via SYSFS_PATH) was sent out
   previously, but needed a resend anyhow. Having it is useful for testing the
   later changes to tools/perf.
 - the second patch is a bugfix to the powerpc hv-24x7 code which was
   previously sent out, which is a good idea to have when testing these patches
   on POWER8 hardware.

 - document perf sysfs and the changes to add parameterized events
   - semi-notably: removes the growing list of specific POWER cpu events and
 begins documenting them generically, much like the docs for
 /sys/modules/MODULENAME do for modules.
 - tools/perf changes to support parameterized events
 - export some parameterized events from the powerpc pmus hv_24x7 and hv_gpci

Description of "event parameters" from the documentation patch:

Event parameters are a basic way for partial events to be specified in
sysfs with per-event names given to the fields that need to be filled in
when using a particular event.

It is intended for supporting cases where the single 'cpu' parameter is
insufficient. For example, POWER 8 has events for physical
sockets/cores/cpus that are accessible from with virtual machines. To
keep using the single 'cpu' parameter we'd need to perform a mapping
between Linux's cpus and the physical machine's cpus (in this case
Linux is running under a hypervisor). This isn't possible because
bindings between our cpus and physical cpus may not be fixed, and we
probably won't have a "cpu" on each physical cpu.

Description of the sysfs contents when events are parameterized (copied from an
included patch):

Examples:

domain=0x1,offset=0x8,starting_index=phys_cpu

In the case of the last example, a value replacing "phys_cpu"
would need to be provided by the user selecting the particular
event. This is refered to as "event parameterization". All
non-numerical values indicate an event parameter.

Notes on how perf-list displays parameterized events (and how to use them,
again culled from an included patch):

PARAMETERIZED EVENTS


Some pmu events listed by 'perf-list' will be displayed with '?' in 
them. For
example:

  hv_gpci/dtbp_ptitc,phys_processor_idx=?/

This means that when provided as an event, a value for 
phys_processor_idx must
also be supplied. For example:

  perf stat -e 'hv_gpci/dtbp_ptitc,phys_processor_idx=0x2/' ...


Cody P Schafer (16):
  tools/perf: allow overriding sysfs and proc finding with env var
  powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack
allocations
  perf Documentation: sysfs events/ interfaces
  perf Documentation: remove duplicated docs for powerpc cpu specific
events
  perf Documentation: add event parameters
  tools/perf: annotate list_head with type info
  tools/perf: support parsing parameterized events
  tools/perf: extend format_alias() to include event parameters
  tools/perf: document parameterized events and note symbolically formed
events
  perf: provide sysfs_show for struct perf_pmu_events_attr
  byteorder: provide a linux/byteorder.h with {be,le}_to_cpu() and
cpu_to_{be,le}() macros
  powerpc/perf/hv-24x7: parse catalog and populate sysfs with events
  powerpc/perf/hv-24x7: Documentaion for new sysfs entries which expose
descriptions
  perf: add PMU_EVENT_ATTR_STRING() helper
  powerpc/perf/{hv-gpci,hv-common}: generate requests with counters
annotated
  powerpc/perf/hv-gpci: add the remaining gpci requests

 .../testing/sysfs-bus-event_source-devices-events  | 617 ++--
 .../testing/sysfs-bus-event_source-devices-hv_24x7 |  22 +
 arch/powerpc/perf/hv-24x7-catalog.h|  25 +
 arch/powerpc/perf/hv-24x7-domains.h|  19 +
 arch/powerpc/perf/hv-24x7.c| 812 -
 arch/powerpc/perf/hv-24x7.h|  12 +-
 arch/powerpc/perf/hv-common.c  |  10 +-
 arch/powerpc/perf/hv-gpci-requests.h   | 258 +++
 arch/powerpc/perf/hv-gpci.c|   8 +
 arch/powerpc/perf/hv-gpci.h|  37 +-
 arch/powerpc/perf/req-gen/_begin.h |  13 +
 arch/powerpc/perf/req-gen/_clear.h |   5 +
 arch/powerpc/perf/req-gen/_end.h   |   4 +
 arch/powerpc/perf/req-gen/_request-begin.h |  15 +
 arch/powerpc/perf/req-gen/_request-end.h   |   8 +
 arch/powerpc/perf/req-gen/perf.h   | 155 
 include/linux/byteorder.h  |  34 +
 include/linux/perf_event.h |  10 +
 kernel/events/core.c   |   8 +
 tools/lib/api/fs/fs.c  |  43 +-
 tools/perf/Documentation/perf-list.txt |  13 +
 

[PATCH 00/16] perf: add support for parameterized events from sysfs (powerpc 24x7)

2014-05-27 Thread Cody P Schafer
What this patchset does:

 - the first patch (override sysfs in tools/perf via SYSFS_PATH) was sent out
   previously, but needed a resend anyhow. Having it is useful for testing the
   later changes to tools/perf.
 - the second patch is a bugfix to the powerpc hv-24x7 code which was
   previously sent out, which is a good idea to have when testing these patches
   on POWER8 hardware.

 - document perf sysfs and the changes to add parameterized events
   - semi-notably: removes the growing list of specific POWER cpu events and
 begins documenting them generically, much like the docs for
 /sys/modules/MODULENAME do for modules.
 - tools/perf changes to support parameterized events
 - export some parameterized events from the powerpc pmus hv_24x7 and hv_gpci

Description of event parameters from the documentation patch:

Event parameters are a basic way for partial events to be specified in
sysfs with per-event names given to the fields that need to be filled in
when using a particular event.

It is intended for supporting cases where the single 'cpu' parameter is
insufficient. For example, POWER 8 has events for physical
sockets/cores/cpus that are accessible from with virtual machines. To
keep using the single 'cpu' parameter we'd need to perform a mapping
between Linux's cpus and the physical machine's cpus (in this case
Linux is running under a hypervisor). This isn't possible because
bindings between our cpus and physical cpus may not be fixed, and we
probably won't have a cpu on each physical cpu.

Description of the sysfs contents when events are parameterized (copied from an
included patch):

Examples:

domain=0x1,offset=0x8,starting_index=phys_cpu

In the case of the last example, a value replacing phys_cpu
would need to be provided by the user selecting the particular
event. This is refered to as event parameterization. All
non-numerical values indicate an event parameter.

Notes on how perf-list displays parameterized events (and how to use them,
again culled from an included patch):

PARAMETERIZED EVENTS


Some pmu events listed by 'perf-list' will be displayed with '?' in 
them. For
example:

  hv_gpci/dtbp_ptitc,phys_processor_idx=?/

This means that when provided as an event, a value for 
phys_processor_idx must
also be supplied. For example:

  perf stat -e 'hv_gpci/dtbp_ptitc,phys_processor_idx=0x2/' ...


Cody P Schafer (16):
  tools/perf: allow overriding sysfs and proc finding with env var
  powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack
allocations
  perf Documentation: sysfs events/ interfaces
  perf Documentation: remove duplicated docs for powerpc cpu specific
events
  perf Documentation: add event parameters
  tools/perf: annotate list_head with type info
  tools/perf: support parsing parameterized events
  tools/perf: extend format_alias() to include event parameters
  tools/perf: document parameterized events and note symbolically formed
events
  perf: provide sysfs_show for struct perf_pmu_events_attr
  byteorder: provide a linux/byteorder.h with {be,le}_to_cpu() and
cpu_to_{be,le}() macros
  powerpc/perf/hv-24x7: parse catalog and populate sysfs with events
  powerpc/perf/hv-24x7: Documentaion for new sysfs entries which expose
descriptions
  perf: add PMU_EVENT_ATTR_STRING() helper
  powerpc/perf/{hv-gpci,hv-common}: generate requests with counters
annotated
  powerpc/perf/hv-gpci: add the remaining gpci requests

 .../testing/sysfs-bus-event_source-devices-events  | 617 ++--
 .../testing/sysfs-bus-event_source-devices-hv_24x7 |  22 +
 arch/powerpc/perf/hv-24x7-catalog.h|  25 +
 arch/powerpc/perf/hv-24x7-domains.h|  19 +
 arch/powerpc/perf/hv-24x7.c| 812 -
 arch/powerpc/perf/hv-24x7.h|  12 +-
 arch/powerpc/perf/hv-common.c  |  10 +-
 arch/powerpc/perf/hv-gpci-requests.h   | 258 +++
 arch/powerpc/perf/hv-gpci.c|   8 +
 arch/powerpc/perf/hv-gpci.h|  37 +-
 arch/powerpc/perf/req-gen/_begin.h |  13 +
 arch/powerpc/perf/req-gen/_clear.h |   5 +
 arch/powerpc/perf/req-gen/_end.h   |   4 +
 arch/powerpc/perf/req-gen/_request-begin.h |  15 +
 arch/powerpc/perf/req-gen/_request-end.h   |   8 +
 arch/powerpc/perf/req-gen/perf.h   | 155 
 include/linux/byteorder.h  |  34 +
 include/linux/perf_event.h |  10 +
 kernel/events/core.c   |   8 +
 tools/lib/api/fs/fs.c  |  43 +-
 tools/perf/Documentation/perf-list.txt |  13 +
 tools/perf/Documentation/perf-record.txt

[PATCH 02/16] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-27 Thread Cody P Schafer
Ian pointed out the use of __aligned(4096) caused rather large stack
consumption in single_24x7_request(), so use the kmem_cache
hv_page_cache (which we've already got set up for other allocations)
insead of allocating locally.

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Reported-by: Ian Munsie imun...@au1.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 arch/powerpc/perf/hv-24x7.c | 52 -
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index e0766b8..9a7a830 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -294,7 +294,7 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
 u16 lpar, u64 *res,
 bool success_expected)
 {
-   unsigned long ret;
+   unsigned long ret = -ENOMEM;
 
/*
 * request_buffer and result_buffer are not required to be 4k aligned,
@@ -304,7 +304,27 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
struct reqb {
struct hv_24x7_request_buffer buf;
struct hv_24x7_request req;
-   } __packed __aligned(4096) request_buffer = {
+   } __packed *request_buffer;
+   struct resb {
+   struct hv_24x7_data_result_buffer buf;
+   struct hv_24x7_result res;
+   struct hv_24x7_result_element elem;
+   __be64 result;
+   } __packed *result_buffer;
+
+   BUILD_BUG_ON(sizeof(*request_buffer)  4096);
+   BUILD_BUG_ON(sizeof(*result_buffer)  4096);
+
+   request_buffer = kmem_cache_alloc(hv_page_cache, GFP_USER);
+
+   if (!request_buffer)
+   goto out_reqb;
+
+   result_buffer = kmem_cache_zalloc(hv_page_cache, GFP_USER);
+   if (!result_buffer)
+   goto out_resb;
+
+   *request_buffer = (struct reqb) {
.buf = {
.interface_version = HV_24X7_IF_VERSION_CURRENT,
.num_requests = 1,
@@ -320,28 +340,30 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
}
};
 
-   struct resb {
-   struct hv_24x7_data_result_buffer buf;
-   struct hv_24x7_result res;
-   struct hv_24x7_result_element elem;
-   __be64 result;
-   } __packed __aligned(4096) result_buffer = {};
-
ret = plpar_hcall_norets(H_GET_24X7_DATA,
-   virt_to_phys(request_buffer), sizeof(request_buffer),
-   virt_to_phys(result_buffer),  sizeof(result_buffer));
+   virt_to_phys(request_buffer), sizeof(*request_buffer),
+   virt_to_phys(result_buffer),  sizeof(*result_buffer));
 
if (ret) {
if (success_expected)
pr_err_ratelimited(hcall failed: %d %#x %#x %d = 
0x%lx (%ld) detail=0x%x failing ix=%x\n,
domain, offset, ix, lpar,
ret, ret,
-   result_buffer.buf.detailed_rc,
-   result_buffer.buf.failing_request_ix);
-   return ret;
+   result_buffer-buf.detailed_rc,
+   result_buffer-buf.failing_request_ix);
+   goto out_hcall;
}
 
-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer-result);
+   kfree(result_buffer);
+   kfree(request_buffer);
+   return ret;
+
+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
 }
 
-- 
1.9.3

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


[PATCH 03/16] perf Documentation: sysfs events/ interfaces

2014-05-27 Thread Cody P Schafer
Add documentation for the event, event.scale, and event.unit
files in sysfs.

event.scale and event.unit were undocumented.
event was previously documented only for specific powerpc pmu events.

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 .../testing/sysfs-bus-event_source-devices-events  | 60 ++
 1 file changed, 60 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index 7b40a3c..a5226f0 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -599,3 +599,63 @@ Description:   POWER-systems specific performance 
monitoring events
Further, multiple terms like 'event=0x' can be specified
and separated with comma. All available terms are defined in
the /sys/bus/event_source/devices/dev/format file.
+
+What: /sys/bus/event_source/devices/pmu/events/event
+Date: 2014/02/24
+Contact:   Linux kernel mailing list linux-kernel@vger.kernel.org
+Description:   Per-pmu performance monitoring events specific to the running 
system
+
+   Each file (except for some of those with a '.' in them, '.unit'
+   and '.scale') in the 'events' directory describes a single
+   performance monitoring event supported by the pmu. The name
+   of the file is the name of the event.
+
+   File contents:
+
+   term[=value][,term[=value]]...
+
+   Where term is one of the terms listed under
+   /sys/bus/event_source/devices/pmu/format/ and value is
+   a number is base-16 format with a '0x' prefix (lowercase only).
+   If a term is specified alone (without an assigned value), it
+   is implied that 0x1 is assigned to that term.
+
+   Examples (each of these lines would be in a seperate file):
+
+   event=0x2abc
+   event=0x423,inv,cmask=0x3
+   domain=0x1,offset=0x8,starting_index=0x
+
+   Each of the assignments indicates a value to be assigned to a
+   particular set of bits (as defined by the format file
+   corresponding to the term) in the perf_event structure passed
+   to the perf_open syscall.
+
+What: /sys/bus/event_source/devices/pmu/events/event.unit
+Date: 2014/02/24
+Contact:   Linux kernel mailing list linux-kernel@vger.kernel.org
+Description:   Perf event units
+
+   A string specifying the English plural numerical unit that 
event
+   (once multiplied by event.scale) represents.
+
+   Example:
+
+   Joules
+
+What: /sys/bus/event_source/devices/pmu/events/event.scale
+Date: 2014/02/24
+Contact:   Linux kernel mailing list linux-kernel@vger.kernel.org
+Description:   Perf event scaling factors
+
+   A string representing a floating point value expressed in
+   scientific notation to be multiplied by the event count
+   recieved from the kernel to match the unit specified in the
+   event.unit file.
+
+   Example:
+
+   2.3283064365386962890625e-10
+
+   This is provided to avoid performing floating point arithmetic
+   in the kernel.
-- 
1.9.3

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


[PATCH 04/16] perf Documentation: remove duplicated docs for powerpc cpu specific events

2014-05-27 Thread Cody P Schafer
Listing specific events doesn't actually help us at all here because:
 - these events actually vary between different ppc processors, they
   aren't garunteed to be present.
 - the documentation of the (generic) file contents is now superceded by the
   docs for arbitrary event file contents.

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 .../testing/sysfs-bus-event_source-devices-events  | 573 -
 1 file changed, 573 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index a5226f0..20979f8 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -27,579 +27,6 @@ Description:Generic performance monitoring events
basename.
 
 
-What:  /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL
-   /sys/devices/cpu/events/PM_BRU_FIN
-   /sys/devices/cpu/events/PM_BR_MPRED
-   /sys/devices/cpu/events/PM_CMPLU_STALL
-   /sys/devices/cpu/events/PM_CMPLU_STALL_BRU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DFU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_DIV
-   /sys/devices/cpu/events/PM_CMPLU_STALL_ERAT_MISS
-   /sys/devices/cpu/events/PM_CMPLU_STALL_FXU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_IFU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_LSU
-   /sys/devices/cpu/events/PM_CMPLU_STALL_REJECT
-   /sys/devices/cpu/events/PM_CMPLU_STALL_SCALAR
-   /sys/devices/cpu/events/PM_CMPLU_STALL_SCALAR_LONG
-   /sys/devices/cpu/events/PM_CMPLU_STALL_STORE
-   /sys/devices/cpu/events/PM_CMPLU_STALL_THRD
-   /sys/devices/cpu/events/PM_CMPLU_STALL_VECTOR
-   /sys/devices/cpu/events/PM_CMPLU_STALL_VECTOR_LONG
-   /sys/devices/cpu/events/PM_CYC
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_BR_MPRED
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_BR_MPRED_IC_MISS
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
-   /sys/devices/cpu/events/PM_GCT_NOSLOT_IC_MISS
-   /sys/devices/cpu/events/PM_GRP_CMPL
-   /sys/devices/cpu/events/PM_INST_CMPL
-   /sys/devices/cpu/events/PM_LD_MISS_L1
-   /sys/devices/cpu/events/PM_LD_REF_L1
-   /sys/devices/cpu/events/PM_RUN_CYC
-   /sys/devices/cpu/events/PM_RUN_INST_CMPL
-   /sys/devices/cpu/events/PM_IC_DEMAND_L2_BR_ALL
-   /sys/devices/cpu/events/PM_GCT_UTIL_7_TO_10_SLOTS
-   /sys/devices/cpu/events/PM_PMC2_SAVED
-   /sys/devices/cpu/events/PM_VSU0_16FLOP
-   /sys/devices/cpu/events/PM_MRK_LSU_DERAT_MISS
-   /sys/devices/cpu/events/PM_MRK_ST_CMPL
-   /sys/devices/cpu/events/PM_NEST_PAIR3_ADD
-   /sys/devices/cpu/events/PM_L2_ST_DISP
-   /sys/devices/cpu/events/PM_L2_CASTOUT_MOD
-   /sys/devices/cpu/events/PM_ISEG
-   /sys/devices/cpu/events/PM_MRK_INST_TIMEO
-   /sys/devices/cpu/events/PM_L2_RCST_DISP_FAIL_ADDR
-   /sys/devices/cpu/events/PM_LSU1_DC_PREF_STREAM_CONFIRM
-   /sys/devices/cpu/events/PM_IERAT_WR_64K
-   /sys/devices/cpu/events/PM_MRK_DTLB_MISS_16M
-   /sys/devices/cpu/events/PM_IERAT_MISS
-   /sys/devices/cpu/events/PM_MRK_PTEG_FROM_LMEM
-   /sys/devices/cpu/events/PM_FLOP
-   /sys/devices/cpu/events/PM_THRD_PRIO_4_5_CYC
-   /sys/devices/cpu/events/PM_BR_PRED_TA
-   /sys/devices/cpu/events/PM_EXT_INT
-   /sys/devices/cpu/events/PM_VSU_FSQRT_FDIV
-   /sys/devices/cpu/events/PM_MRK_LD_MISS_EXPOSED_CYC
-   /sys/devices/cpu/events/PM_LSU1_LDF
-   /sys/devices/cpu/events/PM_IC_WRITE_ALL
-   /sys/devices/cpu/events/PM_LSU0_SRQ_STFWD
-   /sys/devices/cpu/events/PM_PTEG_FROM_RL2L3_MOD
-   /sys/devices/cpu/events/PM_MRK_DATA_FROM_L31_SHR
-   /sys/devices/cpu/events/PM_DATA_FROM_L21_MOD
-   /sys/devices/cpu/events/PM_VSU1_SCAL_DOUBLE_ISSUED
-   /sys/devices/cpu/events/PM_VSU0_8FLOP
-   /sys/devices/cpu/events/PM_POWER_EVENT1
-   /sys/devices/cpu/events/PM_DISP_CLB_HELD_BAL
-   /sys/devices/cpu/events/PM_VSU1_2FLOP
-   /sys/devices/cpu/events/PM_LWSYNC_HELD
-   /sys/devices/cpu/events/PM_PTEG_FROM_DL2L3_SHR
-   /sys/devices/cpu/events/PM_INST_FROM_L21_MOD
-   /sys/devices/cpu/events/PM_IERAT_XLATE_WR_16MPLUS
-   /sys/devices/cpu/events/PM_IC_REQ_ALL

[PATCH 01/16] tools/perf: allow overriding sysfs and proc finding with env var

2014-05-27 Thread Cody P Schafer
SYSFS_PATH and PROC_PATH environment variables now let the user override
the detection of sysfs and proc locations for testing purposes.

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 tools/lib/api/fs/fs.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb78..c1b49c3 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
 /* TODO merge/factor in debugfs.c here */
 
+#include ctype.h
 #include errno.h
 #include stdbool.h
 #include stdio.h
+#include stdlib.h
 #include string.h
 #include sys/vfs.h
 
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
 }
 
+static void mem_toupper(char *f, size_t len)
+{
+   while (len) {
+   *f = toupper(*f);
+   f++;
+   len--;
+   }
+}
+
+/*
+ * Check for NAME_PATH environment variable to override fs location (for
+ * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * for SYSFS_PATH.
+ */
+static bool fs__env_override(struct fs *fs)
+{
+   char *override_path;
+   size_t name_len = strlen(fs-name);
+   /* name + _PATH + '\0' */
+   char upper_name[name_len + 5 + 1];
+   memcpy(upper_name, fs-name, name_len);
+   mem_toupper(upper_name, name_len);
+   strcpy(upper_name[name_len], _PATH);
+
+   override_path = getenv(upper_name);
+   if (!override_path)
+   return false;
+
+   fs-found = true;
+   strncpy(fs-path, override_path, sizeof(fs-path));
+   return true;
+}
+
 static const char *fs__get_mountpoint(struct fs *fs)
 {
+   if (fs__env_override(fs))
+   return fs-path;
+
if (fs__check_mounts(fs))
return fs-path;
 
-   return fs__read_mounts(fs) ? fs-path : NULL;
+   if (fs__read_mounts(fs))
+   return fs-path;
+
+   return NULL;
 }
 
 static const char *fs__mountpoint(int idx)
-- 
1.9.3

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


[PATCH 06/16] tools/perf: annotate list_head with type info

2014-05-27 Thread Cody P Schafer
CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 tools/perf/util/pmu.c | 4 ++--
 tools/perf/util/pmu.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 00a7dcb..906ae40 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -14,8 +14,8 @@
 
 struct perf_pmu_alias {
char *name;
-   struct list_head terms;
-   struct list_head list;
+   struct list_head terms; /* HEAD struct parse_events_term - list */
+   struct list_head list;  /* ELEM */
char unit[UNIT_MAX_LEN+1];
double scale;
 };
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 8b64125..4a85230 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -17,9 +17,9 @@ struct perf_pmu {
char *name;
__u32 type;
struct cpu_map *cpus;
-   struct list_head format;
-   struct list_head aliases;
-   struct list_head list;
+   struct list_head format;  /* HEAD struct perf_pmu_format - list */
+   struct list_head aliases; /* HEAD struct perf_pmu_alias - list */
+   struct list_head list;/* ELEM */
 };
 
 struct perf_pmu *perf_pmu__find(const char *name);
-- 
1.9.3

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


[PATCH 07/16] tools/perf: support parsing parameterized events

2014-05-27 Thread Cody P Schafer
Enable event specification like:

pmu/event_name,param1=0x1,param2=0x4/

Assuming that

/sys/bus/event_source/devices/pmu/events/event_name

Contains something like

bar=param2,foo=1,baz=param1

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 tools/perf/util/parse-events.h |  1 +
 tools/perf/util/pmu.c  | 55 ++
 2 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index f1cb4c4..1147e87 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -60,6 +60,7 @@ struct parse_events_term {
int type_val;
int type_term;
struct list_head list;
+   bool used;
 };
 
 struct parse_events_evlist {
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 906ae40..db53fac 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -504,27 +504,57 @@ static __u64 pmu_format_value(unsigned long *format, 
__u64 value)
 }
 
 /*
+ * Term is a string term, and might be a param-term. Try to look up it's value
+ * in the remaining terms.
+ * - We have a term like base-or-format-term=param-term,
+ * - We need to find the value supplied for param-term (with param-term named
+ *   in a config string) later on in the term list.
+ */
+static int pmu_resolve_param_term(struct parse_events_term *term,
+ struct list_head *head_terms,
+ __u64 *value)
+{
+   struct parse_events_term *t;
+
+   list_for_each_entry(t, head_terms, list)
+   if (t-type_val == PARSE_EVENTS__TERM_TYPE_NUM) {
+   if (!strcmp(t-config, term-val.str)) {
+   t-used = true;
+   *value = t-val.num;
+   return 0;
+   }
+   }
+
+   return -1;
+}
+
+/*
  * Setup one of config[12] attr members based on the
  * user input data - term parameter.
  */
 static int pmu_config_term(struct list_head *formats,
   struct perf_event_attr *attr,
-  struct parse_events_term *term)
+  struct parse_events_term *term,
+  struct list_head *head_terms)
 {
struct perf_pmu_format *format;
__u64 *vp;
+   __u64 val;
+
+   /*
+* If this is a parameter we've already used for parameterized-eval,
+* skip it in normal eval.
+*/
+   if (term-used)
+   return 0;
 
/*
-* Support only for hardcoded and numnerial terms.
 * Hardcoded terms should be already in, so nothing
 * to be done for them.
 */
if (parse_events__is_hardcoded_term(term))
return 0;
 
-   if (term-type_val != PARSE_EVENTS__TERM_TYPE_NUM)
-   return -EINVAL;
-
format = pmu_find_format(formats, term-config);
if (!format)
return -EINVAL;
@@ -544,11 +574,16 @@ static int pmu_config_term(struct list_head *formats,
}
 
/*
-* XXX If we ever decide to go with string values for
-* non-hardcoded terms, here's the place to translate
-* them into value.
+* Either directly use a numeric term, or try to translate string terms
+* using event parameters.
 */
-   *vp |= pmu_format_value(format-bits, term-val.num);
+   if (term-type_val == PARSE_EVENTS__TERM_TYPE_NUM)
+   val = term-val.num;
+   else
+   if (pmu_resolve_param_term(term, head_terms, val))
+   return -EINVAL;
+
+   *vp |= pmu_format_value(format-bits, val);
return 0;
 }
 
@@ -559,7 +594,7 @@ int perf_pmu__config_terms(struct list_head *formats,
struct parse_events_term *term;
 
list_for_each_entry(term, head_terms, list)
-   if (pmu_config_term(formats, attr, term))
+   if (pmu_config_term(formats, attr, term, head_terms))
return -EINVAL;
 
return 0;
-- 
1.9.3

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


[PATCH 09/16] tools/perf: document parameterized events and note symbolically formed events

2014-05-27 Thread Cody P Schafer
CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 tools/perf/Documentation/perf-list.txt   | 13 +
 tools/perf/Documentation/perf-record.txt |  5 +
 2 files changed, 18 insertions(+)

diff --git a/tools/perf/Documentation/perf-list.txt 
b/tools/perf/Documentation/perf-list.txt
index 6fce6a6..626818b 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -89,6 +89,19 @@ raw encoding of 0x1A8 can be used:
 You should refer to the processor specific documentation for getting these
 details. Some of them are referenced in the SEE ALSO section below.
 
+PARAMETERIZED EVENTS
+
+
+Some pmu events listed by 'perf-list' will be displayed with '?' in them. For
+example:
+
+  hv_gpci/dtbp_ptitc,phys_processor_idx=?/
+
+This means that when provided as an event, a value for phys_processor_idx must
+also be supplied. For example:
+
+  perf stat -e 'hv_gpci/dtbp_ptitc,phys_processor_idx=0x2/' ...
+
 OPTIONS
 ---
 
diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index c71b0f3..c005180 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -33,6 +33,11 @@ OPTIONS
 - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
  hexadecimal event descriptor.
 
+   - a symbolicly formed PMU event like 'pmu/value1=0x3,value2/' where
+ 'value1' and 'value2' are defined as formats in
+ /sys/bus/event_sources/devices/pmu/format/* OR are one of 'config',
+ 'config1', 'config2'.
+
 - a hardware breakpoint event in the form of '\mem:addr[:access]'
   where addr is the address in memory you want to break in.
   Access is the memory access type (read, write, execute) it can
-- 
1.9.3

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


[PATCH 05/16] perf Documentation: add event parameters

2014-05-27 Thread Cody P Schafer
Event parameters are a basic way for partial events to be specified in
sysfs with per-event names given to the fields that need to be filled in
when using a particular event.

It is intended for supporting cases where the single 'cpu' parameter is
insufficient. For example, POWER 8 has events for physical
sockets/cores/cpus that are accessible from with virtual machines. To
keep using the single 'cpu' parameter we'd need to perform a mapping
between Linux's cpus and the physical machine's cpus (in this case
Linux is running under a hypervisor). This isn't possible because
bindings between our cpus and physical cpus may not be fixed, and we
probably won't have a cpu on each physical cpu.

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 Documentation/ABI/testing/sysfs-bus-event_source-devices-events | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
index 20979f8..c1f9850 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -52,12 +52,18 @@ Description:Per-pmu performance monitoring events 
specific to the running syste
event=0x2abc
event=0x423,inv,cmask=0x3
domain=0x1,offset=0x8,starting_index=0x
+   domain=0x1,offset=0x8,starting_index=phys_cpu
 
Each of the assignments indicates a value to be assigned to a
particular set of bits (as defined by the format file
corresponding to the term) in the perf_event structure passed
to the perf_open syscall.
 
+   In the case of the last example, a value replacing phys_cpu
+   would need to be provided by the user selecting the particular
+   event. This is refered to as event parameterization. All
+   non-numerical values indicate an event parameter.
+
 What: /sys/bus/event_source/devices/pmu/events/event.unit
 Date: 2014/02/24
 Contact:   Linux kernel mailing list linux-kernel@vger.kernel.org
-- 
1.9.3

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


[PATCH 08/16] tools/perf: extend format_alias() to include event parameters

2014-05-27 Thread Cody P Schafer
This causes `perf list pmu` to show parameters for parameterized events
like follows:

  pmu/event_name,param1=?,param2=?/ [Kernel PMU event]

An example:

  
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=?/
 [Kernel PMU event]

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 tools/perf/util/pmu.c | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index db53fac..7b8d067 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -741,10 +741,33 @@ void perf_pmu__set_format(unsigned long *bits, long from, 
long to)
set_bit(b, bits);
 }
 
+static int sub_non_neg(int a, int b)
+{
+   if (b  a)
+   return 0;
+   return a - b;
+}
+
 static char *format_alias(char *buf, int len, struct perf_pmu *pmu,
  struct perf_pmu_alias *alias)
 {
-   snprintf(buf, len, %s/%s/, pmu-name, alias-name);
+   struct parse_events_term *term;
+   int used = snprintf(buf, len, %s/%s, pmu-name, alias-name);
+
+   list_for_each_entry(term, alias-terms, list)
+   if (term-type_val == PARSE_EVENTS__TERM_TYPE_STR)
+   used += snprintf(buf + used, sub_non_neg(len, used),
+   ,%s=?, term-val.str);
+
+   if (sub_non_neg(len, used)  0) {
+   buf[used] = '/';
+   used++;
+   }
+   if (sub_non_neg(len, used)  0) {
+   buf[used] = '\0';
+   used++;
+   } else
+   buf[len - 1] = '\0';
return buf;
 }
 
@@ -795,6 +818,7 @@ void print_pmu_events(const char *event_glob, bool 
name_only)
if (is_cpu  !name_only)
aliases[j] = format_alias_or(buf, sizeof(buf),
  pmu, alias);
+
aliases[j] = strdup(aliases[j]);
j++;
}
-- 
1.9.3

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


[PATCH 10/16] perf: provide sysfs_show for struct perf_pmu_events_attr

2014-05-27 Thread Cody P Schafer
(struct perf_pmu_events_attr) is defined in include/linux/perf_event.h,
but the only show for it is in x86 and contains x86 specific stuff.

Make a generic one for those of us who are just using the event_str.

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 include/linux/perf_event.h | 3 +++
 kernel/events/core.c   | 8 
 2 files changed, 11 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 3356abc..6c1d6dd 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -867,6 +867,9 @@ struct perf_pmu_events_attr {
const char *event_str;
 };
 
+ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute 
*attr,
+ char *page);
+
 #define PMU_EVENT_ATTR(_name, _var, _id, _show)
\
 static struct perf_pmu_events_attr _var = {\
.attr = __ATTR(_name, 0444, _show, NULL),   \
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f83a71a..6830e21 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7971,6 +7971,14 @@ void __init perf_event_init(void)
 != 1024);
 }
 
+ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute 
*attr,
+ char *page)
+{
+   struct perf_pmu_events_attr *pmu_attr =
+   container_of(attr, struct perf_pmu_events_attr, attr);
+   return sprintf(page, %s\n, pmu_attr-event_str);
+}
+
 static int __init perf_event_sysfs_init(void)
 {
struct pmu *pmu;
-- 
1.9.3

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


[PATCH 11/16] byteorder: provide a linux/byteorder.h with {be,le}_to_cpu() and cpu_to_{be,le}() macros

2014-05-27 Thread Cody P Schafer
Rather manually specifying the size of the integer to be converted, key
off of the type size. Reduces duplicate size info and the occurance of
certain types of bugs (using the wrong sized conversion).

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 include/linux/byteorder.h | 34 ++
 1 file changed, 34 insertions(+)
 create mode 100644 include/linux/byteorder.h

diff --git a/include/linux/byteorder.h b/include/linux/byteorder.h
new file mode 100644
index 000..c7ab8da
--- /dev/null
+++ b/include/linux/byteorder.h
@@ -0,0 +1,34 @@
+#ifndef LINUX_BYTEORDER_H_
+#define LINUX_BYTEORDER_H_
+
+#include asm/byteorder.h
+
+#define be_to_cpu(v) \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
+   (void)0
+
+#define le_to_cpu(v) \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), le16_to_cpu(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), le32_to_cpu(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), le64_to_cpu(v), \
+   (void)0
+
+#define cpu_to_le(v) \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), cpu_to_le16(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), cpu_to_le32(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), cpu_to_le64(v), \
+   (void)0
+
+#define cpu_to_be(v) \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v, \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint16_t), cpu_to_be16(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint32_t), cpu_to_be32(v), \
+   __builtin_choose_expr(sizeof(v) == sizeof(uint64_t), cpu_to_be64(v), \
+   (void)0
+
+#endif
-- 
1.9.3

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


[PATCH 13/16] powerpc/perf/hv-24x7: Documentaion for new sysfs entries which expose descriptions

2014-05-27 Thread Cody P Schafer
CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 .../testing/sysfs-bus-event_source-devices-hv_24x7 | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 
b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
index e78ee79..5b501d7 100644
--- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
@@ -21,3 +21,25 @@ Contact: Cody P Schafer c...@linux.vnet.ibm.com
 Description:
Exposes the version field of the 24x7 catalog. This is also
extractable from the provided binary catalog sysfs entry.
+
+What:  /sys/bus/event_source/devices/hv_24x7/event_descs/event-name
+Date:  February 2014
+Contact:   Cody P Schafer c...@linux.vnet.ibm.com
+Description:
+   Provides the description of a particular event as provided by
+   the firmware. If firmware does not provide a description, no
+   file will be created.
+
+   Note that the event-name lacks the domain suffix appended for
+   events in the events/ dir.
+
+What:  
/sys/bus/event_source/devices/hv_24x7/event_long_descs/event-name
+Date:  February 2014
+Contact:   Cody P Schafer c...@linux.vnet.ibm.com
+Description:
+   Provides the long description of a particular event as
+   provided by the firmware. If firmware does not provide a
+   description, no file will be created.
+
+   Note that the event-name lacks the domain suffix appended for
+   events in the events/ dir.
-- 
1.9.3

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


[PATCH 12/16] powerpc/perf/hv-24x7: parse catalog and populate sysfs with events

2014-05-27 Thread Cody P Schafer
Retrieves and parses the 24x7 catalog on POWER systems that supply it
(right now, only POWER 8). Events are exposed via sysfs in the standard
fashion, and are all parameterized.

Catalog is (at the moment) only parsed on boot. It needs re-parsing
when a some hypervisor events occur. At that point we'll also need to
prevent old events from continuing to function (counter that is passed
in via spare space in the config values?).

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 arch/powerpc/perf/hv-24x7-catalog.h |  25 ++
 arch/powerpc/perf/hv-24x7-domains.h |  19 +
 arch/powerpc/perf/hv-24x7.c | 760 +++-
 arch/powerpc/perf/hv-24x7.h |  12 +-
 4 files changed, 804 insertions(+), 12 deletions(-)
 create mode 100644 arch/powerpc/perf/hv-24x7-domains.h

diff --git a/arch/powerpc/perf/hv-24x7-catalog.h 
b/arch/powerpc/perf/hv-24x7-catalog.h
index 21b19dd..69e2e1f 100644
--- a/arch/powerpc/perf/hv-24x7-catalog.h
+++ b/arch/powerpc/perf/hv-24x7-catalog.h
@@ -30,4 +30,29 @@ struct hv_24x7_catalog_page_0 {
__u8 reserved6[2];
 } __packed;
 
+struct hv_24x7_event_data {
+   __be16 length; /* in bytes, must be a multiple of 16 */
+   __u8 reserved1[2];
+   __u8 domain; /* Chip = 1, Core = 2 */
+   __u8 reserved2[1];
+   __be16 event_group_record_offs; /* in bytes, must be 8 byte aligned */
+   __be16 event_group_record_len; /* in bytes */
+
+   /* in bytes, offset from event_group_record */
+   __be16 event_counter_offs;
+
+   /* verified_state, unverified_state, caveat_state, broken_state, ... */
+   __be32 flags;
+
+   __be16 primary_group_ix;
+   __be16 group_count;
+   __be16 event_name_len;
+   __u8 remainder[];
+   /* __u8 event_name[event_name_len - 2]; */
+   /* __be16 event_description_len; */
+   /* __u8 event_desc[event_description_len - 2]; */
+   /* __be16 detailed_desc_len; */
+   /* __u8 detailed_desc[detailed_desc_len - 2]; */
+} __packed;
+
 #endif
diff --git a/arch/powerpc/perf/hv-24x7-domains.h 
b/arch/powerpc/perf/hv-24x7-domains.h
new file mode 100644
index 000..9c5c862
--- /dev/null
+++ b/arch/powerpc/perf/hv-24x7-domains.h
@@ -0,0 +1,19 @@
+
+/*
+ * DOMAIN(name, num, index_kind, is_physical)
+ *
+ * @name: an all caps token, suitable for use in generating an enum member and
+ *appending to an event name in sysfs.
+ * @num: the number corresponding to the domain as given in documentation. We
+ *   assume the catalog domain and the hcall domain have the same numbering
+ *   (so far they do), but this may need to be changed in the future.
+ * @index_kind: a stringifiable token describing the meaning of the index 
within the
+ *  given domain. Must fit the parsing rules of the perf sysfs api.
+ * @is_physical: true if the domain is physical, false otherwise (if virtual).
+ */
+DOMAIN(PHYSICAL_CHIP, 0x01, chip, true)
+DOMAIN(PHYSICAL_CORE, 0x02, core, true)
+DOMAIN(VIRTUAL_PROCESSOR_HOME_CORE, 0x03, vcpu, false)
+DOMAIN(VIRTUAL_PROCESSOR_HOME_CHIP, 0x04, vcpu, false)
+DOMAIN(VIRTUAL_PROCESSOR_HOME_NODE, 0x05, vcpu, false)
+DOMAIN(VIRTUAL_PROCESSOR_REMOTE_NODE, 0x06, vcpu, false)
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 9a7a830..c9b7c55 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -1,3 +1,4 @@
+#define DEBUG 1
 /*
  * Hypervisor supplied 24x7 performance counter support
  *
@@ -12,9 +13,13 @@
 
 #define pr_fmt(fmt) hv-24x7:  fmt
 
+#include linux/byteorder.h
 #include linux/perf_event.h
+#include linux/rbtree.h
 #include linux/module.h
 #include linux/slab.h
+#include linux/vmalloc.h
+
 #include asm/firmware.h
 #include asm/hvcall.h
 #include asm/io.h
@@ -23,6 +28,66 @@
 #include hv-24x7-catalog.h
 #include hv-common.h
 
+static const char *domain_to_index_string(unsigned domain)
+{
+   switch (domain) {
+#define DOMAIN(n, v, x, c) \
+   case HV_PERF_DOMAIN_##n:\
+   return #x;
+#include hv-24x7-domains.h
+#undef DOMAIN
+   default:
+   WARN(1, unknown domain %d\n, domain);
+   return UNKNOWN_DOMAIN_INDEX_STRING;
+   }
+}
+
+static const char *event_domain_suffix(unsigned domain)
+{
+   switch (domain) {
+#define DOMAIN(n, v, x, c) \
+   case HV_PERF_DOMAIN_##n:\
+   return __ #n;
+#include hv-24x7-domains.h
+#undef DOMAIN
+   default:
+   WARN(1, unknown domain %d\n, domain);
+   return __UNKNOWN_DOMAIN_SUFFIX;
+   }
+}
+
+static bool domain_is_valid(unsigned domain)
+{
+   switch (domain) {
+#define DOMAIN(n, v, x, c) \
+   case HV_PERF_DOMAIN_##n:\
+   /* fall through */
+#include hv-24x7-domains.h
+#undef DOMAIN
+   return true;
+   default:
+   return false;
+   }
+}
+
+static bool is_physical_domain

[PATCH 15/16] powerpc/perf/{hv-gpci,hv-common}: generate requests with counters annotated

2014-05-27 Thread Cody P Schafer
This adds (in req-gen/) a framework for defining gpci counter requests.
It uses macro magic similar to ftrace.

Also convert the existing hv-gpci request structures and enum values to
use the new framework (and adjust old users of the structs and enum
values to cope with changes in naming).

In exchange for this macro disaster, we get autogenerated event listing
for GPCI in sysfs, build time field offset checking, and zero
duplication of information about GPCI requests.

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 arch/powerpc/perf/hv-common.c  |  10 +-
 arch/powerpc/perf/hv-gpci-requests.h   |  79 +++
 arch/powerpc/perf/hv-gpci.c|   8 ++
 arch/powerpc/perf/hv-gpci.h|  37 +++
 arch/powerpc/perf/req-gen/_begin.h |  13 +++
 arch/powerpc/perf/req-gen/_clear.h |   5 +
 arch/powerpc/perf/req-gen/_end.h   |   4 +
 arch/powerpc/perf/req-gen/_request-begin.h |  15 +++
 arch/powerpc/perf/req-gen/_request-end.h   |   8 ++
 arch/powerpc/perf/req-gen/perf.h   | 155 +
 10 files changed, 304 insertions(+), 30 deletions(-)
 create mode 100644 arch/powerpc/perf/hv-gpci-requests.h
 create mode 100644 arch/powerpc/perf/req-gen/_begin.h
 create mode 100644 arch/powerpc/perf/req-gen/_clear.h
 create mode 100644 arch/powerpc/perf/req-gen/_end.h
 create mode 100644 arch/powerpc/perf/req-gen/_request-begin.h
 create mode 100644 arch/powerpc/perf/req-gen/_request-end.h
 create mode 100644 arch/powerpc/perf/req-gen/perf.h

diff --git a/arch/powerpc/perf/hv-common.c b/arch/powerpc/perf/hv-common.c
index 47e02b3..7dce8f10 100644
--- a/arch/powerpc/perf/hv-common.c
+++ b/arch/powerpc/perf/hv-common.c
@@ -9,13 +9,13 @@ unsigned long hv_perf_caps_get(struct hv_perf_caps *caps)
unsigned long r;
struct p {
struct hv_get_perf_counter_info_params params;
-   struct cv_system_performance_capabilities caps;
+   struct hv_gpci_system_performance_capabilities caps;
} __packed __aligned(sizeof(uint64_t));
 
struct p arg = {
.params = {
.counter_request = cpu_to_be32(
-   CIR_SYSTEM_PERFORMANCE_CAPABILITIES),
+   HV_GPCI_system_performance_capabilities),
.starting_index = cpu_to_be32(-1),
.counter_info_version_in = 0,
}
@@ -31,9 +31,9 @@ unsigned long hv_perf_caps_get(struct hv_perf_caps *caps)
 
caps-version = arg.params.counter_info_version_out;
caps-collect_privileged = !!arg.caps.perf_collect_privileged;
-   caps-ga = !!(arg.caps.capability_mask  CV_CM_GA);
-   caps-expanded = !!(arg.caps.capability_mask  CV_CM_EXPANDED);
-   caps-lab = !!(arg.caps.capability_mask  CV_CM_LAB);
+   caps-ga = !!(arg.caps.capability_mask  HV_GPCI_CM_GA);
+   caps-expanded = !!(arg.caps.capability_mask  HV_GPCI_CM_EXPANDED);
+   caps-lab = !!(arg.caps.capability_mask  HV_GPCI_CM_LAB);
 
return r;
 }
diff --git a/arch/powerpc/perf/hv-gpci-requests.h 
b/arch/powerpc/perf/hv-gpci-requests.h
new file mode 100644
index 000..0dfc4d9
--- /dev/null
+++ b/arch/powerpc/perf/hv-gpci-requests.h
@@ -0,0 +1,79 @@
+
+#include req-gen/_begin.h
+
+/*
+ * Based on the document getPerfCountInfo v1.07
+ */
+
+/* this needs to be -1 encoded in hex suitable for parsing by tools/perf. */
+#define M1 0x
+
+/*
+ * #define REQUEST_NAME counter_request_name
+ * #define REQUEST_NUM r_num
+ * #define REQUEST_IDX_KIND starting_index_kind
+ * #include I(REQUEST_BEGIN)
+ * REQUEST(
+ * __field(...)
+ * __field(...)
+ * __array(...)
+ * __count(...)
+ * )
+ * #include I(REQUEST_END)
+ *
+ * - starting_index_kind is one of:
+ *   M1: must be -1
+ *   chip_id: hardware chip id or -1 for current hw chip
+ *   phys_processor_idx:
+ *
+ * __count(offset, bytes, name):
+ * a counter that should be exposed via perf
+ * __field(offset, bytes, name)
+ * a normal field
+ * __array(offset, bytes, name)
+ * an array of bytes
+ *
+ *
+ * @bytes for __count, and __field _must_ be a numeral token
+ * in decimal, not an expression and not in hex.
+ *
+ *
+ * TODO:
+ * - expose secondary index (if any counter ever uses it, only 0xA0
+ *   appears to use it right now, and it doesn't have any counters)
+ * - embed versioning info
+ * - include counter descriptions
+ */
+#define REQUEST_NAME dispatch_timebase_by_processor
+#define REQUEST_NUM 0x10
+#define REQUEST_IDX_KIND phys_processor_idx
+#include I(REQUEST_BEGIN)
+REQUEST(__count(0, 8,  processor_time_in_timebase_cycles)
+   __field(0x8,4,  hw_processor_id)
+   __field(0xC,2,  owning_part_id)
+   __field(0xE,1,  processor_state)
+   __field(0xF,1,  version

[PATCH 16/16] powerpc/perf/hv-gpci: add the remaining gpci requests

2014-05-27 Thread Cody P Schafer
Add the remaining gpci requests that contain counters suitable for use
by perf. Omit those that don't contain any counters (but note their
ommision).

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 arch/powerpc/perf/hv-gpci-requests.h | 179 +++
 1 file changed, 179 insertions(+)

diff --git a/arch/powerpc/perf/hv-gpci-requests.h 
b/arch/powerpc/perf/hv-gpci-requests.h
index 0dfc4d9..af3b73c 100644
--- a/arch/powerpc/perf/hv-gpci-requests.h
+++ b/arch/powerpc/perf/hv-gpci-requests.h
@@ -65,6 +65,33 @@ REQUEST(__count(0,   8,  
processor_time_in_timebase_cycles)
 )
 #include I(REQUEST_END)
 
+#define REQUEST_NAME 
entitled_capped_uncapped_donated_idle_timebase_by_partition
+#define REQUEST_NUM 0x20
+#define REQUEST_IDX_KIND sibling_part_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 8,  partition_id)
+   __count(0x8,8,  entitled_cycles)
+   __count(0x10,   8,  consumed_capped_cycles)
+   __count(0x18,   8,  consumed_uncapped_cycles)
+   __count(0x20,   8,  cycles_donated)
+   __count(0x28,   8,  purr_idle_cycles)
+)
+#include I(REQUEST_END)
+
+/*
+ * Not avaliable for counter_info_version = 0x8, use
+ * run_instruction_cycles_by_partition(0x100) instead.
+ */
+#define REQUEST_NAME run_instructions_run_cycles_by_partition
+#define REQUEST_NUM 0x30
+#define REQUEST_IDX_KIND sibling_part_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 8,  partition_id)
+   __count(0x8,8,  instructions_completed)
+   __count(0x10,   8,  cycles)
+)
+#include I(REQUEST_END)
+
 #define REQUEST_NAME system_performance_capabilities
 #define REQUEST_NUM 0x40
 #define REQUEST_IDX_KIND M1
@@ -75,5 +102,157 @@ REQUEST(__field(0, 1,  perf_collect_privileged)
 )
 #include I(REQUEST_END)
 
+#define REQUEST_NAME processor_bus_utilization_abc_links
+#define REQUEST_NUM 0x50
+#define REQUEST_IDX_KIND hw_chip_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 4,  hw_chip_id)
+   __array(0x4,0xC,reserved1)
+   __count(0x10,   8,  total_link_cycles)
+   __count(0x18,   8,  idle_cycles_for_a_link)
+   __count(0x20,   8,  idle_cycles_for_b_link)
+   __count(0x28,   8,  idle_cycles_for_c_link)
+   __array(0x30,   0x20,   reserved2)
+)
+#include I(REQUEST_END)
+
+#define REQUEST_NAME processor_bus_utilization_wxyz_links
+#define REQUEST_NUM 0x60
+#define REQUEST_IDX_KIND hw_chip_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 4,  hw_chip_id)
+   __array(0x4,0xC,reserved1)
+   __count(0x10,   8,  total_link_cycles)
+   __count(0x18,   8,  idle_cycles_for_w_link)
+   __count(0x20,   8,  idle_cycles_for_x_link)
+   __count(0x28,   8,  idle_cycles_for_y_link)
+   __count(0x30,   8,  idle_cycles_for_z_link)
+   __array(0x38,   0x28,   reserved2)
+)
+#include I(REQUEST_END)
+
+#define REQUEST_NAME processor_bus_utilization_gx_links
+#define REQUEST_NUM 0x70
+#define REQUEST_IDX_KIND hw_chip_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 4,  hw_chip_id)
+   __array(0x4,0xC,reserved1)
+   __count(0x10,   8,  gx0_in_address_cycles)
+   __count(0x18,   8,  gx0_in_data_cycles)
+   __count(0x20,   8,  gx0_in_retries)
+   __count(0x28,   8,  gx0_in_bus_cycles)
+   __count(0x30,   8,  gx0_in_cycles_total)
+   __count(0x38,   8,  gx0_out_address_cycles)
+   __count(0x40,   8,  gx0_out_data_cycles)
+   __count(0x48,   8,  gx0_out_retries)
+   __count(0x50,   8,  gx0_out_bus_cycles)
+   __count(0x58,   8,  gx0_out_cycles_total)
+   __count(0x60,   8,  gx1_in_address_cycles)
+   __count(0x68,   8,  gx1_in_data_cycles)
+   __count(0x70,   8,  gx1_in_retries)
+   __count(0x78,   8,  gx1_in_bus_cycles)
+   __count(0x80,   8,  gx1_in_cycles_total)
+   __count(0x88,   8,  gx1_out_address_cycles)
+   __count(0x90,   8,  gx1_out_data_cycles)
+   __count(0x98,   8,  gx1_out_retries)
+   __count(0xA0,   8,  gx1_out_bus_cycles)
+   __count(0xA8,   8,  gx1_out_cycles_total)
+)
+#include I(REQUEST_END)
+
+#define REQUEST_NAME processor_bus_utilization_mc_links
+#define REQUEST_NUM 0x80
+#define REQUEST_IDX_KIND hw_chip_id
+#include I(REQUEST_BEGIN)
+REQUEST(__field(0, 4,  hw_chip_id)
+   __array(0x4,0xC,reserved1)
+   __count(0x10,   8,  mc0_frames)
+   __count(0x18,   8,  mc0_reads)
+   __count(0x20,   8,  mc0_write)
+   __count(0x28,   8,  mc0_total_cycles)
+   __count(0x30,   8,  mc1_frames)
+   __count(0x38,   8,  mc1_reads)
+   __count(0x40,   8,  mc1_writes)
+   __count(0x48,   8,  mc1_total_cycles)
+)
+#include I(REQUEST_END)
+
+/* Processor_config (0x90) skipped, no counters */
+/* Current_processor_frequency

[PATCH 14/16] perf: add PMU_EVENT_ATTR_STRING() helper

2014-05-27 Thread Cody P Schafer
Helper for constructing static struct perf_pmu_events_attr s.

CC: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
Signed-off-by: Cody P Schafer d...@codyps.com
---
 include/linux/perf_event.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 6c1d6dd..1313171 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -876,6 +876,13 @@ static struct perf_pmu_events_attr _var = {
\
.id   =  _id,   \
 };
 
+#define PMU_EVENT_ATTR_STRING(_name, _var, _value) \
+static struct perf_pmu_events_attr _var = {\
+   .attr = __ATTR(_name, 0444, perf_event_sysfs_show, NULL),   \
+   .event_str = _value,\
+};
+
+
 #define PMU_FORMAT_ATTR(_name, _format)
\
 static ssize_t \
 _name##_show(struct device *dev,   \
-- 
1.9.3

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


Re: [PATCH v2] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-22 Thread Cody P Schafer

On 05/22/2014 04:49 PM, Stephen Rothwell wrote:

Hi Cody,

On Thu, 22 May 2014 15:44:25 -0700 Cody P Schafer  
wrote:


if (ret) {
if (success_expected)
pr_err_ratelimited("hcall failed: %d %#x %#x %d => 0x%lx 
(%ld) detail=0x%x failing ix=%x\n",
domain, offset, ix, lpar,
ret, ret,
-   result_buffer.buf.detailed_rc,
-   result_buffer.buf.failing_request_ix);
-   return ret;
+   result_buffer->buf.detailed_rc,
+   result_buffer->buf.failing_request_ix);
+   goto out_hcall;
}

-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer->result);


not a biggie, but this last bit could be (remove the goto out_hcall and
teh label and then)

} else {
*res = be64_to_cpu(result_buffer->result);
}



I've got a slight preference toward keeping it as is, which lets all of 
the non-error path code stay outside of if/else blocks (and the error 
handling is kept ever so slightly more consistent).



+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
  }



otherwise looks good to me.



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


[PATCH v2] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-22 Thread Cody P Schafer
Ian pointed out the use of __aligned(4096) caused rather large stack
consumption in single_24x7_request(), so use the kmem_cache
hv_page_cache (which we've already got set up for other allocations)
insead of allocating locally.

Reported-by: Ian Munsie 
Signed-off-by: Cody P Schafer 
---
In v2:
  - remove duplicate exit path


 arch/powerpc/perf/hv-24x7.c | 48 +++--
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index e0766b8..998863b 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -294,7 +294,7 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
 u16 lpar, u64 *res,
 bool success_expected)
 {
-   unsigned long ret;
+   unsigned long ret = -ENOMEM;
 
/*
 * request_buffer and result_buffer are not required to be 4k aligned,
@@ -304,7 +304,27 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
struct reqb {
struct hv_24x7_request_buffer buf;
struct hv_24x7_request req;
-   } __packed __aligned(4096) request_buffer = {
+   } __packed *request_buffer;
+   struct resb {
+   struct hv_24x7_data_result_buffer buf;
+   struct hv_24x7_result res;
+   struct hv_24x7_result_element elem;
+   __be64 result;
+   } __packed *result_buffer;
+
+   BUILD_BUG_ON(sizeof(*request_buffer) > 4096);
+   BUILD_BUG_ON(sizeof(*result_buffer) > 4096);
+
+   request_buffer = kmem_cache_alloc(hv_page_cache, GFP_USER);
+
+   if (!request_buffer)
+   goto out_reqb;
+
+   result_buffer = kmem_cache_zalloc(hv_page_cache, GFP_USER);
+   if (!result_buffer)
+   goto out_resb;
+
+   *request_buffer = (struct reqb) {
.buf = {
.interface_version = HV_24X7_IF_VERSION_CURRENT,
.num_requests = 1,
@@ -320,28 +340,26 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
}
};
 
-   struct resb {
-   struct hv_24x7_data_result_buffer buf;
-   struct hv_24x7_result res;
-   struct hv_24x7_result_element elem;
-   __be64 result;
-   } __packed __aligned(4096) result_buffer = {};
-
ret = plpar_hcall_norets(H_GET_24X7_DATA,
-   virt_to_phys(_buffer), sizeof(request_buffer),
-   virt_to_phys(_buffer),  sizeof(result_buffer));
+   virt_to_phys(request_buffer), sizeof(*request_buffer),
+   virt_to_phys(result_buffer),  sizeof(*result_buffer));
 
if (ret) {
if (success_expected)
pr_err_ratelimited("hcall failed: %d %#x %#x %d => 
0x%lx (%ld) detail=0x%x failing ix=%x\n",
domain, offset, ix, lpar,
ret, ret,
-   result_buffer.buf.detailed_rc,
-   result_buffer.buf.failing_request_ix);
-   return ret;
+   result_buffer->buf.detailed_rc,
+   result_buffer->buf.failing_request_ix);
+   goto out_hcall;
}
 
-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer->result);
+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
 }
 
-- 
1.9.3

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


Re: [PATCH] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-22 Thread Cody P Schafer

On 05/22/2014 03:38 PM, Stephen Rothwell wrote:

Hi Cody,

On Thu, 22 May 2014 15:29:08 -0700 Cody P Schafer  
wrote:


-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer->result);
+   kfree(result_buffer);
+   kfree(request_buffer);
+   return ret;


Why not just fall through here by removing the above 3 lines?


No reason except me not noticing it.


+
+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
  }




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


[PATCH] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-22 Thread Cody P Schafer
Ian pointed out the use of __aligned(4096) caused rather large stack
consumption in single_24x7_request(), so use the kmem_cache
hv_page_cache (which we've already got set up for other allocations)
insead of allocating locally.

Reported-by: Ian Munsie 
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-24x7.c | 52 -
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index e0766b8..9a7a830 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -294,7 +294,7 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
 u16 lpar, u64 *res,
 bool success_expected)
 {
-   unsigned long ret;
+   unsigned long ret = -ENOMEM;
 
/*
 * request_buffer and result_buffer are not required to be 4k aligned,
@@ -304,7 +304,27 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
struct reqb {
struct hv_24x7_request_buffer buf;
struct hv_24x7_request req;
-   } __packed __aligned(4096) request_buffer = {
+   } __packed *request_buffer;
+   struct resb {
+   struct hv_24x7_data_result_buffer buf;
+   struct hv_24x7_result res;
+   struct hv_24x7_result_element elem;
+   __be64 result;
+   } __packed *result_buffer;
+
+   BUILD_BUG_ON(sizeof(*request_buffer) > 4096);
+   BUILD_BUG_ON(sizeof(*result_buffer) > 4096);
+
+   request_buffer = kmem_cache_alloc(hv_page_cache, GFP_USER);
+
+   if (!request_buffer)
+   goto out_reqb;
+
+   result_buffer = kmem_cache_zalloc(hv_page_cache, GFP_USER);
+   if (!result_buffer)
+   goto out_resb;
+
+   *request_buffer = (struct reqb) {
.buf = {
.interface_version = HV_24X7_IF_VERSION_CURRENT,
.num_requests = 1,
@@ -320,28 +340,30 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
}
};
 
-   struct resb {
-   struct hv_24x7_data_result_buffer buf;
-   struct hv_24x7_result res;
-   struct hv_24x7_result_element elem;
-   __be64 result;
-   } __packed __aligned(4096) result_buffer = {};
-
ret = plpar_hcall_norets(H_GET_24X7_DATA,
-   virt_to_phys(_buffer), sizeof(request_buffer),
-   virt_to_phys(_buffer),  sizeof(result_buffer));
+   virt_to_phys(request_buffer), sizeof(*request_buffer),
+   virt_to_phys(result_buffer),  sizeof(*result_buffer));
 
if (ret) {
if (success_expected)
pr_err_ratelimited("hcall failed: %d %#x %#x %d => 
0x%lx (%ld) detail=0x%x failing ix=%x\n",
domain, offset, ix, lpar,
ret, ret,
-   result_buffer.buf.detailed_rc,
-   result_buffer.buf.failing_request_ix);
-   return ret;
+   result_buffer->buf.detailed_rc,
+   result_buffer->buf.failing_request_ix);
+   goto out_hcall;
}
 
-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer->result);
+   kfree(result_buffer);
+   kfree(request_buffer);
+   return ret;
+
+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
 }
 
-- 
1.9.3

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


Re: [PATCH v4 09/11] powerpc/perf: add support for the hv 24x7 interface

2014-05-22 Thread Cody P Schafer

On 05/22/2014 01:19 AM, Ian Munsie wrote:

Hi Cody,

I just tried building this with gcc 4.5, which failed with the following
warning (treated as an error):

cc1: warnings being treated as errors
arch/powerpc/perf/hv-24x7.c: In function 'single_24x7_request':
arch/powerpc/perf/hv-24x7.c:346:1: error: the frame size of 8192 bytes is 
larger than 2048 bytes
make[3]: *** [arch/powerpc/perf/hv-24x7.o] Error 1
make[2]: *** [arch/powerpc/perf] Error 2

My .config has CONFIG_FRAME_WARN=2048 (default on 64bit), but the
alignment constraints in this function may require 8K on the stack -
possibly a bit large?



Yep, it is a bit large. In other places in hv-24x7 that use similar 
firmware interfaces (with similar alignment requirements), I've used a 
kmem_cache (hv_page_cache). Testing out a patch that uses that here as well.




Notably for some reason this warning no longer seems to trigger on gcc
4.8 (or at least somewhere between 4.5-4.8), though the assembly does
still show it aligning the buffers.


That's a bit concerning (and might be why I didn't pick it up, using gcc 
4.9.0 over here). Looking at the gcc docs, it seems to indicate that 
alloca() and VLAs aren't counted for -Wframe-larger-than. Perhaps gcc 
decided to move locally defined structures with alignment requirements 
into that same bucket? (while size of the structures is statically 
determinable, the stack consumption due to alignment is [to some degree] 
variable).


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


Re: [PATCH v4 09/11] powerpc/perf: add support for the hv 24x7 interface

2014-05-22 Thread Cody P Schafer

On 05/22/2014 01:19 AM, Ian Munsie wrote:

Hi Cody,

I just tried building this with gcc 4.5, which failed with the following
warning (treated as an error):

cc1: warnings being treated as errors
arch/powerpc/perf/hv-24x7.c: In function 'single_24x7_request':
arch/powerpc/perf/hv-24x7.c:346:1: error: the frame size of 8192 bytes is 
larger than 2048 bytes
make[3]: *** [arch/powerpc/perf/hv-24x7.o] Error 1
make[2]: *** [arch/powerpc/perf] Error 2

My .config has CONFIG_FRAME_WARN=2048 (default on 64bit), but the
alignment constraints in this function may require 8K on the stack -
possibly a bit large?



Yep, it is a bit large. In other places in hv-24x7 that use similar 
firmware interfaces (with similar alignment requirements), I've used a 
kmem_cache (hv_page_cache). Testing out a patch that uses that here as well.




Notably for some reason this warning no longer seems to trigger on gcc
4.8 (or at least somewhere between 4.5-4.8), though the assembly does
still show it aligning the buffers.


That's a bit concerning (and might be why I didn't pick it up, using gcc 
4.9.0 over here). Looking at the gcc docs, it seems to indicate that 
alloca() and VLAs aren't counted for -Wframe-larger-than. Perhaps gcc 
decided to move locally defined structures with alignment requirements 
into that same bucket? (while size of the structures is statically 
determinable, the stack consumption due to alignment is [to some degree] 
variable).


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


[PATCH] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-22 Thread Cody P Schafer
Ian pointed out the use of __aligned(4096) caused rather large stack
consumption in single_24x7_request(), so use the kmem_cache
hv_page_cache (which we've already got set up for other allocations)
insead of allocating locally.

Reported-by: Ian Munsie imun...@au1.ibm.com
Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
---
 arch/powerpc/perf/hv-24x7.c | 52 -
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index e0766b8..9a7a830 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -294,7 +294,7 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
 u16 lpar, u64 *res,
 bool success_expected)
 {
-   unsigned long ret;
+   unsigned long ret = -ENOMEM;
 
/*
 * request_buffer and result_buffer are not required to be 4k aligned,
@@ -304,7 +304,27 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
struct reqb {
struct hv_24x7_request_buffer buf;
struct hv_24x7_request req;
-   } __packed __aligned(4096) request_buffer = {
+   } __packed *request_buffer;
+   struct resb {
+   struct hv_24x7_data_result_buffer buf;
+   struct hv_24x7_result res;
+   struct hv_24x7_result_element elem;
+   __be64 result;
+   } __packed *result_buffer;
+
+   BUILD_BUG_ON(sizeof(*request_buffer)  4096);
+   BUILD_BUG_ON(sizeof(*result_buffer)  4096);
+
+   request_buffer = kmem_cache_alloc(hv_page_cache, GFP_USER);
+
+   if (!request_buffer)
+   goto out_reqb;
+
+   result_buffer = kmem_cache_zalloc(hv_page_cache, GFP_USER);
+   if (!result_buffer)
+   goto out_resb;
+
+   *request_buffer = (struct reqb) {
.buf = {
.interface_version = HV_24X7_IF_VERSION_CURRENT,
.num_requests = 1,
@@ -320,28 +340,30 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
}
};
 
-   struct resb {
-   struct hv_24x7_data_result_buffer buf;
-   struct hv_24x7_result res;
-   struct hv_24x7_result_element elem;
-   __be64 result;
-   } __packed __aligned(4096) result_buffer = {};
-
ret = plpar_hcall_norets(H_GET_24X7_DATA,
-   virt_to_phys(request_buffer), sizeof(request_buffer),
-   virt_to_phys(result_buffer),  sizeof(result_buffer));
+   virt_to_phys(request_buffer), sizeof(*request_buffer),
+   virt_to_phys(result_buffer),  sizeof(*result_buffer));
 
if (ret) {
if (success_expected)
pr_err_ratelimited(hcall failed: %d %#x %#x %d = 
0x%lx (%ld) detail=0x%x failing ix=%x\n,
domain, offset, ix, lpar,
ret, ret,
-   result_buffer.buf.detailed_rc,
-   result_buffer.buf.failing_request_ix);
-   return ret;
+   result_buffer-buf.detailed_rc,
+   result_buffer-buf.failing_request_ix);
+   goto out_hcall;
}
 
-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer-result);
+   kfree(result_buffer);
+   kfree(request_buffer);
+   return ret;
+
+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
 }
 
-- 
1.9.3

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


Re: [PATCH] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-22 Thread Cody P Schafer

On 05/22/2014 03:38 PM, Stephen Rothwell wrote:

Hi Cody,

On Thu, 22 May 2014 15:29:08 -0700 Cody P Schafer c...@linux.vnet.ibm.com 
wrote:


-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer-result);
+   kfree(result_buffer);
+   kfree(request_buffer);
+   return ret;


Why not just fall through here by removing the above 3 lines?


No reason except me not noticing it.


+
+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
  }




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


[PATCH v2] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-22 Thread Cody P Schafer
Ian pointed out the use of __aligned(4096) caused rather large stack
consumption in single_24x7_request(), so use the kmem_cache
hv_page_cache (which we've already got set up for other allocations)
insead of allocating locally.

Reported-by: Ian Munsie imun...@au1.ibm.com
Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
---
In v2:
  - remove duplicate exit path


 arch/powerpc/perf/hv-24x7.c | 48 +++--
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index e0766b8..998863b 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -294,7 +294,7 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
 u16 lpar, u64 *res,
 bool success_expected)
 {
-   unsigned long ret;
+   unsigned long ret = -ENOMEM;
 
/*
 * request_buffer and result_buffer are not required to be 4k aligned,
@@ -304,7 +304,27 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
struct reqb {
struct hv_24x7_request_buffer buf;
struct hv_24x7_request req;
-   } __packed __aligned(4096) request_buffer = {
+   } __packed *request_buffer;
+   struct resb {
+   struct hv_24x7_data_result_buffer buf;
+   struct hv_24x7_result res;
+   struct hv_24x7_result_element elem;
+   __be64 result;
+   } __packed *result_buffer;
+
+   BUILD_BUG_ON(sizeof(*request_buffer)  4096);
+   BUILD_BUG_ON(sizeof(*result_buffer)  4096);
+
+   request_buffer = kmem_cache_alloc(hv_page_cache, GFP_USER);
+
+   if (!request_buffer)
+   goto out_reqb;
+
+   result_buffer = kmem_cache_zalloc(hv_page_cache, GFP_USER);
+   if (!result_buffer)
+   goto out_resb;
+
+   *request_buffer = (struct reqb) {
.buf = {
.interface_version = HV_24X7_IF_VERSION_CURRENT,
.num_requests = 1,
@@ -320,28 +340,26 @@ static unsigned long single_24x7_request(u8 domain, u32 
offset, u16 ix,
}
};
 
-   struct resb {
-   struct hv_24x7_data_result_buffer buf;
-   struct hv_24x7_result res;
-   struct hv_24x7_result_element elem;
-   __be64 result;
-   } __packed __aligned(4096) result_buffer = {};
-
ret = plpar_hcall_norets(H_GET_24X7_DATA,
-   virt_to_phys(request_buffer), sizeof(request_buffer),
-   virt_to_phys(result_buffer),  sizeof(result_buffer));
+   virt_to_phys(request_buffer), sizeof(*request_buffer),
+   virt_to_phys(result_buffer),  sizeof(*result_buffer));
 
if (ret) {
if (success_expected)
pr_err_ratelimited(hcall failed: %d %#x %#x %d = 
0x%lx (%ld) detail=0x%x failing ix=%x\n,
domain, offset, ix, lpar,
ret, ret,
-   result_buffer.buf.detailed_rc,
-   result_buffer.buf.failing_request_ix);
-   return ret;
+   result_buffer-buf.detailed_rc,
+   result_buffer-buf.failing_request_ix);
+   goto out_hcall;
}
 
-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer-result);
+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
 }
 
-- 
1.9.3

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


Re: [PATCH v2] powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack allocations

2014-05-22 Thread Cody P Schafer

On 05/22/2014 04:49 PM, Stephen Rothwell wrote:

Hi Cody,

On Thu, 22 May 2014 15:44:25 -0700 Cody P Schafer c...@linux.vnet.ibm.com 
wrote:


if (ret) {
if (success_expected)
pr_err_ratelimited(hcall failed: %d %#x %#x %d = 0x%lx 
(%ld) detail=0x%x failing ix=%x\n,
domain, offset, ix, lpar,
ret, ret,
-   result_buffer.buf.detailed_rc,
-   result_buffer.buf.failing_request_ix);
-   return ret;
+   result_buffer-buf.detailed_rc,
+   result_buffer-buf.failing_request_ix);
+   goto out_hcall;
}

-   *res = be64_to_cpu(result_buffer.result);
+   *res = be64_to_cpu(result_buffer-result);


not a biggie, but this last bit could be (remove the goto out_hcall and
teh label and then)

} else {
*res = be64_to_cpu(result_buffer-result);
}



I've got a slight preference toward keeping it as is, which lets all of 
the non-error path code stay outside of if/else blocks (and the error 
handling is kept ever so slightly more consistent).



+out_hcall:
+   kfree(result_buffer);
+out_resb:
+   kfree(request_buffer);
+out_reqb:
return ret;
  }



otherwise looks good to me.



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


Re: [PATCH] powerpc/pseries: relocate "config DTL" so KConfig nests properly

2014-05-13 Thread Cody P Schafer

On 05/12/2014 11:23 PM, Michael Neuling wrote:

powerpc/pseries: relocate "config DTL" so KConfig nests properly


I don't know what that means.  Can you describe it in more detail?



So the "config DTL" refers to the configuration entry.

The "nests properly" refers to the indent that 'make menuconfig' shows 
when a config-option that depends on the config-option proceeding it.


In this case, moving config DTL up so it is below config PPC_SPLPAR 
means that menuconfig will show config DTL nicely indented right below 
config PPC_SPLPAR when PPC_SPLPAR is enabled.


To contrast that, right now if I enable PPC_SPLPAR in menuconfig, all I 
can immediately tell is that "something showed up further down the list 
where I wasn't looking", and I end up having to toggle the option a few 
times to figure out what showed up, or look at the KConfig to find out 
that config DTL depends on config PPC_SPLPAR.


Essentially, this enables menuconfig to provide a visual hint about the 
dependencies between options.



Mikey


On Mon, 2014-05-12 at 20:09 -0700, Cody P Schafer wrote:

Signed-off-by: Cody P Schafer 
---
  arch/powerpc/platforms/pseries/Kconfig | 20 ++--
  1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/Kconfig 
b/arch/powerpc/platforms/pseries/Kconfig
index 2cb8b77..e00dd4d 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -33,6 +33,16 @@ config PPC_SPLPAR
  processors, that is, which share physical processors between
  two or more partitions.

+config DTL
+   bool "Dispatch Trace Log"
+   depends on PPC_SPLPAR && DEBUG_FS
+   help
+ SPLPAR machines can log hypervisor preempt & dispatch events to a
+ kernel buffer. Saying Y here will enable logging these events,
+ which are accessible through a debugfs file.
+
+ Say N if you are unsure.
+
  config PSERIES_MSI
 bool
 depends on PCI_MSI && PPC_PSERIES && EEH
@@ -122,13 +132,3 @@ config HV_PERF_CTRS
  systems. 24x7 is available on Power 8 systems.

If unsure, select Y.
-
-config DTL
-   bool "Dispatch Trace Log"
-   depends on PPC_SPLPAR && DEBUG_FS
-   help
- SPLPAR machines can log hypervisor preempt & dispatch events to a
- kernel buffer. Saying Y here will enable logging these events,
- which are accessible through a debugfs file.
-
- Say N if you are unsure.




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


Re: [PATCH] powerpc/pseries: relocate config DTL so KConfig nests properly

2014-05-13 Thread Cody P Schafer

On 05/12/2014 11:23 PM, Michael Neuling wrote:

powerpc/pseries: relocate config DTL so KConfig nests properly


I don't know what that means.  Can you describe it in more detail?



So the config DTL refers to the configuration entry.

The nests properly refers to the indent that 'make menuconfig' shows 
when a config-option that depends on the config-option proceeding it.


In this case, moving config DTL up so it is below config PPC_SPLPAR 
means that menuconfig will show config DTL nicely indented right below 
config PPC_SPLPAR when PPC_SPLPAR is enabled.


To contrast that, right now if I enable PPC_SPLPAR in menuconfig, all I 
can immediately tell is that something showed up further down the list 
where I wasn't looking, and I end up having to toggle the option a few 
times to figure out what showed up, or look at the KConfig to find out 
that config DTL depends on config PPC_SPLPAR.


Essentially, this enables menuconfig to provide a visual hint about the 
dependencies between options.



Mikey


On Mon, 2014-05-12 at 20:09 -0700, Cody P Schafer wrote:

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
---
  arch/powerpc/platforms/pseries/Kconfig | 20 ++--
  1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/Kconfig 
b/arch/powerpc/platforms/pseries/Kconfig
index 2cb8b77..e00dd4d 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -33,6 +33,16 @@ config PPC_SPLPAR
  processors, that is, which share physical processors between
  two or more partitions.

+config DTL
+   bool Dispatch Trace Log
+   depends on PPC_SPLPAR  DEBUG_FS
+   help
+ SPLPAR machines can log hypervisor preempt  dispatch events to a
+ kernel buffer. Saying Y here will enable logging these events,
+ which are accessible through a debugfs file.
+
+ Say N if you are unsure.
+
  config PSERIES_MSI
 bool
 depends on PCI_MSI  PPC_PSERIES  EEH
@@ -122,13 +132,3 @@ config HV_PERF_CTRS
  systems. 24x7 is available on Power 8 systems.

If unsure, select Y.
-
-config DTL
-   bool Dispatch Trace Log
-   depends on PPC_SPLPAR  DEBUG_FS
-   help
- SPLPAR machines can log hypervisor preempt  dispatch events to a
- kernel buffer. Saying Y here will enable logging these events,
- which are accessible through a debugfs file.
-
- Say N if you are unsure.




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


[PATCH] powerpc/pseries: relocate "config DTL" so KConfig nests properly

2014-05-12 Thread Cody P Schafer
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/platforms/pseries/Kconfig | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/Kconfig 
b/arch/powerpc/platforms/pseries/Kconfig
index 2cb8b77..e00dd4d 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -33,6 +33,16 @@ config PPC_SPLPAR
  processors, that is, which share physical processors between
  two or more partitions.
 
+config DTL
+   bool "Dispatch Trace Log"
+   depends on PPC_SPLPAR && DEBUG_FS
+   help
+ SPLPAR machines can log hypervisor preempt & dispatch events to a
+ kernel buffer. Saying Y here will enable logging these events,
+ which are accessible through a debugfs file.
+
+ Say N if you are unsure.
+
 config PSERIES_MSI
bool
depends on PCI_MSI && PPC_PSERIES && EEH
@@ -122,13 +132,3 @@ config HV_PERF_CTRS
  systems. 24x7 is available on Power 8 systems.
 
   If unsure, select Y.
-
-config DTL
-   bool "Dispatch Trace Log"
-   depends on PPC_SPLPAR && DEBUG_FS
-   help
- SPLPAR machines can log hypervisor preempt & dispatch events to a
- kernel buffer. Saying Y here will enable logging these events,
- which are accessible through a debugfs file.
-
- Say N if you are unsure.
-- 
1.9.3

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


[PATCH] powerpc/pseries: relocate config DTL so KConfig nests properly

2014-05-12 Thread Cody P Schafer
Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
---
 arch/powerpc/platforms/pseries/Kconfig | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/Kconfig 
b/arch/powerpc/platforms/pseries/Kconfig
index 2cb8b77..e00dd4d 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -33,6 +33,16 @@ config PPC_SPLPAR
  processors, that is, which share physical processors between
  two or more partitions.
 
+config DTL
+   bool Dispatch Trace Log
+   depends on PPC_SPLPAR  DEBUG_FS
+   help
+ SPLPAR machines can log hypervisor preempt  dispatch events to a
+ kernel buffer. Saying Y here will enable logging these events,
+ which are accessible through a debugfs file.
+
+ Say N if you are unsure.
+
 config PSERIES_MSI
bool
depends on PCI_MSI  PPC_PSERIES  EEH
@@ -122,13 +132,3 @@ config HV_PERF_CTRS
  systems. 24x7 is available on Power 8 systems.
 
   If unsure, select Y.
-
-config DTL
-   bool Dispatch Trace Log
-   depends on PPC_SPLPAR  DEBUG_FS
-   help
- SPLPAR machines can log hypervisor preempt  dispatch events to a
- kernel buffer. Saying Y here will enable logging these events,
- which are accessible through a debugfs file.
-
- Say N if you are unsure.
-- 
1.9.3

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


[PATCH v3] tools/perf: allow overriding sysfs and proc finding with env var

2014-05-01 Thread Cody P Schafer
SYSFS_PATH and PROC_PATH environment variables now let the user override
the detection of sysfs and proc locations for testing purposes.

Signed-off-by: Cody P Schafer 
---
Since v2: use strncpy() when copying into fs->path
Since v1: rebased onto acme's perf/core

 tools/lib/api/fs/fs.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb78..c1b49c3 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
 /* TODO merge/factor in debugfs.c here */
 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
 }
 
+static void mem_toupper(char *f, size_t len)
+{
+   while (len) {
+   *f = toupper(*f);
+   f++;
+   len--;
+   }
+}
+
+/*
+ * Check for "NAME_PATH" environment variable to override fs location (for
+ * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * for SYSFS_PATH.
+ */
+static bool fs__env_override(struct fs *fs)
+{
+   char *override_path;
+   size_t name_len = strlen(fs->name);
+   /* name + "_PATH" + '\0' */
+   char upper_name[name_len + 5 + 1];
+   memcpy(upper_name, fs->name, name_len);
+   mem_toupper(upper_name, name_len);
+   strcpy(_name[name_len], "_PATH");
+
+   override_path = getenv(upper_name);
+   if (!override_path)
+   return false;
+
+   fs->found = true;
+   strncpy(fs->path, override_path, sizeof(fs->path));
+   return true;
+}
+
 static const char *fs__get_mountpoint(struct fs *fs)
 {
+   if (fs__env_override(fs))
+   return fs->path;
+
if (fs__check_mounts(fs))
return fs->path;
 
-   return fs__read_mounts(fs) ? fs->path : NULL;
+   if (fs__read_mounts(fs))
+   return fs->path;
+
+   return NULL;
 }
 
 static const char *fs__mountpoint(int idx)
-- 
1.9.2

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


[PATCH v3] tools/perf: allow overriding sysfs and proc finding with env var

2014-05-01 Thread Cody P Schafer
SYSFS_PATH and PROC_PATH environment variables now let the user override
the detection of sysfs and proc locations for testing purposes.

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
---
Since v2: use strncpy() when copying into fs-path
Since v1: rebased onto acme's perf/core

 tools/lib/api/fs/fs.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb78..c1b49c3 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
 /* TODO merge/factor in debugfs.c here */
 
+#include ctype.h
 #include errno.h
 #include stdbool.h
 #include stdio.h
+#include stdlib.h
 #include string.h
 #include sys/vfs.h
 
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
 }
 
+static void mem_toupper(char *f, size_t len)
+{
+   while (len) {
+   *f = toupper(*f);
+   f++;
+   len--;
+   }
+}
+
+/*
+ * Check for NAME_PATH environment variable to override fs location (for
+ * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * for SYSFS_PATH.
+ */
+static bool fs__env_override(struct fs *fs)
+{
+   char *override_path;
+   size_t name_len = strlen(fs-name);
+   /* name + _PATH + '\0' */
+   char upper_name[name_len + 5 + 1];
+   memcpy(upper_name, fs-name, name_len);
+   mem_toupper(upper_name, name_len);
+   strcpy(upper_name[name_len], _PATH);
+
+   override_path = getenv(upper_name);
+   if (!override_path)
+   return false;
+
+   fs-found = true;
+   strncpy(fs-path, override_path, sizeof(fs-path));
+   return true;
+}
+
 static const char *fs__get_mountpoint(struct fs *fs)
 {
+   if (fs__env_override(fs))
+   return fs-path;
+
if (fs__check_mounts(fs))
return fs-path;
 
-   return fs__read_mounts(fs) ? fs-path : NULL;
+   if (fs__read_mounts(fs))
+   return fs-path;
+
+   return NULL;
 }
 
 static const char *fs__mountpoint(int idx)
-- 
1.9.2

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


Re: [PATCH v2 6/6] powerpc/perf/hv-24x7: catalog version number is be64, not be32

2014-04-27 Thread Cody P Schafer

On 04/27/2014 09:47 PM, Benjamin Herrenschmidt wrote:

On Tue, 2014-04-15 at 10:10 -0700, Cody P Schafer wrote:

The catalog version number was changed from a be32 (with proceeding
32bits of padding) to a be64, update the code to treat it as a be64

Signed-off-by: Cody P Schafer 
--


Have you tested this ?

It doesn't build for me:

arch/powerpc/perf/hv-24x7.c: In function 'catalog_read':
arch/powerpc/perf/hv-24x7.c:223:3: error: format '%d' expects argument of type 
'int', but argument 2 has type 'uint64_t' [-Werror=format]
cc1: all warnings being treated as errors


I have, and I wasn't initially sure how I managed to miss that 
warning-as-error. On examination: My config (for some reason) has 
CONFIG_PPC_DISABLE_WERROR=y set (probably because it's a variation of a 
distro config). Must have been piping the warnings to a file and 
forgotten to check the file.



I'll fix that up in my tree.


Thanks.

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


Re: [PATCH v2 6/6] powerpc/perf/hv-24x7: catalog version number is be64, not be32

2014-04-27 Thread Cody P Schafer

On 04/27/2014 09:47 PM, Benjamin Herrenschmidt wrote:

On Tue, 2014-04-15 at 10:10 -0700, Cody P Schafer wrote:

The catalog version number was changed from a be32 (with proceeding
32bits of padding) to a be64, update the code to treat it as a be64

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
--


Have you tested this ?

It doesn't build for me:

arch/powerpc/perf/hv-24x7.c: In function 'catalog_read':
arch/powerpc/perf/hv-24x7.c:223:3: error: format '%d' expects argument of type 
'int', but argument 2 has type 'uint64_t' [-Werror=format]
cc1: all warnings being treated as errors


I have, and I wasn't initially sure how I managed to miss that 
warning-as-error. On examination: My config (for some reason) has 
CONFIG_PPC_DISABLE_WERROR=y set (probably because it's a variation of a 
distro config). Must have been piping the warnings to a file and 
forgotten to check the file.



I'll fix that up in my tree.


Thanks.

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


[PATCH v2] tools/perf: allow overriding sysfs and proc finding with env var

2014-04-16 Thread Cody P Schafer
SYSFS_PATH and PROC_PATH environment variables now let the user override
the detection of sysfs and proc locations for testing purposes.

Signed-off-by: Cody P Schafer 
---
Since v1: rebased onto acme's perf/core

 tools/lib/api/fs/fs.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb78..10783a6 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
 /* TODO merge/factor in debugfs.c here */
 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
 }
 
+static void mem_toupper(char *f, size_t len)
+{
+   while (len) {
+   *f = toupper(*f);
+   f++;
+   len--;
+   }
+}
+
+/*
+ * Check for "NAME_PATH" environment variable to override fs location (for
+ * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * for SYSFS_PATH.
+ */
+static bool fs__env_override(struct fs *fs)
+{
+   char *override_path;
+   size_t name_len = strlen(fs->name);
+   /* name + "_PATH" + '\0' */
+   char upper_name[name_len + 5 + 1];
+   memcpy(upper_name, fs->name, name_len);
+   mem_toupper(upper_name, name_len);
+   strcpy(_name[name_len], "_PATH");
+
+   override_path = getenv(upper_name);
+   if (!override_path)
+   return false;
+
+   fs->found = true;
+   strcpy(fs->path, override_path);
+   return true;
+}
+
 static const char *fs__get_mountpoint(struct fs *fs)
 {
+   if (fs__env_override(fs))
+   return fs->path;
+
if (fs__check_mounts(fs))
return fs->path;
 
-   return fs__read_mounts(fs) ? fs->path : NULL;
+   if (fs__read_mounts(fs))
+   return fs->path;
+
+   return NULL;
 }
 
 static const char *fs__mountpoint(int idx)
-- 
1.9.2

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


[PATCH v2] tools/perf: allow overriding sysfs and proc finding with env var

2014-04-16 Thread Cody P Schafer
SYSFS_PATH and PROC_PATH environment variables now let the user override
the detection of sysfs and proc locations for testing purposes.

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
---
Since v1: rebased onto acme's perf/core

 tools/lib/api/fs/fs.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb78..10783a6 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
 /* TODO merge/factor in debugfs.c here */
 
+#include ctype.h
 #include errno.h
 #include stdbool.h
 #include stdio.h
+#include stdlib.h
 #include string.h
 #include sys/vfs.h
 
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
 }
 
+static void mem_toupper(char *f, size_t len)
+{
+   while (len) {
+   *f = toupper(*f);
+   f++;
+   len--;
+   }
+}
+
+/*
+ * Check for NAME_PATH environment variable to override fs location (for
+ * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * for SYSFS_PATH.
+ */
+static bool fs__env_override(struct fs *fs)
+{
+   char *override_path;
+   size_t name_len = strlen(fs-name);
+   /* name + _PATH + '\0' */
+   char upper_name[name_len + 5 + 1];
+   memcpy(upper_name, fs-name, name_len);
+   mem_toupper(upper_name, name_len);
+   strcpy(upper_name[name_len], _PATH);
+
+   override_path = getenv(upper_name);
+   if (!override_path)
+   return false;
+
+   fs-found = true;
+   strcpy(fs-path, override_path);
+   return true;
+}
+
 static const char *fs__get_mountpoint(struct fs *fs)
 {
+   if (fs__env_override(fs))
+   return fs-path;
+
if (fs__check_mounts(fs))
return fs-path;
 
-   return fs__read_mounts(fs) ? fs-path : NULL;
+   if (fs__read_mounts(fs))
+   return fs-path;
+
+   return NULL;
 }
 
 static const char *fs__mountpoint(int idx)
-- 
1.9.2

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


[tip:perf/urgent] perf tools: Instead of redirecting flex output, use -o

2014-04-15 Thread tip-bot for Cody P Schafer
Commit-ID:  c9e87a472594fd237b2d19dcbe4a3424297f0b1a
Gitweb: http://git.kernel.org/tip/c9e87a472594fd237b2d19dcbe4a3424297f0b1a
Author: Cody P Schafer 
AuthorDate: Mon, 14 Apr 2014 12:47:01 +0200
Committer:  Jiri Olsa 
CommitDate: Tue, 15 Apr 2014 13:57:21 +0200

perf tools: Instead of redirecting flex output, use -o

This gives us a real filename instead of having '' show up all
over the place when debugging.

Signed-off-by: Cody P Schafer 
Link: 
http://lkml.kernel.org/r/1396652539-2416-1-git-send-email-c...@linux.vnet.ibm.com
Signed-off-by: Jiri Olsa 
---
 tools/perf/Makefile.perf | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 50d875d..e969233 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -192,13 +192,13 @@ endif
 export PERL_PATH
 
 $(OUTPUT)util/parse-events-flex.c: util/parse-events.l 
$(OUTPUT)util/parse-events-bison.c
-   $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h 
$(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
+   $(QUIET_FLEX)$(FLEX) -o $@ 
--header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) 
util/parse-events.l
 
 $(OUTPUT)util/parse-events-bison.c: util/parse-events.y
$(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) 
-o $(OUTPUT)util/parse-events-bison.c -p parse_events_
 
 $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
-   $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t 
util/pmu.l > $(OUTPUT)util/pmu-flex.c
+   $(QUIET_FLEX)$(FLEX) -o $@ --header-file=$(OUTPUT)util/pmu-flex.h 
util/pmu.l
 
 $(OUTPUT)util/pmu-bison.c: util/pmu.y
$(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c -p 
perf_pmu_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/6] powerpc/perf/hv_gpci: probe failures use pr_debug(), and padding reduced

2014-04-15 Thread Cody P Schafer
fixup for "powerpc/perf: Add support for the hv gpci (get performance
counter info) interface".

Makes the "not enabled" message less awful (and hidden unless
debugging).

Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-gpci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index 278ba7b..8fee1dc 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -273,13 +273,13 @@ static int hv_gpci_init(void)
struct hv_perf_caps caps;
 
if (!firmware_has_feature(FW_FEATURE_LPAR)) {
-   pr_info("not a virtualized system, not enabling\n");
+   pr_debug("not a virtualized system, not enabling\n");
return -ENODEV;
}
 
hret = hv_perf_caps_get();
if (hret) {
-   pr_info("could not obtain capabilities, error 0x%80lx, not 
enabling\n",
+   pr_debug("could not obtain capabilities, not enabling, 
rc=%ld\n",
hret);
return -ENODEV;
}
-- 
1.9.2

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


[PATCH v2 0/6] powerpc/perf/hv_{gpci,24x7}: fixes

2014-04-15 Thread Cody P Schafer
 - 24x7 and gpci probing now uses pr_debug() and doesn't pad to 80 characters
 - Catalog access is fixed for LE kernels
 - remove c99 feature sparse doesn't like
 - 1 device attr made static


Cody P Schafer (6):
  powerpc/perf/hv_24x7: probe errors changed to pr_debug(), padding
fixed
  powerpc/perf/hv_gpci: probe failures use pr_debug(), and padding
reduced
  powerpc/perf/hv-gpci: make device attr static
  powerpc/perf/hv-24x7: use (unsigned long) not (u32) values when
calling plpar_hcall_norets()
  powerpc/perf/hv-24x7: remove [static 4096], sparse chokes on it
  powerpc/perf/hv-24x7: catalog version number is be64, not be32

 arch/powerpc/perf/hv-24x7.c | 30 +-
 arch/powerpc/perf/hv-gpci.c |  6 +++---
 2 files changed, 24 insertions(+), 12 deletions(-)

-- 
1.9.2

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


[PATCH v2 4/6] powerpc/perf/hv-24x7: use (unsigned long) not (u32) values when calling plpar_hcall_norets()

2014-04-15 Thread Cody P Schafer
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-24x7.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index f5bca73..3e8f60a 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -155,16 +155,28 @@ static ssize_t read_offset_data(void *dest, size_t 
dest_len,
return copy_len;
 }
 
-static unsigned long h_get_24x7_catalog_page(char page[static 4096],
-u32 version, u32 index)
+static unsigned long h_get_24x7_catalog_page_(unsigned long phys_4096,
+ unsigned long version,
+ unsigned long index)
 {
-   WARN_ON(!IS_ALIGNED((unsigned long)page, 4096));
+   pr_devel("h_get_24x7_catalog_page(0x%lx, %lu, %lu)",
+   phys_4096,
+   version,
+   index);
+   WARN_ON(!IS_ALIGNED(phys_4096, 4096));
return plpar_hcall_norets(H_GET_24X7_CATALOG_PAGE,
-   virt_to_phys(page),
+   phys_4096,
version,
index);
 }
 
+static unsigned long h_get_24x7_catalog_page(char page[static 4096],
+u32 version, u32 index)
+{
+   return h_get_24x7_catalog_page_(virt_to_phys(page),
+   version, index);
+}
+
 static ssize_t catalog_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
loff_t offset, size_t count)
-- 
1.9.2

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


[PATCH v2 3/6] powerpc/perf/hv-gpci: make device attr static

2014-04-15 Thread Cody P Schafer
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-gpci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index 8fee1dc..c9d399a 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -78,7 +78,7 @@ static ssize_t kernel_version_show(struct device *dev,
return sprintf(page, "0x%x\n", COUNTER_INFO_VERSION_CURRENT);
 }
 
-DEVICE_ATTR_RO(kernel_version);
+static DEVICE_ATTR_RO(kernel_version);
 HV_CAPS_ATTR(version, "0x%x\n");
 HV_CAPS_ATTR(ga, "%d\n");
 HV_CAPS_ATTR(expanded, "%d\n");
-- 
1.9.2

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


[PATCH v2 5/6] powerpc/perf/hv-24x7: remove [static 4096], sparse chokes on it

2014-04-15 Thread Cody P Schafer
Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-24x7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 3e8f60a..95a67f8 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -170,7 +170,7 @@ static unsigned long h_get_24x7_catalog_page_(unsigned long 
phys_4096,
index);
 }
 
-static unsigned long h_get_24x7_catalog_page(char page[static 4096],
+static unsigned long h_get_24x7_catalog_page(char page[],
 u32 version, u32 index)
 {
return h_get_24x7_catalog_page_(virt_to_phys(page),
-- 
1.9.2

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


[PATCH v2 1/6] powerpc/perf/hv_24x7: probe errors changed to pr_debug(), padding fixed

2014-04-15 Thread Cody P Schafer
fixup for "powerpc/perf: Add support for the hv 24x7 interface"

Makes the "not enabled" message less awful (and hides it in most cases).

Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-24x7.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 297c9105..f5bca73 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -485,13 +485,13 @@ static int hv_24x7_init(void)
struct hv_perf_caps caps;
 
if (!firmware_has_feature(FW_FEATURE_LPAR)) {
-   pr_info("not a virtualized system, not enabling\n");
+   pr_debug("not a virtualized system, not enabling\n");
return -ENODEV;
}
 
hret = hv_perf_caps_get();
if (hret) {
-   pr_info("could not obtain capabilities, error 0x%80lx, not 
enabling\n",
+   pr_debug("could not obtain capabilities, not enabling, 
rc=%ld\n",
hret);
return -ENODEV;
}
-- 
1.9.2

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


[PATCH v2 6/6] powerpc/perf/hv-24x7: catalog version number is be64, not be32

2014-04-15 Thread Cody P Schafer
The catalog version number was changed from a be32 (with proceeding
32bits of padding) to a be64, update the code to treat it as a be64

Signed-off-by: Cody P Schafer 
---
 arch/powerpc/perf/hv-24x7.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 95a67f8..9d4badc 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -171,7 +171,7 @@ static unsigned long h_get_24x7_catalog_page_(unsigned long 
phys_4096,
 }
 
 static unsigned long h_get_24x7_catalog_page(char page[],
-u32 version, u32 index)
+u64 version, u32 index)
 {
return h_get_24x7_catalog_page_(virt_to_phys(page),
version, index);
@@ -185,7 +185,7 @@ static ssize_t catalog_read(struct file *filp, struct 
kobject *kobj,
ssize_t ret = 0;
size_t catalog_len = 0, catalog_page_len = 0, page_count = 0;
loff_t page_offset = 0;
-   uint32_t catalog_version_num = 0;
+   uint64_t catalog_version_num = 0;
void *page = kmem_cache_alloc(hv_page_cache, GFP_USER);
struct hv_24x7_catalog_page_0 *page_0 = page;
if (!page)
@@ -197,7 +197,7 @@ static ssize_t catalog_read(struct file *filp, struct 
kobject *kobj,
goto e_free;
}
 
-   catalog_version_num = be32_to_cpu(page_0->version);
+   catalog_version_num = be64_to_cpu(page_0->version);
catalog_page_len = be32_to_cpu(page_0->length);
catalog_len = catalog_page_len * 4096;
 
@@ -255,7 +255,7 @@ e_free: 
\
 static DEVICE_ATTR_RO(_name)
 
 PAGE_0_ATTR(catalog_version, "%lld\n",
-   (unsigned long long)be32_to_cpu(page_0->version));
+   (unsigned long long)be64_to_cpu(page_0->version));
 PAGE_0_ATTR(catalog_len, "%lld\n",
(unsigned long long)be32_to_cpu(page_0->length) * 4096);
 static BIN_ATTR_RO(catalog, 0/* real length varies */);
-- 
1.9.2

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


[PATCH v2 6/6] powerpc/perf/hv-24x7: catalog version number is be64, not be32

2014-04-15 Thread Cody P Schafer
The catalog version number was changed from a be32 (with proceeding
32bits of padding) to a be64, update the code to treat it as a be64

Signed-off-by: Cody P Schafer c...@linux.vnet.ibm.com
---
 arch/powerpc/perf/hv-24x7.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 95a67f8..9d4badc 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -171,7 +171,7 @@ static unsigned long h_get_24x7_catalog_page_(unsigned long 
phys_4096,
 }
 
 static unsigned long h_get_24x7_catalog_page(char page[],
-u32 version, u32 index)
+u64 version, u32 index)
 {
return h_get_24x7_catalog_page_(virt_to_phys(page),
version, index);
@@ -185,7 +185,7 @@ static ssize_t catalog_read(struct file *filp, struct 
kobject *kobj,
ssize_t ret = 0;
size_t catalog_len = 0, catalog_page_len = 0, page_count = 0;
loff_t page_offset = 0;
-   uint32_t catalog_version_num = 0;
+   uint64_t catalog_version_num = 0;
void *page = kmem_cache_alloc(hv_page_cache, GFP_USER);
struct hv_24x7_catalog_page_0 *page_0 = page;
if (!page)
@@ -197,7 +197,7 @@ static ssize_t catalog_read(struct file *filp, struct 
kobject *kobj,
goto e_free;
}
 
-   catalog_version_num = be32_to_cpu(page_0-version);
+   catalog_version_num = be64_to_cpu(page_0-version);
catalog_page_len = be32_to_cpu(page_0-length);
catalog_len = catalog_page_len * 4096;
 
@@ -255,7 +255,7 @@ e_free: 
\
 static DEVICE_ATTR_RO(_name)
 
 PAGE_0_ATTR(catalog_version, %lld\n,
-   (unsigned long long)be32_to_cpu(page_0-version));
+   (unsigned long long)be64_to_cpu(page_0-version));
 PAGE_0_ATTR(catalog_len, %lld\n,
(unsigned long long)be32_to_cpu(page_0-length) * 4096);
 static BIN_ATTR_RO(catalog, 0/* real length varies */);
-- 
1.9.2

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


  1   2   3   4   5   6   7   8   9   10   >