All of lore.kernel.org
 help / color / mirror / Atom feed
From: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
To: Daniel Axtens <dja@axtens.net>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	Stephane Eranian <eranian@google.com>,
	Paul Mackerras <paulus@samba.org>,
	Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
	Anshuman Khandual <khandual@linux.vnet.ibm.com>
Subject: Re: [PATCH v1 4/9]powerpc/powernv: Add generic nest pmu ops
Date: Thu, 04 Jun 2015 14:36:04 +0530	[thread overview]
Message-ID: <557014FC.2000209@linux.vnet.ibm.com> (raw)
In-Reply-To: <1433289819.438.38.camel@axtens.net>



On Wednesday 03 June 2015 05:33 AM, Daniel Axtens wrote:
> 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

Sure. Will rephrase it.
>
>>   
>> +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?
I guess it can. Will check it out.

>> +
>> +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.
Yes right. I will remove it.

>> +
>> +	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?
Since these Nest PMUs does not support sampling. IIUC, "perf record" 
interface uses
the event start/stop ops. Incase of perf stat interface event add/del 
interface are used to enable and disable the counters. Now, when we 
disable or delete, we update the event counter with the delta value.

>> +}
>> +
> Regards,
> Daniel Axtens

Thanks for the review
Maddy

  reply	other threads:[~2015-06-04  9:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 15:59 [PATCH v1 0/9]powerpc/powernv: Nest Instrumentation support Madhavan Srinivasan
2015-06-02 15:59 ` [PATCH v1 1/9]powerpc/powernv: Data structure and macros definition Madhavan Srinivasan
2015-06-02 23:11   ` Daniel Axtens
2015-06-04  7:48     ` Madhavan Srinivasan
2015-06-04 10:48     ` Mike & Meg
2015-06-02 15:59 ` [PATCH v1 2/9]powerpc/powernv: nest pmu init function with cpumask attr Madhavan Srinivasan
2015-06-02 23:14   ` Daniel Axtens
2015-06-04  8:06     ` Madhavan Srinivasan
2015-06-02 15:59 ` [PATCH v1 3/9]powerpc/powernv: Add cpu hotplug support Madhavan Srinivasan
2015-06-02 23:38   ` Daniel Axtens
2015-06-04  8:30     ` Madhavan Srinivasan
2015-06-02 15:59 ` [PATCH v1 4/9]powerpc/powernv: Add generic nest pmu ops Madhavan Srinivasan
2015-06-03  0:03   ` Daniel Axtens
2015-06-04  9:06     ` Madhavan Srinivasan [this message]
2015-06-04  9:27     ` Madhavan Srinivasan
2015-06-02 15:59 ` [PATCH v1 5/9]powerpc/powernv: nest pmu feature detection support Madhavan Srinivasan
2015-06-03  0:21   ` Daniel Axtens
2015-06-04  9:52     ` Madhavan Srinivasan
2015-06-02 15:59 ` [PATCH v1 6/9]powerpc/powernv: dt parser function for nest pmu and its events Madhavan Srinivasan
2015-06-03  0:46   ` Daniel Axtens
2015-06-04 10:03     ` Madhavan Srinivasan
2015-06-02 15:59 ` [PATCH v1 7/9]powerpc/powernv: Event attr creation and PMU registration Madhavan Srinivasan
2015-06-03  1:06   ` Daniel Axtens
2015-06-09 11:41     ` Madhavan Srinivasan
2015-06-02 15:59 ` [PATCH v1 8/9] powerpc/powernv: Add OPAL support for Nest PMU Madhavan Srinivasan
2015-06-03  0:54   ` Daniel Axtens
2015-06-04 10:26     ` Madhavan Srinivasan
2015-06-02 15:59 ` [PATCH v1 9/9]powerpc/powernv: Makefile changes to include nest pmu Madhavan Srinivasan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=557014FC.2000209@linux.vnet.ibm.com \
    --to=maddy@linux.vnet.ibm.com \
    --cc=dja@axtens.net \
    --cc=eranian@google.com \
    --cc=khandual@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=sukadev@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.