[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v11 1/7] bitmap: fix bitmap_count_one
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH v11 1/7] bitmap: fix bitmap_count_one |
Date: |
Thu, 13 Dec 2018 14:28:01 +0000 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
* Wei Wang (address@hidden) wrote:
> BITMAP_LAST_WORD_MASK(nbits) returns 0xffffffff when "nbits=0", which
> makes bitmap_count_one fail to handle the "nbits=0" case. It appears to be
> preferred to remain BITMAP_LAST_WORD_MASK identical to the kernel
> implementation that it is ported from.
>
> So this patch fixes bitmap_count_one to handle the nbits=0 case.
OK; it's a little odd that it's only bitmap_count_one that's being fixed
for this case; but OK.
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
> Inital Discussion Link:
> https://www.mail-archive.com/address@hidden/msg554316.html
> Signed-off-by: Wei Wang <address@hidden>
> CC: Juan Quintela <address@hidden>
> CC: Dr. David Alan Gilbert <address@hidden>
> CC: Peter Xu <address@hidden>
> ---
> include/qemu/bitmap.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
> index 509eedd..679f1bd 100644
> --- a/include/qemu/bitmap.h
> +++ b/include/qemu/bitmap.h
> @@ -221,6 +221,10 @@ static inline int bitmap_intersects(const unsigned long
> *src1,
>
> static inline long bitmap_count_one(const unsigned long *bitmap, long nbits)
> {
> + if (unlikely(!nbits)) {
> + return 0;
> + }
> +
> if (small_nbits(nbits)) {
> return ctpopl(*bitmap & BITMAP_LAST_WORD_MASK(nbits));
> } else {
> --
> 1.8.3.1
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- [Qemu-devel] [PATCH v11 0/7] virtio-balloon: free page hint support, Wei Wang, 2018/12/11
- [Qemu-devel] [PATCH v11 1/7] bitmap: fix bitmap_count_one, Wei Wang, 2018/12/11
- Re: [Qemu-devel] [PATCH v11 1/7] bitmap: fix bitmap_count_one,
Dr. David Alan Gilbert <=
- [Qemu-devel] [PATCH v11 3/7] migration: use bitmap_mutex in migration_bitmap_clear_dirty, Wei Wang, 2018/12/11
- [Qemu-devel] [PATCH v11 2/7] bitmap: bitmap_count_one_with_offset, Wei Wang, 2018/12/11
- [Qemu-devel] [PATCH v11 4/7] migration: API to clear bits of guest free pages from the dirty bitmap, Wei Wang, 2018/12/11
- [Qemu-devel] [PATCH v11 5/7] migration/ram.c: add a notifier chain for precopy, Wei Wang, 2018/12/11
- [Qemu-devel] [PATCH v11 6/7] migration/ram.c: add the free page optimization enable flag, Wei Wang, 2018/12/11
- [Qemu-devel] [PATCH v11 7/7] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT, Wei Wang, 2018/12/11