public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: dwalker@mvista.com
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, johnstul@us.ibm.com
Subject: [PATCH 06/10] -mm  clocksource: add block notifier
Date: Thu, 03 Aug 2006 20:24:20 -0700	[thread overview]
Message-ID: <20060804032522.163918000@mvista.com> (raw)
In-Reply-To: 20060804032414.304636000@mvista.com

[-- Attachment #1: clocksource_add_block_notify_on_new_clock.patch --]
[-- Type: text/plain, Size: 3921 bytes --]

Adds a call back interface for register/rating change
events.

Signed-Off-By: Daniel Walker <dwalker@mvista.com>

---
 include/linux/clocksource.h |    9 +++++++++
 kernel/time/clocksource.c   |   19 ++++++++++++++++++-
 kernel/timer.c              |   12 ++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

Index: linux-2.6.17/include/linux/clocksource.h
===================================================================
--- linux-2.6.17.orig/include/linux/clocksource.h
+++ linux-2.6.17/include/linux/clocksource.h
@@ -14,6 +14,7 @@
 #include <linux/list.h>
 #include <linux/plist.h>
 #include <linux/sysdev.h>
+#include <linux/notifier.h>
 #include <asm/div64.h>
 #include <asm/io.h>
 
@@ -26,6 +27,12 @@ typedef u64 cycle_t;
  */
 extern struct clocksource clocksource_jiffies;
 
+/*
+ * Block notifier flags.
+ */
+#define CLOCKSOURCE_NOTIFY_REGISTER	1
+#define CLOCKSOURCE_NOTIFY_RATING	2
+
 /**
  * struct clocksource - hardware abstraction for a free running counter
  *	Provides mostly state-free accessors to the underlying hardware.
@@ -206,6 +213,8 @@ static inline void clocksource_calculate
 
 /* used to install a new clocksource */
 extern int clocksource_register(struct clocksource*);
+extern int clocksource_notifier_register(struct notifier_block*);
+extern int clocksource_notifier_unregister(struct notifier_block*);
 extern int clocksource_sysfs_register(struct sysdev_attribute*);
 extern void clocksource_sysfs_unregister(struct sysdev_attribute*);
 extern void clocksource_rating_change(struct clocksource*);
Index: linux-2.6.17/kernel/time/clocksource.c
===================================================================
--- linux-2.6.17.orig/kernel/time/clocksource.c
+++ linux-2.6.17/kernel/time/clocksource.c
@@ -44,6 +44,18 @@
 static struct plist_head clocksource_list =
 	PLIST_HEAD_INIT(clocksource_list, clocksource_lock);
 static DEFINE_SPINLOCK(clocksource_lock);
+static ATOMIC_NOTIFIER_HEAD(clocksource_list_notifier);
+
+/**
+ * clocksource_notifier_register - Registers a list change notifier
+ * @nb:		pointer to a notifier block
+ *
+ * Returns zero always.
+ */
+int clocksource_notifier_register(struct notifier_block *nb)
+{
+	return atomic_notifier_chain_register(&clocksource_list_notifier, nb);
+}
 
 /**
  * __is_registered - Returns a clocksource if it's registered
@@ -135,6 +147,9 @@ int clocksource_register(struct clocksou
  		plist_add(&c->list, &clocksource_list);
 	}
 	spin_unlock_irqrestore(&clocksource_lock, flags);
+
+	atomic_notifier_call_chain(&clocksource_list_notifier,
+				   CLOCKSOURCE_NOTIFY_REGISTER, c);
 	return ret;
 }
 EXPORT_SYMBOL(clocksource_register);
@@ -162,7 +177,9 @@ void clocksource_rating_change(struct cl
 	plist_node_init(&c->list, CLOCKSOURCE_RATING(c->rating));
 	plist_add(&c->list, &clocksource_list);
 
-	/* XXX: Add block notifier to signal new rating */
+	atomic_notifier_call_chain(&clocksource_list_notifier,
+				   CLOCKSOURCE_NOTIFY_RATING, c);
+
 	spin_unlock_irqrestore(&clocksource_lock, flags);
 }
 EXPORT_SYMBOL(clocksource_rating_change);
Index: linux-2.6.17/kernel/timer.c
===================================================================
--- linux-2.6.17.orig/kernel/timer.c
+++ linux-2.6.17/kernel/timer.c
@@ -1030,6 +1030,17 @@ static int __init boot_override_clocksou
 }
 __setup("timeofday_clocksource=", boot_override_clocksource);
 
+static int
+clocksource_callback(struct notifier_block *nb, unsigned long op, void *c)
+{
+	atomic_inc(&clock_check);
+	return 0;
+}
+
+static struct notifier_block clocksource_nb = {
+	.notifier_call = clocksource_callback,
+};
+
 #else
 #define change_clocksource(x)	do { 0; } while(0)
 #endif
@@ -1120,6 +1131,7 @@ static int __init timekeeping_init_devic
 
 #ifdef CONFIG_GENERIC_TIME
 	atomic_inc(&clock_check);
+	clocksource_notifier_register(&clocksource_nb);
 	clocksource_sysfs_register(&attr_timeofday_clocksource);
 #endif
 	return error;

--

  parent reply	other threads:[~2006-08-04  3:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-04  3:24 [PATCH 00/10] -mm generic clocksoure API dwalker
2006-08-04  3:24 ` [PATCH 01/10] -mm clocksource: increase initcall priority dwalker
2006-08-04 18:39   ` john stultz
2006-08-04  3:24 ` [PATCH 02/10] -mm clocksource: small cleanup dwalker
2006-08-04 18:40   ` john stultz
2006-08-04  3:24 ` [PATCH 03/10] -mm clocksource: enable plist dwalker
2006-08-04  3:24 ` [PATCH 04/10] -mm clocksource: add some new API calls dwalker
2006-08-04 19:06   ` john stultz
2006-08-04 19:28     ` Daniel Walker
2006-08-04 21:05       ` Thomas Gleixner
2006-08-04  3:24 ` [PATCH 05/10] -mm clocksource: convert generic timeofday dwalker
2006-08-04  3:24 ` dwalker [this message]
2006-08-04  3:24 ` [PATCH 07/10] -mm clocksource: remove update_callback dwalker
2006-08-04 19:28   ` john stultz
2006-08-04  3:24 ` [PATCH 08/10] -mm clocksource: cleanup on -mm dwalker
2006-08-04 19:53   ` john stultz
2006-08-04 21:11     ` Daniel Walker
2006-08-04 22:16       ` john stultz
2006-08-04 23:16         ` Daniel Walker
2006-08-04  3:24 ` [PATCH 09/10] -mm clocksource: initialize list value dwalker
2006-08-04  3:24 ` [PATCH 10/10] -mm clocksource: add generic sched_clock() dwalker
  -- strict thread matches above, loose matches on Subject: below --
2006-10-06 18:54 [PATCH 00/10] -mm: generic clocksource API -v2 Daniel Walker
2006-10-06 18:54 ` [PATCH 06/10] -mm: clocksource: add block notifier Daniel Walker
2006-10-09 19:45   ` john stultz

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=20060804032522.163918000@mvista.com \
    --to=dwalker@mvista.com \
    --cc=akpm@osdl.org \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /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