[PATCH v1 4/9]powerpc/powernv: Add generic nest pmu ops

Daniel Axtens dja at axtens.net
Wed Jun 3 10:03:39 AEST 2015


On Tue, 2015-06-02 at 21:29 +0530, Madhavan Srinivasan wrote:
> Patch adds generic nest pmu functions and format attribute.
> 
I'm not sure this commit message accurately reflects the content of the
patch. At any rate, please could you:
 - say what the patch adds the functions and attributes to.
 - phrase your message as "Add generic ..." not "Patch adds
generic ...": see
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches#n155


>  
> +PMU_FORMAT_ATTR(event, "config:0-20");
> +struct attribute *p8_nest_format_attrs[] = {
> +	&format_attr_event.attr,
> +	NULL,
> +};
> +
> +struct attribute_group p8_nest_format_group = {
> +	.name = "format",
> +	.attrs = p8_nest_format_attrs,
> +};
Can these structs be constified?

> +
> +int p8_nest_event_init(struct perf_event *event)
> +{
> +	int chip_id;
> +
> +	if (event->attr.type != event->pmu->type)
> +		return -ENOENT;
> +
> +	/* Sampling not supported yet */
> +	if (event->hw.sample_period)
> +		return -EINVAL;
> +
> +	/* unsupported modes and filters */
> +	if (event->attr.exclude_user   ||
> +	    event->attr.exclude_kernel ||
> +	    event->attr.exclude_hv     ||
> +	    event->attr.exclude_idle   ||
> +	    event->attr.exclude_host   ||
> +	    event->attr.exclude_guest  ||
> +	    event->attr.sample_period) /* no sampling */
> +		return -EINVAL;
You test for sample period twice here.

> +
> +	if (event->cpu < 0)
> +		return -EINVAL;
> +
> +	chip_id = topology_physical_package_id(event->cpu);
> +	event->hw.event_base = event->attr.config +
> +				p8_perchip_nest_info[chip_id].vbase;
> +
> +	return 0;
> +}
> +
> +void p8_nest_read_counter(struct perf_event *event)
> +{
> +	u64 *addr;
> +	u64 data = 0;
> +
> +	addr = (u64 *)event->hw.event_base;
> +	data = __be64_to_cpu((uint64_t)*addr);
> +	local64_set(&event->hw.prev_count, data);
> +}
> +
> +void p8_nest_perf_event_update(struct perf_event *event)
> +{
> +	u64 counter_prev, counter_new, final_count;
> +	uint64_t *addr;
> +
> +	addr = (u64 *)event->hw.event_base;
> +	counter_prev = local64_read(&event->hw.prev_count);
> +	counter_new = __be64_to_cpu((uint64_t)*addr);
> +	final_count = counter_new - counter_prev;
> +
> +	local64_set(&event->hw.prev_count, counter_new);
> +	local64_add(final_count, &event->count);
> +}
> +
> +void p8_nest_event_start(struct perf_event *event, int flags)
> +{
> +	event->hw.state = 0;
> +	p8_nest_read_counter(event);
> +}
> +
> +void p8_nest_event_stop(struct perf_event *event, int flags)
> +{
> +	p8_nest_perf_event_update(event);
> +}
> +
> +int p8_nest_event_add(struct perf_event *event, int flags)
> +{
> +	p8_nest_event_start(event, flags);
> +	return 0;
> +}
> +
> +void p8_nest_event_del(struct perf_event *event, int flags)
> +{
> +	p8_nest_event_stop(event, flags);
Is this necessary?

Stop calls update, which I guess makes sense as it finalises the value.
But if the event is being deleted anyway, why not just do nothing here?
> +}
> +

Regards,
Daniel Axtens
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 860 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20150603/fc7b5c65/attachment.sig>


More information about the Linuxppc-dev mailing list