lkml.org 
[lkml]   [2017]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [virtio-dev] Re: [PATCH v19 3/7] xbitmap: add more operations
On 12/14/2017 11:47 AM, Wei Wang wrote:
> On 12/13/2017 10:16 PM, Tetsuo Handa wrote:
>
>
>>
>>> if (set)
>>> ret = find_next_bit(&tmp,
>>> BITS_PER_LONG, ebit);
>>> else
>>> ret = find_next_zero_bit(&tmp,
>>> BITS_PER_LONG,
>>> ebit);
>>> if (ret < BITS_PER_LONG)
>>> return ret - 2 + ida_start;
>>> } else if (bitmap) {
>>> if (set)
>>> ret = find_next_bit(bitmap->bitmap,
>>> IDA_BITMAP_BITS, bit);
>>> else
>>> ret =
>>> find_next_zero_bit(bitmap->bitmap,
>>> IDA_BITMAP_BITS, bit);
>> "bit" may not be 0 for the first round and "bit" is always 0 afterwords.
>> But where is the guaranteed that "end" is a multiple of
>> IDA_BITMAP_BITS ?
>> Please explain why it is correct to use IDA_BITMAP_BITS unconditionally
>> for the last round.
>
> There missed something here, it will be:
>
> nbits = min(end - ida_start + 1, IDA_BITMAP_BITS - bit);


captured a bug here, should be:
nbits = min(end - ida_start + 1, (unsigned long)IDA_BITMAP_BITS);


> if (set)
> ret = find_next_bit(bitmap->bitmap, nbits, bit);
> else
> ret = find_next_zero_bit(bitmap->bitmap,
> nbits, bit);
> if (ret < nbits)
> return ret + ida_start;
>
>

Best,
Wei




\
 
 \ /
  Last update: 2017-12-14 12:46    [W:0.111 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site