Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3936191pxb; Mon, 8 Feb 2021 04:04:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyphZEWEGcmudkeMsYq4d4lkcL1gyClpdgOwIDg+57NAgH8yv86DboixpPQ2loSt8JERNQ7 X-Received: by 2002:a17:906:35cf:: with SMTP id p15mr5519460ejb.20.1612785864814; Mon, 08 Feb 2021 04:04:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612785864; cv=none; d=google.com; s=arc-20160816; b=sxDZ0ek53g7EW/SvialPw6lt1y0Wg3f1xMXgVahz8sgqCFWC5sQfDwX1az6h7zXGbJ JMqKbwxOu1sK8SabK/Oz6MI6Oi+Mh8jfnVi9Fh9Cuxbe7zmPO21C6YgQ48jH+9tWaWjQ rsmP1MMiXZG7JkGZygzRSkRpksExOf9vb2HPvNX6FlBxD24huKhVRXHXc5rzLzr+ThAQ 8agMzp0wVcqXdx3uqk2ALTjom8hbRSc1MvhgCwwOWQ7Onxj13aT5i1N40G95pb6n3AX6 LvPPkLj3JVKZvsrThsXR9dNMMwNxYRSx/RzwMkxetjz6A8wITTdtxk2npTuAIpkK5G0N OxhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=zGrVRyh4Bb806FG6nBatBhxLklpw43eAz07n9qXefLM=; b=A5BSEKvTXcaLjxkeN9MA/fS2xz40bkRqLjGxb5mh958RdiwOQv3zdil2LeKpfnJt0Q 4RXej7ZO5ZM/431cCraVm/PyGWkoy8X0OyEUFL4gvdCDNWm7i5qSwgDfFVVfuQM9cctj Jk/3zZusuS21eW33Uk9z9IWLl1ZHfcCqpuHbUm+UcP+V9na1mRaIFmmf9Gg+j42cgpa5 lSnvM+OXApNQxQIoigLPdCXWvt0aVwN1iWCFtWLIUnT8EBkOOXN0abzxO3zKh1AR295v g/POojGoaB8JqLOfK5hIE3Oy2MJiuqP0zjGgLcqqL9S8019iYKT3wyA6DRogucgfCNfR LERg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=xB+0y4mG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si1715947edx.217.2021.02.08.04.03.59; Mon, 08 Feb 2021 04:04:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=xB+0y4mG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233585AbhBHMDP (ORCPT + 99 others); Mon, 8 Feb 2021 07:03:15 -0500 Received: from mail.xenproject.org ([104.130.215.37]:50458 "EHLO mail.xenproject.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233295AbhBHLlR (ORCPT ); Mon, 8 Feb 2021 06:41:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=zGrVRyh4Bb806FG6nBatBhxLklpw43eAz07n9qXefLM=; b=xB+0y4mG9nGyv+K0rMSe7assdJ Blahn0VgEg8Z2h3s3tSzkEDkVSLPk8YVcpox5SrzLQSMtLCND17pUY4746K1Rf/aCyLYeX05a6aBV LBMzMH6iJ7qhPg76qhe4KgSgnpBFn1GsWh29UzJj56x7WqovrDEFuHAPIWCJKjCGwgRQ=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l94u2-0002aq-Ul; Mon, 08 Feb 2021 11:40:26 +0000 Received: from [54.239.6.177] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l94u2-0000zS-Lb; Mon, 08 Feb 2021 11:40:26 +0000 Subject: Re: [PATCH 7/7] xen/evtchn: read producer index only once To: Juergen Gross , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Boris Ostrovsky , Stefano Stabellini References: <20210206104932.29064-1-jgross@suse.com> <20210206104932.29064-8-jgross@suse.com> From: Julien Grall Message-ID: <8032d8a9-b28f-95e1-a5a8-e955ada4dc0a@xen.org> Date: Mon, 8 Feb 2021 11:40:24 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210206104932.29064-8-jgross@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/02/2021 10:49, Juergen Gross wrote: > In evtchn_read() use READ_ONCE() for reading the producer index in > order to avoid the compiler generating multiple accesses. > > Signed-off-by: Juergen Gross > --- > drivers/xen/evtchn.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c > index 421382c73d88..f6b199b597bf 100644 > --- a/drivers/xen/evtchn.c > +++ b/drivers/xen/evtchn.c > @@ -211,7 +211,7 @@ static ssize_t evtchn_read(struct file *file, char __user *buf, > goto unlock_out; > > c = u->ring_cons; > - p = u->ring_prod; > + p = READ_ONCE(u->ring_prod); For consistency, don't you also need the write side in evtchn_interrupt() to use WRITE_ONCE()? > if (c != p) > break; > > -- Julien Grall