From patchwork Mon Jul 18 17:22:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9234975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BA79560756 for ; Mon, 18 Jul 2016 18:00:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF399205AF for ; Mon, 18 Jul 2016 18:00:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A40EB20748; Mon, 18 Jul 2016 18:00:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 23417205AF for ; Mon, 18 Jul 2016 18:00:40 +0000 (UTC) Received: from localhost ([::1]:49494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPCqM-0006zw-PA for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Jul 2016 14:00:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPCFE-0007Xb-Cl for qemu-devel@nongnu.org; Mon, 18 Jul 2016 13:22:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPCFA-0002zj-4x for qemu-devel@nongnu.org; Mon, 18 Jul 2016 13:22:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPCF9-0002zf-Uy for qemu-devel@nongnu.org; Mon, 18 Jul 2016 13:22:12 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5000E44810; Mon, 18 Jul 2016 17:22:11 +0000 (UTC) Received: from [10.36.112.45] (ovpn-112-45.ams2.redhat.com [10.36.112.45]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6IHM8Y9003304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 18 Jul 2016 13:22:10 -0400 To: Sergey Fedorov , qemu-devel@nongnu.org References: <1468851450-9863-1-git-send-email-pbonzini@redhat.com> <578D0938.2050004@gmail.com> <578D0A60.4020608@gmail.com> <8c52110d-c009-087c-be04-3920d97af323@redhat.com> <578D0CD6.3080005@gmail.com> <4c479cb3-a8ef-caab-4dbc-3bfd014c7a0a@redhat.com> <578D0F42.4040203@gmail.com> From: Paolo Bonzini Message-ID: <84ba6ace-e0bd-515a-5194-2e6704d22805@redhat.com> Date: Mon, 18 Jul 2016 19:22:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <578D0F42.4040203@gmail.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 18 Jul 2016 17:22:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH] atomics: add volatile_read/volatile_set X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, sergey.fedorov@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 18/07/2016 19:17, Sergey Fedorov wrote: > On 18/07/16 20:11, Paolo Bonzini wrote: >> >> On 18/07/2016 19:07, Sergey Fedorov wrote: >>> On 18/07/16 20:00, Paolo Bonzini wrote: >>>> On 18/07/2016 18:57, Sergey Fedorov wrote: >>>>> On 18/07/16 19:53, Paolo Bonzini wrote: >>>>>> On 18/07/2016 18:52, Sergey Fedorov wrote: >>>>>>> So how are we going to use them? >>>>>> Instead of atomic_read/atomic_set when marking invalid TBs. >>>>> But shouldn't they be atomic to avoid reading torn writes? >>>> A torn write would probably fail to match anyway, but even if it doesn't >>>> it is indistinguishable from a race, isn't it? >>> I'm afraid, torn write can happen to be a false match against a wrong >>> TB. In case of a race with atomic access we either get the right TB or >>> an invalid one which couldn't match any valid CPU state. Probably, we >>> have to make sure (and document this) that TB invalidation process >>> cannot make a partially invalidated TB which can match any meaningful >>> CPU state. >> x86 is atomic (because flags are 32-bit); those that have cs_base==0 are >> safe against torn writes too. Only SPARC perhaps could use >> "tb->cs_base|=1" instead in case 0xffffffff........ matches another TB. > > That could really work but needs some comment, of course. Yup. A simpler possibility is this: I'll send a fixup patch now, ack it and I'll send another pull request. :) > BTW, what is > the main point of such change? A bit more performance on some 32-bit hosts? No, succeeding to compile on 32-bit hosts. :) diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index e327a35..3278d8a 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -753,14 +753,14 @@ static inline void cpu_get_invalid_tb_cpu_state(target_ulong *pc, target_ulong *cs_base, uint32_t *flags) { - *cs_base = -1; /* npc must be a multible of 4 */ + *flags = TB_FLAG_MMU_MASK; } static inline bool cpu_tb_cpu_state_is_invalidated(target_ulong pc, target_ulong cs_base, uint32_t flags) { - return cs_base == -1; + return flags == TB_FLAG_MMU_MASK; } static inline bool tb_fpu_enabled(int tb_flags)