From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: Re: [PATCH kvm-unit-test 2/6] Introduce atomic operations Date: Fri, 27 Aug 2010 08:39:30 -0300 Message-ID: <20100827113930.GN2985@mothafucka.localdomain> References: <20100827054733.7409.63882.stgit@FreeLancer> <20100827054920.7409.41514.stgit@FreeLancer> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: mtosatti@redhat.com, avi@redhat.com, kvm@vger.kernel.org To: Jason Wang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:26113 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751549Ab0H0Ljd (ORCPT ); Fri, 27 Aug 2010 07:39:33 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7RBdW8r014714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 27 Aug 2010 07:39:32 -0400 Content-Disposition: inline In-Reply-To: <20100827054920.7409.41514.stgit@FreeLancer> Sender: kvm-owner@vger.kernel.org List-ID: 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?