From owner-svn-src-all@freebsd.org Thu Jun 23 08:18:07 2016 Return-Path: Delivered-To: svn-src-all@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 113D6AC63F4; Thu, 23 Jun 2016 08:18:07 +0000 (UTC) (envelope-from zec@fer.hr) Received: from mail.fer.hr (mail.fer.hr [161.53.72.233]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mail.fer.hr", Issuer "TERENA SSL CA 3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6AA52170C; Thu, 23 Jun 2016 08:18:05 +0000 (UTC) (envelope-from zec@fer.hr) Received: from x23 (161.53.63.210) by MAIL.fer.hr (161.53.72.233) with Microsoft SMTP Server (TLS) id 14.3.279.2; Thu, 23 Jun 2016 10:16:52 +0200 Date: Thu, 23 Jun 2016 10:17:57 +0200 From: Marko Zec To: "Bjoern A. Zeeb" CC: , , , , , Subject: Re: svn commit: r302099 - head/sys/netinet Message-ID: <20160623101757.3e8022fe@x23> In-Reply-To: <201606230034.u5N0Y3Ea069103@repo.freebsd.org> References: <201606230034.u5N0Y3Ea069103@repo.freebsd.org> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; amd64-portbld-freebsd10.1) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [161.53.63.210] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2016 08:18:07 -0000 On Thu, 23 Jun 2016 00:34:03 +0000 "Bjoern A. Zeeb" wrote: > Author: bz > Date: Thu Jun 23 00:34:03 2016 > New Revision: 302099 > URL: https://svnweb.freebsd.org/changeset/base/302099 > > Log: > Check the V_tcbinfo.ipi_count to hit 0 before doing the full TCP > cleanup. That way timers can finish cleanly and we do not gamble with > a DELAY(). > Reviewed by: gnn, jtl > Approved by: re (gjb) > Obtained from: projects/vnet > MFC after: 2 weeks > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D6923 As much as this change is welcome, it unnecesarily introduces a mandatory 100 ms delay on each vnet teardown, which I already pointed out in a comment to r301601 two weeks ago, which remained unanswered, along with the question why a delay of 100 ms was introduced here, when before r302099 the delay was only a single clock tick? And furthermore the delay computation expresion here is not style(9) compliant... Hence, please rectify the above objections, perhaps by something like: =================================================================== --- tcp_subr.c (revision 302126) +++ tcp_subr.c (working copy) @@ -739,10 +739,11 @@ * Sleep to let all tcpcb timers really disappear and cleanup. */ do { - pause("tcpdes", hz/10); INP_LIST_RLOCK(&V_tcbinfo); n = V_tcbinfo.ipi_count; INP_LIST_RUNLOCK(&V_tcbinfo); + if (n != 0) + pause("tcpdes", hz / 100); } while (n != 0); tcp_hc_destroy(); syncache_destroy(); Thanks, Marko > > Modified: > head/sys/netinet/tcp_subr.c > > Modified: head/sys/netinet/tcp_subr.c > ============================================================================== > --- head/sys/netinet/tcp_subr.c Thu Jun 23 00:32:58 > 2016 (r302098) +++ head/sys/netinet/tcp_subr.c Thu Jun > 23 00:34:03 2016 (r302099) @@ -731,18 +731,19 @@ tcp_init(void) > static void > tcp_destroy(void *unused __unused) > { > - int error; > + int error, n; > > /* > * All our processes are gone, all our sockets should be > cleaned > * up, which means, we should be past the tcp_discardcb() > calls. > - * Sleep to let all tcpcb timers really disappear and then > cleanup. > - * Timewait will cleanup its queue and will be ready to go. > - * XXX-BZ In theory a few ticks should be good enough to > make sure > - * the timers are all really gone. We should see if we > could use a > - * better metric here and, e.g., check a tcbcb count as an > optimization? > + * Sleep to let all tcpcb timers really disappear and > cleanup. */ > - DELAY(1000000 / hz); > + do { > + pause("tcpdes", hz/10); > + INP_LIST_RLOCK(&V_tcbinfo); > + n = V_tcbinfo.ipi_count; > + INP_LIST_RUNLOCK(&V_tcbinfo); > + } while (n != 0); > tcp_hc_destroy(); > syncache_destroy(); > tcp_tw_destroy(); >