Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Jun 2006 06:30:38 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 100037 for review
Message-ID:  <200606260630.k5Q6Uc3m024128@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=100037

Change 100037 by jb@jb_freebsd2 on 2006/06/26 06:29:57

	Create system initialisation callbacks for the DTrace providers
	so that ther are initialised early in the boot process and available
	for tracing the device probes etc (which may be loaded in modules
	too, but they are listed later in the system initialisation order)/

Affected files ...

.. //depot/projects/dtrace/src/sys/cddl/dev/fbt/fbt.c#3 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/profile/profile.c#2 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/prototype.c#3 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/sdt/sdt.c#3 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/systrace/systrace.c#6 edit

Differences ...

==== //depot/projects/dtrace/src/sys/cddl/dev/fbt/fbt.c#3 (text+ko) ====

@@ -101,12 +101,12 @@
 #endif
 
 static d_open_t	fbt_open;
-static int	fbt_load(void);
 static int	fbt_unload(void);
 static void	fbt_provide_module(void *, modctl_t *);
 static void	fbt_destroy(void *, dtrace_id_t, void *);
 static void	fbt_enable(void *, dtrace_id_t, void *);
 static void	fbt_disable(void *, dtrace_id_t, void *);
+static void	fbt_load(void *);
 static void	fbt_suspend(void *, dtrace_id_t, void *);
 static void	fbt_resume(void *, dtrace_id_t, void *);
 
@@ -251,15 +251,18 @@
 	    strncmp(name, "kdb_", 4) == 0 ||
 	    strncmp(name, "intr_", 5) == 0 ||
 
+	    strncmp(name, "X_", 2) == 0 ||
 	    strncmp(name, "vm", 2) == 0 ||
 	    strncmp(name, "th", 2) == 0 ||
 	    strncmp(name, "sh", 2) == 0 ||
 	    strncmp(name, "fi", 2) == 0 ||
 	    strncmp(name, "fd", 2) == 0 ||
+	    strncmp(name, "elf", 3) == 0 ||
 	    strncmp(name, "str", 3) == 0 ||
 	    strncmp(name, "nfs", 3) == 0 ||
 	    strncmp(name, "ata_", 4) == 0 ||
 	    strncmp(name, "acpi", 4) == 0 ||
+	    strncmp(name, "link_", 5) == 0 ||
 	    strncmp(name, "bufobj", 6) == 0 ||
 	    strncmp(name, "linker", 6) == 0 ||
 	    strncmp(name, "witness", 7) == 0 ||
@@ -589,11 +592,9 @@
 		*fbt->fbtp_patchpoint = fbt->fbtp_patchval;
 }
 
-static int
-fbt_load()
+static void
+fbt_load(void *dummy)
 {
-	int error = 0;
-
 	/* Default the probe table size if not specified. */
 	if (fbt_probetab_size == 0)
 		fbt_probetab_size = FBT_PROBETAB_SIZE;
@@ -607,15 +608,9 @@
 
 	dtrace_invop_add(fbt_invop);
 
-	if ((error = dtrace_register("fbt", &fbt_attr, DTRACE_PRIV_USER,
-	    NULL, &fbt_pops, NULL, &fbt_id)) != 0)
-		return (error);
-
-	/* Create the /dev/dtrace/fbt entry. */
-	fbt_cdev = make_dev(&fbt_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
-	    "dtrace/fbt");
-
-	return (error);
+	if (dtrace_register("fbt", &fbt_attr, DTRACE_PRIV_USER,
+	    NULL, &fbt_pops, NULL, &fbt_id) != 0)
+		return;
 }
 
 
@@ -649,8 +644,9 @@
 
 	switch (type) {
 	case MOD_LOAD:
-		printf("fbt -----------------------------------------------\n");
-		error = fbt_load();
+		/* Create the /dev/dtrace/fbt entry. */
+		fbt_cdev = make_dev(&fbt_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
+		    "dtrace/fbt");
 		break;
 
 	case MOD_UNLOAD:
@@ -676,6 +672,8 @@
 	return (0);
 }
 
+SYSINIT(fbt_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, fbt_load, NULL)
+
 DEV_MODULE(fbt, fbt_modevent, NULL);
 MODULE_VERSION(fbt, 1);
 MODULE_DEPEND(fbt, dtrace, 1, 1, 1);

==== //depot/projects/dtrace/src/sys/cddl/dev/profile/profile.c#2 (text+ko) ====

@@ -131,13 +131,13 @@
 } profile_probe_percpu_t;
 
 static d_open_t	profile_open;
-static int	profile_load(void);
 static int	profile_unload(void);
-static void	profile_provide(void *, dtrace_probedesc_t *);
+static void	profile_create(hrtime_t, char *, int);
 static void	profile_destroy(void *, dtrace_id_t, void *);
 static void	profile_enable(void *, dtrace_id_t, void *);
 static void	profile_disable(void *, dtrace_id_t, void *);
-static void	profile_create(hrtime_t, char *, int);
+static void	profile_load(void *);
+static void	profile_provide(void *, dtrace_probedesc_t *);
 
 static int profile_rates[] = {
     97, 199, 499, 997, 1999,
@@ -476,20 +476,12 @@
 	prof->prof_cyclic = CYCLIC_NONE;
 }
 
-static int
-profile_load()
+static void
+profile_load(void *dummy)
 {
-	int error = 0;
-
-	if ((error = dtrace_register("profile", &profile_attr, DTRACE_PRIV_USER,
-	    NULL, &profile_pops, NULL, &profile_id)) != 0)
-		return (error);
-
-	/* Create the /dev/dtrace/profile entry. */
-	profile_cdev = make_dev(&profile_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
-	    "dtrace/profile");
-
-	return (error);
+	if (dtrace_register("profile", &profile_attr, DTRACE_PRIV_USER,
+	    NULL, &profile_pops, NULL, &profile_id) != 0)
+		return;
 }
 
 
@@ -514,8 +506,9 @@
 
 	switch (type) {
 	case MOD_LOAD:
-		printf("profile ------------------------------------------------\n");
-		error = profile_load();
+		/* Create the /dev/dtrace/profile entry. */
+		profile_cdev = make_dev(&profile_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
+		    "dtrace/profile");
 		break;
 
 	case MOD_UNLOAD:
@@ -540,6 +533,8 @@
 	return (0);
 }
 
+SYSINIT(profile_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, profile_load, NULL)
+
 DEV_MODULE(profile, profile_modevent, NULL);
 MODULE_VERSION(profile, 1);
 MODULE_DEPEND(profile, dtrace, 1, 1, 1);

==== //depot/projects/dtrace/src/sys/cddl/dev/prototype.c#3 (text+ko) ====

@@ -62,12 +62,12 @@
 #include <sys/sdt.h>
 
 static d_open_t	prototype_open;
-static int	prototype_load(void);
 static int	prototype_unload(void);
 static void	prototype_provide(void *, dtrace_probedesc_t *);
 static void	prototype_destroy(void *, dtrace_id_t, void *);
 static void	prototype_enable(void *, dtrace_id_t, void *);
 static void	prototype_disable(void *, dtrace_id_t, void *);
+static void	prototype_load(void *);
 
 static struct cdevsw prototype_cdevsw = {
 	.d_version	= D_VERSION,
@@ -127,20 +127,12 @@
 {
 }
 
-static int
-prototype_load()
+static void
+prototype_load(void *dummy)
 {
-	int error = 0;
-
-	if ((error = dtrace_register("prototype", &prototype_attr, DTRACE_PRIV_USER,
-	    NULL, &prototype_pops, NULL, &prototype_id)) != 0)
-		return (error);
-
-	/* Create the /dev/dtrace/prototype entry. */
-	prototype_cdev = make_dev(&prototype_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
-	    "dtrace/prototype");
-
-	return (error);
+	if (dtrace_register("prototype", &prototype_attr, DTRACE_PRIV_USER,
+	    NULL, &prototype_pops, NULL, &prototype_id) != 0)
+		return;
 }
 
 
@@ -165,8 +157,9 @@
 
 	switch (type) {
 	case MOD_LOAD:
-		printf("prototype -----------------------------------------------\n");
-		error = prototype_load();
+		/* Create the /dev/dtrace/prototype entry. */
+		prototype_cdev = make_dev(&prototype_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
+		    "dtrace/prototype");
 		break;
 
 	case MOD_UNLOAD:
@@ -192,6 +185,8 @@
 	return (0);
 }
 
+SYSINIT(prototype_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, prototype_load, NULL)
+
 DEV_MODULE(prototype, prototype_modevent, NULL);
 MODULE_VERSION(prototype, 1);
 MODULE_DEPEND(prototype, dtrace, 1, 1, 1);

==== //depot/projects/dtrace/src/sys/cddl/dev/sdt/sdt.c#3 (text+ko) ====

@@ -63,13 +63,13 @@
 #include <sys/sdt.h>
 
 static d_open_t	sdt_open;
-static int	sdt_load(void);
 static int	sdt_provide_ref(struct sdt_ref *, void *);
 static int	sdt_unload(void);
 static void	sdt_provide(void *, dtrace_probedesc_t *);
 static void	sdt_destroy(void *, dtrace_id_t, void *);
 static void	sdt_enable(void *, dtrace_id_t, void *);
 static void	sdt_disable(void *, dtrace_id_t, void *);
+static void	sdt_load(void *);
 
 static struct cdevsw sdt_cdevsw = {
 	.d_version	= D_VERSION,
@@ -171,26 +171,18 @@
 #endif
 }
 
-static int
-sdt_load()
+static void
+sdt_load(void *dummy)
 {
-	int error = 0;
-
-	if ((error = dtrace_register("sdt", &sdt_attr, DTRACE_PRIV_USER,
-	    NULL, &sdt_pops, NULL, &sdt_id)) != 0)
-		return (error);
+	if (dtrace_register("sdt", &sdt_attr, DTRACE_PRIV_USER,
+	    NULL, &sdt_pops, NULL, &sdt_id) != 0)
+		return;
 
-	/* Create the /dev/dtrace/sdt entry. */
-	sdt_cdev = make_dev(&sdt_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
-	    "dtrace/sdt");
-
 	/*
 	 * Register the read DTrace probe function pointer in place
 	 * of the stub.
 	 */
 	sdt_probe_func = dtrace_probe;
-
-	return (error);
 }
 
 
@@ -220,8 +212,9 @@
 
 	switch (type) {
 	case MOD_LOAD:
-		printf("sdt ----------------------------------------------------\n");
-		error = sdt_load();
+		/* Create the /dev/dtrace/sdt entry. */
+		sdt_cdev = make_dev(&sdt_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
+		    "dtrace/sdt");
 		break;
 
 	case MOD_UNLOAD:
@@ -246,6 +239,8 @@
 	return (0);
 }
 
+SYSINIT(sdt_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, sdt_load, NULL)
+
 DEV_MODULE(sdt, sdt_modevent, NULL);
 MODULE_VERSION(sdt, 1);
 MODULE_DEPEND(sdt, dtrace, 1, 1, 1);

==== //depot/projects/dtrace/src/sys/cddl/dev/systrace/systrace.c#6 (text+ko) ====

@@ -75,7 +75,6 @@
 extern char	*syscallnames[];
 
 static d_open_t	systrace_open;
-static int	systrace_load(void);
 static int	systrace_unload(void);
 static void	systrace_args(int, void *, u_int64_t *, int *);
 static void	systrace_probe(u_int32_t, int, struct sysent *, void *);
@@ -83,6 +82,7 @@
 static void	systrace_destroy(void *, dtrace_id_t, void *);
 static void	systrace_enable(void *, dtrace_id_t, void *);
 static void	systrace_disable(void *, dtrace_id_t, void *);
+static void	systrace_load(void *);
 
 static struct cdevsw systrace_cdevsw = {
 	.d_version	= D_VERSION,
@@ -229,22 +229,14 @@
 	sysent[sysnum].sy_return = 0;
 }
 
-static int
-systrace_load()
+static void
+systrace_load(void *dummy)
 {
-	int error = 0;
-
-	if ((error = dtrace_register("syscall", &systrace_attr, DTRACE_PRIV_USER,
-	    NULL, &systrace_pops, NULL, &systrace_id)) != 0)
-		return (error);
+	if (dtrace_register("syscall", &systrace_attr, DTRACE_PRIV_USER,
+	    NULL, &systrace_pops, NULL, &systrace_id) != 0)
+		return;
 
-	/* Create the /dev/dtrace/systrace entry. */
-	systrace_cdev = make_dev(&systrace_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
-	    "dtrace/systrace");
-
 	systrace_probe_func = systrace_probe;
-
-	return (error);
 }
 
 
@@ -271,8 +263,9 @@
 
 	switch (type) {
 	case MOD_LOAD:
-		printf("systrace -----------------------------------------------\n");
-		error = systrace_load();
+		/* Create the /dev/dtrace/systrace entry. */
+		systrace_cdev = make_dev(&systrace_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
+	 	   "dtrace/systrace");
 		break;
 
 	case MOD_UNLOAD:
@@ -297,6 +290,8 @@
 	return (0);
 }
 
+SYSINIT(systrace_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_load, NULL)
+
 DEV_MODULE(systrace, systrace_modevent, NULL);
 MODULE_VERSION(systrace, 1);
 MODULE_DEPEND(systrace, dtrace, 1, 1, 1);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606260630.k5Q6Uc3m024128>