vhost: avoid concurrency when logging dirty pages
[dpdk.git] / lib / librte_vhost / vhost.h
index 58aec2e..7ca2a03 100644 (file)
@@ -247,18 +247,14 @@ struct virtio_net {
 #define VHOST_LOG_PAGE 4096
 
 /*
- * Atomically set a bit in memory.
+ * Mark all pages belonging to the same dirty log bitmap byte
+ * as dirty. The goal is to avoid concurrency between different
+ * threads doing atomic read-modify-writes on the same byte.
  */
-static __rte_always_inline void
-vhost_set_bit(unsigned int nr, volatile uint8_t *addr)
-{
-       __sync_fetch_and_or_8(addr, (1U << nr));
-}
-
 static __rte_always_inline void
 vhost_log_page(uint8_t *log_base, uint64_t page)
 {
-       vhost_set_bit(page % 8, &log_base[page / 8]);
+       log_base[page / 8] = 0xff;
 }
 
 static __rte_always_inline void