From owner-p4-projects@FreeBSD.ORG Thu May 25 01:52:26 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 21E3516A444; Thu, 25 May 2006 01:52:26 +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 7A1C816A437 for ; Thu, 25 May 2006 01:52:24 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8DC3943D49 for ; Thu, 25 May 2006 01:52:20 +0000 (GMT) (envelope-from jb@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 k4P1pRjY005768 for ; Thu, 25 May 2006 01:51:27 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k4P1pRGG005765 for perforce@freebsd.org; Thu, 25 May 2006 01:51:27 GMT (envelope-from jb@freebsd.org) Date: Thu, 25 May 2006 01:51:27 GMT Message-Id: <200605250151.k4P1pRGG005765@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 97783 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 01:52:27 -0000 http://perforce.freebsd.org/chv.cgi?CH=97783 Change 97783 by jb@jb_freebsd2 on 2006/05/25 01:50:48 Add a load counter that is incremented each time a linker file is loaded and use the incremented value to 'stamp' the linker_file structure so that clients can detect if the file has been reloaded without having to retain a lock on the structure. Add a field to the linker_file structure to track the number of enabled (FBT or SDT) probes and prevent the file from being unloaded if probes are enabled. Affected files ... .. //depot/projects/dtrace/src/sys/kern/kern_linker.c#9 edit .. //depot/projects/dtrace/src/sys/sys/linker.h#7 edit Differences ... ==== //depot/projects/dtrace/src/sys/kern/kern_linker.c#9 (text+ko) ==== @@ -77,6 +77,12 @@ static struct sx kld_sx; /* kernel linker lock */ +/* + * Load counter used by clients to determine if a linker file has been + * re-loaded. This counter is incremented for each file load. + */ +static int loadcnt; + static linker_class_list_t classes; static linker_file_list_t linker_files; static int next_file_id = 1; @@ -473,6 +479,7 @@ LINKER_GET_NEXT_FILE_ID(lf->id); lf->ndeps = 0; lf->deps = NULL; + lf->loadcnt = ++loadcnt; STAILQ_INIT(&lf->common); TAILQ_INIT(&lf->modules); sx_xlock(&kld_sx); @@ -891,6 +898,15 @@ lf = linker_find_file_by_id(fileid); if (lf) { KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs)); + + /* Check if there are DTrace probes enabled on this file. */ + if (lf->nenabled > 0) { + printf("kldunload: attempt to unload file that has" + " DTrace probes enabled\n"); + error = EBUSY; + goto out; + } + if (lf->userrefs == 0) { /* * XXX: maybe LINKER_UNLOAD_FORCE should override ? ==== //depot/projects/dtrace/src/sys/sys/linker.h#7 (text+ko) ==== @@ -84,8 +84,13 @@ STAILQ_HEAD(, common_symbol) common; /* list of common symbols */ TAILQ_HEAD(, module) modules; /* modules in this file */ TAILQ_ENTRY(linker_file) loaded; /* preload dependency support */ + int loadcnt; /* load counter value */ - /* Function Boundary Tracing (FBT) fields. */ + /* + * Function Boundary Tracing (FBT) or Statically Defined Tracing (SDT) + * fields. + */ + int nenabled; /* number of enabled probes. */ int fbt_nentries; /* number of fbt entries created. */ };