All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Levon <levon@movementarian.org>
To: oprofile-list@lists.sourceforge.net, torvalds@transmeta.com,
	linux-kernel@vger.kernel.org, rusty@rustcorp.com.au
Subject: [PATCH 2/2] Module load notification take 3
Date: Tue, 25 Mar 2003 02:13:50 +0000	[thread overview]
Message-ID: <20030325021350.GA96216@compsoc.man.ac.uk> (raw)
In-Reply-To: <20030325020316.GA95492@compsoc.man.ac.uk>


Implement a module load notifier for the benefit of OProfile, tested
with .66 on UP.
 
This patch (2/2) hooks OProfile into the notifier. You should still be
able to use OProfile 0.5.1 or thereabouts ...

thanks,
john

diff -X dontdiff -Naur linux-linus/drivers/oprofile/buffer_sync.c linux-cvs/drivers/oprofile/buffer_sync.c
--- linux-linus/drivers/oprofile/buffer_sync.c	2003-03-25 01:38:46.000000000 +0000
+++ linux-cvs/drivers/oprofile/buffer_sync.c	2003-03-25 01:34:52.000000000 +0000
@@ -24,6 +24,7 @@
 #include <linux/notifier.h>
 #include <linux/dcookies.h>
 #include <linux/profile.h>
+#include <linux/module.h>
 #include <linux/fs.h>
  
 #include "oprofile_stats.h"
@@ -67,6 +68,19 @@
 }
 
  
+static int module_load_notify(struct notifier_block * self, unsigned long val, void * data)
+{
+	if (val != MODULE_STATE_COMING)
+		return 0;
+
+	sync_cpu_buffers();
+	down(&buffer_sem);
+	add_event_entry(ESCAPE_CODE);
+	add_event_entry(MODULE_LOADED_CODE);
+	up(&buffer_sem);
+	return 0;
+}
+
 static struct notifier_block exit_task_nb = {
 	.notifier_call	= exit_task_notify,
 };
@@ -79,6 +93,10 @@
 	.notifier_call	= mm_notify,
 };
  
+static struct notifier_block module_load_nb = {
+	.notifier_call = module_load_notify,
+};
+
  
 int sync_start(void)
 {
@@ -98,9 +116,14 @@
 	err = profile_event_register(EXEC_UNMAP, &exec_unmap_nb);
 	if (err)
 		goto out3;
+	err = register_module_notifier(&module_load_nb);
+	if (err)
+		goto out4;
 
 out:
 	return err;
+out4:
+	profile_event_unregister(EXEC_UNMAP, &exec_unmap_nb);
 out3:
 	profile_event_unregister(EXIT_MMAP, &exit_mmap_nb);
 out2:
@@ -113,6 +136,7 @@
 
 void sync_stop(void)
 {
+	unregister_module_notifier(&module_load_nb);
 	profile_event_unregister(EXIT_TASK, &exit_task_nb);
 	profile_event_unregister(EXIT_MMAP, &exit_mmap_nb);
 	profile_event_unregister(EXEC_UNMAP, &exec_unmap_nb);
diff -X dontdiff -Naur linux-linus/drivers/oprofile/event_buffer.h linux-cvs/drivers/oprofile/event_buffer.h
--- linux-linus/drivers/oprofile/event_buffer.h	2003-03-17 21:43:41.000000000 +0000
+++ linux-cvs/drivers/oprofile/event_buffer.h	2003-03-25 01:31:43.000000000 +0000
@@ -24,12 +24,13 @@
  * then one of the following codes, then the
  * relevant data.
  */
-#define ESCAPE_CODE		~0UL
+#define ESCAPE_CODE			~0UL
 #define CTX_SWITCH_CODE 		1
 #define CPU_SWITCH_CODE 		2
 #define COOKIE_SWITCH_CODE 		3
 #define KERNEL_ENTER_SWITCH_CODE	4
 #define KERNEL_EXIT_SWITCH_CODE		5
+#define MODULE_LOADED_CODE		6
  
 /* add data to the event buffer */
 void add_event_entry(unsigned long data);

  reply	other threads:[~2003-03-25  2:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-25  2:03 [PATCH 1/2] Module load notification take 3 John Levon
2003-03-25  2:13 ` John Levon [this message]
2003-03-25  6:32 ` Rusty Russell
2003-03-25 11:41   ` John Levon
2003-03-27  2:20     ` Rusty Russell
2003-03-27  4:17       ` John Levon
2003-03-27  5:26         ` Rusty Russell

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=20030325021350.GA96216@compsoc.man.ac.uk \
    --to=levon@movementarian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oprofile-list@lists.sourceforge.net \
    --cc=rusty@rustcorp.com.au \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.