All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Daney <david.s.daney@gmail.com>
To: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org,
	a.p.zijlstra@chello.nl, paulus@samba.org, mingo@elte.hu,
	acme@redhat.com, jamie.iles@picochip.com, will.deacon@arm.com
Subject: Re: [PATCH v5 09/12] MIPS/Perf-events: replace pmu names with numeric IDs
Date: Thu, 27 May 2010 16:10:38 -0700	[thread overview]
Message-ID: <4BFEFBEE.7050108@gmail.com> (raw)
In-Reply-To: <1274965420-5091-10-git-send-email-dengcheng.zhu@gmail.com>

On 05/27/2010 06:03 AM, Deng-Cheng Zhu wrote:
> Using Perf-events as the backend, clients such as Oprofile will need to
> enquire the pmu names. A convenient way to do this is to use pmu id to
> index the exported name array. And this is what we are doing here.
>
> NOTE: While using scripts/checkpatch.pl to check this patch, a style
> warning is reported. I suppose it is a false positive, and will report to
> the maintainer. The message is:
> =======================================
> WARNING:
> EXPORT_SYMBOL(foo); should immediately follow its function/variable
> #81: FILE: arch/mips/kernel/perf_event.c:112:
> +EXPORT_SYMBOL_GPL(mips_pmu_names);
> =======================================

I don't like this one.

In cpu-probe.c we used to have this same type of parallel name array, 
and it was messy.

You know what type of cpu you are running on, so I don't understand the 
advantage of querying by name.  What possible use could there be to 
knowing the names of processors that are not applicable to the current 
runtime?

David Daney



>
> Signed-off-by: Deng-Cheng Zhu<dengcheng.zhu@gmail.com>
> ---
>   arch/mips/include/asm/pmu.h          |   26 ++++++++++++++++++++++++++
>   arch/mips/kernel/perf_event.c        |   31 ++++++++++++++++++++++++++++++-
>   arch/mips/kernel/perf_event_mipsxx.c |   12 +++++++-----
>   3 files changed, 63 insertions(+), 6 deletions(-)
>
> diff --git a/arch/mips/include/asm/pmu.h b/arch/mips/include/asm/pmu.h
> index 2822810..16d4fcd 100644
> --- a/arch/mips/include/asm/pmu.h
> +++ b/arch/mips/include/asm/pmu.h
> @@ -89,4 +89,30 @@ extern unsigned int rm9000_perfcount_irq;
>
>   #endif /* CONFIG_CPU_* */
>
> +/* MIPS PMU IDs for use by internal perf clients. */
> +enum mips_pmu_id {
> +	/* mipsxx */
> +	MIPS_PMU_ID_20K = 0,
> +	MIPS_PMU_ID_24K,
> +	MIPS_PMU_ID_25K,
> +	MIPS_PMU_ID_1004K,
> +	MIPS_PMU_ID_34K,
> +	MIPS_PMU_ID_74K,
> +	MIPS_PMU_ID_5K,
> +	MIPS_PMU_ID_R10000V2,
> +	MIPS_PMU_ID_R10000,
> +	MIPS_PMU_ID_R12000,
> +	MIPS_PMU_ID_SB1,
> +	/* rm9000 */
> +	MIPS_PMU_ID_RM9000,
> +	/* loongson2 */
> +	MIPS_PMU_ID_LOONGSON2,
> +	/* unsupported */
> +	MIPS_PMU_ID_UNSUPPORTED,
> +};
> +
> +extern const char *mips_pmu_names[];
> +
> +extern enum mips_pmu_id mipspmu_get_pmu_id(void);
> +
>   #endif /* __MIPS_PMU_H__ */
> diff --git a/arch/mips/kernel/perf_event.c b/arch/mips/kernel/perf_event.c
> index 0ef54e6..f05e2b1 100644
> --- a/arch/mips/kernel/perf_event.c
> +++ b/arch/mips/kernel/perf_event.c
> @@ -88,8 +88,31 @@ static DEFINE_MUTEX(raw_event_mutex);
>   #define UNSUPPORTED_PERF_EVENT_ID 0xffffffff
>   #define C(x) PERF_COUNT_HW_CACHE_##x
>
> +/* MIPS PMU names */
> +const char *mips_pmu_names[] = {
> +	/* mipsxx */
> +	[MIPS_PMU_ID_20K]		= "mips/20K",
> +	[MIPS_PMU_ID_24K]		= "mips/24K",
> +	[MIPS_PMU_ID_25K]		= "mips/25K",
> +	[MIPS_PMU_ID_1004K]		= "mips/1004K",
> +	[MIPS_PMU_ID_34K]		= "mips/34K",
> +	[MIPS_PMU_ID_74K]		= "mips/74K",
> +	[MIPS_PMU_ID_5K]		= "mips/5K",
> +	[MIPS_PMU_ID_R10000V2]		= "mips/r10000-v2.x",
> +	[MIPS_PMU_ID_R10000]		= "mips/r10000",
> +	[MIPS_PMU_ID_R12000]		= "mips/r12000",
> +	[MIPS_PMU_ID_SB1]		= "mips/sb1",
> +	/* rm9000 */
> +	[MIPS_PMU_ID_RM9000]		= "mips/rm9000",
> +	/* loongson2 */
> +	[MIPS_PMU_ID_LOONGSON2]		= "mips/loongson2",
> +	/* unsupported */
> +	[MIPS_PMU_ID_UNSUPPORTED]	= NULL,
> +};
> +EXPORT_SYMBOL_GPL(mips_pmu_names);
> +
>   struct mips_pmu {
> -	const char	*name;
> +	enum mips_pmu_id id;
>   	irqreturn_t	(*handle_irq)(int irq, void *dev);
>   	int		(*handle_shared_irq)(void);
>   	void		(*start)(void);
> @@ -111,6 +134,12 @@ struct mips_pmu {
>
>   static const struct mips_pmu *mipspmu;
>
> +enum mips_pmu_id mipspmu_get_pmu_id(void)
> +{
> +	return mipspmu ? mipspmu->id : MIPS_PMU_ID_UNSUPPORTED;
> +}
> +EXPORT_SYMBOL_GPL(mipspmu_get_pmu_id);
> +
>   static int
>   mipspmu_event_set_period(struct perf_event *event,
>   			struct hw_perf_event *hwc,
> diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
> index 1c92917..4e37a3a 100644
> --- a/arch/mips/kernel/perf_event_mipsxx.c
> +++ b/arch/mips/kernel/perf_event_mipsxx.c
> @@ -962,22 +962,22 @@ init_hw_perf_events(void)
>
>   	switch (current_cpu_type()) {
>   	case CPU_24K:
> -		mipsxxcore_pmu.name = "mips/24K";
> +		mipsxxcore_pmu.id = MIPS_PMU_ID_24K;
>   		mipsxxcore_pmu.num_counters = counters;
>   		mipspmu =&mipsxxcore_pmu;
>   		break;
>   	case CPU_34K:
> -		mipsxxcore_pmu.name = "mips/34K";
> +		mipsxxcore_pmu.id = MIPS_PMU_ID_34K;
>   		mipsxxcore_pmu.num_counters = counters;
>   		mipspmu =&mipsxxcore_pmu;
>   		break;
>   	case CPU_74K:
> -		mipsxx74Kcore_pmu.name = "mips/74K";
> +		mipsxx74Kcore_pmu.id = MIPS_PMU_ID_74K;
>   		mipsxx74Kcore_pmu.num_counters = counters;
>   		mipspmu =&mipsxx74Kcore_pmu;
>   		break;
>   	case CPU_1004K:
> -		mipsxxcore_pmu.name = "mips/1004K";
> +		mipsxxcore_pmu.id = MIPS_PMU_ID_1004K;
>   		mipsxxcore_pmu.num_counters = counters;
>   		mipspmu =&mipsxxcore_pmu;
>   		break;
> @@ -989,7 +989,9 @@ init_hw_perf_events(void)
>
>   	if (mipspmu)
>   		pr_cont("%s PMU enabled, %d counters available to each "
> -			"CPU\n", mipspmu->name, mipspmu->num_counters);
> +			"CPU\n",
> +			mips_pmu_names[mipspmu->id],
> +			mipspmu->num_counters);
>
>   	return 0;
>   }

  reply	other threads:[~2010-05-27 23:10 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 13:03 [PATCH v5 00/12] MIPS performance event support v5 Deng-Cheng Zhu
2010-05-27 13:03 ` [PATCH v5 01/12] MIPS/Oprofile: extract PMU defines/helper functions for sharing Deng-Cheng Zhu
2010-05-27 21:48   ` David Daney
2010-05-29  3:06     ` Deng-Cheng Zhu
2010-05-29  3:06       ` Deng-Cheng Zhu
2010-05-29 18:20       ` David Daney
2010-05-27 13:03 ` [PATCH v5 02/12] MIPS: use generic atomic64 in non-64bit kernels Deng-Cheng Zhu
2010-05-27 21:55   ` David Daney
2010-05-27 13:03 ` [PATCH v5 03/12] MIPS: add support for software performance events Deng-Cheng Zhu
2010-05-27 22:15   ` David Daney
2010-05-27 13:03 ` [PATCH v5 04/12] MIPS: add support for hardware performance events (skeleton) Deng-Cheng Zhu
2010-05-27 22:33   ` David Daney
2010-05-29  3:08     ` Deng-Cheng Zhu
2010-05-29  3:08       ` Deng-Cheng Zhu
2010-05-27 13:03 ` [PATCH v5 05/12] MIPS/Perf-events: add callchain support Deng-Cheng Zhu
2010-05-27 22:39   ` David Daney
2010-05-27 13:03 ` [PATCH v5 06/12] MIPS: add support for hardware performance events (mipsxx) Deng-Cheng Zhu
2010-05-27 22:44   ` David Daney
2010-05-29  3:10     ` Deng-Cheng Zhu
2010-05-29  3:10       ` Deng-Cheng Zhu
2010-05-29 18:13       ` David Daney
2010-05-27 13:03 ` [PATCH v5 07/12] MIPS/Perf-events: add raw event support for mipsxx 24K/34K/74K/1004K Deng-Cheng Zhu
2010-05-27 22:48   ` David Daney
2010-05-29  3:10     ` Deng-Cheng Zhu
2010-05-29  3:10       ` Deng-Cheng Zhu
2010-05-27 13:03 ` [PATCH v5 08/12] MIPS: move mipsxx pmu helper functions to Perf-events Deng-Cheng Zhu
2010-05-27 22:52   ` David Daney
2010-05-29  3:12     ` Deng-Cheng Zhu
2010-05-29  3:12       ` Deng-Cheng Zhu
2010-05-27 13:03 ` [PATCH v5 09/12] MIPS/Perf-events: replace pmu names with numeric IDs Deng-Cheng Zhu
2010-05-27 23:10   ` David Daney [this message]
2010-05-29  3:13     ` Deng-Cheng Zhu
2010-05-29  3:13       ` Deng-Cheng Zhu
2010-05-27 13:03 ` [PATCH v5 10/12] MIPS/Perf-events: allow modules to get pmu number of counters Deng-Cheng Zhu
2010-05-27 23:16   ` David Daney
2010-05-29  3:14     ` Deng-Cheng Zhu
2010-05-29  3:14       ` Deng-Cheng Zhu
2010-05-27 13:03 ` [PATCH v5 11/12] MIPS/Oprofile: use Perf-events framework as backend Deng-Cheng Zhu
2010-05-27 23:24   ` David Daney
2010-05-29  3:15     ` Deng-Cheng Zhu
2010-05-29  3:15       ` Deng-Cheng Zhu
2010-05-27 13:03 ` [PATCH v5 12/12] MIPS/Oprofile: remove old files and update Kconfig/Makefile Deng-Cheng Zhu
2010-05-27 23:26   ` David Daney
2010-05-29  3:18     ` Deng-Cheng Zhu
2010-05-29  3:18       ` Deng-Cheng Zhu
2010-05-27 13:15 ` [PATCH v5 00/12] MIPS performance event support v5 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=4BFEFBEE.7050108@gmail.com \
    --to=david.s.daney@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dengcheng.zhu@gmail.com \
    --cc=jamie.iles@picochip.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 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.