mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Paul Mackerras <paulus@samba.org>
Cc: mingo@redhat.com, hpa@zytor.com, eranian@google.com,
	linux-kernel@vger.kernel.org, davem@davemloft.net,
	fweisbec@gmail.com, ming.m.lin@intel.com, tglx@linutronix.de,
	mingo@elte.hu, linux-tip-commits@vger.kernel.org
Subject: Re: [tip:perf/core] perf: Add group scheduling transactional APIs
Date: Mon, 10 May 2010 10:11:55 +0200	[thread overview]
Message-ID: <1273479115.5605.3329.camel@twins> (raw)
In-Reply-To: <20100508102841.GA10650@brick.ozlabs.ibm.com>

On Sat, 2010-05-08 at 20:28 +1000, Paul Mackerras wrote:

> Here's the patch I ended up with.

Ok, I'll take this one. Thanks Paul!

One small question on the patch below:

> --------------
> Subject: perf, powerpc: Implement group scheduling transactional APIs
> From: Lin Ming <ming.m.lin@intel.com>
> 
> [paulus@samba.org: Set cpuhw->event[i]->hw.config in
> power_pmu_commit_txn.]
> 
> Signed-off-by: Lin Ming <ming.m.lin@intel.com>
> Signed-off-by: Paul Mackerras <paulus@samba.org>
> ---
> diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c
> index 08460a2..43b83c3 100644
> --- a/arch/powerpc/kernel/perf_event.c
> +++ b/arch/powerpc/kernel/perf_event.c
> @@ -35,6 +35,9 @@ struct cpu_hw_events {
>  	u64 alternatives[MAX_HWEVENTS][MAX_EVENT_ALTERNATIVES];
>  	unsigned long amasks[MAX_HWEVENTS][MAX_EVENT_ALTERNATIVES];
>  	unsigned long avalues[MAX_HWEVENTS][MAX_EVENT_ALTERNATIVES];
> +
> +	unsigned int group_flag;
> +	int n_txn_start;
>  };
>  DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events);
>  
> @@ -805,12 +748,22 @@ static int power_pmu_enable(struct perf_event *event)
>  	cpuhw->event[n0] = event;
>  	cpuhw->events[n0] = event->hw.config;
>  	cpuhw->flags[n0] = event->hw.event_base;
> +
> +	/*
> +	 * If group events scheduling transaction was started,
> +	 * skip the schedulability test here, it will be peformed
> +	 * at commit time(->commit_txn) as a whole
> +	 */
> +	if (cpuhw->group_flag & PERF_EVENT_TXN_STARTED)
> +		goto nocheck;
> +
>  	if (check_excludes(cpuhw->event, cpuhw->flags, n0, 1))
>  		goto out;
>  	if (power_check_constraints(cpuhw, cpuhw->events, cpuhw->flags, n0 + 1))
>  		goto out;
>  	event->hw.config = cpuhw->events[n0];
> +
> +nocheck:
>  	++cpuhw->n_events;
>  	++cpuhw->n_added;
>  
> @@ -896,11 +849,65 @@ static void power_pmu_unthrottle(struct perf_event *event)
>  	local_irq_restore(flags);
>  }
>  
> +/*
> + * Start group events scheduling transaction
> + * Set the flag to make pmu::enable() not perform the
> + * schedulability test, it will be performed at commit time
> + */
> +void power_pmu_start_txn(const struct pmu *pmu)
> +{
> +	struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
> +
> +	cpuhw->group_flag |= PERF_EVENT_TXN_STARTED;
> +	cpuhw->n_txn_start = cpuhw->n_events;
> +}
> +
> +/*
> + * Stop group events scheduling transaction
> + * Clear the flag and pmu::enable() will perform the
> + * schedulability test.
> + */
> +void power_pmu_cancel_txn(const struct pmu *pmu)
> +{
> +	struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
> +
> +	cpuhw->group_flag &= ~PERF_EVENT_TXN_STARTED;
> +}
> +
> +/*
> + * Commit group events scheduling transaction
> + * Perform the group schedulability test as a whole
> + * Return 0 if success
> + */
> +int power_pmu_commit_txn(const struct pmu *pmu)
> +{
> +	struct cpu_hw_events *cpuhw;
> +	long i, n;
> +
> +	if (!ppmu)
> +		return -EAGAIN;
> +	cpuhw = &__get_cpu_var(cpu_hw_events);
> +	n = cpuhw->n_events;
> +	if (check_excludes(cpuhw->event, cpuhw->flags, 0, n))
> +		return -EAGAIN;
> +	i = power_check_constraints(cpuhw, cpuhw->events, cpuhw->flags, n);
> +	if (i < 0)
> +		return -EAGAIN;
> +
> +	for (i = cpuhw->n_txn_start; i < n; ++i)
> +		cpuhw->event[i]->hw.config = cpuhw->events[i];
> +
> +	return 0;
> +}

Can't you compute n_txn_start by subtracting n_added from n_events ?

  reply	other threads:[~2010-05-10  8:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-23  5:56 [RFC][PATCH v2 1/4] perf: core, add " Lin Ming
2010-05-07 18:44 ` [tip:perf/core] perf: Add " tip-bot for Lin Ming
2010-05-07 21:55   ` Peter Zijlstra
2010-05-08 10:28     ` Paul Mackerras
2010-05-10  8:11       ` Peter Zijlstra [this message]
2010-05-10 11:38         ` Paul Mackerras
2010-05-11 15:43       ` [tip:perf/core] perf, powerpc: Implement " tip-bot for Lin Ming

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=1273479115.5605.3329.camel@twins \
    --to=peterz@infradead.org \
    --cc=davem@davemloft.net \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®