From: Thomas Gleixner <tglx@linutronix.de>
To: Andrew Morton <akpm@osdl.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: [patch 1/2] hrtimer
Date: Sat, 25 Mar 2006 12:46:01 -0000 [thread overview]
Message-ID: <20060325121223.557385000@localhost.localdomain> (raw)
In-Reply-To: 20060325121219.172731000@localhost.localdomain
[-- Attachment #1: hrtimer-create-generic-sleeper.patch --]
[-- Type: text/plain, Size: 2334 bytes --]
The removal of the data field in the hrtimer structure enforces the embedding
of the timer into another data structure. nanosleep now uses a private
implementation of the most common used timer callback function (simple task wakeup).
In order to avoid the reimplentation of such functionality all over the place
a generic hrtimer_sleeper functionality is created.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/hrtimer.h | 16 ++++++++++++++++
kernel/hrtimer.c | 19 +++++++++++++++++++
2 files changed, 35 insertions(+)
Index: linux-2.6.16/include/linux/hrtimer.h
===================================================================
--- linux-2.6.16.orig/include/linux/hrtimer.h
+++ linux-2.6.16/include/linux/hrtimer.h
@@ -58,6 +58,19 @@ struct hrtimer {
};
/**
+ * struct hrtimer_sleeper - simple sleeper structure
+ *
+ * @timer: embedded timer structure
+ * @task: task to wake up
+ *
+ * task is set to NULL, when the timer expires.
+ */
+struct hrtimer_sleeper {
+ struct hrtimer timer;
+ struct task_struct *task;
+};
+
+/**
* struct hrtimer_base - the timer base for a specific clock
*
* @index: clock type index for per_cpu support when moving a timer
@@ -127,6 +140,9 @@ extern long hrtimer_nanosleep(struct tim
const enum hrtimer_mode mode,
const clockid_t clockid);
+extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
+ struct task_struct *tsk);
+
/* Soft interrupt function to run the hrtimer queues: */
extern void hrtimer_run_queues(void);
Index: linux-2.6.16/kernel/hrtimer.c
===================================================================
--- linux-2.6.16.orig/kernel/hrtimer.c
+++ linux-2.6.16/kernel/hrtimer.c
@@ -656,6 +656,25 @@ void hrtimer_run_queues(void)
* Sleep related functions:
*/
+static int hrtimer_wakeup(struct hrtimer *timer)
+{
+ struct hrtimer_sleeper *t =
+ container_of(timer, struct hrtimer_sleeper, timer);
+ struct task_struct *task = t->task;
+
+ t->task = NULL;
+ if (task)
+ wake_up_process(task);
+
+ return HRTIMER_NORESTART;
+}
+
+void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, task_t *task)
+{
+ sl->timer.function = hrtimer_wakeup;
+ sl->task = task;
+}
+
struct sleep_hrtimer {
struct hrtimer timer;
struct task_struct *task;
--
next prev parent reply other threads:[~2006-03-25 12:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-25 12:46 [patch 0/2] hrtimer: generic sleeper infrastructure Thomas Gleixner
2006-03-25 12:46 ` Thomas Gleixner [this message]
2006-03-25 12:46 ` [patch 2/2] hrtimer Thomas Gleixner
2006-03-26 2:32 ` Andrew Morton
2006-03-26 22:10 ` Thomas Gleixner
2006-03-27 23:55 ` Oleg Nesterov
2006-03-28 0:03 ` Roman Zippel
2006-03-28 8:29 ` Thomas Gleixner
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=20060325121223.557385000@localhost.localdomain \
--to=tglx@linutronix.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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.