From: Frederic Weisbecker <fweisbec@gmail.com>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
mingo@elte.hu, paulus@samba.org, davem@davemloft.net,
perfmon2-devel@lists.sf.net, eranian@gmail.com
Subject: Re: [PATCH] perf_events: improve x86 event scheduling (v5)
Date: Mon, 18 Jan 2010 14:43:25 +0100 [thread overview]
Message-ID: <20100118134324.GB10364@nowhere> (raw)
In-Reply-To: <4b5430c6.0f975e0a.1bf9.ffff85fe@mx.google.com>
On Mon, Jan 18, 2010 at 10:58:01AM +0200, Stephane Eranian wrote:
> +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 n0, n1, ret;
> +
> + /* n0 = total number of events */
> + n0 = collect_events(cpuc, leader, true);
> + if (n0 < 0)
> + return n0;
> +
> + ret = x86_schedule_events(cpuc, n0, assign);
> + if (ret)
> + return ret;
> +
> + ret = x86_event_sched_in(leader, cpuctx, cpu);
> + if (ret)
> + return ret;
> +
> + n1 = 1;
> + list_for_each_entry(sub, &leader->sibling_list, group_entry) {
> + if (sub->state != PERF_EVENT_STATE_OFF) {
> + ret = x86_event_sched_in(sub, cpuctx, cpu);
> + if (ret)
> + goto undo;
> + ++n1;
> + }
> + }
> + /*
> + * copy new assignment, now we know it is possible
> + * will be used by hw_perf_enable()
> + */
> + memcpy(cpuc->assign, assign, n0*sizeof(int));
> +
> + cpuc->n_events = n0;
> + cpuc->n_added = n1;
> + ctx->nr_active += n1;
> +
> + /*
> + * 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;
> +undo:
> + x86_event_sched_out(leader, cpuctx, cpu);
> + n0 = 1;
> + list_for_each_entry(sub, &leader->sibling_list, group_entry) {
> + if (sub->state == PERF_EVENT_STATE_ACTIVE) {
> + x86_event_sched_out(sub, cpuctx, cpu);
> + if (++n0 == n1)
> + break;
> + }
> + }
> + return ret;
Looking at all these numerous places where this whole constraint
and ad hoc scheduling machine tries to catch up with what the
core can already do (handle non-x86 events, revert in failure,
first handle leader, then handle the rest, etc...), I wonder
if this hw_group_sched_in() based design is a good idea.
Shouldn't we actually use the core based pmu->enable(),disable()
model called from kernel/perf_event.c:event_sched_in(),
like every other events, where we can fill up the queue of hardware
events to be scheduled, and then call a hw_check_constraints()
when we finish a group scheduling?
I guess this would simplify all this code, avoid it to run through
the list of events, handle software events, revert partial enabled
by itself etc...
Hm?
next prev parent reply other threads:[~2010-01-18 13:43 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-18 8:58 [PATCH] perf_events: improve x86 event scheduling (v5) Stephane Eranian
2010-01-18 13:43 ` Frederic Weisbecker [this message]
2010-01-18 13:54 ` Peter Zijlstra
2010-01-18 14:12 ` Stephane Eranian
2010-01-18 14:20 ` Peter Zijlstra
2010-01-18 14:33 ` Peter Zijlstra
2010-01-18 14:20 ` Frederic Weisbecker
2010-01-18 14:32 ` Peter Zijlstra
2010-01-18 14:45 ` Frederic Weisbecker
2010-01-18 14:56 ` Peter Zijlstra
2010-01-18 16:18 ` Frederic Weisbecker
2010-01-18 16:26 ` Peter Zijlstra
2010-01-18 16:51 ` Frederic Weisbecker
2010-01-18 17:13 ` Peter Zijlstra
2010-01-18 17:29 ` Frederic Weisbecker
2010-01-18 20:01 ` Peter Zijlstra
2010-01-19 12:22 ` Peter Zijlstra
2010-01-19 13:24 ` Peter Zijlstra
2010-01-19 15:55 ` Frederic Weisbecker
2010-01-19 16:25 ` Peter Zijlstra
2010-02-27 17:38 ` Frederic Weisbecker
2010-01-19 15:40 ` Frederic Weisbecker
2010-01-21 10:08 ` Stephane Eranian
2010-01-21 10:11 ` Peter Zijlstra
2010-01-21 10:21 ` Stephane Eranian
2010-01-21 10:28 ` Peter Zijlstra
2010-01-21 10:38 ` Stephane Eranian
2010-01-21 10:45 ` Frederic Weisbecker
2010-01-21 11:44 ` Stephane Eranian
2010-01-21 12:02 ` Frederic Weisbecker
2010-01-18 14:37 ` Peter Zijlstra
2010-01-18 14:53 ` Frederic Weisbecker
2010-01-18 14:59 ` Peter Zijlstra
2010-01-18 16:22 ` Frederic Weisbecker
2010-01-21 10:36 ` Peter Zijlstra
2010-01-21 10:43 ` Stephane Eranian
2010-01-21 10:46 ` Peter Zijlstra
2010-01-21 14:06 ` Stephane Eranian
2010-01-21 13:55 ` [tip:perf/urgent] perf: x86: Add support for the ANY bit tip-bot for Stephane Eranian
2010-01-29 9:26 ` [tip:perf/core] perf_events, x86: Improve x86 event scheduling tip-bot for Stephane Eranian
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=20100118134324.GB10364@nowhere \
--to=fweisbec@gmail.com \
--cc=davem@davemloft.net \
--cc=eranian@gmail.com \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=perfmon2-devel@lists.sf.net \
--cc=peterz@infradead.org \
/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