Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2018-01-03 Thread Wei Wang
On 01/02/2018 10:09 PM, Matthew Wilcox wrote: On Fri, Dec 22, 2017 at 04:49:11PM +0800, Wei Wang wrote: Thanks for the improvement. I also found a small bug in xb_zero. With the following changes, it has passed the current test cases and tested with the virtio-balloon usage without any issue. T

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2018-01-02 Thread Matthew Wilcox
On Fri, Dec 22, 2017 at 04:49:11PM +0800, Wei Wang wrote: > Thanks for the improvement. I also found a small bug in xb_zero. With the > following changes, it has passed the current test cases and tested with the > virtio-balloon usage without any issue. Thanks; I applied the change. Can you suppl

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-23 Thread Wei Wang
On 12/23/2017 10:33 PM, Tetsuo Handa wrote: + bitmap = rcu_dereference_raw(*slot); + if (!bitmap) { + bitmap = this_cpu_xchg(ida_bitmap, NULL); + if (!bitmap) + return -ENOMEM; I can't understand this. I can understand if it were

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-23 Thread Matthew Wilcox
On Sat, Dec 23, 2017 at 11:33:45PM +0900, Tetsuo Handa wrote: > Matthew Wilcox wrote: > > On Sat, Dec 23, 2017 at 11:59:54AM +0900, Tetsuo Handa wrote: > > > Matthew Wilcox wrote: > > > > + bit %= IDA_BITMAP_BITS; > > > > + radix_tree_iter_init(&iter, index); > > > > + slot = idr_

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-23 Thread Tetsuo Handa
Matthew Wilcox wrote: > On Sat, Dec 23, 2017 at 11:59:54AM +0900, Tetsuo Handa wrote: > > Matthew Wilcox wrote: > > > + bit %= IDA_BITMAP_BITS; > > > + radix_tree_iter_init(&iter, index); > > > + slot = idr_get_free_cmn(root, &iter, GFP_NOWAIT | __GFP_NOWARN, index); > > > + if (IS_ERR(slot)) { > >

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-22 Thread Matthew Wilcox
On Sat, Dec 23, 2017 at 11:59:54AM +0900, Tetsuo Handa wrote: > Matthew Wilcox wrote: > > + bit %= IDA_BITMAP_BITS; > > + radix_tree_iter_init(&iter, index); > > + slot = idr_get_free_cmn(root, &iter, GFP_NOWAIT | __GFP_NOWARN, index); > > + if (IS_ERR(slot)) { > > + if (slot == E

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-22 Thread Tetsuo Handa
Matthew Wilcox wrote: > +/** > + * xb_set_bit() - Set a bit in the XBitmap. > + * @xb: The XBitmap. > + * @bit: Index of the bit to set. > + * > + * This function is used to set a bit in the xbitmap. > + * > + * Return: 0 on success. -ENOMEM if memory could not be allocated. > + */ > +int xb_set_bi

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-22 Thread Wei Wang
On 12/22/2017 05:03 AM, Matthew Wilcox wrote: OK, here's a rewrite of xbitmap. Compared to the version you sent: - xb_find_set() is the rewrite I sent out yesterday. - xb_find_clear() is a new implementation. I use the IDR_FREE tag to find clear bits. This led to me finding a bug in ra

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-22 Thread Wei Wang
On 12/21/2017 10:37 PM, Tetsuo Handa wrote: Matthew Wilcox wrote: +/** + * xb_find_set - find the next set bit in a range of bits + * @xb: the xbitmap to search from + * @offset: the offset in the range to start searching + * @size: the size of the range + * + * Returns: the found bit or, @size

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-21 Thread Matthew Wilcox
OK, here's a rewrite of xbitmap. Compared to the version you sent: - xb_find_set() is the rewrite I sent out yesterday. - xb_find_clear() is a new implementation. I use the IDR_FREE tag to find clear bits. This led to me finding a bug in radix_tree_for_each_tagged(). - xb_zero() is also a

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-21 Thread Tetsuo Handa
Matthew Wilcox wrote: > > +/** > > + * xb_find_set - find the next set bit in a range of bits > > + * @xb: the xbitmap to search from > > + * @offset: the offset in the range to start searching > > + * @size: the size of the range > > + * > > + * Returns: the found bit or, @size if no set bit is fo

Re: [Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-21 Thread Matthew Wilcox
First of all, the test-suite doesn't build, so I don't know whether you ran it or not. Then I added the xb_find_set() call below, and it fails the assert, so you should probably fix that. diff --git a/lib/xbitmap.c b/lib/xbitmap.c index f03a0f9f9e29..b29af08a7597 100644 --- a/lib/xbitmap.c +++ b

[Qemu-devel] [PATCH v20 3/7 RESEND] xbitmap: add more operations

2017-12-20 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 to