[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 1/5] bitmap: bitmap_count_one_with_offset
From: |
Wei Wang |
Subject: |
[Qemu-devel] [PATCH v5 1/5] bitmap: bitmap_count_one_with_offset |
Date: |
Fri, 16 Mar 2018 18:48:25 +0800 |
Count the number of 1s in a bitmap starting from an offset.
Signed-off-by: Wei Wang <address@hidden>
CC: Dr. David Alan Gilbert <address@hidden>
CC: Juan Quintela <address@hidden>
CC: Michael S. Tsirkin <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
---
include/qemu/bitmap.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
index 509eedd..e3f31f1 100644
--- a/include/qemu/bitmap.h
+++ b/include/qemu/bitmap.h
@@ -228,6 +228,19 @@ static inline long bitmap_count_one(const unsigned long
*bitmap, long nbits)
}
}
+static inline long bitmap_count_one_with_offset(const unsigned long *bitmap,
+ long offset, long nbits)
+{
+ long aligned_offset = QEMU_ALIGN_DOWN(offset, BITS_PER_LONG);
+ long redundant_bits = offset - aligned_offset;
+ long bits_to_count = nbits + redundant_bits;
+ const unsigned long *bitmap_start = bitmap +
+ aligned_offset / BITS_PER_LONG;
+
+ return bitmap_count_one(bitmap_start, bits_to_count) -
+ bitmap_count_one(bitmap_start, redundant_bits);
+}
+
void bitmap_set(unsigned long *map, long i, long len);
void bitmap_set_atomic(unsigned long *map, long i, long len);
void bitmap_clear(unsigned long *map, long start, long nr);
--
1.8.3.1
- [Qemu-devel] [PATCH v5 0/5] virtio-balloon: free page hint reporting support, Wei Wang, 2018/03/16
- [Qemu-devel] [PATCH v5 1/5] bitmap: bitmap_count_one_with_offset,
Wei Wang <=
- [Qemu-devel] [PATCH v5 5/5] migration: use the free page hint feature from balloon, Wei Wang, 2018/03/16
- [Qemu-devel] [PATCH v5 2/5] migration: use bitmap_mutex in migration_bitmap_clear_dirty, Wei Wang, 2018/03/16
- [Qemu-devel] [PATCH v5 3/5] migration: API to clear bits of guest free pages from the dirty bitmap, Wei Wang, 2018/03/16
- [Qemu-devel] [PATCH v5 4/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT, Wei Wang, 2018/03/16
- Re: [Qemu-devel] [PATCH v5 4/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT, Michael S. Tsirkin, 2018/03/16
- Re: [Qemu-devel] [PATCH v5 4/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT, Wei Wang, 2018/03/18
- Re: [Qemu-devel] [PATCH v5 4/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT, Michael S. Tsirkin, 2018/03/19
- Re: [Qemu-devel] [virtio-dev] Re: [PATCH v5 4/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT, Wei Wang, 2018/03/19
- Re: [Qemu-devel] [virtio-dev] Re: [PATCH v5 4/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT, Michael S. Tsirkin, 2018/03/19
- Re: [Qemu-devel] [virtio-dev] Re: [PATCH v5 4/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT, Wei Wang, 2018/03/19