Re: [PATCH v2 4/5] perf: Define PMU_TXN_READ interface

From: Sukadev Bhattiprolu
Date: Thu Apr 16 2015 - 13:28:08 EST


Peter Zijlstra [peterz@xxxxxxxxxxxxx] wrote:
| On Tue, Apr 07, 2015 at 05:34:58PM -0700, Sukadev Bhattiprolu wrote:
| > diff --git a/kernel/events/core.c b/kernel/events/core.c
| > index 1ac99d1..a001582 100644
| > --- a/kernel/events/core.c
| > +++ b/kernel/events/core.c
| > @@ -3644,6 +3644,33 @@ static void orphans_remove_work(struct work_struct *work)
| > put_ctx(ctx);
| > }
| >
| > +/*
| > + * Use the transaction interface to read the group of events in @leader.
| > + * PMUs like the 24x7 counters in Power, can use this to queue the events
| > + * in the ->read() operation and perform the actual read in ->commit_txn.
| > + *
| > + * Other PMUs can ignore the ->start_txn and ->commit_txn and read each
| > + * PMU directly in the ->read() operation.
| > + */
| > +static int perf_event_read_txn(struct perf_event *leader)
|
| perf_event_read_group() might be a better name. Ah, I see that's already
| taken. Bugger.
|
| See the below patch.

Sure, will include your patch in the next version and use
perf_event_read_group().

|
| > +{
| > + int ret;
| > + struct perf_event *sub;
| > + struct pmu *pmu;
| > +
| > + pmu = leader->pmu;
| > +
| > + pmu->start_txn(pmu, PERF_PMU_TXN_READ);
| > +
| > + perf_event_read(leader);
| > + list_for_each_entry(sub, &leader->sibling_list, group_entry)
| > + perf_event_read(sub);
| > +
| > + ret = pmu->commit_txn(pmu, PERF_PMU_TXN_READ);
| > +
| > + return ret;
| > +}
|
| And while were here, should we change the NOP txn implementation to not
| call perf_pmu_disable for TXN_READ ?
|
| That seems entirely unneeded in this case.

Yes. Should we use a per-cpu, per-pmu variable to save/check the
transaction type like this? (I am using the cpuhw->group_flag in
x86, Power and other PMUs)