PERFORCE change 124478 for review
Marko Zec
zec at FreeBSD.org
Wed Aug 1 10:07:34 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=124478
Change 124478 by zec at zec_tpx32 on 2007/08/01 17:07:22
Introduce a few printf()s for tracking ordering of vnet
module instatiation and cleanup. Enabled / disabled
at compile time via DEBUG_ORDERING.
A few indentation cleanups here and there.
Affected files ...
.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#30 edit
Differences ...
==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#30 (text+ko) ====
@@ -72,6 +72,8 @@
static int vnet_mod_constructor(struct vnet_modlink *);
static int vnet_mod_destructor(struct vnet_modlink *);
+#define DEBUG_ORDERING
+
#ifdef VI_PREALLOC_SIZE
/*
* A private memory allocator can be enabled by setting VI_PREALLOC_SIZE
@@ -598,7 +600,19 @@
{
const struct vnet_modinfo *vmi = vml->vml_modinfo;
- if (vml->vml_modinfo->vmi_struct_size) {
+#ifdef DEBUG_ORDERING
+ printf("instatiating vnet_%s", vmi->vmi_name);
+ if (vml->vml_iarg)
+ printf("/%s", vml->vml_iname);
+ printf(": ");
+ if (vmi->vmi_struct_size)
+ printf("malloc(%d); ", vmi->vmi_struct_size);
+ if (vmi->vmi_iattach != NULL)
+ printf("iattach()");
+ printf("\n");
+#endif
+
+ if (vmi->vmi_struct_size) {
void *mem = vi_malloc(vmi->vmi_struct_size, M_VNET,
M_NOWAIT | M_ZERO);
if (mem == NULL) /* XXX should return error, not panic */
@@ -606,8 +620,8 @@
curvnet->mod_data[vmi->vmi_id] = mem;
}
- if (vml->vml_modinfo->vmi_iattach != NULL)
- vml->vml_modinfo->vmi_iattach(vml->vml_iarg);
+ if (vmi->vmi_iattach != NULL)
+ vmi->vmi_iattach(vml->vml_iarg);
return 0;
}
@@ -615,16 +629,29 @@
static int vnet_mod_destructor(vml)
struct vnet_modlink *vml;
{
- if (vml->vml_modinfo->vmi_idetach)
- vml->vml_modinfo->vmi_idetach(vml->vml_iarg);
- if (vml->vml_modinfo->vmi_struct_size) {
- if (curvnet->mod_data[vml->vml_modinfo->vmi_id] == NULL)
- panic("vi_destroy: %s\n",
- vml->vml_modinfo->vmi_name);
- vi_free(curvnet->mod_data[vml->vml_modinfo->vmi_id],
- M_VNET);
- curvnet->mod_data[vml->vml_modinfo->vmi_id] = NULL;
- }
+ const struct vnet_modinfo *vmi = vml->vml_modinfo;
+
+#ifdef DEBUG_ORDERING
+ printf("destroying vnet_%s", vmi->vmi_name);
+ if (vml->vml_iarg)
+ printf("/%s", vml->vml_iname);
+ printf(": ");
+ if (vmi->vmi_idetach != NULL)
+ printf("idetach(); ");
+ if (vmi->vmi_struct_size)
+ printf("free()");
+ printf("\n");
+#endif
+
+ if (vmi->vmi_idetach)
+ vmi->vmi_idetach(vml->vml_iarg);
+
+ if (vmi->vmi_struct_size) {
+ if (curvnet->mod_data[vmi->vmi_id] == NULL)
+ panic("vi_destroy: %s\n", vmi->vmi_name);
+ vi_free(curvnet->mod_data[vmi->vmi_id], M_VNET);
+ curvnet->mod_data[vmi->vmi_id] = NULL;
+ }
return 0;
}
More information about the p4-projects
mailing list