Received: by 10.223.164.202 with SMTP id h10csp3774327wrb; Mon, 20 Nov 2017 04:57:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMbhZ2VAmkNkjwKFYWQgT9FVxaLn+IYeCuZC8eCwiHLFai853vRrPbAUFxwrtQc/GYEO+Yf0 X-Received: by 10.84.129.2 with SMTP id 2mr13817666plb.343.1511182633501; Mon, 20 Nov 2017 04:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511182633; cv=none; d=google.com; s=arc-20160816; b=CIxDAZNNdEw1IqAk03UM17rPytsJyBnZ98PAx9k8QvMfFIVf04NWGR6AsA4q91ZFtj 0bCxQVRB20ychmjP6aRULGyFfbV927fi2xYxCl9gXTE1wWWDEMkdaie+xEe4KvHBYtmJ /yryxbjke/ajSSHiI0gdR9wlg2LONB5fJN7kbYCx8yZ2ANlkzMxd+UTa/MDziwux3rFg pjfAjak94Hs2MO+7CMV6AWJTbdEfJsqeilxfVowGyg5WzspFZRGx2n82l+x/Q+WO01xz rDHhwH3LKQFvBiNdWtZrsdNP/Fjw1+h4EB7dUW4gnYolZzvUQbomo6HHVCOdFSh31QWa Bpzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=0Ngo/OQ/Z0PG0m1T3DcR8AkvjqBZp8qs3w4cIZgQbmY=; b=NDfGWLNsiqZwDtUsDnWLFX9V2pt2lr5hf2BMW+rYiFGWlW69jW34lq5WXqDHJgtqjI Cjj/xDDyryKDkoNWw2JkJP/TbWFSAP8XZPoHHX4yY0LJjB4GeFDAaK+kOwXiv6fnOZ2R WtBJFa9zkDOyQOHjBE44mQSWlwFRApWfcjc9pFhrOcCuHKdojo7cSIoFRu7r9QfGD/MA qD2uLcxMW8chzBLEoAwUfy0CU5X5yZ7I9kJ6FY76GQxspjm5nZdPSBemRYuG/bVYJbpn J2vuMvS9+DAsjsZxMzS7qS/thwvaGpNpet8vzvrGiE2OsIztYQmFDQrF6MUWsloAI/a3 jlTQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t189si8086890pgt.317.2017.11.20.04.57.03; Mon, 20 Nov 2017 04:57:13 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751213AbdKTM4V (ORCPT + 67 others); Mon, 20 Nov 2017 07:56:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49846 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbdKTM4T (ORCPT ); Mon, 20 Nov 2017 07:56:19 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DE0B5277E; Mon, 20 Nov 2017 12:56:19 +0000 (UTC) Received: from vader (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with SMTP id 9D3E360C90; Mon, 20 Nov 2017 12:56:11 +0000 (UTC) Date: Mon, 20 Nov 2017 13:56:10 +0100 From: 'Eduardo Otubo' To: Paul Durrant Cc: "xen-devel@lists.xenproject.org" , "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 Message-ID: <20171120125610.GA12153@vader> References: <20171120104109.11585-1-otubo@redhat.com> <593f1c5a3bf24a2dbce56287391e776d@AMSPEX02CL03.citrite.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <593f1c5a3bf24a2dbce56287391e776d@AMSPEX02CL03.citrite.net> User-Agent: Mutt/1.8.3+47 (5f034395e53d) (2017-05-23) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 20 Nov 2017 12:56:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 20, 2017 at 10:55:55AM +0000, Paul Durrant wrote: > > -----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 Well, that's a scenario I didn't foresee. I'll come up with a solution in order avoid this problem. Thanks for the review. > > > xennet_disconnect_backend(info); > > > > unregister_netdev(info->netdev); > > -- > > 2.13.6 > -- Eduardo Otubo From 1584583599404063825@xxx Mon Nov 20 11:18:00 +0000 2017 X-GM-THRID: 1584581341753935999 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread