diff mbox

[RFC,v3,07/13] ram_addr.h: Make exclusive bitmap accessors atomic

Message ID 1436516626-8322-8-git-send-email-a.rigo@virtualopensystems.com
State New
Headers show

Commit Message

Alvise Rigo July 10, 2015, 8:23 a.m. UTC
Suggested-by: Jani Kokkonen <jani.kokkonen@huawei.com>
Suggested-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Alvise Rigo <a.rigo@virtualopensystems.com>
---
 include/exec/ram_addr.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alex Bennée July 17, 2015, 1:32 p.m. UTC | #1
Alvise Rigo <a.rigo@virtualopensystems.com> writes:

> Suggested-by: Jani Kokkonen <jani.kokkonen@huawei.com>
> Suggested-by: Claudio Fontana <claudio.fontana@huawei.com>
> Signed-off-by: Alvise Rigo <a.rigo@virtualopensystems.com>
> ---
>  include/exec/ram_addr.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
> index 2766541..e51bd65 100644
> --- a/include/exec/ram_addr.h
> +++ b/include/exec/ram_addr.h
> @@ -255,7 +255,7 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest,
>  /* Exclusive bitmap accessors. */
>  static inline void cpu_physical_memory_set_excl_dirty(ram_addr_t addr)
>  {
> -    set_bit(addr >> TARGET_PAGE_BITS,
> +    set_bit_atomic(addr >> TARGET_PAGE_BITS,
>              ram_list.dirty_memory[DIRTY_MEMORY_EXCLUSIVE]);
>  }
>  
> @@ -267,8 +267,8 @@ static inline int cpu_physical_memory_excl_is_dirty(ram_addr_t addr)
>  
>  static inline void cpu_physical_memory_clear_excl_dirty(ram_addr_t addr)
>  {
> -    clear_bit(addr >> TARGET_PAGE_BITS,
> -              ram_list.dirty_memory[DIRTY_MEMORY_EXCLUSIVE]);
> +    bitmap_test_and_clear_atomic(ram_list.dirty_memory[DIRTY_MEMORY_EXCLUSIVE],
> +                                 addr >> TARGET_PAGE_BITS, 1);

Does this call for simply implementing a clear_bit_atomic() rather than
the fancy bitmap_test_and_clear_atomic. Looking at atomic.h it seems the
primitives you need are there.

>  }
>  
>  #endif
diff mbox

Patch

diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 2766541..e51bd65 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -255,7 +255,7 @@  uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest,
 /* Exclusive bitmap accessors. */
 static inline void cpu_physical_memory_set_excl_dirty(ram_addr_t addr)
 {
-    set_bit(addr >> TARGET_PAGE_BITS,
+    set_bit_atomic(addr >> TARGET_PAGE_BITS,
             ram_list.dirty_memory[DIRTY_MEMORY_EXCLUSIVE]);
 }
 
@@ -267,8 +267,8 @@  static inline int cpu_physical_memory_excl_is_dirty(ram_addr_t addr)
 
 static inline void cpu_physical_memory_clear_excl_dirty(ram_addr_t addr)
 {
-    clear_bit(addr >> TARGET_PAGE_BITS,
-              ram_list.dirty_memory[DIRTY_MEMORY_EXCLUSIVE]);
+    bitmap_test_and_clear_atomic(ram_list.dirty_memory[DIRTY_MEMORY_EXCLUSIVE],
+                                 addr >> TARGET_PAGE_BITS, 1);
 }
 
 #endif