Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3239395ybf; Tue, 3 Mar 2020 02:13:05 -0800 (PST) X-Google-Smtp-Source: ADFU+vs37wLaPSjNaR5MlkV1jOiii5H5SoPoxDzS1wIYVRLr5AF/z0+sAk+ci3JwuFf408npYQo5 X-Received: by 2002:a9d:76d6:: with SMTP id p22mr2871248otl.37.1583230385559; Tue, 03 Mar 2020 02:13:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583230385; cv=none; d=google.com; s=arc-20160816; b=mAKtfDvrqeCNQexlVWWPzjddSgosrEaX5aH97X9Ki3Ux3AeEjhhuuO6jBKiUCKWche Be7x6plhAbjUbuv/vREHfz7mk140RTkAqRIfurhMEOV/8E5aT0FfDV/4o5C74iUKxbeg 90WvR4s/GwdeunbaVMrYgRky7CbbYefyFBBna8ERAITDpO74OiLixZ9KDpq+0Qm4oQzm S1Qjm+3TF8As+KaKjYb3VntZvOOE3ON29DVKDbI9Rhrl5F3JBB5XG++fdjfrxcUuoIdF 5eLRQLmvvVSKikvNzDfkWqVmHlLFnfFzdL1647a9NaUSWIz9xri1lrAbXIQQqpDBI5KT axVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=QFxG9RCA40BrkjxxC1U2JfSdDk/sXGRl4lMZI+3OtTI=; b=jW0/DSDNBbkeu4L3oquCWdgchzwmVvosLHU7+l+XmcWcR0wB5eY0WUQTwHDGGYEr3s ffwMZwpOzPvG3FBdaT8INQ7dM+ONnuRGkiYklZ+Lp1ayjZboqgdjAC52I3aVKSC7E4rh AJ2qLptkA8BpTjB67c3tCOY6AbV4khSUdTWUzyvl+PHkafR1mbks3Xoz46UJxQeunFqp Xh5FQMbNsL/UM9ONFqqPOzYIU/ryd8Qo6aXJFm1pALzqLtchJQE3jA0yYyMj5Gdwl9F5 uv4EQ0b7YoFq9acnWvKD+P9p3tTXH1kZuLGEAapeCH78P5zDfZiDSvHDCTiar2qPJeqV Pt+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m82si7776900oig.129.2020.03.03.02.12.52; Tue, 03 Mar 2020 02:13:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728423AbgCCKMD (ORCPT + 99 others); Tue, 3 Mar 2020 05:12:03 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40527 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbgCCKMD (ORCPT ); Tue, 3 Mar 2020 05:12:03 -0500 Received: by mail-ed1-f67.google.com with SMTP id p3so3593896edx.7 for ; Tue, 03 Mar 2020 02:12:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QFxG9RCA40BrkjxxC1U2JfSdDk/sXGRl4lMZI+3OtTI=; b=O3/YTyt61C3Z9YYiUKN2u/7coX7iu23nwTHvU6CcU/XmNl56JSNKteQGqwkzUovKF0 NefUssP8KNC98fpS+/VehkaYdG9A7xUjOxrALLQoxL6ZmCI352nNi7+UIWNh03KD9FGn tB4ilL5QmIdYl/nutenu28RGJaF+41d27IzaKzDOQIs79cikyhMPmfZ00vHsE+sMFQ3s gc8BjRsWsf0hXfktvwiphbocqXoxZgXw69TcZnMRDau7udIW7ZSnC4WYOOBANOifsyAn ws3sJzPBzJ1CN/6LxN1b9R2S58904q3elGuaHBYLyG4NPaK7GGMl343ACYAsJ+lDXARp Zs6w== X-Gm-Message-State: ANhLgQ36r7/vlvM0yrNXO9UjZ/cpCARUAW4C27ZZecqaR3iysjBkDTKV pEfeHuZWDEQ57fhgR4XHFCE= X-Received: by 2002:a50:ec89:: with SMTP id e9mr3297178edr.123.1583230321762; Tue, 03 Mar 2020 02:12:01 -0800 (PST) Received: from a483e7b01a66.ant.amazon.com (54-240-197-230.amazon.com. [54.240.197.230]) by smtp.gmail.com with ESMTPSA id by19sm635002ejc.85.2020.03.03.02.12.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Mar 2020 02:12:00 -0800 (PST) Subject: Re: [Xen-devel] [PATCH 2/2] xenbus: req->err should be updated before req->state To: Dongli Zhang , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: jgross@suse.com, boris.ostrovsky@oracle.com, sstabellini@kernel.org, joe.jin@oracle.com References: <20200303015859.18813-1-dongli.zhang@oracle.com> <20200303015859.18813-2-dongli.zhang@oracle.com> From: Julien Grall Message-ID: <4c2594c8-9146-fbd9-6074-9c8366afb391@xen.org> Date: Tue, 3 Mar 2020 10:11:59 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200303015859.18813-2-dongli.zhang@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 03/03/2020 01:58, Dongli Zhang wrote: > This patch adds the barrier to guarantee that req->err is always updated > before req->state. > > Otherwise, read_reply() would not return ERR_PTR(req->err) but > req->body, when process_writes()->xb_write() is failed. The memory barrier below looks good. However, as mentionned in patch #1, barrier() is not the correct barrier to pair with virt_wmb(). > > Signed-off-by: Dongli Zhang > --- > drivers/xen/xenbus/xenbus_comms.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/xen/xenbus/xenbus_comms.c b/drivers/xen/xenbus/xenbus_comms.c > index 852ed161fc2a..eb5151fc8efa 100644 > --- a/drivers/xen/xenbus/xenbus_comms.c > +++ b/drivers/xen/xenbus/xenbus_comms.c > @@ -397,6 +397,8 @@ static int process_writes(void) > if (state.req->state == xb_req_state_aborted) > kfree(state.req); > else { > + /* write err, then update state */ > + virt_wmb(); > state.req->state = xb_req_state_got_reply; > wake_up(&state.req->wq); > } > Cheers, -- Julien Grall