From owner-svn-src-head@FreeBSD.ORG Tue Nov 27 23:16:57 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 42E4D123; Tue, 27 Nov 2012 23:16:57 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0D8368FC08; Tue, 27 Nov 2012 23:16:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qARNGuJL080899; Tue, 27 Nov 2012 23:16:56 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qARNGurs080897; Tue, 27 Nov 2012 23:16:56 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211272316.qARNGurs080897@svn.freebsd.org> From: Andre Oppermann Date: Tue, 27 Nov 2012 23:16:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243639 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Nov 2012 23:16:57 -0000 Author: andre Date: Tue Nov 27 23:16:56 2012 New Revision: 243639 URL: http://svnweb.freebsd.org/changeset/base/243639 Log: Complete r243631 by applying the remainder of kern_mbuf.c that got lost while merging into the commit tree. MFC after: 1 month X-MFC-with: r243631 Modified: head/sys/kern/kern_mbuf.c Modified: head/sys/kern/kern_mbuf.c ============================================================================== --- head/sys/kern/kern_mbuf.c Tue Nov 27 22:35:48 2012 (r243638) +++ head/sys/kern/kern_mbuf.c Tue Nov 27 23:16:56 2012 (r243639) @@ -107,36 +107,38 @@ struct mbstat mbstat; * tunable_mbinit() has to be run before init_maxsockets() thus * the SYSINIT order below is SI_ORDER_MIDDLE while init_maxsockets() * runs at SI_ORDER_ANY. + * + * NB: This has to be done before VM init. */ static void tunable_mbinit(void *dummy) { - /* This has to be done before VM init. */ TUNABLE_INT_FETCH("kern.ipc.nmbclusters", &nmbclusters); - if (nmbclusters == 0) { -#ifdef VM_AUTOTUNE_NMBCLUSTERS - nmbclusters = VM_AUTOTUNE_NMBCLUSTERS; -#else - nmbclusters = 1024 + maxusers * 64; -#endif -#ifdef VM_MAX_AUTOTUNE_NMBCLUSTERS - if (nmbclusters > VM_MAX_AUTOTUNE_NMBCLUSTERS) - nmbclusters = VM_MAX_AUTOTUNE_NMBCLUSTERS; -#endif - } + if (nmbclusters == 0) + nmbclusters = maxmbufmem / MCLBYTES / 4; TUNABLE_INT_FETCH("kern.ipc.nmbjumbop", &nmbjumbop); if (nmbjumbop == 0) - nmbjumbop = nmbclusters / 2; + nmbjumbop = maxmbufmem / MJUMPAGESIZE / 4; TUNABLE_INT_FETCH("kern.ipc.nmbjumbo9", &nmbjumbo9); if (nmbjumbo9 == 0) - nmbjumbo9 = nmbclusters / 4; + nmbjumbo9 = maxmbufmem / MJUM9BYTES / 6; TUNABLE_INT_FETCH("kern.ipc.nmbjumbo16", &nmbjumbo16); if (nmbjumbo16 == 0) - nmbjumbo16 = nmbclusters / 8; + nmbjumbo16 = maxmbufmem / MJUM16BYTES / 6; + + /* + * We need at least as many mbufs as we have clusters of + * the various types added together. + */ + TUNABLE_INT_FETCH("kern.ipc.nmbufs", &nmbufs); + if (nmbufs < nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) + nmbufs = lmax(maxmbufmem / MSIZE / 5, + nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16); + } SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_mbinit, NULL); @@ -241,7 +243,7 @@ sysctl_nmbufs(SYSCTL_HANDLER_ARGS) if (newnmbufs > nmbufs) { nmbufs = newnmbufs; uma_zone_set_max(zone_mbuf, nmbufs); - nmbclusters = uma_zone_get_max(zone_mbuf); + nmbufs = uma_zone_get_max(zone_mbuf); EVENTHANDLER_INVOKE(nmbufs_change); } else error = EINVAL;