[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1276710480.1745.608.camel@laptop>
Date: Wed, 16 Jun 2010 19:48:00 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Frederic Weisbecker <fweisbec@...il.com>
Cc: paulus <paulus@...ba.org>,
stephane eranian <eranian@...glemail.com>,
Robert Richter <robert.richter@....com>,
Will Deacon <will.deacon@....com>,
Paul Mundt <lethal@...ux-sh.org>,
Cyrill Gorcunov <gorcunov@...il.com>,
Lin Ming <ming.m.lin@...el.com>,
Yanmin <yanmin_zhang@...ux.intel.com>,
Deng-Cheng Zhu <dengcheng.zhu@...il.com>,
David Miller <davem@...emloft.net>,
linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH 3/8] perf: register pmu implementations
On Wed, 2010-06-16 at 19:03 +0200, Frederic Weisbecker wrote:
> > +static struct pmu perf_breakpoint = {
> > + .event_init = hw_breakpoint_event_init,
>
>
>
> Should be bp_perf_event_init?
Ah, yes, like said, the compiler didn't get near yet..
>
> > + .enable = arch_install_hw_breakpoint,
> > + .disable = arch_uninstall_hw_breakpoint,
> > + .read = hw_breakpoint_pmu_read,
> > +};
> <snip>
> > +static int perf_swevent_int(struct perf_event *event)
> > +{
> > + if (event->attr.type != PERF_TYPE_SOFTWARE)
> > + return -ENOENT
>
>
> perf_swevent_init() ?
copy/paste gone wild..
> > +void perf_pmu_unregister(struct pmu *pmu)
> > +{
> > + spin_lock(&pmus_lock);
> > + list_del_rcu(&pmu->entry);
> > + spin_unlock(&pmus_lock);
> > +
> > + synchronize_srcu(&pmus_srcu);
> > +}
> Who needs this?
Nobody yet..
> > +
> > +struct pmu *perf_init_event(struct perf_event *event)
> > +{
> > + struct pmu *pmu;
> > + 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);
>
>
>
> This could use a simple mutex instead of a spinlock + srcu_sync on
> writer and srcu on reader.
Right, that spinlock needs to be a mutex for sure, a later patch adds an
allocation under it.
But even with a mutex we need srcu_sync in there to sync against the
readers.
> That doesn't matter much that said. What I don't understand is
> why we need to synchronize the writers. Walking the list with
> list_*_rcu() looks justified once we support boot events, but
> until then...
Well, the typical unregister user would be a module, if you unregister
and then dealloc the struct pmu by unloading the module a reader might
still see a reference to it if you don't srcu_sync it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists