From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, paulus@samba.org,
davem@davemloft.net, perfmon2-devel@lists.sf.net,
"Frédéric Weisbecker" <fweisbec@gmail.com>
Subject: Re: [PATCH] perf_events: improve x86 event scheduling
Date: Wed, 13 Jan 2010 17:29:53 +0100 [thread overview]
Message-ID: <1263400193.4244.238.camel@laptop> (raw)
In-Reply-To: <bd4cb8901001130154p732672b6x56e758c1ab33a8e8@mail.gmail.com>
On Wed, 2010-01-13 at 10:54 +0100, Stephane Eranian wrote:
> > One concern I do have is the loss of error checking on
> > event_sched_in()'s event->pmu->enable(), that could be another
> > 'hardware' PMU like breakpoints, in which case it could fail.
> >
> Well, x86_pmu_enable() does return an error code, so it is up
> to the upper layer to handle the error gracefully and in particular
> in perf_ctx_adjust_freq().
> +static void event_sched_in(struct perf_event *event, int cpu)
> +{
> + event->state = PERF_EVENT_STATE_ACTIVE;
> + event->oncpu = cpu;
> + event->tstamp_running += event->ctx->time - event->tstamp_stopped;
> + if (is_software_event(event))
> + event->pmu->enable(event);
> +}
> +
> +/*
> + * Called to enable a whole group of events.
> + * Returns 1 if the group was enabled, or -EAGAIN if it could not be.
> + * Assumes the caller has disabled interrupts and has
> + * frozen the PMU with hw_perf_save_disable.
> + *
> + * called with PMU disabled. If successful and return value 1,
> + * then guaranteed to call perf_enable() and hw_perf_enable()
> + */
> +int hw_perf_group_sched_in(struct perf_event *leader,
> + struct perf_cpu_context *cpuctx,
> + struct perf_event_context *ctx, int cpu)
> +{
> + struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
> + struct perf_event *sub;
> + int assign[X86_PMC_IDX_MAX];
> + int n, n0, ret;
> +
> + n0 = cpuc->n_events;
> +
> + n = collect_events(cpuc, leader, true);
> + if (n < 0)
> + return n;
> +
> + ret = x86_schedule_events(cpuc, n, assign);
> + if (ret)
> + return ret;
> +
> + /*
> + * copy new assignment, now we know it is possible
> + * will be used by hw_perf_enable()
> + */
> + memcpy(cpuc->assign, assign, n*sizeof(int));
> +
> + cpuc->n_events = n;
> + cpuc->n_added = n - n0;
> +
> + n = 1;
> + event_sched_in(leader, cpu);
> + list_for_each_entry(sub, &leader->sibling_list, group_entry) {
> + if (sub->state != PERF_EVENT_STATE_OFF) {
> + event_sched_in(sub, cpu);
> + ++n;
> + }
> + }
> + ctx->nr_active += n;
> +
> + /*
> + * 1 means successful and events are active
> + * This is not quite true because we defer
> + * actual activation until hw_perf_enable() but
> + * this way we* ensure caller won't try to enable
> + * individual events
> + */
> + return 1;
> +}
That most certainly looses error codes for all !is_x86_event() events in
the group.
So you either need to deal with that event_sched_in() failing, or
guarantee that it always succeeds (forcing software events only for
example).
next prev parent reply other threads:[~2010-01-13 16:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-12 10:50 [PATCH] perf_events: improve x86 event scheduling Stephane Eranian
2010-01-12 16:10 ` Peter Zijlstra
2010-01-13 9:54 ` Stephane Eranian
2010-01-13 16:29 ` Peter Zijlstra [this message]
2010-01-13 16:52 ` Stephane Eranian
2010-01-13 17:22 ` Stephane Eranian
2010-01-17 14:12 ` Frederic Weisbecker
2010-01-17 14:42 ` Stephane Eranian
2010-01-17 16:19 ` Frederic Weisbecker
2010-01-17 21:53 ` Stephane Eranian
2010-01-18 11:13 ` Peter Zijlstra
2010-01-18 11:53 ` [PATCH] perf: fix the is_software_event() definition Peter Zijlstra
2010-01-18 12:07 ` Frederic Weisbecker
2010-01-18 12:19 ` Peter Zijlstra
2010-01-18 13:46 ` [perfmon2] " stephane eranian
2010-01-18 12:57 ` stephane eranian
2010-01-18 13:06 ` Frederic Weisbecker
2010-01-18 12:53 ` stephane eranian
2010-01-18 13:00 ` 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=1263400193.4244.238.camel@laptop \
--to=peterz@infradead.org \
--cc=davem@davemloft.net \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=perfmon2-devel@lists.sf.net \
/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