Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6302619ybl; Mon, 23 Dec 2019 03:47:21 -0800 (PST) X-Google-Smtp-Source: APXvYqwIvGuCEjuqsKHcUuqUdLvdjyDv209aM7DMuF22MVhFrfebETL7r57phZn2nSP6T38bSINO X-Received: by 2002:a9d:590b:: with SMTP id t11mr32772939oth.161.1577101641827; Mon, 23 Dec 2019 03:47:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577101641; cv=none; d=google.com; s=arc-20160816; b=OMYh5qykfYsi5wysQ9axJ30H34FCkV12rg+hAV3GoOzMJXWbuMfvm8Ir6nvK/1zDT2 IJqMBxweuv1hs1veHQ2D8sbKQInyknCL/rPfWcB499hfC4BJFy3DBNK2VzTZlOgcTY5q ayVUbW88Q+S+SOEYvLb0oIg2VPr8+i+KCYMdWSTgDnNq6/aBH/QYzD2v+RzZ1QMEXvd/ cOsLZqja6eFcuVtynPvF3KLOSkafX7+eexoiucW6v83o3EzClZljpIy0nuLCCQuAEXCT ofFPPmvQ4F4P/qGrkGpDd1D7o/g8NmFMYiMLlJkJTqaKgnU0m7MMOJUDiMXWtBS65lPq Ew/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:ironport-sdr :dkim-signature; bh=vvmp92KNUpBEgXRjRfQ+MICqzu1qMXT+80kMSZKetok=; b=oRsC+VzYwqqstvzSwQUO9LebwWfN6W95iKTi2GRzMs2kRHW2etrSvVDw3tfWXmBEHZ aaNC3ztgJeER2lezEVtRQC1r+60fyaJ05pOYQsm1HH5xy9wuAYV8K0SOQpfsCWtbAV0K 09ZBm3zGcRKWeic6jkSp1WrTmf12u1I8bPcxvvBgx7Rb6Bu4AmuETjdjhdga6gyoqIu9 MO2GParthjBZ3qd+A9M2+w4G0u6i4DYR2A24pekVzsAzoYxoZF7OYCUL+M/U6j7ypt3u 5eJqN7osyqivLgGm7Ha2GYtPEnNvnggA6ncDrjsKlFxLGuKhng7VrofuCLsD5GFX+Mfp cQxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=RZW9Py3q; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si3278611otz.198.2019.12.23.03.47.10; Mon, 23 Dec 2019 03:47:21 -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; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=RZW9Py3q; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbfLWLqe (ORCPT + 99 others); Mon, 23 Dec 2019 06:46:34 -0500 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:18754 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726257AbfLWLqe (ORCPT ); Mon, 23 Dec 2019 06:46:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1577101593; x=1608637593; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=vvmp92KNUpBEgXRjRfQ+MICqzu1qMXT+80kMSZKetok=; b=RZW9Py3q1sMRx2fvzBMpOvftnXSo81qErb5ABgPl+oRDP9t8NhXWApz2 Q8F6t/xTfHT8SxKkqfDJRWZoSSj73vHx32YEca4m+MMyUEsRnrM/4+ANe SN5o3jTi/ySnfJgxaverB1KgHnaH33qGUMj4Hv18UGO9ayXEc3vcUGlPk 8=; IronPort-SDR: bYFdawsqLJaf///3+Xmev8apsMjp4iYZk+WyLjr5J5nVgZ60Q04Yv7ot07mFMeKy50f3Bvfqg2 YdpJMNxOkl2g== X-IronPort-AV: E=Sophos;i="5.69,347,1571702400"; d="scan'208";a="9790850" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 23 Dec 2019 11:46:31 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com (Postfix) with ESMTPS id 6C2C1A27B1; Mon, 23 Dec 2019 11:46:31 +0000 (UTC) Received: from EX13D32EUC002.ant.amazon.com (10.43.164.94) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Mon, 23 Dec 2019 11:46:30 +0000 Received: from EX13D32EUC003.ant.amazon.com (10.43.164.24) by EX13D32EUC002.ant.amazon.com (10.43.164.94) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 23 Dec 2019 11:46:29 +0000 Received: from EX13D32EUC003.ant.amazon.com ([10.43.164.24]) by EX13D32EUC003.ant.amazon.com ([10.43.164.24]) with mapi id 15.00.1367.000; Mon, 23 Dec 2019 11:46:29 +0000 From: "Durrant, Paul" To: Wei Liu CC: "xen-devel@lists.xenproject.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Paul Durrant , "David S. Miller" Subject: RE: [PATCH net-next] xen-netback: support dynamic unbind/bind Thread-Topic: [PATCH net-next] xen-netback: support dynamic unbind/bind Thread-Index: AQHVuXeo48GmlxuNH0abtWhDKbfEbafHl0uAgAACIOA= Date: Mon, 23 Dec 2019 11:46:29 +0000 Message-ID: <1d1189a3acd8473fadc420d902fd4692@EX13D32EUC003.ant.amazon.com> References: <20191223095923.2458-1-pdurrant@amazon.com> <20191223113545.nwugg7lsorttunuu@debian> In-Reply-To: <20191223113545.nwugg7lsorttunuu@debian> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.43.165.29] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Wei Liu > Sent: 23 December 2019 11:36 > To: Durrant, Paul > Cc: xen-devel@lists.xenproject.org; netdev@vger.kernel.org; linux- > kernel@vger.kernel.org; Wei Liu ; Paul Durrant > ; David S. Miller > Subject: Re: [PATCH net-next] xen-netback: support dynamic unbind/bind >=20 > On Mon, Dec 23, 2019 at 09:59:23AM +0000, Paul Durrant wrote: > [...] > > diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen- > netback/interface.c > > index f15ba3de6195..0c8a02a1ead7 100644 > > --- a/drivers/net/xen-netback/interface.c > > +++ b/drivers/net/xen-netback/interface.c > > @@ -585,6 +585,7 @@ int xenvif_connect_ctrl(struct xenvif *vif, > grant_ref_t ring_ref, > > struct net_device *dev =3D vif->dev; > > void *addr; > > struct xen_netif_ctrl_sring *shared; > > + RING_IDX rsp_prod, req_prod; > > int err; > > > > err =3D xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif), > > @@ -593,7 +594,14 @@ int xenvif_connect_ctrl(struct xenvif *vif, > grant_ref_t ring_ref, > > goto err; > > > > shared =3D (struct xen_netif_ctrl_sring *)addr; > > - BACK_RING_INIT(&vif->ctrl, shared, XEN_PAGE_SIZE); > > + rsp_prod =3D READ_ONCE(shared->rsp_prod); > > + req_prod =3D READ_ONCE(shared->req_prod); > > + > > + BACK_RING_ATTACH(&vif->ctrl, shared, rsp_prod, XEN_PAGE_SIZE); > > + > > + err =3D -EIO; > > + if (req_prod - rsp_prod > RING_SIZE(&vif->ctrl)) > > + goto err_unmap; >=20 > I think it makes more sense to attach the ring after this check has been > done, but I can see you want to structure code like this to reuse the > unmap error path. Looks a little odd, agreed. The reason I did it this way is so that I can u= se RING_SIZE() rather than having to use __RING_SIZE(); makes the code just= a little bit shorter... which reminds me I ought to neaten up blkback simi= larly. >=20 > So: >=20 > Reviewed-by: Wei Liu >=20 > Nice work btw. Thanks :-) Paul