From: Peter Zijlstra <peterz@infradead.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: paulus <paulus@samba.org>,
stephane eranian <eranian@googlemail.com>,
Robert Richter <robert.richter@amd.com>,
Will Deacon <will.deacon@arm.com>,
Paul Mundt <lethal@linux-sh.org>,
Cyrill Gorcunov <gorcunov@gmail.com>,
Lin Ming <ming.m.lin@intel.com>,
Yanmin <yanmin_zhang@linux.intel.com>,
Deng-Cheng Zhu <dengcheng.zhu@gmail.com>,
David Miller <davem@davemloft.net>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 05/11] perf: register pmu implementations
Date: Mon, 28 Jun 2010 17:16:37 +0200 [thread overview]
Message-ID: <1277738197.3561.132.camel@laptop> (raw)
In-Reply-To: <20100628132101.GB5668@nowhere>
On Mon, 2010-06-28 at 15:21 +0200, Frederic Weisbecker wrote:
> On Thu, Jun 24, 2010 at 04:28:09PM +0200, Peter Zijlstra wrote:
> > + if (bp->attr.type != PERF_TYPE_BREAKPOINT)
> > + return -ENOENT;
> > +
> > + err = register_perf_hw_breakpoint(bp);
> > + if (err)
> > + return err;
> > +
> > + bp->destroy = bp_perf_event_destroy;
> Seems it would make sense to also have destroy in the pmu, it's the same
> along every events in the same class right?
>
> But this can be for later.
Ah, indeed.
> > +static LIST_HEAD(pmus);
> > +static DEFINE_MUTEX(pmus_lock);
> > +static struct srcu_struct pmus_srcu;
> > +
> > +int perf_pmu_register(struct pmu *pmu)
> > +{
> > + mutex_lock(&pmus_lock);
> > + list_add_rcu(&pmu->entry, &pmus);
> > + mutex_unlock(&pmus_lock);
> > +
> > + return 0;
> > +}
> > +
> > +void perf_pmu_unregister(struct pmu *pmu)
> > +{
> > + mutex_lock(&pmus_lock);
> > + list_del_rcu(&pmu->entry);
> > + mutex_unlock(&pmus_lock);
> >
> > - atomic_inc(&perf_swevent_enabled[event_id]);
> > - event->destroy = sw_perf_event_destroy;
> > + synchronize_srcu(&pmus_srcu);
> > +}
> > +
> > +struct pmu *perf_init_event(struct perf_event *event)
> > +{
> > + struct pmu *pmu = NULL;
> > + int idx;
> > +
> > + idx = srcu_read_lock(&pmus_srcu);
> > + list_for_each_entry_rcu(pmu, &pmus, entry) {
> > + int ret = pmu->event_init(event);
> > + if (!ret)
> > + break;
> > + if (ret != -ENOENT) {
> > + pmu = ERR_PTR(ret);
> > + break;
> > }
> > - pmu = &perf_ops_generic;
> > - break;
> > }
> > + srcu_read_unlock(&pmus_srcu, idx);
> >
> > return pmu;
> > }
>
>
>
> I'm still not sure why all this locking is needed. We don't even
> support pmus in modules.
>
> Is there something coming soon that will use this?
> I remember something about KVM.
Possibly, not sure. We could put the unregister thing in a later patch,
but I wanted to make sure it was sanely possibly and its only a few
lines of code.
> And who will have to use srcu? It seems the event fastpath would
> be concerned, right? Will that have an impact on the performances?
Only event creation like above (perf_init_event) will have to use SRCU,
so not really a hot path.
> > @@ -5743,15 +5742,15 @@ perf_cpu_notify(struct notifier_block *s
> > {
> > unsigned int cpu = (long)hcpu;
> >
> > - switch (action) {
> > + switch (action & ~CPU_TASKS_FROZEN) {
> >
> > case CPU_UP_PREPARE:
> > - case CPU_UP_PREPARE_FROZEN:
> > + case CPU_DOWN_FAILED:
> > perf_event_init_cpu(cpu);
> > break;
> >
> > + case CPU_UP_CANCELED:
> > case CPU_DOWN_PREPARE:
> > - case CPU_DOWN_PREPARE_FROZEN:
> > perf_event_exit_cpu(cpu);
> > break;
>
>
>
> That doesn't seem to be related to this patch initial topic.
Ah indeed, that needs to go live in its own patch.
next prev parent reply other threads:[~2010-06-28 15:16 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-24 14:28 [RFC][PATCH 00/11] perf pmu interface -v2 Peter Zijlstra
2010-06-24 14:28 ` [PATCH 01/11] perf, x86: Fix Nehalem PMU quirk Peter Zijlstra
2010-06-24 14:28 ` [PATCH 02/11] perf: Fix argument of perf_arch_fetch_caller_regs Peter Zijlstra
2010-06-24 14:28 ` [PATCH 03/11] perf, sparc64: Fix maybe_change_configuration() PCR setting Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 04/11] perf: deconstify struct pmu Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 05/11] perf: register pmu implementations Peter Zijlstra
2010-06-28 13:21 ` Frederic Weisbecker
2010-06-28 15:16 ` Peter Zijlstra [this message]
2010-06-28 15:29 ` Frederic Weisbecker
2010-07-09 3:08 ` Paul Mackerras
2010-07-09 8:14 ` Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 06/11] perf: Unindent labels Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 07/11] perf: Reduce perf_disable() usage Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 08/11] perf: Per PMU disable Peter Zijlstra
2010-07-09 7:31 ` Paul Mackerras
2010-07-09 8:36 ` Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 09/11] perf: Default PMU ops Peter Zijlstra
2010-06-29 14:49 ` Frederic Weisbecker
2010-06-29 14:57 ` Peter Zijlstra
2010-06-29 15:00 ` Frederic Weisbecker
2010-06-29 14:58 ` Frederic Weisbecker
2010-06-29 14:59 ` Peter Zijlstra
2010-06-29 15:03 ` Frederic Weisbecker
2010-06-29 16:34 ` Peter Zijlstra
2010-06-29 18:07 ` Frederic Weisbecker
2010-06-29 18:09 ` Peter Zijlstra
2010-06-29 18:11 ` Frederic Weisbecker
2010-06-29 18:19 ` Peter Zijlstra
2010-06-29 18:21 ` Frederic Weisbecker
2010-06-24 14:28 ` [RFC][PATCH 10/11] perf: Shrink hw_perf_event Peter Zijlstra
2010-06-29 15:06 ` Frederic Weisbecker
2010-06-24 14:28 ` [RFC][PATCH 11/11] perf: Rework the PMU methods Peter Zijlstra
2010-06-29 15:37 ` Frederic Weisbecker
2010-06-29 16:40 ` Peter Zijlstra
2010-06-29 18:09 ` Frederic Weisbecker
2010-06-25 11:11 ` [RFC][PATCH 00/11] perf pmu interface -v2 Will Deacon
2010-06-25 11:16 ` Peter Zijlstra
2010-06-25 14:36 ` Will Deacon
2010-06-25 14:50 ` Peter Zijlstra
2010-07-01 14:36 ` Peter Zijlstra
2010-07-01 15:02 ` Peter Zijlstra
2010-07-01 15:31 ` MattFleming
2010-07-01 15:39 ` Peter Zijlstra
2010-07-01 16:04 ` Matt Fleming
2010-07-02 2:57 ` Paul Mundt
2010-07-02 9:52 ` Peter Zijlstra
2010-07-05 11:14 ` Paul Mundt
2010-07-08 11:13 ` Peter Zijlstra
2010-07-08 11:19 ` Ingo Molnar
2010-07-18 19:37 ` Matt Fleming
2010-07-02 12:55 ` Will Deacon
2010-06-26 11:22 ` Matt Fleming
2010-06-26 16:22 ` Corey Ashford
2010-06-28 15:13 ` Peter Zijlstra
2010-06-30 17:19 ` Corey Ashford
2010-06-30 18:11 ` Peter Zijlstra
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=1277738197.3561.132.camel@laptop \
--to=peterz@infradead.org \
--cc=davem@davemloft.net \
--cc=dengcheng.zhu@gmail.com \
--cc=eranian@googlemail.com \
--cc=fweisbec@gmail.com \
--cc=gorcunov@gmail.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.m.lin@intel.com \
--cc=paulus@samba.org \
--cc=robert.richter@amd.com \
--cc=will.deacon@arm.com \
--cc=yanmin_zhang@linux.intel.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
Powered by JetHome