From owner-svn-src-projects@FreeBSD.ORG Sat May 30 19:21:56 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F12B9106564A; Sat, 30 May 2009 19:21:56 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C50568FC15; Sat, 30 May 2009 19:21:56 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4UJLuom016656; Sat, 30 May 2009 19:21:56 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4UJLuBh016655; Sat, 30 May 2009 19:21:56 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200905301921.n4UJLuBh016655@svn.freebsd.org> From: Robert Watson Date: Sat, 30 May 2009 19:21:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193108 - projects/pnet/sys/net X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2009 19:21:57 -0000 Author: rwatson Date: Sat May 30 19:21:56 2009 New Revision: 193108 URL: http://svn.freebsd.org/changeset/base/193108 Log: Rather than asserting that protocols set a per-protocol queue limit during netisr registration, use a default value (256). If the default is greater than the maximum, truncate. Provide loader tunables to set both, but not at runtime. Modified: projects/pnet/sys/net/netisr.c Modified: projects/pnet/sys/net/netisr.c ============================================================================== --- projects/pnet/sys/net/netisr.c Sat May 30 19:11:45 2009 (r193107) +++ projects/pnet/sys/net/netisr.c Sat May 30 19:21:56 2009 (r193108) @@ -167,11 +167,24 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthrea */ #define NETISR_DEFAULT_MAXQLIMIT 10240 static u_int netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT; +TUNABLE_INT("net.isr.maxqlimit", &netisr_maxqlimit); SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RD, &netisr_maxqlimit, 0, "Maximum netisr per-protocol, per-CPU queue depth."); /* + * The default per-workstream queue limit for protocols that don't initialize + * the nh_qlimit field of their struct netisr_handler. If this is set above + * netisr_maxqlimit, we truncate it to the maximum during boot. + */ +#define NETISR_DEFAULT_DEFAULTQLIMIT 256 +static u_int netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT; +TUNABLE_INT("net.isr.defaultqlimit", &netisr_defaultqlimit); +SYSCTL_INT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RD, + &netisr_defaultqlimit, 0, + "Default netisr per-protocol, per-CPU queue limit if not set by protocol"); + +/* * Each protocol is described by a struct netisr_proto, which holds all * global per-protocol information. This data structure is set up by * netisr_register(), and derived from the public struct netisr_handler. @@ -346,8 +359,6 @@ netisr_register(const struct netisr_hand KASSERT(nhp->nh_policy != NETISR_POLICY_CPU || nhp->nh_m2cpuid != NULL, ("%s: nh_policy == CPU but m2cpuid not defined for %s", __func__, name)); - KASSERT(nhp->nh_qlimit != 0, - ("%s: nh_qlimit 0 for %s", __func__, name)); KASSERT(proto < NETISR_MAXPROT, ("%s(%u, %s): protocol too big", __func__, proto, name)); @@ -364,7 +375,9 @@ netisr_register(const struct netisr_hand np[proto].np_handler = nhp->nh_handler; np[proto].np_m2flow = nhp->nh_m2flow; np[proto].np_m2cpuid = nhp->nh_m2cpuid; - if (nhp->nh_qlimit > netisr_maxqlimit) { + if (nhp->nh_qlimit == 0) + np[proto].np_qlimit = netisr_defaultqlimit; + else if (nhp->nh_qlimit > netisr_maxqlimit) { printf("%s: %s requested queue limit %u capped to " "net.isr.maxqlimit %u\n", __func__, name, nhp->nh_qlimit, netisr_maxqlimit); @@ -1022,6 +1035,8 @@ netisr_init(void *arg) netisr_maxthreads = 1; if (netisr_maxthreads > MAXCPU) netisr_maxthreads = MAXCPU; + if (netisr_defaultqlimit > netisr_maxqlimit) + netisr_defaultqlimit = netisr_maxqlimit; #ifdef DEVICE_POLLING /* * The device polling code is not yet aware of how to deal with