Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1157013
| Path | csiph.com!aioe.org!newsfeed.CARNet.hr!news.spin.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Daniel Axtens <dja@axtens.net> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v1 7/9]powerpc/powernv: Event attr creation and PMU registration |
| Date | Wed, 03 Jun 2015 03:10:02 +0200 |
| Message-ID | <px5lU-1O2-13@gated-at.bofh.it> (permalink) |
| References | <pwWVk-6d0-7@gated-at.bofh.it> <pwWVl-6d0-29@gated-at.bofh.it> |
| X-Original-To | Madhavan Srinivasan <maddy@linux.vnet.ibm.com> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; bh=CfVEF4+XLBTvmgrIOwSQnjX8SjLGGuFlU4XWnSqoZu0=; b=hZRMvrQsja9vDe1KJ6gmkBMM3zhX66XKwNIHs/PGkML/oEzlEOxOVk/b8XNHiZyAQE or97df1GjFPeOOK/c2//5cs8hjmzZUtIpCuyQsrGRE58r0dbLHRInsdzuqDw4EiVWf8O 0dERfQyyZR4kSx6mXNuWEbr+tmU95f0NiaUy8= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:mime-version; bh=CfVEF4+XLBTvmgrIOwSQnjX8SjLGGuFlU4XWnSqoZu0=; b=lUfqpbYGPptZGLQ03rweYHC/iwDMK3Dj8LRUS7fgi6wohfVGounqKnRjdtZ+ixyhnF UOMDPuf40yClZEdyna2Qrko7b5/zY4b0J2I5+dVLTj2qAWQXKHpJSA5lu8BuB3BX8Dmr O4qMjbcqvtoghMKDsSw8bHzjIpwXsvwNM4om/rUse/owxKmSS3pmBxog2buZr7gO8cQB JuTb+nj75Rj9ODjQNdpGFu9qWEtUnKcKLUtb0Wl8r2qX69UbnqKGRA52k0LDdnc+IT/J 6JZ+9lO0+f8VQ3Rtl6ycIXs/pmSF6MxmF0iHDMf/4FdIVD6Dg03QvY0h/QlaP1Ax1gJ/ K0/A== |
| X-Gm-Message-State | ALoCoQl1wEPI8Eb6wyQIV3n9VjGTfAJD02kRhxIiOxvfWO9UeieqFVscgPGxd0ujAmkUsfRCe4NL |
| X-Received | by 10.66.229.65 with SMTP id so1mr54546876pac.92.1433293640847; Tue, 02 Jun 2015 18:07:20 -0700 (PDT) |
| Content-Type | multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-3UvNLlBH0iFn4hydQOlX" |
| X-Mailer | Evolution 3.12.9-1+b1 |
| MIME-Version | 1.0 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 145 |
| Organization | linux.* mail to news gateway |
| X-Original-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> |
| X-Original-Date | Wed, 03 Jun 2015 11:06:32 +1000 |
| X-Original-Message-ID | <1433293592.438.74.camel@axtens.net> |
| X-Original-References | <1433260778-26497-1-git-send-email-maddy@linux.vnet.ibm.com> <1433260778-26497-8-git-send-email-maddy@linux.vnet.ibm.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | aioe.org linux.kernel:1157013 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Tue, 2015-06-02 at 21:29 +0530, Madhavan Srinivasan wrote:
> Patch adds common event attribute function and Nest pmu registration call.
>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> Cc: Stephane Eranian <eranian@google.com>
> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> ---
> arch/powerpc/perf/nest-pmu.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 52 insertions(+)
>
> diff --git a/arch/powerpc/perf/nest-pmu.c b/arch/powerpc/perf/nest-pmu.c
> index 514a0be..dd84fd7 100644
> --- a/arch/powerpc/perf/nest-pmu.c
> +++ b/arch/powerpc/perf/nest-pmu.c
> @@ -244,6 +244,49 @@ static int update_pmu_ops(struct nest_pmu *pmu)
> return 0;
> }
>
> +/*
> + * Populate event name and string in attribute
> + */
> +struct attribute *dev_str_attr(char *name, char *str)
> +{
> + struct perf_pmu_events_attr *attr;
> +
> + attr = kzalloc(sizeof(*attr), GFP_KERNEL);
> +
> + attr->event_str = (const char *)str;
Erk. Two things:
- Is str const or not? If you're treating it as const here, should you
pass that through the function signature?
- Who is responsible for the memory behind it? It looks like a caller
can't construct str dynamically, pass it to this function and then free
it, because that will invalidate attr->event_str. Is this documented?
> + attr->attr.attr.name = name;
> + attr->attr.attr.mode = 0444;
> + attr->attr.show = perf_event_sysfs_show;
> +
> + return &attr->attr.attr;
If you're returning the address of attr->attr.attr, then:
- why don't you just deal directly with struct attribute * in the
function? Why an entire struct perf_pmu_events_attr *?
- with the function as written, if you return just &attr->attr.attr,
don't attr->event_str and attr->attr.show get lost?
> +}
> +
> +int update_events_in_group(
> + struct ppc64_nest_ima_events *p8_events, int idx,
> + struct nest_pmu *pmu)
> +{
> + struct attribute_group *attr_group;
> + struct attribute **attrs;
> + int i;
> +
> + attr_group = kzalloc(((sizeof(struct attribute *) * (idx + 1)) +
> + sizeof(*attr_group)), GFP_KERNEL);
> + if (!attr_group)
> + return -ENOMEM;
> +
> + attrs = (struct attribute **)(attr_group + 1);
> + attr_group->name = "events";
> + attr_group->attrs = attrs;
> +
> + for (i=0; i< idx; i++, p8_events++)
> + attrs[i] = dev_str_attr((char *)p8_events->ev_name,
> + (char *)p8_events->ev_value);
> +
> + pmu->attr_groups[0] = attr_group;
> + return 0;
> +}
I'm very confused by what this function is trying to do. Could you add
some comments? I'm particularly confused by the relationship between
attrs and attr_group.
> +
> +
> static int nest_pmu_create(struct device_node *dev, int pmu_index)
> {
> struct ppc64_nest_ima_events **p8_events_arr;
> @@ -364,6 +407,15 @@ static int nest_pmu_create(struct device_node *dev, int pmu_index)
> }
> }
>
> + update_events_in_group(
> + (struct ppc64_nest_ima_events *)p8_events_arr,
> + idx, pmu_ptr);
> + update_pmu_ops(pmu_ptr);
> +
> + /* Register the pmu */
> + perf_pmu_register(&pmu_ptr->pmu, pmu_ptr->pmu.name, -1);
> + printk(KERN_INFO "Nest PMU %s Registered\n", pmu_ptr->pmu.name);
> +
> return 0;
> }
>
Regards,
Daniel
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [PATCH v1 7/9]powerpc/powernv: Event attr creation and PMU registration Daniel Axtens <dja@axtens.net> - 2015-06-03 03:10 +0200
csiph-web