From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751109AbdKTLFh convert rfc822-to-8bit (ORCPT ); Mon, 20 Nov 2017 06:05:37 -0500 Received: from smtp.eu.citrix.com ([185.25.65.24]:53392 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbdKTLFf (ORCPT ); Mon, 20 Nov 2017 06:05:35 -0500 X-Greylist: delayed 578 seconds by postgrey-1.27 at vger.kernel.org; Mon, 20 Nov 2017 06:05:35 EST X-IronPort-AV: E=Sophos;i="5.44,426,1505779200"; d="scan'208";a="63484522" From: Paul Durrant To: "'Eduardo Otubo'" , "xen-devel@lists.xenproject.org" CC: "netdev@vger.kernel.org" , Wei Liu , "linux-kernel@vger.kernel.org" , "vkuznets@redhat.com" , "cavery@redhat.com" , "cheshi@redhat.com" , "mgamal@redhat.com" Subject: RE: [PATCH] xen-netfront: remove warning when unloading module Thread-Topic: [PATCH] xen-netfront: remove warning when unloading module Thread-Index: AQHTYewcyRlMWf7TRkC3b1B+7ajKV6MdF+IA Date: Mon, 20 Nov 2017 10:55:55 +0000 Message-ID: <593f1c5a3bf24a2dbce56287391e776d@AMSPEX02CL03.citrite.net> References: <20171120104109.11585-1-otubo@redhat.com> In-Reply-To: <20171120104109.11585-1-otubo@redhat.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Eduardo Otubo [mailto:otubo@redhat.com] > Sent: 20 November 2017 10:41 > To: xen-devel@lists.xenproject.org > Cc: netdev@vger.kernel.org; Paul Durrant ; Wei > Liu ; linux-kernel@vger.kernel.org; > vkuznets@redhat.com; cavery@redhat.com; cheshi@redhat.com; > mgamal@redhat.com; Eduardo Otubo > Subject: [PATCH] xen-netfront: remove warning when unloading module > > When unloading module xen_netfront from guest, dmesg would output > warning messages like below: > > [ 105.236836] xen:grant_table: WARNING: g.e. 0x903 still in use! > [ 105.236839] deferring g.e. 0x903 (pfn 0x35805) > > This problem relies on netfront and netback being out of sync. By the time > netfront revokes the g.e.'s netback didn't have enough time to free all of > them, hence displaying the warnings on dmesg. > > The trick here is to make netfront to wait until netback frees all the g.e.'s > and only then continue to cleanup for the module removal, and this is done > by > manipulating both device states. > > Signed-off-by: Eduardo Otubo > --- > drivers/net/xen-netfront.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c > index 8b8689c6d887..b948e2a1ce40 100644 > --- a/drivers/net/xen-netfront.c > +++ b/drivers/net/xen-netfront.c > @@ -2130,6 +2130,17 @@ static int xennet_remove(struct xenbus_device > *dev) > > dev_dbg(&dev->dev, "%s\n", dev->nodename); > > + xenbus_switch_state(dev, XenbusStateClosing); > + while (xenbus_read_driver_state(dev->otherend) != > XenbusStateClosing){ > + cpu_relax(); > + schedule(); > + } > + xenbus_switch_state(dev, XenbusStateClosed); > + while (dev->xenbus_state != XenbusStateClosed){ > + cpu_relax(); > + schedule(); > + } > + Waitiing for closing should be ok but waiting for closed is risky. As soon as a backend is in the closed state then a toolstack can completely remove the backend xenstore area, resulting a state of XenbusStateUnknown, which would cause your second loop to spin forever. Paul > xennet_disconnect_backend(info); > > unregister_netdev(info->netdev); > -- > 2.13.6