From owner-freebsd-net@FreeBSD.ORG Fri Jan 19 14:18:09 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 374DC16A400 for ; Fri, 19 Jan 2007 14:18:09 +0000 (UTC) (envelope-from rrs@cisco.com) Received: from sj-iport-2.cisco.com (sj-iport-2-in.cisco.com [171.71.176.71]) by mx1.freebsd.org (Postfix) with ESMTP id 0819A13C441 for ; Fri, 19 Jan 2007 14:18:08 +0000 (UTC) (envelope-from rrs@cisco.com) Received: from sj-dkim-3.cisco.com ([171.71.179.195]) by sj-iport-2.cisco.com with ESMTP; 19 Jan 2007 06:17:46 -0800 X-IronPort-AV: i="4.13,211,1167638400"; d="scan'208"; a="356962755:sNHT1776272592" Received: from sj-core-5.cisco.com (sj-core-5.cisco.com [171.71.177.238]) by sj-dkim-3.cisco.com (8.12.11/8.12.11) with ESMTP id l0JEHi57026887 for ; Fri, 19 Jan 2007 06:17:44 -0800 Received: from xbh-sjc-211.amer.cisco.com (xbh-sjc-211.cisco.com [171.70.151.144]) by sj-core-5.cisco.com (8.12.10/8.12.6) with ESMTP id l0JEHiUw015412 for ; Fri, 19 Jan 2007 06:17:44 -0800 (PST) Received: from xfe-sjc-211.amer.cisco.com ([171.70.151.174]) by xbh-sjc-211.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 19 Jan 2007 06:17:44 -0800 Received: from [127.0.0.1] ([171.68.225.134]) by xfe-sjc-211.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 19 Jan 2007 06:17:43 -0800 Message-ID: <45B0D2E3.9050203@cisco.com> Date: Fri, 19 Jan 2007 09:17:07 -0500 From: Randall Stewart User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.8) Gecko/20061029 FreeBSD/i386 SeaMonkey/1.0.6 MIME-Version: 1.0 To: freebsd-net Content-Type: multipart/mixed; boundary="------------040707050509060703070909" X-OriginalArrivalTime: 19 Jan 2007 14:17:43.0880 (UTC) FILETIME=[95FC6480:01C73BD4] DKIM-Signature: v=0.5; a=rsa-sha256; q=dns/txt; l=4535; t=1169216264; x=1170080264; c=relaxed/simple; s=sjdkim3002; h=Content-Type:From:Subject:Content-Transfer-Encoding:MIME-Version; d=cisco.com; i=rrs@cisco.com; z=From:=20Randall=20Stewart=20 |Subject:=20kern_mbuf.c=20patch |Sender:=20; bh=M+qJMMlidYbaXzrUyCnaP5cKGJF6wusd1XyNuA0zHUA=; b=Ie7dKhOA+O3sMExsN/6jzat5Ym7G4gZBCpZqOJkkX5m4APY8x8ArpMJKt3JxBYD0BMZNf6Qu hDnvpukCFFkRSuKj9SZ16Pa0hLm0DpJ3V1AWoL7K/rJko7sKUG8tUcF4; Authentication-Results: sj-dkim-3; header.From=rrs@cisco.com; dkim=pass (sig from cisco.com/sjdkim3002 verified; ); Subject: kern_mbuf.c patch X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jan 2007 14:18:09 -0000 This is a multi-part message in MIME format. --------------040707050509060703070909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit All: George and I have been discussing making the attached change to limit kernel large cluster growth. Note I also have added a fix so that if the limit is 0 (unlimited), then you cannot change the limit (back downward)... This is in response to Li Xin's comments about the code I posted earlier.. I have no idea if the "default numbers" for these are correct... it was a wild swag guess. Maybe someone might have a better idea of what the default limits for 4k/9k and 16k clusters should be :) Comments would be appreciated :-) R -- Randall Stewart NSSTG - Cisco Systems Inc. 803-345-0369 803-317-4952 (cell) --------------040707050509060703070909 Content-Type: text/plain; name="patch.kern_mbuf.limits" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch.kern_mbuf.limits" Index: kern_mbuf.c =================================================================== RCS file: /usr/FreeBSD/src/sys/kern/kern_mbuf.c,v retrieving revision 1.27 diff -u -r1.27 kern_mbuf.c --- kern_mbuf.c 22 Oct 2006 11:52:13 -0000 1.27 +++ kern_mbuf.c 19 Jan 2007 14:06:35 -0000 @@ -107,6 +107,9 @@ /* This has to be done before VM init. */ nmbclusters = 1024 + maxusers * 64; + nmbjumbop = 100 + (maxusers * 4); + nmbjumbo9 = 100 + (maxusers * 2); + nmbjumbo16 = 100 + (maxusers * 2); TUNABLE_INT_FETCH("kern.ipc.nmbclusters", &nmbclusters); } SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_ANY, tunable_mbinit, NULL); @@ -120,7 +123,7 @@ newnmbclusters = nmbclusters; error = sysctl_handle_int(oidp, &newnmbclusters, sizeof(int), req); if (error == 0 && req->newptr) { - if (newnmbclusters > nmbclusters) { + if (nmbclusters && (newnmbclusters > nmbclusters)) { nmbclusters = newnmbclusters; uma_zone_set_max(zone_clust, nmbclusters); EVENTHANDLER_INVOKE(nmbclusters_change); @@ -129,15 +132,75 @@ } return (error); } + +static int +sysctl_nmbjclusters(SYSCTL_HANDLER_ARGS) +{ + int error, newnmbjclusters; + + newnmbjclusters = nmbjumbop; + error = sysctl_handle_int(oidp, &newnmbjclusters, sizeof(int), req); + if (error == 0 && req->newptr) { + if (nmbjumbop && (newnmbjclusters > nmbjumbop)) { + nmbjumbop = newnmbjclusters; + uma_zone_set_max(zone_jumbop, nmbjumbop); + } else + error = EINVAL; + } + return (error); +} + + +static int +sysctl_nmbj9clusters(SYSCTL_HANDLER_ARGS) +{ + int error, newnmbj9clusters; + + newnmbj9clusters = nmbjumbo9; + error = sysctl_handle_int(oidp, &newnmbj9clusters, sizeof(int), req); + if (error == 0 && req->newptr) { + if (nmbjumbo9 && (newnmbj9clusters > nmbjumbo9)) { + nmbjumbo9 = newnmbj9clusters; + uma_zone_set_max(zone_jumbo9, nmbjumbo9); + } else + error = EINVAL; + } + return (error); +} + +static int +sysctl_nmbj16clusters(SYSCTL_HANDLER_ARGS) +{ + int error, newnmbj16clusters; + + newnmbj16clusters = nmbjumbo16; + error = sysctl_handle_int(oidp, &newnmbj16clusters, sizeof(int), req); + if (error == 0 && req->newptr) { + if (nmbjumbo16 && (newnmbj16clusters > nmbjumbo16)) { + nmbjumbo16 = newnmbj16clusters; + uma_zone_set_max(zone_jumbo16, nmbjumbo16); + } else + error = EINVAL; + } + return (error); +} + SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbclusters, CTLTYPE_INT|CTLFLAG_RW, &nmbclusters, 0, sysctl_nmbclusters, "IU", "Maximum number of mbuf clusters allowed"); -SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbop, CTLFLAG_RW, &nmbjumbop, 0, + +SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbjumbop, CTLTYPE_INT|CTLFLAG_RW, +&nmbjumbop, 0, sysctl_nmbjclusters, "IU", "Maximum number of mbuf page size jumbo clusters allowed"); -SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbo9, CTLFLAG_RW, &nmbjumbo9, 0, + +SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbjumbo9, CTLTYPE_INT|CTLFLAG_RW, +&nmbjumbo9, 0, sysctl_nmbj9clusters, "IU", "Maximum number of mbuf 9k jumbo clusters allowed"); -SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbo16, CTLFLAG_RW, &nmbjumbo16, 0, + +SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbjumbo16, CTLTYPE_INT|CTLFLAG_RW, +&nmbjumbo16, 0, sysctl_nmbj16clusters, "IU", "Maximum number of mbuf 16k jumbo clusters allowed"); + SYSCTL_STRUCT(_kern_ipc, OID_AUTO, mbstat, CTLFLAG_RD, &mbstat, mbstat, "Mbuf general information and statistics"); --------------040707050509060703070909--