Commit e5a5886d authored by Sukadev Bhattiprolu's avatar Sukadev Bhattiprolu Committed by Michael Ellerman

powerpc/perf/hv-24x7: Fix usage with chip events.

24x7 counters can belong to different domains (core, chip, virtual CPU
etc). For events in the 'chip' domain, sysfs entry currently looks like:

	$ cd /sys/bus/event_source/devices/hv_24x7/events
	$ cat PM_XLINK_CYCLES__PHYS_CHIP
	domain=0x1,offset=0x230,core=?,lpar=0x0

where the required parameter, 'core=?' is specified with perf as:

	perf stat -C 0 -e hv_24x7/PM_XLINK_CYCLES__PHYS_CHIP,core=1/ \
		/bin/true

This is inconsistent in that 'core' is a required parameter for a chip
event.  Instead, have the the sysfs entry display 'chip=?' for chip
events:

	$ cd /sys/bus/event_source/devices/hv_24x7/events
	$ cat PM_XLINK_CYCLES__PHYS_CHIP
	domain=0x1,offset=0x230,chip=?,lpar=0x0

We also need to add a 'chip' entry in the sysfs format directory:

	$ ls /sys/bus/event_source/devices/hv_24x7/format
	chip  core  domain  lpar  offset  vcpu
	^^^^
	(new)

so the perf tool can automatically check usage and format the chip
parameter correctly:

	$ perf stat -C 0 -v -e hv_24x7/PM_XLINK_CYCLES__PHYS_CHIP/ \
		/bin/true
	Required parameter 'chip' not specified
	invalid or unsupported event: 'hv_24x7/PM_XLINK_CYCLES__PHYS_CHIP/'

	$ perf stat -C 0 -v -e hv_24x7/PM_XLINK_CYCLES__PHYS_CHIP,chip=1/ \
		/bin/true
	hv_24x7/PM_XLINK_CYCLES__PHYS_CHIP,chip=1/: 0 6628908 6628908

	 Performance counter stats for 'CPU(s) 0':

	         0      hv_24x7/PM_XLINK_CYCLES__PHYS_CHIP,chip=1/

	    0.006606970 seconds time elapsed
Signed-off-by: default avatarSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent e0728b50
...@@ -101,6 +101,7 @@ static bool catalog_entry_domain_is_valid(unsigned domain) ...@@ -101,6 +101,7 @@ static bool catalog_entry_domain_is_valid(unsigned domain)
EVENT_DEFINE_RANGE_FORMAT(domain, config, 0, 3); EVENT_DEFINE_RANGE_FORMAT(domain, config, 0, 3);
/* u16 */ /* u16 */
EVENT_DEFINE_RANGE_FORMAT(core, config, 16, 31); EVENT_DEFINE_RANGE_FORMAT(core, config, 16, 31);
EVENT_DEFINE_RANGE_FORMAT(chip, config, 16, 31);
EVENT_DEFINE_RANGE_FORMAT(vcpu, config, 16, 31); EVENT_DEFINE_RANGE_FORMAT(vcpu, config, 16, 31);
/* u32, see "data_offset" */ /* u32, see "data_offset" */
EVENT_DEFINE_RANGE_FORMAT(offset, config, 32, 63); EVENT_DEFINE_RANGE_FORMAT(offset, config, 32, 63);
...@@ -115,6 +116,7 @@ static struct attribute *format_attrs[] = { ...@@ -115,6 +116,7 @@ static struct attribute *format_attrs[] = {
&format_attr_domain.attr, &format_attr_domain.attr,
&format_attr_offset.attr, &format_attr_offset.attr,
&format_attr_core.attr, &format_attr_core.attr,
&format_attr_chip.attr,
&format_attr_vcpu.attr, &format_attr_vcpu.attr,
&format_attr_lpar.attr, &format_attr_lpar.attr,
NULL, NULL,
...@@ -289,10 +291,16 @@ static char *event_fmt(struct hv_24x7_event_data *event, unsigned domain) ...@@ -289,10 +291,16 @@ static char *event_fmt(struct hv_24x7_event_data *event, unsigned domain)
const char *sindex; const char *sindex;
const char *lpar; const char *lpar;
if (is_physical_domain(domain)) { switch (domain) {
case HV_PERF_DOMAIN_PHYS_CHIP:
lpar = "0x0";
sindex = "chip";
break;
case HV_PERF_DOMAIN_PHYS_CORE:
lpar = "0x0"; lpar = "0x0";
sindex = "core"; sindex = "core";
} else { break;
default:
lpar = "?"; lpar = "?";
sindex = "vcpu"; sindex = "vcpu";
} }
...@@ -1089,10 +1097,16 @@ static int add_event_to_24x7_request(struct perf_event *event, ...@@ -1089,10 +1097,16 @@ static int add_event_to_24x7_request(struct perf_event *event,
return -EINVAL; return -EINVAL;
} }
if (is_physical_domain(event_get_domain(event))) switch (event_get_domain(event)) {
case HV_PERF_DOMAIN_PHYS_CHIP:
idx = event_get_chip(event);
break;
case HV_PERF_DOMAIN_PHYS_CORE:
idx = event_get_core(event); idx = event_get_core(event);
else break;
default:
idx = event_get_vcpu(event); idx = event_get_vcpu(event);
}
i = request_buffer->num_requests++; i = request_buffer->num_requests++;
req = &request_buffer->requests[i]; req = &request_buffer->requests[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment