Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Deng-Cheng Zhu <dczhu@mips.com>
To: Deng-Cheng Zhu <dczhu@mips.com>
Cc: <linux-mips@linux-mips.org>, <ralf@linux-mips.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	David Daney <david.daney@cavium.com>,
	David Ahern <dsahern@gmail.com>,
	Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH 3/4] MIPS/Perf-events: temporarily connect event to its pmu at event init
Date: Tue, 25 Oct 2011 13:36:51 +0800	[thread overview]
Message-ID: <4EA64AF3.8060307@mips.com> (raw)
In-Reply-To: <1319453762-12962-4-git-send-email-dczhu@mips.com>

On 10/24/2011 06:56 PM, Deng-Cheng Zhu wrote:
> When arch level event init is called, the event is not yet connected to
> the PMU, thereby causing validate_group() to always do dummy work. On MIPS,
> this is due to the following lines in validate_event() called by
> validate_group():
>
> if (event->pmu !=&pmu || event->state<= PERF_EVENT_STATE_OFF)
>          return 1;
>
> This patch fixes it.
>
> Signed-off-by: Deng-Cheng Zhu<dczhu@mips.com>
> Cc: Peter Zijlstra<a.p.zijlstra@chello.nl>
> Cc: Paul Mackerras<paulus@samba.org>
> Cc: Ingo Molnar<mingo@elte.hu>
> Cc: Arnaldo Carvalho de Melo<acme@ghostprotocols.net>
> Cc: David Daney<david.daney@cavium.com>
> ---
>   arch/mips/kernel/perf_event_mipsxx.c |   17 +++++++++++++----
>   1 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
> index 1f654ca..c804fdd 100644
> --- a/arch/mips/kernel/perf_event_mipsxx.c
> +++ b/arch/mips/kernel/perf_event_mipsxx.c
> @@ -548,6 +548,7 @@ static int __hw_perf_event_init(struct perf_event *event)
>   	struct perf_event_attr *attr =&event->attr;
>   	struct hw_perf_event *hwc =&event->hw;
>   	const struct mips_perf_event *pev;
> +	struct pmu *tmp;
>   	int err;
>
>   	/* Returning MIPS event descriptor for generic perf event. */
> @@ -611,11 +612,19 @@ static int __hw_perf_event_init(struct perf_event *event)
>   	}
>
>   	err = 0;
> -	if (event->group_leader != event) {
> +
> +	/*
> +	 * we temporarily connect event to its pmu such that
> +	 * validate_event() in validate_group() can classify
> +	 * it as a MIPS event by passing (event->pmu ==&pmu).
> +	 */
> +	tmp = event->pmu;
> +	event->pmu =&pmu;
> +
> +	if (event->group_leader != event)
>   		err = validate_group(event);
> -		if (err)
> -			return -EINVAL;
> -	}
> +
> +	event->pmu = tmp;
>
>   	event->destroy = hw_perf_event_destroy;
>

After looking at David Ahern's reply to my another patch (link
provided below), I started to think whether the PMU and event state
checks are redundant in validate_event() on MIPS (ARM may also have
the same consideration).

The related patch link:
http://www.spinics.net/lists/kernel/msg1252452.html

_If_ the state fix goes to group checks instead of to the perf tool,
then the following line in validate_event() on MIPS seems redundant:

if (event->pmu !=&pmu || event->state <= PERF_EVENT_STATE_OFF)
         return 1;

This is because validate_event() is only called by validate_group()
which is called only by __hw_perf_event_init(), and the issue of the
pmu check is already addressed in this patch, and we don't want the
grouped events which are in PERF_EVENT_STATE_OFF (by "attr->disabled =
1") to be filtered out here.

Also, _if_ the state fix goes to group checks instead of to the perf
tool, then X86 may need a patch to allow collect_events() to do real
work in validate_group().

Any comments?


Deng-Cheng

WARNING: multiple messages have this Message-ID (diff)
From: Deng-Cheng Zhu <dczhu@mips.com>
To: Deng-Cheng Zhu <dczhu@mips.com>
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	David Daney <david.daney@cavium.com>,
	David Ahern <dsahern@gmail.com>,
	Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH 3/4] MIPS/Perf-events: temporarily connect event to its pmu at event init
Date: Tue, 25 Oct 2011 13:36:51 +0800	[thread overview]
Message-ID: <4EA64AF3.8060307@mips.com> (raw)
Message-ID: <20111025053651.QW2QT-28Y0TOYuj8soMBRx2RQGqFiV2W9kL_AqOFt1M@z> (raw)
In-Reply-To: <1319453762-12962-4-git-send-email-dczhu@mips.com>

On 10/24/2011 06:56 PM, Deng-Cheng Zhu wrote:
> When arch level event init is called, the event is not yet connected to
> the PMU, thereby causing validate_group() to always do dummy work. On MIPS,
> this is due to the following lines in validate_event() called by
> validate_group():
>
> if (event->pmu !=&pmu || event->state<= PERF_EVENT_STATE_OFF)
>          return 1;
>
> This patch fixes it.
>
> Signed-off-by: Deng-Cheng Zhu<dczhu@mips.com>
> Cc: Peter Zijlstra<a.p.zijlstra@chello.nl>
> Cc: Paul Mackerras<paulus@samba.org>
> Cc: Ingo Molnar<mingo@elte.hu>
> Cc: Arnaldo Carvalho de Melo<acme@ghostprotocols.net>
> Cc: David Daney<david.daney@cavium.com>
> ---
>   arch/mips/kernel/perf_event_mipsxx.c |   17 +++++++++++++----
>   1 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
> index 1f654ca..c804fdd 100644
> --- a/arch/mips/kernel/perf_event_mipsxx.c
> +++ b/arch/mips/kernel/perf_event_mipsxx.c
> @@ -548,6 +548,7 @@ static int __hw_perf_event_init(struct perf_event *event)
>   	struct perf_event_attr *attr =&event->attr;
>   	struct hw_perf_event *hwc =&event->hw;
>   	const struct mips_perf_event *pev;
> +	struct pmu *tmp;
>   	int err;
>
>   	/* Returning MIPS event descriptor for generic perf event. */
> @@ -611,11 +612,19 @@ static int __hw_perf_event_init(struct perf_event *event)
>   	}
>
>   	err = 0;
> -	if (event->group_leader != event) {
> +
> +	/*
> +	 * we temporarily connect event to its pmu such that
> +	 * validate_event() in validate_group() can classify
> +	 * it as a MIPS event by passing (event->pmu ==&pmu).
> +	 */
> +	tmp = event->pmu;
> +	event->pmu =&pmu;
> +
> +	if (event->group_leader != event)
>   		err = validate_group(event);
> -		if (err)
> -			return -EINVAL;
> -	}
> +
> +	event->pmu = tmp;
>
>   	event->destroy = hw_perf_event_destroy;
>

After looking at David Ahern's reply to my another patch (link
provided below), I started to think whether the PMU and event state
checks are redundant in validate_event() on MIPS (ARM may also have
the same consideration).

The related patch link:
http://www.spinics.net/lists/kernel/msg1252452.html

_If_ the state fix goes to group checks instead of to the perf tool,
then the following line in validate_event() on MIPS seems redundant:

if (event->pmu !=&pmu || event->state <= PERF_EVENT_STATE_OFF)
         return 1;

This is because validate_event() is only called by validate_group()
which is called only by __hw_perf_event_init(), and the issue of the
pmu check is already addressed in this patch, and we don't want the
grouped events which are in PERF_EVENT_STATE_OFF (by "attr->disabled =
1") to be filtered out here.

Also, _if_ the state fix goes to group checks instead of to the perf
tool, then X86 may need a patch to allow collect_events() to do real
work in validate_group().

Any comments?


Deng-Cheng

  parent reply	other threads:[~2011-10-25  5:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24 10:55 [PATCH 0/4] MIPS/Perf-events: Functional fixes and cleanups Deng-Cheng Zhu
2011-10-24 10:55 ` Deng-Cheng Zhu
2011-10-24 10:55 ` [PATCH 1/4] MIPS/Perf-events: update the map of unsupported events for 74K Deng-Cheng Zhu
2011-10-24 10:55   ` Deng-Cheng Zhu
2011-11-09 20:40   ` Ralf Baechle
2011-11-09 22:00     ` Peter Zijlstra
2011-11-10 10:08     ` Deng-Cheng Zhu
2011-11-10 10:08       ` Deng-Cheng Zhu
2011-10-24 10:56 ` [PATCH 2/4] MIPS/Perf-events: remove erroneous check on active_events Deng-Cheng Zhu
2011-10-24 10:56   ` Deng-Cheng Zhu
2011-10-24 10:56 ` [PATCH 3/4] MIPS/Perf-events: temporarily connect event to its pmu at event init Deng-Cheng Zhu
2011-10-24 10:56   ` Deng-Cheng Zhu
2011-10-25  5:36   ` Deng-Cheng Zhu [this message]
2011-10-25  5:36     ` Deng-Cheng Zhu
2011-10-24 10:56 ` [PATCH 4/4] MIPS/Perf-events: Cleanup event->destroy " Deng-Cheng Zhu
2011-10-24 10:56   ` Deng-Cheng Zhu

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=4EA64AF3.8060307@mips.com \
    --to=dczhu@mips.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=david.daney@cavium.com \
    --cc=dsahern@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=will.deacon@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox