Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756624AbbBQKDL (ORCPT ); Tue, 17 Feb 2015 05:03:11 -0500 Received: from casper.infradead.org ([85.118.1.10]:59455 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756610AbbBQKDJ (ORCPT ); Tue, 17 Feb 2015 05:03:09 -0500 Date: Tue, 17 Feb 2015 11:03:01 +0100 From: Peter Zijlstra To: Sukadev Bhattiprolu Cc: mingo@kernel.org, Michael Ellerman , Anton Blanchard , Stephane Eranian , Jiri Olsa , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH] perf: Implement read_group() PMU operation Message-ID: <20150217100301.GJ5029@twins.programming.kicks-ass.net> References: <20150206025915.GA31650@us.ibm.com> <20150212155856.GC21418@twins.programming.kicks-ass.net> <20150217083312.GA16221@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150217083312.GA16221@us.ibm.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2559 Lines: 65 On Tue, Feb 17, 2015 at 12:33:12AM -0800, Sukadev Bhattiprolu wrote: > Peter Zijlstra [peterz@infradead.org] wrote: > | > --- a/kernel/events/core.c > | > +++ b/kernel/events/core.c > | > @@ -3549,10 +3549,43 @@ static int perf_event_read_group(struct perf_event *event, > | > | You also want perf_output_read_group(). > > Ok. Will look into it. We currently don't support sampling with > the 24x7 counters but we should make sure that the new interface > fits correctly. One thing someone 'could' do is group them together with a software event that _can_ sample, and then use SAMPLE_READ to periodically stuff values into the buffer. > | Since ->read() has a void return value, we can delay its effect, so I'm > | currently thinking we might want to extend the transaction interface for > | this; give pmu::start_txn() a flags argument to indicate scheduling > | (add) or reading (read). > | > | So we'd end up with something like: > | > | pmu->start_txn(pmu, PMU_TXN_READ); > | > | leader->read(); > | > | for_each_sibling() > | sibling->read(); > | > | pmu->commit_txn(); > > So, each of the ->read() calls is really "appending a counter" to a > list of counters that the PMU should read and the values for the counters > (results of the read) are only available after the commit_txn() right? Correct. > In which case, perf_event_read_group() would then follow this commit_txn() > with its "normal" read, and the PMU would return the result cached during > ->commit_txn(). If so, we need a way to invalidate the cached result ? I was thinking of breaking up that code into two loops, once to call ->read() and update states, the second to use the now up-to-date data and frob it into the stream. But I must say I've not entirely given it much thought. But that way you're not stuck with this cache and related problems. > | after which we can use the values updated by the read calls. The trivial > | no-support implementation lets read do its immediate thing like it does > | now. > | > | A more complex driver can then collect the actual counter values and > | execute one hypercall using its pre-allocated memory. > > the hypercall should happen in the ->commit_txn() right ? Yah. Of course, if a ->read() is not part of a txn then it must do the hypercall for just the one value. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/