From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [kvm-unit-tests PATCH 1/2] arm/arm64: spinlock-test fixup Date: Mon, 6 Jul 2015 19:51:40 +0200 Message-ID: <559AC02C.7010707@redhat.com> References: <1436189485-21443-1-git-send-email-drjones@redhat.com> <1436189485-21443-2-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit To: Andrew Jones , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:32902 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752482AbbGFRvo (ORCPT ); Mon, 6 Jul 2015 13:51:44 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 23E4019CB94 for ; Mon, 6 Jul 2015 17:51:44 +0000 (UTC) In-Reply-To: <1436189485-21443-2-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/07/2015 15:31, Andrew Jones wrote: > + if (argc && strcmp(argv[0], "non-atomic") != 0) { You want == here, don't you? The reason I switched was that the non-atomic test didn't work for me. I have now debugged it, and it needs this: @@ -29,12 +29,12 @@ static void gcc_builtin_unlock(int *lock_var) } static void none_lock(int *lock_var) { - while (*lock_var != 0); - *lock_var = 1; + while (*(volatile int *)lock_var != 0); + *(volatile int *)lock_var = 1; } static void none_unlock(int *lock_var) { - *lock_var = 0; + *(volatile int *)lock_var = 0; } static int global_a, global_b; Otherwise the none_lock function does not reload lock_var. Paolo > lock_ops.lock = none_lock; > lock_ops.unlock = none_unlock; > + } else { > + lock_ops.lock = gcc_builtin_lock; > + lock_ops.unlock = gcc_builtin_unlock; > }