linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	linux-kernel@vger.kernel.org, jolsa@redhat.com
Subject: Re: [PATCH v1 4/6] perf: Allow using AUX data in perf samples
Date: Tue, 19 Jun 2018 14:00:44 +0300	[thread overview]
Message-ID: <20180619110044.qid7jdgmgicvhn4u@um.fi.intel.com> (raw)
In-Reply-To: <20180614194720.GA12217@hirez.programming.kicks-ass.net>

On Thu, Jun 14, 2018 at 09:47:20PM +0200, Peter Zijlstra wrote:
> On Tue, Jun 12, 2018 at 10:51:15AM +0300, Alexander Shishkin wrote:
> > @@ -6112,6 +6219,32 @@ void perf_prepare_sample(struct perf_event_header *header,
> >  
> >  	if (sample_type & PERF_SAMPLE_PHYS_ADDR)
> >  		data->phys_addr = perf_virt_to_phys(data->addr);
> > +
> > +	if (sample_type & PERF_SAMPLE_AUX) {
> > +		u64 size;
> > +
> > +		header->size += sizeof(u64); /* size */
> > +
> > +		/*
> > +		 * Given the 16bit nature of header::size, an AUX sample can
> > +		 * easily overflow it, what with all the preceding sample bits.
> > +		 * Make sure this doesn't happen by using up to U16_MAX bytes
> > +		 * per sample in total (rounded down to 8 byte boundary).
> > +		 */
> > +		size = min_t(size_t, U16_MAX - header->size,
> > +			     event->attr.aux_sample_size);
> > +		size = rounddown(size, 8);
> > +		size = perf_aux_sample_size(event, data, size);
> > +
> > +		WARN_ON_ONCE(size + header->size > U16_MAX);
> > +		header->size += size;
> > +	}
> > +	/*
> > +	 * If you're adding more sample types here, you likely need to do
> > +	 * something about the overflowing header::size, like repurpose the
> > +	 * lowest 3 bits of size, which should be always zero at the moment.
> > +	 */
> 
> Bugger yes.. I fairly quickly (but still too late) realized we should've
> used that u16 in u64 increments to allow up to 512K instead of 64K
> events.
>
> Still, even 64K samples are pretty terrifyingly huge. They'll be
> _sloowww_.
> 
> In any case, I suppose we can grab one of the attribute bits to rev. the
> output format -- a la sample_id_all. Do we really want to do that? 512K
> samples.... *shudder*.

Well, as far as PT goes, even a 4K sample carries a thousands of branches,
I can't imagine ever needing more than 64K, but I didn't really want to make
the call. Same goes for the width of aux_sample_size, which should match what
we can theoretically output.

Also as a thought, we could use the perf_adjust_period() to also reduce the
sample size dynamically if it takes too long to copy.

Regards,
--
Alex

  reply	other threads:[~2018-06-19 11:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12  7:51 [PATCH v1 0/6] perf: Add AUX data sampling Alexander Shishkin
2018-06-12  7:51 ` [PATCH v1 1/6] perf: Disable PMU around address filter adjustment Alexander Shishkin
2018-06-12 20:11   ` Peter Zijlstra
2018-06-12  7:51 ` [PATCH v1 2/6] perf: Disable IRQs in address filter sync path Alexander Shishkin
2018-06-12  7:51 ` [PATCH v1 3/6] perf: Add an iterator for AUX data Alexander Shishkin
2018-06-12  7:51 ` [PATCH v1 4/6] perf: Allow using AUX data in perf samples Alexander Shishkin
2018-06-14 19:25   ` Peter Zijlstra
2018-06-14 19:39     ` Peter Zijlstra
2018-06-19 10:51       ` Alexander Shishkin
2018-06-14 19:30   ` Peter Zijlstra
2018-06-14 19:47   ` Peter Zijlstra
2018-06-19 11:00     ` Alexander Shishkin [this message]
2018-06-14 20:03   ` Peter Zijlstra
2018-06-14 20:20   ` Peter Zijlstra
2018-06-19 10:47     ` Alexander Shishkin
2018-06-21 20:16       ` Peter Zijlstra
2018-10-02 14:00         ` Alexander Shishkin
2019-08-09 12:32         ` Alexander Shishkin
2019-09-26 12:04           ` Alexander Shishkin
2019-09-26 14:44           ` Peter Zijlstra
2019-09-30 11:50             ` Alexander Shishkin
2018-06-12  7:51 ` [PATCH v1 5/6] perf: Drop PERF_FLAG_FD_OUTPUT Alexander Shishkin
2018-06-12  7:51 ` [PATCH v1 6/6] perf: Allow set-output for task contexts of different types Alexander Shishkin
2018-06-14 19:36   ` 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=20180619110044.qid7jdgmgicvhn4u@um.fi.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).