Vladimir Marek
2008-Apr-29 07:29 UTC
[dtrace-discuss] Can''t unload module - helper script
Hi,
Lately I was chasing some bug with module unloading, and I forged some
dtrace to give me clues why does not that work. Hope it helps someone.
============================ Sample output ============================Go on
Filename: drv/x25
Modname: x25
Primary module: 0
Reference count: 0 (600024a784c)
Probes enabled: 0
Installed: 1
Loaded: 1
Reqs: 60004ec2d50
Deps: 0
req: Filename: strmod/x25timer
req: Modname: x25timer
req: Primary module: 0
req: Reference count: 1 (600024a77ac)
req: Probes enabled: 0
req: Installed: 1
req: Loaded: 1
req: Reqs: 0
req: Deps: 0
req: Filename: strmod/s_dlpi
req: Modname: s_dlpi
req: Primary module: 0
req: Reference count: 1 (600024a734c)
req: Probes enabled: 0
req: Installed: 1
req: Loaded: 1
req: Reqs: 0
req: Deps: 0
req: Filename: strmod/x25secu
req: Modname: x25secu
req: Primary module: 0
req: Reference count: 1 (600024a720c)
req: Probes enabled: 0
req: Installed: 1
req: Loaded: 1
req: Reqs: 0
req: Deps: 0
detach_driver returns 0
mod_removestrmod returns: 1883769656
mod_name_to_major returns 281
Device reference count 1 (70480aec)
mod_dprintf: Cannot unload device driver <%s>, refcnt %d
mod_removedrv returns: 16
mod_remove returns: 16
moduninstall returns: 16
=======================================================================
--
Vlad
-------------- next part --------------
#!/usr/bin/sh
set -u
PRINT_MODCTL=''
printf ("%sFilename: %s\n", desc, stringof(mp->mod_filename));
printf ("%sModname: %s\n", desc, stringof(mp->mod_modname));
printf ("%sPrimary module: %d\n", desc, mp->mod_prim);
printf ("%sReference count: %d (%p)\n", desc, mp->mod_ref,
&mp->mod_ref);
printf ("%sProbes enabled: %d\n", desc, mp->mod_nenabled);
printf ("%sInstalled: %d\n", desc, mp->mod_installed);
printf ("%sLoaded: %d\n", desc, mp->mod_loaded);
printf ("%sReqs: %p\n", desc, mp->mod_requisites);
printf ("%sDeps: %p\n", desc, mp->mod_dependents);
printf ("\n");
'';
PRINT_REQ=''
fbt:genunix:moduninstall:entry
/self->reqs/
{
desc = " req: ";
mp = self->reqs->modl_modp;
''"$PRINT_MODCTL"''
self->reqs = self->reqs->modl_next;
}
'';
PRINT_DEP=''
fbt:genunix:moduninstall:entry
/self->deps/
{
desc = " dep: ";
mp = self->deps->modl_modp;
''"$PRINT_MODCTL"''
self->deps = self->deps->modl_next;
}
'';
/usr/sbin/dtrace -n ''
#pragma D option quiet
#pragma D option destructive
BEGIN
{
printf ("Go on\n\n");
}
fbt:genunix:moduninstall:entry
{
mp = (struct modctl *)arg0;
desc = "";
''"$PRINT_MODCTL"''
self->reqs = mp->mod_requisites;
self->deps = mp->mod_dependents;
}
''"$PRINT_REQ"''
''"$PRINT_REQ"''
''"$PRINT_REQ"''
fbt:genunix:moduninstall:entry
/self->reqs/
{
printf (" ... and other reqs\n\n");
}
''"$PRINT_DEP"''
''"$PRINT_DEP"''
''"$PRINT_DEP"''
fbt:genunix:moduninstall:entry
/self->deps/
{
printf (" ... and other deps\n\n");
}
fbt:genunix:moduninstall:entry
{
self->reqs = 0;
self->deps = 0;
self->go = 1;
}
fbt:genunix:moduninstall:return
{
self->go = 0; printf ("moduninstall returns: %d\n\n", arg1);
}
fbt:genunix:detach_driver:return
/self->go/
{
printf ("detach_driver returns %d\n", arg1);
}
mod_remove:entry
/self->go/
{
self->wild=1;
}
fbt:genunix:mod_remove*:return
/self->go/
{
printf ("%s returns: %d\n", stringof(probefunc), arg1);
self->wild=0;
}
fbt:genunix:mod_dprintf:entry
{
printf ("mod_dprintf: %s", stringof(arg1));
}
fbt:genunix:mod_removedrv:entry
/self->go/
{
self->mod_removedrv=1;
}
fbt:genunix:mod_name_to_major:return
/self->mod_removedrv/
{
printf("mod_name_to_major returns %d\n", arg1);
dp=`devopsp[arg1];
printf ("Device reference count %d (%p)\n", dp->devo_refcnt,
&(dp->devo_refcnt));
}
fbt:genunix:mod_removedrv:return
/self->go/
{
self->mod_removedrv=0;
}
''
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 193 bytes
Desc: not available
URL:
<http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20080429/c6a9657d/attachment.bin>