From: Lin Ming <ming.m.lin@intel.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
"eranian@gmail.com" <eranian@gmail.com>,
"Gary.Mohr@Bull.com" <Gary.Mohr@bull.com>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
"arjan@linux.intel.com" <arjan@linux.intel.com>,
"Zhang, Yanmin" <yanmin_zhang@linux.intel.com>,
Paul Mackerras <paulus@samba.org>,
"David S. Miller" <davem@davemloft.net>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Paul Mundt <lethal@linux-sh.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH 2/9] perf: core, remove hw_perf_event_init
Date: Wed, 12 May 2010 10:11:12 +0800 [thread overview]
Message-ID: <1273630272.30322.98.camel@minggr.sh.intel.com> (raw)
In-Reply-To: <20100510122443.GA5563@nowhere>
On Mon, 2010-05-10 at 20:24 +0800, Frederic Weisbecker wrote:
> On Mon, May 10, 2010 at 05:26:35PM +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
> >
> > Signed-off-by: Lin Ming <ming.m.lin@intel.com>
> > ---
> > include/linux/perf_event.h | 9 +++++++++
> > kernel/perf_event.c | 39 +++++++++++++++++++++++++++++++--------
> > 2 files changed, 40 insertions(+), 8 deletions(-)
> >
> > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> > index 5856d3b..6246c99 100644
> > --- a/include/linux/perf_event.h
> > +++ b/include/linux/perf_event.h
> > @@ -225,6 +225,8 @@ struct perf_event_attr {
> > __u32 bp_type;
> > __u64 bp_addr;
> > __u64 bp_len;
> > +
> > + int pmu_id;
> > };
> >
> > /*
> > @@ -553,6 +555,9 @@ struct perf_event;
> > * struct pmu - generic performance monitoring unit
> > */
> > struct pmu {
> > + int id;
> > + struct list_head entry;
> > +
> > int (*enable) (struct perf_event *event);
> > void (*disable) (struct perf_event *event);
> > int (*start) (struct perf_event *event);
> > @@ -569,6 +574,8 @@ struct pmu {
> > void (*start_txn) (struct pmu *pmu);
> > void (*cancel_txn) (struct pmu *pmu);
> > int (*commit_txn) (struct pmu *pmu);
> > +
> > + int (*init_event) (struct perf_event *event);
> > };
> >
> > /**
> > @@ -1014,6 +1021,8 @@ extern int perf_swevent_get_recursion_context(void);
> > extern void perf_swevent_put_recursion_context(int rctx);
> > extern void perf_event_enable(struct perf_event *event);
> > extern void perf_event_disable(struct perf_event *event);
> > +
> > +extern void perf_event_register_pmu(struct pmu *pmu);
> > #else
> > static inline void
> > perf_event_task_sched_in(struct task_struct *task) { }
> > diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> > index 36baf85..f19d40e 100644
> > --- a/kernel/perf_event.c
> > +++ b/kernel/perf_event.c
> > @@ -40,6 +40,12 @@
> > */
> > static DEFINE_PER_CPU(struct perf_cpu_context, perf_cpu_context);
> >
> > +/*
> > + * The list of multiple hw pmus
> > + */
> > +static struct list_head pmus;
> > +static int pmu_id_curr;
> > +
> > int perf_max_events __read_mostly = 1;
> > static int perf_reserved_percpu __read_mostly;
> > static int perf_overcommit __read_mostly = 1;
> > @@ -75,11 +81,6 @@ static DEFINE_SPINLOCK(perf_resource_lock);
> > /*
> > * Architecture provided APIs - weak aliases:
> > */
> > -extern __weak struct pmu *hw_perf_event_init(struct perf_event *event)
> > -{
> > - return NULL;
> > -}
> > -
> > void __weak hw_perf_disable(void) { barrier(); }
> > void __weak hw_perf_enable(void) { barrier(); }
> >
> > @@ -4670,6 +4671,19 @@ static struct pmu *sw_perf_event_init(struct perf_event *event)
> > return pmu;
> > }
> >
> > +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;
> > +}
> > +
> > /*
> > * Allocate and initialize a event structure
> > */
> > @@ -4685,7 +4699,7 @@ perf_event_alloc(struct perf_event_attr *attr,
> > struct pmu *pmu;
> > struct perf_event *event;
> > struct hw_perf_event *hwc;
> > - long err;
> > + long err = 0;
> >
> > event = kzalloc(sizeof(*event), gfpflags);
> > if (!event)
> > @@ -4750,7 +4764,9 @@ perf_event_alloc(struct perf_event_attr *attr,
> > case PERF_TYPE_RAW:
> > case PERF_TYPE_HARDWARE:
> > case PERF_TYPE_HW_CACHE:
> > - pmu = hw_perf_event_init(event);
> > + pmu = perf_event_lookup_pmu(event);
> > + if (pmu && pmu->init_event)
> > + err = pmu->init_event(event);
>
>
>
> Having the same for software, tracepoints and breakpoints events would
> be nice, so that we have a single simple path in perf_event_alloc
> to initialize the event.
Will add this later.
For now, let's first work on the hw pmus.
>
> Thanks.
>
prev parent reply other threads:[~2010-05-12 2:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 9:26 [RFC][PATCH 2/9] perf: core, remove hw_perf_event_init Lin Ming
2010-05-10 9:40 ` Peter Zijlstra
2010-05-10 10:17 ` Lin Ming
2010-05-10 10:19 ` Peter Zijlstra
2010-05-10 10:22 ` Lin Ming
2010-05-10 12:27 ` Frederic Weisbecker
2010-05-10 12:54 ` Peter Zijlstra
2010-05-10 23:09 ` Frederic Weisbecker
2010-05-11 6:38 ` Peter Zijlstra
2010-05-11 6:44 ` Lin Ming
2010-05-11 6:51 ` Ingo Molnar
2010-05-11 7:00 ` Lin Ming
2010-05-11 9:18 ` Peter Zijlstra
2010-05-11 6:50 ` Frederic Weisbecker
2010-05-10 9:42 ` Peter Zijlstra
2010-05-10 10:15 ` Lin Ming
2010-05-10 12:24 ` Frederic Weisbecker
2010-05-12 2:11 ` Lin Ming [this message]
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=1273630272.30322.98.camel@minggr.sh.intel.com \
--to=ming.m.lin@intel.com \
--cc=Gary.Mohr@bull.com \
--cc=arjan@linux.intel.com \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=davem@davemloft.net \
--cc=eranian@gmail.com \
--cc=fweisbec@gmail.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=rmk+kernel@arm.linux.org.uk \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.