On 9/13/23 07:47, Helge Deller wrote:
+        haddr = (uint32_t *)((uintptr_t)vaddr);
+        old = *haddr;

This is horribly incorrect, both for user-only and system mode.

+        /* if already zero, do not write 0 again to reduce memory presssure */
+        if (old == 0) {
+            return 0;
+        }
+        old = qatomic_xchg(haddr, (uint32_t) 0);

You're also dropping the required host memory barrier.

Frankly, the current tcg_gen_atomic_xchg_reg is as optimized as you'll be able to do. I really doubt the "avoid write 0" is measurable at all.


r~

Reply via email to