public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Levon <levon@movementarian.org>
To: torvalds@transmeta.com, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] OProfile: fix init / exit routine
Date: Thu, 12 Jun 2003 03:02:33 +0100	[thread overview]
Message-ID: <10553833533873@movementarian.org> (raw)
In-Reply-To: <10553833522557@movementarian.org>


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);


      reply	other threads:[~2003-06-12  1:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-12  2:02 [PATCH 1/4] OProfile: Export task->tgid in the buffer John Levon
2003-06-12  2:02 ` [PATCH 2/4] OProfile: update Changes John Levon
2003-06-12  2:02   ` [PATCH 3/4] OProfile: remove useless code John Levon
2003-06-12  2:02     ` John Levon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10553833533873@movementarian.org \
    --to=levon@movementarian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox