Date: Thu, 25 May 2006 01:51:27 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 97783 for review Message-ID: <200605250151.k4P1pRGG005765@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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. */ };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605250151.k4P1pRGG005765>