From owner-p4-projects@FreeBSD.ORG Thu May 25 22:42:07 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D070416AA9D; Thu, 25 May 2006 22:38:20 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 65F1216C8E8 for ; Thu, 25 May 2006 22:35:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F9A943D60 for ; Thu, 25 May 2006 22:35:01 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k4PMY4KA078883 for ; Thu, 25 May 2006 22:34:04 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k4PMY4L6078880 for perforce@freebsd.org; Thu, 25 May 2006 22:34:04 GMT (envelope-from jhb@freebsd.org) Date: Thu, 25 May 2006 22:34:04 GMT Message-Id: <200605252234.k4PMY4L6078880@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 97832 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 May 2006 22:42:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=97832 Change 97832 by jhb@jhb_mutex on 2006/05/25 22:33:49 linker_file_unload() is now only called by the linker class implementations, so move it over into that semi-private API and axe the wrapper making the internal function the real one as it is always called with the linker lock held. Affected files ... .. //depot/projects/smpng/sys/kern/kern_linker.c#61 edit .. //depot/projects/smpng/sys/sys/linker.h#23 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_linker.c#61 (text+ko) ==== @@ -127,7 +127,6 @@ linker_file_t dep); static caddr_t linker_file_lookup_symbol_internal(linker_file_t file, const char* name, int deps); -static int linker_file_unload_internal(linker_file_t _file, int flags); static int linker_load_module(const char *kldname, const char *modname, struct linker_file *parent, struct mod_depend *verinfo, struct linker_file **lfpp); @@ -389,8 +388,7 @@ if (lf) { error = linker_file_register_modules(lf); if (error == EEXIST) { - linker_file_unload_internal(lf, - LINKER_UNLOAD_FORCE); + linker_file_unload(lf, LINKER_UNLOAD_FORCE); return (error); } linker_file_register_sysctls(lf); @@ -461,7 +459,7 @@ } else KASSERT(modname == NULL && verinfo == NULL, ("linker_release_module: both file and name")); - error = linker_file_unload_internal(lf, LINKER_UNLOAD_NORMAL); + error = linker_file_unload(lf, LINKER_UNLOAD_NORMAL); KLD_UNLOCK(); return (error); } @@ -540,23 +538,9 @@ return (lf); } -int +static int linker_file_unload(linker_file_t file, int flags) { - int error, locked; - - locked = KLD_LOCKED(); - if (!locked) - KLD_LOCK(); - error = linker_file_unload_internal(file, flags); - if (!locked) - KLD_UNLOCK(); - return (error); -} - -static int -linker_file_unload_internal(linker_file_t file, int flags) -{ module_t mod, next; modlist_t ml, nextml; struct common_symbol *cp; @@ -624,7 +608,7 @@ if (file->deps) { for (i = 0; i < file->ndeps; i++) - linker_file_unload_internal(file->deps[i], flags); + linker_file_unload(file->deps[i], flags); free(file->deps, M_LINKER); file->deps = NULL; } @@ -957,7 +941,7 @@ pkm.pm_size = lf->size; #endif lf->userrefs--; - error = linker_file_unload_internal(lf, flags); + error = linker_file_unload(lf, flags); if (error) lf->userrefs++; } @@ -1399,7 +1383,7 @@ nver) != NULL) { printf("module %s already" " present!\n", modname); - linker_file_unload_internal(lf, + linker_file_unload(lf, LINKER_UNLOAD_FORCE); TAILQ_REMOVE(&loaded_files, lf, loaded); @@ -1426,7 +1410,7 @@ */ TAILQ_FOREACH(lf, &loaded_files, loaded) { printf("KLD file %s is missing dependencies\n", lf->filename); - linker_file_unload_internal(lf, LINKER_UNLOAD_FORCE); + linker_file_unload(lf, LINKER_UNLOAD_FORCE); TAILQ_REMOVE(&loaded_files, lf, loaded); } @@ -1469,7 +1453,7 @@ if (error) { printf("KLD file %s - could not finalize loading\n", lf->filename); - linker_file_unload_internal(lf, LINKER_UNLOAD_FORCE); + linker_file_unload(lf, LINKER_UNLOAD_FORCE); continue; } linker_file_register_modules(lf); @@ -1893,7 +1877,7 @@ break; if (modname && verinfo && modlist_lookup2(modname, verinfo) == NULL) { - linker_file_unload_internal(lfdep, LINKER_UNLOAD_FORCE); + linker_file_unload(lfdep, LINKER_UNLOAD_FORCE); error = ENOENT; break; } ==== //depot/projects/smpng/sys/sys/linker.h#23 (text+ko) ==== @@ -119,11 +119,6 @@ linker_file_t _file); /* - * Unload a file, freeing up memory. - */ -int linker_file_unload(linker_file_t _file, int flags); - -/* * Iterate over all of the currently loaded linker files calling the * predicate function while the function returns 0. Returns the value * returned by the last predicate function. @@ -149,6 +144,7 @@ * Functions soley for use by the linker class handlers. */ int linker_add_class(linker_class_t _cls); +int linker_file_unload(linker_file_t _file, int flags); int linker_load_dependencies(linker_file_t _lf); linker_file_t linker_make_file(const char* _filename, linker_class_t _cls);