[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [QEMU 5/7] bitmap: Add a new bitmap_move function
From: |
Liang Li |
Subject: |
[Qemu-devel] [QEMU 5/7] bitmap: Add a new bitmap_move function |
Date: |
Mon, 13 Jun 2016 18:16:47 +0800 |
Sometimes, it is need to move a portion of bitmap to another place
in a large bitmap, if overlap happens, the bitmap_copy can't not
work correctly, we need a new function to do this work.
Signed-off-by: Liang Li <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 ec5146f..6ac89ca 100644
--- a/include/qemu/bitmap.h
+++ b/include/qemu/bitmap.h
@@ -37,6 +37,7 @@
* bitmap_set(dst, pos, nbits) Set specified bit area
* bitmap_set_atomic(dst, pos, nbits) Set specified bit area with atomic ops
* bitmap_clear(dst, pos, nbits) Clear specified bit area
+ * bitmap_move(dst, src, nbits) Move *src to *dst
* bitmap_test_and_clear_atomic(dst, pos, nbits) Test and clear area
* bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area
*/
@@ -136,6 +137,18 @@ static inline void bitmap_copy(unsigned long *dst, const
unsigned long *src,
}
}
+static inline void bitmap_move(unsigned long *dst, const unsigned long *src,
+ long nbits)
+{
+ if (small_nbits(nbits)) {
+ unsigned long tmp = *src;
+ *dst = tmp;
+ } else {
+ long len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+ memmove(dst, src, len);
+ }
+}
+
static inline int bitmap_and(unsigned long *dst, const unsigned long *src1,
const unsigned long *src2, long nbits)
{
--
1.9.1
- [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache, (continued)
- [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache, Liang Li, 2016/06/13
- Re: [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache, Li, Liang Z, 2016/06/13
- Re: [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache, Dr. David Alan Gilbert, 2016/06/13
- Re: [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache, Li, Liang Z, 2016/06/13
- Re: [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache, Li, Liang Z, 2016/06/16
[Qemu-devel] [QEMU 5/7] bitmap: Add a new bitmap_move function,
Liang Li <=
[Qemu-devel] [QEMU 6/7] kvm: Add two new arch specific functions, Liang Li, 2016/06/13
[Qemu-devel] [QEMU 7/7] migration: skip free pages during live migration, Liang Li, 2016/06/13