Received: by 10.223.164.202 with SMTP id h10csp3777046wrb; Mon, 20 Nov 2017 05:00:03 -0800 (PST) X-Google-Smtp-Source: AGs4zMbKPaHi6BdIPWbfIMqrE3j2FejAYQIJdxsTKeXLuYO2Z7GhZJiigxnJPvvpWFTz8DV8vxrT X-Received: by 10.101.100.76 with SMTP id s12mr13569809pgv.173.1511182803749; Mon, 20 Nov 2017 05:00:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511182803; cv=none; d=google.com; s=arc-20160816; b=Z9lP5a/k+DdgxLAwopUaMzm/rZOWk8E37dmU2uCqGQtBFRoZ6On05+ctgcPt2+vM59 f0kUBignNPGqB08aBcp0qDrmB0RSaguS306nTREfBpvAAIme7jI10DvS1KxDgMAOPhu4 /w1Jpb6sVQr/O6sK4FSdKj5JpF2kuBgyL83n+k5709voMydQoIhou7+6E++2kyUNVC/G 0qtQt2y9j/oI2MsmZfq5Rd8dq6Ls3XqaxTd1a3yug5LFDg5Kr1+2oLK+/otM17ffW2No srSNduHaD3ulFuj7QQ+nephn5idxjn7Xo8M0mDr2KcqNy16mB0nV3f8pUtVmv+ytISr/ txnw== 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=1cixBrRF31DiwgHzpuBEyqQI8fgcaTNzIvNFyJGxcVI=; b=aXeQEqGq8FhW1sX86OZ4P1N5FuQFzA4jV3W6A4/OSp/6V29gCujKjjA5Xj+kZqpwQV P8ho0wSapMUhBHZn/KQPr293WvFj7ulUtMM+VtYJn7/Q3b8JY5IG/GzOwQWTPnKJuK0n vsZWWac9ZOGr1WoaR6+uaeP51cffxpJckH39zJEbPEOWMky7s+0LsVyw3JwPJL03DdyH USAgd6TF2e0N43CLlNoiIPsGG1DtBOih670zoxaHKZohdTt/cG930E6RHgJ0yIHqSHH3 6mti9sWDPrxCmeRBVh3yNhenDvA7oX1fAAJ8wWktC2wNu5g9Wk2RFecM1Cq55y7OunUs /bEQ== 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 g66si8944793pfj.184.2017.11.20.04.59.53; Mon, 20 Nov 2017 05:00:03 -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 S1751179AbdKTM7R (ORCPT + 67 others); Mon, 20 Nov 2017 07:59:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46956 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbdKTM7Q (ORCPT ); Mon, 20 Nov 2017 07:59:16 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E23CB49022; Mon, 20 Nov 2017 12:59:15 +0000 (UTC) Received: from vader (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with SMTP id 4A2085EDE7; Mon, 20 Nov 2017 12:59:07 +0000 (UTC) Date: Mon, 20 Nov 2017 13:59:07 +0100 From: Eduardo Otubo To: Juergen Gross Cc: Wei Liu , xen-devel@lists.xenproject.org, netdev@vger.kernel.org, paul.durrant@citrix.com, linux-kernel@vger.kernel.org, vkuznets@redhat.com, cavery@redhat.com, cheshi@redhat.com, mgamal@redhat.com, Boris Ostrovsky Subject: Re: [PATCH] xen-netfront: remove warning when unloading module Message-ID: <20171120125907.GB12153@vader> References: <20171120104109.11585-1-otubo@redhat.com> <20171120104919.ziq45hikwbzlnvbo@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3+47 (5f034395e53d) (2017-05-23) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 20 Nov 2017 12:59:15 +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 12:17:11PM +0100, Juergen Gross wrote: > On 20/11/17 11:49, Wei Liu wrote: > > CC netfront maintainers. > > > > On Mon, Nov 20, 2017 at 11:41:09AM +0100, Eduardo Otubo wrote: > >> 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(); > >> + } > > I really don't like the busy waits. > > Can't you use e.g. a wait queue and wait_event_interruptible() instead? I thought about using these, but I don't think the busy waits here are much of a problem because it's just unloading a kernel module, not a very repetitive action. But yes I can go for this approach on v2. > > BTW: what happens if the device is already in closed state if you enter > xennet_remove()? In case this is impossible, please add a comment to > indicate you've thought about that case. Looks like this is the same problem Paul Durrant mentioned on his comment. I'll work on this as well on v2. Thanks for the review and the help on IRC :-) From 1584589840823657458@xxx Mon Nov 20 12:57:13 +0000 2017 X-GM-THRID: 1584581341753935999 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread