From owner-freebsd-xen@freebsd.org Mon Nov 7 09:36:27 2016 Return-Path: Delivered-To: freebsd-xen@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8FC9C32055 for ; Mon, 7 Nov 2016 09:36:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9904E17B for ; Mon, 7 Nov 2016 09:36:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id uA79aREH026157 for ; Mon, 7 Nov 2016 09:36:27 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-xen@FreeBSD.org Subject: [Bug 213541] xen unable to load Date: Mon, 07 Nov 2016 09:36:27 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: 11.0-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: royger@freebsd.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-xen@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-xen@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussion of the freebsd port to xen - implementation and usage List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2016 09:36:27 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D213541 --- Comment #18 from Roger Pau Monn=C3=83=C2=A9 --- Hello, You will have to provide a little bit more info, are you able to boot fine without Xen? Do you think you can setup a serial console and provide the fu= ll output of the non-booting case? Thanks, Roger. --=20 You are receiving this mail because: You are the assignee for the bug.= From owner-freebsd-xen@freebsd.org Tue Nov 8 13:05:13 2016 Return-Path: Delivered-To: freebsd-xen@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1E43EC36A10 for ; Tue, 8 Nov 2016 13:05:13 +0000 (UTC) (envelope-from prvs=11366e8ad=roger.pau@citrix.com) Received: from SMTP.EU.CITRIX.COM (smtp.ctxuk.citrix.com [185.25.65.24]) (using TLSv1.2 with cipher RC4-SHA (128/128 bits)) (Client CN "mail.citrix.com", Issuer "DigiCert SHA2 Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 76FB1F77 for ; Tue, 8 Nov 2016 13:05:11 +0000 (UTC) (envelope-from prvs=11366e8ad=roger.pau@citrix.com) X-IronPort-AV: E=Sophos;i="5.31,462,1473120000"; d="scan'208";a="34473027" Date: Tue, 8 Nov 2016 14:04:56 +0100 From: "roger.pau@citrix.com" To: Liuyingdong CC: "freebsd-xen@freebsd.org" , "Zhaojun (Euler)" , Suoben Subject: Re: [PATCH]netfront: need release all resources after adding and removing NICs time and again Message-ID: <20161108130456.ejiuhjjxjt5c6yeq@mac> References: <3655E9A8B903724782E1F75DCFD74E6BF966FF5A@szxema506-mbs.china.huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <3655E9A8B903724782E1F75DCFD74E6BF966FF5A@szxema506-mbs.china.huawei.com> User-Agent: NeoMutt/20161028 (1.7.1) X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) X-DLP: AMS1 X-BeenThere: freebsd-xen@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussion of the freebsd port to xen - implementation and usage List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Nov 2016 13:05:13 -0000 On Fri, Nov 04, 2016 at 07:43:41AM +0000, Liuyingdong wrote: > On xen,freebsd 10.2 virtual machines hang after adding and removing NICs time and again(more than 30 times). > I found error log is as follows: > "netfront can't alloc tx grant refs" Hello, Thanks for the patch, although I'm not able to import it, git complain with: patch: **** malformed patch at line 7: } Could you please resend it using git send-email? I also have a couple of comments below regarding style. > > Signed-off-by: Liudong Liu > > diff --git a/dev/xen/netfront/netfront.c b/dev/xen/netfront/netfront.c > index 5497139..e96bbba 100644 > --- a/dev/xen/netfront/netfront.c > +++ b/dev/xen/netfront/netfront.c > @@ -790,6 +790,44 @@ netif_release_tx_bufs(struct netfront_info *np) > } > } Missing new line. > +static void netif_release_rx_bufs_copy(struct netfront_info *np) This needs to be on a new line. > +{ > + struct mbuf *m; > + int i, ref; > + int busy = 0, inuse = 0; > + > + XN_RX_LOCK(np); > + > + for (i = 0; i < NET_RX_RING_SIZE; i++) { > + ref = np->grant_rx_ref[i]; > + > + if (ref == GRANT_REF_INVALID) > + continue; > + > + inuse++; > + > + m = np->rx_mbufs[i]; > + > + if (!gnttab_end_foreign_access_ref(ref)) > + { > + busy++; > + continue; > + } > + > + gnttab_release_grant_reference(&np->gref_rx_head, ref); > + np->grant_rx_ref[i] = GRANT_REF_INVALID; > + add_id_to_freelist(np->rx_mbufs, i); > + > + m_freem(m); > + } > + > + if (busy) > + DPRINTK("%s: Unable to release %d of %d inuse grant references out of %ld total.\n", > + __FUNCTION__, busy, inuse, NET_RX_RING_SIZE); Please use device_printf for this instead of the function name. Also, could you align the string so it doesn't extend past 80 characters? Roger. From owner-freebsd-xen@freebsd.org Fri Nov 11 02:06:27 2016 Return-Path: Delivered-To: freebsd-xen@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11ACAC3A1A2 for ; Fri, 11 Nov 2016 02:06:27 +0000 (UTC) (envelope-from liuyingdong@huawei.com) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [119.145.14.65]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "myname.my.domain", Issuer "www.mirapoint.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 420E888A for ; Fri, 11 Nov 2016 02:06:25 +0000 (UTC) (envelope-from liuyingdong@huawei.com) Received: from 172.24.1.47 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.47]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DQL25548; Fri, 11 Nov 2016 10:04:44 +0800 (CST) Received: from [127.0.0.1] (10.177.20.238) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Fri, 11 Nov 2016 10:04:33 +0800 From: liuyingdong To: freebsd xen Subject: Re: [PATCH]netfront: need release all resources after adding and removing NICs time and again CC: , , , Message-ID: <5825272C.3010704@huawei.com> Date: Fri, 11 Nov 2016 10:04:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.20.238] X-CFilter-Loop: Reflected X-BeenThere: freebsd-xen@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussion of the freebsd port to xen - implementation and usage List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2016 02:06:27 -0000 Hello Roger, Sorry, I am a freshman. I ran the following command to git kernel source of freebsd 10.2.0: git clone https://github.com/freebsd/freebsd.git git checkout origin/release/10.2.0 On the base of the above, I make a patch file as fellows: diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c index d89c0e0..903eb98 100644 --- a/sys/dev/xen/netfront/netfront.c +++ b/sys/dev/xen/netfront/netfront.c @@ -2172,6 +2172,46 @@ netfront_detach(device_t dev) } static void +netif_release_rx_bufs_copy(struct netfront_info *np) +{ + struct mbuf *m; + int i, ref; + int busy = 0, inuse = 0; + + XN_RX_LOCK(np); + + for (i = 0; i < NET_RX_RING_SIZE; i++) { + ref = np->grant_rx_ref[i]; + + if (ref == GRANT_REF_INVALID) + continue; + + inuse++; + + m = np->rx_mbufs[i]; + + if (!gnttab_end_foreign_access_ref(ref)) + { + busy++; + continue; + } + + gnttab_release_grant_reference(&np->gref_rx_head, ref); + np->grant_rx_ref[i] = GRANT_REF_INVALID; + add_id_to_freelist(np->rx_mbufs, i); + + m_freem(m); + } + + if (busy) + device_printf(np->xbdev, "Unable to release %d of %d " + "inuse grant references out of %ld total.\n", + busy, inuse, NET_RX_RING_SIZE); + + XN_RX_UNLOCK(np); +} + +static void netif_free(struct netfront_info *info) { XN_LOCK(info); @@ -2185,6 +2225,13 @@ netif_free(struct netfront_info *info) info->xn_ifp = NULL; } ifmedia_removeall(&info->sc_media); + + netif_release_tx_bufs(info); + if (info->copying_receiver) + netif_release_rx_bufs_copy(info); + + gnttab_free_grant_references(info->gref_tx_head); + gnttab_free_grant_references(info->gref_rx_head); } static void Yours Yingdong Liu -----邮件原件----- 发件人: roger.pau@citrix.com [mailto:roger.pau@citrix.com] 发送时间: 2016年11月8日 21:05 收件人: Liuyingdong 抄送: freebsd-xen@freebsd.org; Zhaojun (Euler); Suoben 主题: Re: [PATCH]netfront: need release all resources after adding and removing NICs time and again On Fri, Nov 04, 2016 at 07:43:41AM +0000, Liuyingdong wrote: > On xen,freebsd 10.2 virtual machines hang after adding and removing NICs time and again(more than 30 times). > I found error log is as follows: > "netfront can't alloc tx grant refs" Hello, Thanks for the patch, although I'm not able to import it, git complain with: patch: **** malformed patch at line 7: } Could you please resend it using git send-email? I also have a couple of comments below regarding style. > > Signed-off-by: Yingdong Liu > > diff --git a/dev/xen/netfront/netfront.c b/dev/xen/netfront/netfront.c > index 5497139..e96bbba 100644 > --- a/dev/xen/netfront/netfront.c > +++ b/dev/xen/netfront/netfront.c > @@ -790,6 +790,44 @@ netif_release_tx_bufs(struct netfront_info *np) > } > } Missing new line. > +static void netif_release_rx_bufs_copy(struct netfront_info *np) This needs to be on a new line. > +{ > + struct mbuf *m; > + int i, ref; > + int busy = 0, inuse = 0; > + > + XN_RX_LOCK(np); > + > + for (i = 0; i < NET_RX_RING_SIZE; i++) { > + ref = np->grant_rx_ref[i]; > + > + if (ref == GRANT_REF_INVALID) > + continue; > + > + inuse++; > + > + m = np->rx_mbufs[i]; > + > + if (!gnttab_end_foreign_access_ref(ref)) > + { > + busy++; > + continue; > + } > + > + gnttab_release_grant_reference(&np->gref_rx_head, ref); > + np->grant_rx_ref[i] = GRANT_REF_INVALID; > + add_id_to_freelist(np->rx_mbufs, i); > + > + m_freem(m); > + } > + > + if (busy) > + DPRINTK("%s: Unable to release %d of %d inuse grant references out of %ld total.\n", > + __FUNCTION__, busy, inuse, > + NET_RX_RING_SIZE); Please use device_printf for this instead of the function name. Also, could you align the string so it doesn't extend past 80 characters? Roger.