From: m.nazarewicz@samsung.com (Michał Nazarewicz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] arm: provide a mechanism to reserve performance counters
Date: Wed, 06 Jan 2010 13:00:56 +0100 [thread overview]
Message-ID: <op.u530zufm7p4s8u@localhost> (raw)
In-Reply-To: <1262602122-10373-2-git-send-email-jamie.iles@picochip.com>
On Mon, 04 Jan 2010 11:48:38 +0100, Jamie Iles <jamie.iles@picochip.com> wrote:
> To add support for perf events and to allow the hardware
> counters to be shared with oprofile, we need a way to reserve
> access to the pmu (performance monitor unit).
>
> Cc: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Jamie Iles <jamie.iles@picochip.com>
> diff --git a/arch/arm/include/asm/pmu.h b/arch/arm/include/asm/pmu.h
> new file mode 100644
> index 0000000..5840d2d
> --- /dev/null
> +++ b/arch/arm/include/asm/pmu.h
> @@ -0,0 +1,74 @@
[...]
> +#ifndef __ARM_PMU_H__
> +#define __ARM_PMU_H__
> +
> +#ifdef CONFIG_CPU_HAS_PMU
[...]
> +#else /* CONFIG_CPU_HAS_PMU */
> +
> +static inline const struct pmu_irqs *
> +reserve_pmu(void)
> +{
> + ERR_PTR(-ENODEV);
- ERR_PTR(-ENODEV);
+ return ERR_PTR(-ENODEV);
> +}
> +
> +static inline int
> +release_pmu(const struct pmu_irqs *irqs)
> +{
+ return -ENODEV;
> +}
> +
> +static inline int
> +init_pmu(void)
> +{
> + return -ENODEV;
> +}
> +
> +#endif /* CONFIG_CPU_HAS_PMU */
> +
> +#endif /* __ARM_PMU_H__ */
> diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c
> new file mode 100644
> index 0000000..a8c015d
> --- /dev/null
> +++ b/arch/arm/kernel/pmu.c
> @@ -0,0 +1,107 @@
[...]
> +static const int irqs[] = {
[...]
> +};
> +
> +static const struct pmu_irqs pmu_irqs = {
> + .irqs = irqs,
> + .num_irqs = ARRAY_SIZE(irqs),
> +};
> +
> +static DECLARE_MUTEX(pmu_mutex);
Isn't mutex an overkill? A bit field would be enough:
-static DECLARE_MUTEX(pmu_mutex);
+static volatile long pmu_mutex;
> +
> +const struct pmu_irqs *
> +reserve_pmu(void)
> +{
> + int ret = down_trylock(&pmu_mutex) ? -EBUSY : 0;
> +
> + return ret ? ERR_PTR(ret) : &pmu_irqs;
- int ret = down_trylock(&pmu_mutex) ? -EBUSY : 0;
-
- return ret ? ERR_PTR(ret) : &pmu_irqs;
+ return test_and_set_bit_lock(0, &pmu_mutex) ? ERR_PTR(-EBUSY) : &pmm_irqs;
> +}
> +EXPORT_SYMBOL_GPL(reserve_pmu);
> +
> +int
> +release_pmu(const struct pmu_irqs *irqs)
> +{
> + if (WARN_ON(irqs != &pmu_irqs))
> + return -EINVAL;
> + up(&pmu_mutex);
- up(&pmu_mutex);
+ clear_bit_unlock(&pmm_mutex);
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(release_pmu);
[...]
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Micha? "mina86" Nazarewicz (o o)
ooo +---<mina86@mina86.com>---<mina86@jabber.org>---ooO--(_)--Ooo--
next prev parent reply other threads:[~2010-01-06 12:00 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-04 10:48 ARM perf events support v4 Jamie Iles
2010-01-04 10:48 ` [PATCH 1/5] arm: provide a mechanism to reserve performance counters Jamie Iles
2010-01-04 10:48 ` [PATCH 2/5] arm/oprofile: reserve the PMU when starting Jamie Iles
2010-01-04 10:48 ` [PATCH 3/5] arm: use the spinlocked, generic atomic64 support Jamie Iles
2010-01-04 10:48 ` [PATCH 4/5] arm: enable support for software perf events Jamie Iles
2010-01-04 10:48 ` [PATCH 5/5] arm/perfevents: implement perf event support for ARMv6 Jamie Iles
2010-01-04 11:17 ` Russell King - ARM Linux
2010-01-04 11:46 ` Jamie Iles
2010-01-05 18:07 ` Will Deacon
2010-01-05 18:23 ` Jean Pihet
2010-01-05 22:26 ` Jamie Iles
2010-01-05 22:31 ` Russell King - ARM Linux
2010-01-06 0:18 ` Jamie Iles
2010-01-06 12:09 ` Will Deacon
2010-01-06 12:14 ` Jamie Iles
2010-01-04 11:11 ` [PATCH 4/5] arm: enable support for software perf events Russell King - ARM Linux
2010-01-04 12:26 ` Jamie Iles
2010-01-04 12:32 ` Russell King - ARM Linux
2010-01-05 18:57 ` [PATCH 3/5] arm: use the spinlocked, generic atomic64 support Jamie Lokier
2010-01-05 19:08 ` Jamie Iles
2010-01-06 12:00 ` Michał Nazarewicz [this message]
2010-01-06 12:15 ` [PATCH 1/5] arm: provide a mechanism to reserve performance counters Jamie Iles
-- strict thread matches above, loose matches on Subject: below --
2010-01-14 12:14 ARM perf events support v5 Jamie Iles
2010-01-14 12:14 ` [PATCH 1/5] arm: provide a mechanism to reserve performance counters Jamie Iles
2010-01-21 9:30 ` Jamie Iles
2009-12-15 11:15 ARMv6 performance counters v3 Jamie Iles
2009-12-15 11:15 ` [PATCH 1/5] arm: provide a mechanism to reserve performance counters Jamie Iles
2009-12-15 14:13 ` Will Deacon
2009-12-15 14:36 ` Jamie Iles
2009-12-15 17:06 ` Will Deacon
2009-12-17 16:14 ` Will Deacon
2009-12-17 16:27 ` Jamie Iles
2009-12-14 14:04 ARMv6 performance counters v2 Jamie Iles
2009-12-14 14:04 ` [PATCH 1/5] arm: provide a mechanism to reserve performance counters Jamie Iles
2009-12-14 14:39 ` Will Deacon
2009-12-14 15:03 ` Jamie Iles
2009-12-14 16:01 ` Jean Pihet
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=op.u530zufm7p4s8u@localhost \
--to=m.nazarewicz@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).