[PATCH 4/4] OProfile: fix init / exit routine

John Levon (levon@movementarian.org)
Thu, 12 Jun 2003 03:02:33 +0100


Ensure that the arch exit routines are always called when needed,
previously we could end up with a nasty crash if using oprofile.timer=1,
or the FS register failed.

diff -Naur -X dontdiff linux-cvs/drivers/oprofile/oprof.c linux-fixes/drivers/oprofile/oprof.c
--- linux-cvs/drivers/oprofile/oprof.c 2003-05-26 05:42:45.000000000 +0100
+++ linux-fixes/drivers/oprofile/oprof.c 2003-06-12 03:07:14.000000000 +0100
@@ -131,36 +131,33 @@

static int __init oprofile_init(void)
{
- int err = -ENODEV;
+ /* Architecture must fill in the interrupt ops and the
+ * logical CPU type, or we can fall back to the timer
+ * interrupt profiler.
+ */
+ int err = oprofile_arch_init(&oprofile_ops);

- if (!timer) {
- /* Architecture must fill in the interrupt ops and the
- * logical CPU type, or we can fall back to the timer
- * interrupt profiler.
- */
- err = oprofile_arch_init(&oprofile_ops);
- }
-
- if (err == -ENODEV) {
+ if (err == -ENODEV || timer) {
timer_init(&oprofile_ops);
err = 0;
- }
-
- if (err)
+ } else if (err) {
goto out;
+ }

if (!oprofile_ops->cpu_type) {
printk(KERN_ERR "oprofile: cpu_type not set !\n");
err = -EFAULT;
- goto out;
+ } else {
+ err = oprofilefs_register();
}
-
- err = oprofilefs_register();
- if (err)
- goto out;

+ if (err)
+ goto out_exit;
out:
return err;
+out_exit:
+ oprofile_arch_exit();
+ goto out;
}


diff -Naur -X dontdiff linux-cvs/include/linux/oprofile.h linux-fixes/include/linux/oprofile.h
--- linux-cvs/include/linux/oprofile.h 2003-04-05 05:12:09.000000000 +0100
+++ linux-fixes/include/linux/oprofile.h 2003-06-12 02:03:47.000000000 +0100
@@ -40,7 +40,9 @@

/**
* One-time initialisation. *ops must be set to a filled-in
- * operations structure.
+ * operations structure. This is called even in timer interrupt
+ * mode.
+ *
* Return 0 on success.
*/
int oprofile_arch_init(struct oprofile_operations ** ops);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/