From: Peter Zijlstra on
On Mon, 2010-05-10 at 17:26 +0800, Lin Ming wrote:
> A new field "pmu_id" is added to struct perf_event_attr.
>
> 2 new functions: perf_event_register_pmu, perf_event_lookup_pmu
> perf_event_register_pmu: the pmu registration facility
> perf_event_lookup_pmu: lookup the pmu via the passed in event->attr.pmu_id.
>
> A new api pmu->init_event to replace hw_perf_event_init

Another problem, this patch breaks all of perf by removing the weak call
before there is a replacement.

Please rework such that there is a smooth transition.

Also, for compatibilities sake, the cpu pmu will be required to get
pmu_id==0, this doesn't provide that.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Peter Zijlstra on
On Mon, 2010-05-10 at 17:26 +0800, Lin Ming wrote:
> +static struct pmu *perf_event_lookup_pmu(struct perf_event *event)
> +{
> + struct pmu *pmu;
> + int pmu_id = event->attr.pmu_id;
> +
> + list_for_each_entry(pmu, &pmus, entry) {
> + if (pmu->id == pmu_id)
> + return pmu;
> + }
> +
> + return NULL;
> +}

> +void perf_event_register_pmu(struct pmu *pmu)
> +{
> + pmu->id = pmu_id_curr++;
> + list_add_tail(&pmu->entry, &pmus);
> +}

That will be wanting some sort of synchronization
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Peter Zijlstra on
On Mon, 2010-05-10 at 18:17 +0800, Lin Ming wrote:
> On Mon, 2010-05-10 at 17:40 +0800, Peter Zijlstra wrote:
> > On Mon, 2010-05-10 at 17:26 +0800, Lin Ming wrote:
> > > +static struct pmu *perf_event_lookup_pmu(struct perf_event *event)
> > > +{
> > > + struct pmu *pmu;
> > > + int pmu_id = event->attr.pmu_id;
> > > +
> > > + list_for_each_entry(pmu, &pmus, entry) {
> > > + if (pmu->id == pmu_id)
> > > + return pmu;
> > > + }
> > > +
> > > + return NULL;
> > > +}
> >
> > > +void perf_event_register_pmu(struct pmu *pmu)
> > > +{
> > > + pmu->id = pmu_id_curr++;
> > > + list_add_tail(&pmu->entry, &pmus);
> > > +}
> >
> > That will be wanting some sort of synchronization
>
> Will add a mutex to protect the list of pmus.

I'm thinking RCU might be better suited, a mutex for lookup doesn't
sound ideal.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Lin Ming on
On Mon, 2010-05-10 at 17:40 +0800, Peter Zijlstra wrote:
> On Mon, 2010-05-10 at 17:26 +0800, Lin Ming wrote:
> > +static struct pmu *perf_event_lookup_pmu(struct perf_event *event)
> > +{
> > + struct pmu *pmu;
> > + int pmu_id = event->attr.pmu_id;
> > +
> > + list_for_each_entry(pmu, &pmus, entry) {
> > + if (pmu->id == pmu_id)
> > + return pmu;
> > + }
> > +
> > + return NULL;
> > +}
>
> > +void perf_event_register_pmu(struct pmu *pmu)
> > +{
> > + pmu->id = pmu_id_curr++;
> > + list_add_tail(&pmu->entry, &pmus);
> > +}
>
> That will be wanting some sort of synchronization

Will add a mutex to protect the list of pmus.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Lin Ming on
On Mon, 2010-05-10 at 18:19 +0800, Peter Zijlstra wrote:
> On Mon, 2010-05-10 at 18:17 +0800, Lin Ming wrote:
> > On Mon, 2010-05-10 at 17:40 +0800, Peter Zijlstra wrote:
> > > On Mon, 2010-05-10 at 17:26 +0800, Lin Ming wrote:
> > > > +static struct pmu *perf_event_lookup_pmu(struct perf_event *event)
> > > > +{
> > > > + struct pmu *pmu;
> > > > + int pmu_id = event->attr.pmu_id;
> > > > +
> > > > + list_for_each_entry(pmu, &pmus, entry) {
> > > > + if (pmu->id == pmu_id)
> > > > + return pmu;
> > > > + }
> > > > +
> > > > + return NULL;
> > > > +}
> > >
> > > > +void perf_event_register_pmu(struct pmu *pmu)
> > > > +{
> > > > + pmu->id = pmu_id_curr++;
> > > > + list_add_tail(&pmu->entry, &pmus);
> > > > +}
> > >
> > > That will be wanting some sort of synchronization
> >
> > Will add a mutex to protect the list of pmus.
>
> I'm thinking RCU might be better suited, a mutex for lookup doesn't
> sound ideal.

Thanks for the idea, I'll do that.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/