Re: [PATCH v18 05/10] xbitmap: add more operations

2017-12-07 Thread Michael S. Tsirkin
On Thu, Dec 07, 2017 at 08:01:24PM +0800, Wei Wang wrote: > On 12/03/2017 09:50 AM, Tetsuo Handa wrote: > > Matthew Wilcox wrote: > > > On Fri, Dec 01, 2017 at 03:09:08PM +, Wang, Wei W wrote: > > > > On Friday, December 1, 2017 9:02 PM, Tetsuo Handa wrote: > > > > > If start == end is legal,

Re: [PATCH v18 05/10] xbitmap: add more operations

2017-12-07 Thread Wei Wang
On 12/03/2017 09:50 AM, Tetsuo Handa wrote: Matthew Wilcox wrote: On Fri, Dec 01, 2017 at 03:09:08PM +, Wang, Wei W wrote: On Friday, December 1, 2017 9:02 PM, Tetsuo Handa wrote: If start == end is legal, for (; start < end; start = (start | (IDA_BITMAP_BITS - 1)) + 1) { makes this

Re: [PATCH v18 05/10] xbitmap: add more operations

2017-12-01 Thread Matthew Wilcox
On Fri, Dec 01, 2017 at 03:09:08PM +, Wang, Wei W wrote: > On Friday, December 1, 2017 9:02 PM, Tetsuo Handa wrote: > > If start == end is legal, > > > >for (; start < end; start = (start | (IDA_BITMAP_BITS - 1)) + 1) { > > > > makes this loop do nothing because 10 < 10 is false. > >

RE: [PATCH v18 05/10] xbitmap: add more operations

2017-12-01 Thread Wang, Wei W
On Friday, December 1, 2017 9:02 PM, Tetsuo Handa wrote: > Wei Wang wrote: > > On 11/30/2017 06:34 PM, Tetsuo Handa wrote: > > > Wei Wang wrote: > > >> + * @start: the start of the bit range, inclusive > > >> + * @end: the end of the bit range, inclusive > > >> + * > > >> + * This function is used

Re: [PATCH v18 05/10] xbitmap: add more operations

2017-12-01 Thread Matthew Wilcox
On Fri, Dec 01, 2017 at 10:02:01PM +0900, Tetsuo Handa wrote: > If start == end is legal, > >for (; start < end; start = (start | (IDA_BITMAP_BITS - 1)) + 1) { > > makes this loop do nothing because 10 < 10 is false. ... and this is why we add tests to the test-suite!

Re: [PATCH v18 05/10] xbitmap: add more operations

2017-12-01 Thread Wei Wang
On 11/30/2017 06:34 PM, Tetsuo Handa wrote: Wei Wang wrote: + * @start: the start of the bit range, inclusive + * @end: the end of the bit range, inclusive + * + * This function is used to clear a bit in the xbitmap. If all the bits of the + * bitmap are 0, the bitmap will be freed. + */ +void

Re: [PATCH v18 05/10] xbitmap: add more operations

2017-11-30 Thread Matthew Wilcox
On Thu, Nov 30, 2017 at 10:35:03PM +0900, Tetsuo Handa wrote: > According to xb_set_bit(), it seems to me that we are trying to avoid memory > allocation > for "struct ida_bitmap" when all set bits within a 1024-bits bitmap reside in > the first > 61 bits. > > But does such saving help? Is

[PATCH v18 05/10] xbitmap: add more operations

2017-11-29 Thread Wei Wang
This patch adds support to find next 1 or 0 bit in a xbmitmap range and clear a range of bits. More possible optimizations to add in the future: 1) xb_set_bit_range: set a range of bits. 2) when searching a bit, if the bit is not found in the slot, move on to the next slot directly. 3) add tags