[lkml]   [2009]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: III.1 - Sampling period randomization
    > III/ Requests
    > 1/ Sampling period randomization
    > It is our experience (on Itanium, for instance), that for certain
    > sampling measurements, it is beneficial to randomize the sampling
    > period a bit. This is in particular the case when sampling on an
    > event that happens very frequently and which is not related to
    > timing, e.g., branch_instructions_retired. Randomization helps
    > mitigate the bias. You do not need something sophisticated. But
    > when you are using a kernel-level sampling buffer, you need to
    > have the kernel randomize. Randomization needs to be supported per
    > event.

    This is on the todo list, it should be pretty straight forward to
    implement. Basically add a u64 randomize:1 flag and a u64 rand_size,
    and add some noise to hwc->sample_period in perf_counter_overflow(),
    just like the .freq path does.

    In fact the auto-freq sampling counters effectively randomize
    already, as the path of stabilization/convergence is never exactly
    the same. We could add a little bit of constant noise to the freq
    counter and it would auto-correct automatically.

    Since you seem to care abut this sub-feature, would you be
    interested in sending a patch for that? The essential steps are:

    - Take a new bit off perf_counter_attr::__reserved_1 and name
    it attr.randomize.

    - Inject a few bits of trivial noise into the period calculated
    in kernel/perf_counter.c:perf_adjust_period(). The best place
    would be to add it right before this line:

    hwc->sample_period = sample_period;

    If you add a small relative fuzz of below 1% to sample_period
    then the code will auto-correct.

    - All the tools deal just fine with variable periods already, so
    there's no tooling updates needed, beyond adding a --randomize
    flag to tools/perf/builtin-record.c.

    Let us know if you need any help with any of this!

     \ /
      Last update: 2009-06-22 14:01    [W:0.027 / U:7.224 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site