From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH kvm-unit-test 2/6] Introduce atomic operations Date: Sun, 29 Aug 2010 12:39:46 +0300 Message-ID: <4C7A2AE2.9010800@redhat.com> References: <20100827054733.7409.63882.stgit@FreeLancer> <20100827054920.7409.41514.stgit@FreeLancer> <20100827113930.GN2985@mothafucka.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Jason Wang , mtosatti@redhat.com, kvm@vger.kernel.org To: Glauber Costa Return-path: Received: from mx1.redhat.com ([209.132.183.28]:48663 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752524Ab0H2Jjs (ORCPT ); Sun, 29 Aug 2010 05:39:48 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7T9dmGY015736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 29 Aug 2010 05:39:48 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7T9dkfm005555 for ; Sun, 29 Aug 2010 05:39:47 -0400 In-Reply-To: <20100827113930.GN2985@mothafucka.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: 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