Re: [PATCH kvm-unit-test 2/6] Introduce atomic operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 On 08/27/2010 02:39 PM, Glauber Costa wrote:
On Fri, Aug 27, 2010 at 01:49:20PM +0800, Jason Wang wrote:
+u64 atomic64_cmpxchg(atomic64_t *v, u64 old, u64 new)
+{
+        u64 ret;
+        u64 _old = old;
+        u64 _new = new;
+
+        asm volatile("lock cmpxchgq %1,%2"
+                     : "=a" (ret)
+                     : "r" (_new),
+                       "m" (*(volatile long *)&v->counter), "0"(_old)
+                     : "memory"
+                     );
+        return ret;
+}
+
This is wrong.
See http://git.kernel.org/?p=linux/kernel/git/x86/linux-2.6-tip.git;a=commitdiff;h=113fc5a6e8c2288619ff7e8187a6f556b7e0d372

you need to explicitly mark you are changing the memory, here.

Btw, this is mostly header copying, and can miss bug fixes like the one above. Isn't there
a way to just specify in the test they are needed, and then grab them from linux automatically?

That may pull in dependencies. I'd prefer using builtins like __sync_val_compare_and_swap() (but many atomics are not available). Is there some library we can use for this?

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux