mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Robert Richter <rric@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>,
	Andi Kleen <ak@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [RFC 2/2] perf: add AUX area to ring buffer for raw data streams
Date: Fri, 16 May 2014 10:07:24 +0300	[thread overview]
Message-ID: <87egzuyzf7.fsf@ashishki-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20140515180218.GA32115@rric.localhost>

Robert Richter <rric@kernel.org> writes:

> On 15.05.14 18:08:30, Alexander Shishkin wrote:
>> From: Peter Zijlstra <peterz@infradead.org>
>> 
>> This patch introduces "AUX space" in the perf mmap buffer, intended for
>> exporting high bandwidth data streams to userspace, such as instruction
>> flow traces.
>> 
>> AUX space is a ring buffer, defined by aux_{offset,size} fields in the
>> user_page structure, and read/write pointers aux_{head,tail}, which abide
>> by the same rules as data_* counterparts of the main perf buffer.
>> 
>> In order to allocate/mmap AUX, userspace needs to set up aux_offset to
>> such an offset that will be greater than data_offset+data_size and
>> aux_size to be the desired buffer size. Both need to be page aligned.
>> The latter is not forced to be a power of 2 number of pages, so that PMU
>> drivers have to take care of this if necessary in their implementations
>> of ->alloc_aux(). Then, same aux_offset and aux_size should be passed to
>> mmap() call and if everything adds up, you should have an AUX buffer as
>> a result.
>
> Raw data sample (PERF_SAMPLE_RAW) already allow to pass data to
> userspace. What is the reason for a separate buffer? I see the
> following:
>
>  * the buffer accessed from userspace should have a customized format
>    unrelated to perf,
>
>  * zero copying (not sure if this is really possible),
>
>  * data size and alignment requirements that can not be handled by raw
>    data samples.

It is all three. What we're dealing with at the moment is a unit that
generates instruction traces at rates like hhundreds of megabytes per
second. So the only sensible thing to do is zero copy the data.

> If possible, raw data samples should be a first option.
>
> On the other side there might the need of an aux buffer (I would
> better call it raw buffer analog to raw data). So here some comments
> on the implementation and the user i/f.
>
> Instead of extending the current ringbuffer I would better add a 2nd
> ring buffer. The mmap and ringbuffer handling and esp. the access from
> userspace looks much more complex now and it was already complex
> before. So with a 2nd buffer there would be less changes in the
> implementation and handling. Access from userland would remain as it
> currently is, there is no need to modify the header page layout. To
> setup a 2nd buffer, you just need to modify the mmap call in a way
> (maybe by prot, flags or offset argument) to let the kernel know an
> aux buffer should be attached to the event.

Tried that, didn't fly. See the full story here [1]. Though splicing
arbitrary pages into perf buffer is less than trivial, especially so
with hardware that doesn't do scatter-gather. So all in all, AUX area
seems to be a sensible compromise.

[1] http://marc.info/?l=linux-kernel&m=139264764530809&w=2

Regards,
--
Alex

  reply	other threads:[~2014-05-16  7:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 15:08 [RFC 0/2] perf: add AUX space to ring_buffer Alexander Shishkin
2014-05-15 15:08 ` [RFC 1/2] perf: add data_{offset,size} to user_page Alexander Shishkin
2014-05-15 18:14   ` Robert Richter
2014-05-15 15:08 ` [RFC 2/2] perf: add AUX area to ring buffer for raw data streams Alexander Shishkin
2014-05-15 18:02   ` Robert Richter
2014-05-16  7:07     ` Alexander Shishkin [this message]
2014-05-19  8:58   ` Peter Zijlstra
2014-05-19 12:57     ` Alexander Shishkin
2014-05-20  9:51       ` Peter Zijlstra
2014-05-21 14:02         ` Alexander Shishkin
2014-06-05 11:58           ` Ingo Molnar

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=87egzuyzf7.fsf@ashishki-desk.ger.corp.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=ak@linux.intel.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=rric@kernel.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

all inboxes | Powered by JetHome®