From owner-svn-src-all@FreeBSD.ORG Sun Jan 25 16:59:29 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87372106566C; Sun, 25 Jan 2009 16:59:29 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6BAC08FC0C; Sun, 25 Jan 2009 16:59:29 +0000 (UTC) (envelope-from ed@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 n0PGxTGQ022817; Sun, 25 Jan 2009 16:59:29 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0PGxT8p022816; Sun, 25 Jan 2009 16:59:29 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200901251659.n0PGxT8p022816@svn.freebsd.org> From: Ed Schouten Date: Sun, 25 Jan 2009 16:59:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187690 - in stable/7/sys: . contrib/pf dev/cxgb kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 25 Jan 2009 16:59:30 -0000 Author: ed Date: Sun Jan 25 16:59:29 2009 New Revision: 187690 URL: http://svn.freebsd.org/changeset/base/187690 Log: MFC r186747 to releng/7: Remove Giant locking from domains list. During boot, the domain list is locked with Giant. It is not possible to register any protocols after the system has booted, so the lock is only used to protect insertion of entries. There is already a mutex in uipc_domain.c called dom_mtx. Use this mutex to lock the list, instead of using Giant. It won't matter anything with respect to performance, but we'll never get rid of Giant if we don't remove from places where we don't need it. Approved by: rwatson MFC after: 3 weeks Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/uipc_domain.c Modified: stable/7/sys/kern/uipc_domain.c ============================================================================== --- stable/7/sys/kern/uipc_domain.c Sun Jan 25 16:52:41 2009 (r187689) +++ stable/7/sys/kern/uipc_domain.c Sun Jan 25 16:59:29 2009 (r187690) @@ -72,7 +72,7 @@ static void pfslowtimo(void *); struct domain *domains; /* registered protocol domains */ int domain_init_status = 0; -struct mtx dom_mtx; /* domain list lock */ +static struct mtx dom_mtx; /* domain list lock */ MTX_SYSINIT(domain, &dom_mtx, "domain list", MTX_DEF); /* @@ -316,13 +316,13 @@ found: * Protect us against races when two protocol registrations for * the same protocol happen at the same time. */ - mtx_lock(&Giant); + mtx_lock(&dom_mtx); /* The new protocol must not yet exist. */ for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) { if ((pr->pr_type == npr->pr_type) && (pr->pr_protocol == npr->pr_protocol)) { - mtx_unlock(&Giant); + mtx_unlock(&dom_mtx); return (EEXIST); /* XXX: Check only protocol? */ } /* While here, remember the first free spacer. */ @@ -332,7 +332,7 @@ found: /* If no free spacer is found we can't add the new protocol. */ if (fpr == NULL) { - mtx_unlock(&Giant); + mtx_unlock(&dom_mtx); return (ENOMEM); } @@ -340,7 +340,7 @@ found: bcopy(npr, fpr, sizeof(*fpr)); /* Job is done, no more protection required. */ - mtx_unlock(&Giant); + mtx_unlock(&dom_mtx); /* Initialize and activate the protocol. */ protosw_init(fpr); @@ -376,13 +376,13 @@ found: dpr = NULL; /* Lock out everyone else while we are manipulating the protosw. */ - mtx_lock(&Giant); + mtx_lock(&dom_mtx); /* The protocol must exist and only once. */ for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) { if ((pr->pr_type == type) && (pr->pr_protocol == protocol)) { if (dpr != NULL) { - mtx_unlock(&Giant); + mtx_unlock(&dom_mtx); return (EMLINK); /* Should not happen! */ } else dpr = pr; @@ -391,7 +391,7 @@ found: /* Protocol does not exist. */ if (dpr == NULL) { - mtx_unlock(&Giant); + mtx_unlock(&dom_mtx); return (EPROTONOSUPPORT); } @@ -412,7 +412,7 @@ found: dpr->pr_usrreqs = &nousrreqs; /* Job is done, not more protection required. */ - mtx_unlock(&Giant); + mtx_unlock(&dom_mtx); return (0); }