lkml.org 
[lkml]   [2008]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 05/24] perfmon: X86 generic code (x86)
Thomas,

On Thu, Nov 27, 2008 at 12:16 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Wed, 26 Nov 2008, stephane eranian wrote:
>> > What a nonsense. We have a bitmask already. Why not iterate over the
>> > bitmask and be done ?
>> >
>>
>> Bitmask can be sparsed. Num represents the number of bits we have to find.
>> The idea is that we don't need to scan the entire bitmask, we stop as soon as
>> we have found all the bits we care about (i.e., all the bits that are set).
>>
>> Example:
>> num = 3
>> bitmask=0000000010001001
>> ^ we will iterate until we are
>> done with that bit.
>
> Errm.
>
> #define for_each_bit(bit, addr, size) \
> for ((bit) = find_first_bit((addr), (size)); \
> (bit) < (size); \
> (bit) = find_next_bit((addr), (size), (bit) + 1))
>
> find_first_bit() and find_next_bit() are single instructions on most
> architectures. "size" is known upfront at setup time of the
> context/set and can be cached.
>
> This takes exactly 3 iterations, while your method needs 8. And it
> gets worse with the following example:
>
> Example:
> num = 1
> bitmask=1000 0000 0000 0000 0000 0000 0000 00000
>
> ^ you will iterate until we are done with that bit (32 times)
>
> for_each_bit() will iterate exactly _once_.
>
Ok, you've convinced me. I will make the change.
Thanks.


\
 
 \ /
  Last update: 2008-11-27 10:41    [W:0.070 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site