linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
	Paul Mackerras <paulus@samba.org>,
	dev@codyps.com, linux-kernel@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 4/4] perf/powerpc: Implement group_read() txn interface for 24x7 counters
Date: Tue, 17 Mar 2015 07:57:33 +0100	[thread overview]
Message-ID: <20150317065733.GN2896@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <1425458108-3341-5-git-send-email-sukadev@linux.vnet.ibm.com>

On Wed, Mar 04, 2015 at 12:35:08AM -0800, Sukadev Bhattiprolu wrote:
> +++ b/kernel/events/core.c
> @@ -3677,11 +3677,34 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running,
>  }
>  EXPORT_SYMBOL_GPL(perf_event_read_value);
>  
> +static int do_pmu_group_read(struct perf_event *leader)
> +{
> +	int ret;
> +	struct pmu *pmu;
> +	struct perf_event *sub;
> +
> +	pmu = leader->pmu;
> +	pmu->start_txn(pmu, PERF_PMU_TXN_READ);
> +
> +	pmu->read(leader);
> +	list_for_each_entry(sub, &leader->sibling_list, group_entry)
> +		pmu->read(sub);
> +
> +	/*
> +	 * Commit_txn submits the transaction to read all the counters
> +	 * in the group _and_ updates the event count.
> +	 */
> +	ret = pmu->commit_txn(pmu, PERF_PMU_TXN_READ);
> +
> +	return ret;
> +}
> +
>  static int perf_event_read_group(struct perf_event *event,
>  				   u64 read_format, char __user *buf)
>  {
>  	struct perf_event *leader = event->group_leader, *sub;
>  	struct perf_event_context *ctx = leader->ctx;
> +	struct pmu *pmu;
>  	int n = 0, size = 0, ret;
>  	u64 count, enabled, running;
>  	u64 values[5];
> @@ -3690,7 +3713,21 @@ static int perf_event_read_group(struct perf_event *event,
>  
>  	lockdep_assert_held(&ctx->mutex);
>  
> +	pmu = event->pmu;
>  	update = 1;
> +
> +	if ((read_format & PERF_FORMAT_GROUP) &&
> +			(pmu->capabilities & PERF_PMU_CAP_GROUP_READ)) {
> +		ret = do_pmu_group_read(event);
> +		if (ret)
> +			return ret;
> +		/*
> +		 * ->commit_txn() would have updated the event count,
> +		 * so we don't have to consult the PMU again.
> +		 */
> +		update = 0;
> +	}
> +

Is there a down-side to always doing the txn based group read? If an
arch does not implement the read txn support it'll fall back to doing
independent read ops, but we end up doing those anyway.

That way we get less special case code.

  reply	other threads:[~2015-03-17  6:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04  8:35 [PATCH 0/4] perf: Implement event group read using txn interface Sukadev Bhattiprolu
2015-03-04  8:35 ` [PATCH 1/4] perf: Add 'flags' parameter to pmu txn interfaces Sukadev Bhattiprolu
2015-03-17  6:47   ` Peter Zijlstra
2015-03-26  4:00     ` Sukadev Bhattiprolu
2015-03-04  8:35 ` [PATCH 2/4] perf: Split perf_event_read() and perf_event_count() Sukadev Bhattiprolu
2015-03-04  8:35 ` [PATCH 3/4] perf: Add 'update' parameter to perf_event_read_value() Sukadev Bhattiprolu
2015-03-17  6:54   ` Peter Zijlstra
2015-03-04  8:35 ` [PATCH 4/4] perf/powerpc: Implement group_read() txn interface for 24x7 counters Sukadev Bhattiprolu
2015-03-17  6:57   ` Peter Zijlstra [this message]
2015-03-26  5:57     ` Sukadev Bhattiprolu
2015-04-01 18:10       ` 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=20150317065733.GN2896@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dev@codyps.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=sukadev@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).