From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E47E7C2D0E4 for ; Fri, 27 Nov 2020 15:37:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E2CF20795 for ; Fri, 27 Nov 2020 15:37:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="rXv2Th4+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E2CF20795 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.39602.72546 (Exim 4.92) (envelope-from ) id 1kifnu-0006m0-Gz; Fri, 27 Nov 2020 15:36:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 39602.72546; Fri, 27 Nov 2020 15:36:58 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kifnu-0006lt-E2; Fri, 27 Nov 2020 15:36:58 +0000 Received: by outflank-mailman (input) for mailman id 39602; Fri, 27 Nov 2020 15:36:57 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kifnt-0006lo-TO for xen-devel@lists.xenproject.org; Fri, 27 Nov 2020 15:36:57 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a9943034-007d-4868-b3b2-a216d844de95; Fri, 27 Nov 2020 15:36:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 13F1FAC2D; Fri, 27 Nov 2020 15:36:56 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kifnt-0006lo-TO for xen-devel@lists.xenproject.org; Fri, 27 Nov 2020 15:36:57 +0000 X-Inumbo-ID: a9943034-007d-4868-b3b2-a216d844de95 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a9943034-007d-4868-b3b2-a216d844de95; Fri, 27 Nov 2020 15:36:56 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606491416; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yqCTdveuLnQeOaDXC6rinMP4mldrQaHAOhubivwehf8=; b=rXv2Th4+nR8dQizFX3ytSjb7V6be1qh9f3nb72l2JkDjiLVDjM+J5xWX3ORRP2d9MqhmQV Eb41dvH6qlqICs76QmsbYQU5+ZZdwv9ViiDyuecYF2ga7ywcf44dAr0vFw2QAHi288Z0jL 5Ns0pph3VArvqDAItNv9MTe2zio4LoA= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 13F1FAC2D; Fri, 27 Nov 2020 15:36:56 +0000 (UTC) Subject: Re: [PATCH v8 3/3] xen/events: do some cleanups in evtchn_fifo_set_pending() To: Julien Grall Cc: Andrew Cooper , George Dunlap , Ian Jackson , Stefano Stabellini , Wei Liu , xen-devel@lists.xenproject.org, =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= References: <20201125105122.3650-1-jgross@suse.com> <20201125105122.3650-4-jgross@suse.com> <0ab6f8b5-1a9a-845e-3935-a660e5c7fc16@xen.org> <29c8daf7-8af4-df16-716e-113bcc3e96a1@suse.com> <7e4f42a5-4ab6-8aac-c8d9-95403c90dc4b@xen.org> From: Jan Beulich Message-ID: <4de58d09-dbcb-fcb8-0761-fc464428a7c3@suse.com> Date: Fri, 27 Nov 2020 16:36:57 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <7e4f42a5-4ab6-8aac-c8d9-95403c90dc4b@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 27.11.2020 16:17, Julien Grall wrote: > > > On 27/11/2020 14:48, Jan Beulich wrote: >> On 27.11.2020 15:39, Jürgen Groß wrote: >>> On 27.11.20 15:23, Julien Grall wrote: >>>> On 25/11/2020 10:51, Juergen Gross wrote: >>>>> --- a/xen/common/event_fifo.c >>>>> +++ b/xen/common/event_fifo.c >>>>> @@ -175,6 +175,18 @@ static void evtchn_fifo_set_pending(struct vcpu >>>>> *v, struct evtchn *evtchn) >>>>>           return; >>>>>       } >>>>> +    /* >>>>> +     * Control block not mapped.  The guest must not unmask an >>>>> +     * event until the control block is initialized, so we can >>>>> +     * just drop the event. >>>>> +     */ >>>>> +    if ( unlikely(!v->evtchn_fifo->control_block) ) >>>> >>>> Sort of unrelated, AFAICT, v->evtchn_fifo->control_block can be set >>>> concurrently to this access. >>>> >>>> Thankfully, once the control block is mapped, it can't be unmapped. >>>> However, there is still a possibility that you may see half of the update. >>>> >>>> Shouldn't the field access with ACCESS_ONCE()? >>> >>> Shouldn't this be another patch? Especially as the writing side needs >>> the same treatment. >> >> Indeed. As said on several different occasions - our code base is >> full of places where we chance torn accesses, if there really was >> a compiler to let us down on this. > > I am quite amazed you that you managed to test all the version of > GCC/Clang that were built and confirm this is unlikely to happen :). It's (obviously) not that I tested all of them, but that I know at least a little bit of how gcc generates code, that I'm unaware of reports to the contrary, and that it would seem odd for a compiler to split accesses when they can be done by one insn. Of course one could build a compiler doing only byte accesses ... >> This recurring pattern >> shouldn't lead to unrelated patches getting bloated, unless _all_ >> affected sites get touched anyway. > > You probably missed the point where I say "sort of unrelated". This > wasn't not a suggestion to fix it here (I should have been clearer > though) but instead point out issue as I see them. Point taken. Jan