From: Robert Richter <robert.richter@amd.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: eranian@google.com, linux-kernel@vger.kernel.org, mingo@elte.hu,
paulus@samba.org, fweisbec@gmail.com,
perfmon2-devel@lists.sf.net, eranian@gmail.com
Subject: Re: [PATCH] perf_events: add sampling period randomization support
Date: Tue, 2 Mar 2010 15:18:24 +0100 [thread overview]
Message-ID: <20100302141824.GG13205@erda.amd.com> (raw)
In-Reply-To: <1267530078.25158.41.camel@laptop>
On 02.03.10 12:41:18, Peter Zijlstra wrote:
> On Tue, 2010-03-02 at 11:53 +0100, Robert Richter wrote:
> >
> > Only adding the random value will lead to longer sample periods on
> > average. To compensate this you could calculate something like:
> >
> > event->hw.sample_period = event->attr.sample_period + (new_seed & mask) - (mask >> 1);
>
> Or cheat and do something like:
>
> sample_period ^= (new_seed & mask);
This wont work, it will be asymmetric, e.g. for
(event->attr.sample_period & mask) == 0
the offset would be always positive. Only for
(event->attr.sample_period & mask) == (mask & ~(mask >> 1))
it is correct.
-Robert
--
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com
next prev parent reply other threads:[~2010-03-02 14:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-02 6:07 [PATCH] perf_events: add sampling period randomization support eranian
2010-03-02 6:20 ` David Miller
2010-03-02 8:21 ` Peter Zijlstra
2010-03-02 10:53 ` Robert Richter
2010-03-02 11:41 ` Peter Zijlstra
2010-03-02 14:18 ` Robert Richter [this message]
2010-03-02 13:10 ` Frederic Weisbecker
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=20100302141824.GG13205@erda.amd.com \
--to=robert.richter@amd.com \
--cc=eranian@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=perfmon2-devel@lists.sf.net \
--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