[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/9] bitmap: add bitmap_copy_and_clear_atomic
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 1/9] bitmap: add bitmap_copy_and_clear_atomic |
Date: |
Fri, 21 Apr 2017 11:16:24 +0200 |
Signed-off-by: Gerd Hoffmann <address@hidden>
---
include/qemu/bitmap.h | 2 ++
util/bitmap.c | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
index 63ea2d0b1e..c318da12d7 100644
--- a/include/qemu/bitmap.h
+++ b/include/qemu/bitmap.h
@@ -220,6 +220,8 @@ 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);
bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr);
+void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src,
+ long nr);
unsigned long bitmap_find_next_zero_area(unsigned long *map,
unsigned long size,
unsigned long start,
diff --git a/util/bitmap.c b/util/bitmap.c
index c1a84ca5e3..efced9a7d8 100644
--- a/util/bitmap.c
+++ b/util/bitmap.c
@@ -287,6 +287,17 @@ bool bitmap_test_and_clear_atomic(unsigned long *map, long
start, long nr)
return dirty != 0;
}
+void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src,
+ long nr)
+{
+ while (nr > 0) {
+ *dst = atomic_xchg(src, 0);
+ dst++;
+ src++;
+ nr -= BITS_PER_LONG;
+ }
+}
+
#define ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
/**
--
2.9.3
- [Qemu-devel] [PATCH 0/9] hw/display: make display updates thread safe, part 1, Gerd Hoffmann, 2017/04/21
- [Qemu-devel] [PATCH 2/9] memory: add support getting and using a dirty bitmap copy., Gerd Hoffmann, 2017/04/21
- [Qemu-devel] [PATCH 4/9] vga: make display updates thread safe., Gerd Hoffmann, 2017/04/21
- [Qemu-devel] [PATCH 1/9] bitmap: add bitmap_copy_and_clear_atomic,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 3/9] vga: add vga_scanline_invalidated helper, Gerd Hoffmann, 2017/04/21
- [Qemu-devel] [PATCH 5/9] framebuffer: make display updates thread safe, Gerd Hoffmann, 2017/04/21
- [Qemu-devel] [PATCH 6/9] exynos: make display updates thread safe, Gerd Hoffmann, 2017/04/21
- Re: [Qemu-devel] [PATCH 0/9] hw/display: make display updates thread safe, part 1, Mark Cave-Ayland, 2017/04/21