Re: [tip:perf/core] perf/x86/intel: Clean-up/reduce PEBS code

H. Peter Anvin
2013-09-16T06:18:49Z

On 09/16/2013 01:07 AM, Peter Zijlstra wrote:
> On Fri, Sep 13, 2013 at 11:18:21PM -0700, Andi Kleen wrote:
>> tip-bot for Peter Zijlstra <tipbot@zytor.com> writes:
>>> +
>>> + at = (struct pebs_record_nhm *)(unsigned long)ds->pebs_buffer_base;
>>> + top = (struct pebs_record_nhm *)(unsigned long)ds->pebs_index;
>>>
>>> ds->pebs_index = ds->pebs_buffer_base;
>>>
>>> + n = (top - at) / x86_pmu.pebs_record_size;
>>
>>
>> This adds a full slow division to the PEBS hot path.
>>
>> Does not seem like a improvement to me.
>
> There already was an implicit division there, and
> sizeof(pebs_record_hsw) = 176, can it really optimize that constant
> division?
>

gcc can optimize ANY constant division, if nothing else then by
reciprocal multiplication.

-hpa