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 04/12] MIPS: add support for hardware performance events (skeleton)
Date: Thu, 27 May 2010 15:33:11 -0700 [thread overview]
Message-ID: <4BFEF327.2020701@gmail.com> (raw)
In-Reply-To: <1274965420-5091-5-git-send-email-dengcheng.zhu@gmail.com>
On 05/27/2010 06:03 AM, Deng-Cheng Zhu wrote:
> This patch provides the skeleton of the HW perf event support. To enable
> this feature, we can not choose the SMTC kernel; Oprofile should be
> disabled; kernel performance events be selected. Then we can enable it in
> Kernel type menu.
>
> Oprofile for MIPS platforms initializes irq at arch init time. Currently
> we do not change this logic to allow PMU reservation.
>
> If a platform has EIC, we can use the irq base and perf counter irq
> offset defines for the interrupt controller in mipspmu_get_irq().
>
> Based on this skeleton patch, the 3 different kinds of MIPS PMU, namely,
> mipsxx/loongson2/rm9000, can be supported by adding corresponding lower
> level C files at the bottom. The suggested names of these files are
> perf_event_mipsxx.c/perf_event_loongson2.c/perf_event_rm9000.c. So, for
> example, we can do this by adding "#include perf_event_mipsxx.c" at the
> bottom of perf_event.c.
>
> Signed-off-by: Deng-Cheng Zhu<dengcheng.zhu@gmail.com>
> ---
> arch/mips/Kconfig | 8 +
> arch/mips/include/asm/perf_event.h | 28 ++
> arch/mips/kernel/Makefile | 2 +
> arch/mips/kernel/perf_event.c | 503 ++++++++++++++++++++++++++++++++++++
> 4 files changed, 541 insertions(+), 0 deletions(-)
> create mode 100644 arch/mips/include/asm/perf_event.h
> create mode 100644 arch/mips/kernel/perf_event.c
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 1bccfe5..27577b4 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -1888,6 +1888,14 @@ config NODES_SHIFT
> default "6"
> depends on NEED_MULTIPLE_NODES
>
> +config HW_PERF_EVENTS
> + bool "Enable hardware performance counter support for perf events"
> + depends on PERF_EVENTS&& !MIPS_MT_SMTC&& OPROFILE=n&& CPU_MIPS32
This depends on not consistent with the #if conditions in [01/12] for
pmu.h. They should be I think.
Probably removing the tests from pmu.h and encoding them here is better.
> + default y
> + help
> + Enable hardware performance counter support for perf events. If
> + disabled, perf events will use software events only.
> +
> source "mm/Kconfig"
>
> config SMP
> diff --git a/arch/mips/include/asm/perf_event.h b/arch/mips/include/asm/perf_event.h
> new file mode 100644
> index 0000000..bcf54bc
> --- /dev/null
> +++ b/arch/mips/include/asm/perf_event.h
> @@ -0,0 +1,28 @@
> +/*
> + * linux/arch/mips/include/asm/perf_event.h
> + *
> + * Copyright (C) 2010 MIPS Technologies, Inc. Deng-Cheng Zhu
IANAL, but who holds the copyright? You or MTI ?
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#ifndef __MIPS_PERF_EVENT_H__
> +#define __MIPS_PERF_EVENT_H__
> +
> +extern int (*perf_irq)(void);
> +
This shadows the declaration in asm/time.h. Declare it in exactly one
place please.
[...]
> diff --git a/arch/mips/kernel/perf_event.c b/arch/mips/kernel/perf_event.c
> new file mode 100644
> index 0000000..788815f
> --- /dev/null
> +++ b/arch/mips/kernel/perf_event.c
> @@ -0,0 +1,503 @@
> +/*
> + * Linux performance counter support for MIPS.
> + *
> + * Copyright (C) 2010 MIPS Technologies, Inc. Deng-Cheng Zhu
> + *
Same thing about the copyright.
> + * This code is based on the implementation for ARM, which is in turn
> + * based on the sparc64 perf event code and the x86 code. Performance
> + * counter access is based on the MIPS Oprofile code.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include<linux/cpumask.h>
> +#include<linux/interrupt.h>
> +#include<linux/smp.h>
> +#include<linux/kernel.h>
> +#include<linux/perf_event.h>
> +#include<linux/uaccess.h>
> +
> +#include<asm/irq.h>
> +#include<asm/irq_regs.h>
> +#include<asm/stacktrace.h>
> +#include<asm/pmu.h>
> +
> +
> +#define MAX_PERIOD ((1ULL<< 32) - 1)
> +
> +struct cpu_hw_events {
> + /* Array of events on this cpu. */
> + struct perf_event *events[MIPS_MAX_HWEVENTS];
> +
> + /*
> + * Set the bit (indexed by the counter number) when the counter
> + * is used for an event.
> + */
> + unsigned long used_mask[BITS_TO_LONGS(MIPS_MAX_HWEVENTS)];
> +
> + /*
> + * The borrowed MSB for the performance counter. A MIPS performance
> + * counter uses its bit 31 as a factor of determining whether a counter
Not quite true. They use the high bit, that can be either 31 or 63
depending on the width of the counters.
[...]
> +
> +struct mips_pmu {
> + const char *name;
> + irqreturn_t (*handle_irq)(int irq, void *dev);
> + int (*handle_shared_irq)(void);
> + void (*start)(void);
> + void (*stop)(void);
> + int (*alloc_counter)(struct cpu_hw_events *cpuc,
> + struct hw_perf_event *hwc);
> + unsigned int (*read_counter)(unsigned int idx);
> + void (*write_counter)(unsigned int idx, unsigned int val);
Counters can be 64-bits wide, unsigned int is only 32-bits wide.
[...]
David Daney
next prev parent reply other threads:[~2010-05-27 22:33 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 [this message]
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
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=4BFEF327.2020701@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).