Re: [PATCH] perf_events: add sampling period randomization support
From: David Miller
Date: Tue Mar 02 2010 - 01:20:46 EST
Date: Mon, 1 Mar 2010 22:07:09 -0800
> This patch adds support for randomizing the sampling period.
> Randomization is very useful to mitigate the bias that exists
> with sampling. The random number generator does not need to
> be sophisticated. This patch uses the builtin random32()
> The user activates randomization by setting the perf_event_attr.random
> field to 1 and by passing a bitmask to control the range of variation
> above the base period. Period will vary from period to period & mask.
> Note that randomization is not available when a target interrupt rate
> (freq) is enabled.
> The last used period can be collected using the PERF_SAMPLE_PERIOD flag
> in sample_type.
> The patch has been tested on X86. There is also code for PowerPC but
> I could not test it.
> Signed-off-by: Stephane Eranian <eranian@xxxxxxxxxx>
Please add this, which adds the feature to sparc too.
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index 9f2b2ba..3e28225 100644
@@ -1214,6 +1214,9 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
if (val & (1ULL << 31))
+ if (event->attr.random)
data.period = event->hw.last_period;
if (!sparc_perf_event_set_period(event, hwc, idx))
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/