Re: [PATCH 09/11] Task watchers: Add support for per-task watchers

From: Peter Williams
Date: Tue Jun 20 2006 - 01:27:35 EST


Matt Helsley wrote:
This introduces a second, per-task, blocking notifier chain. The per-task
chain offers watchers the chance to register with a specific task nstead of
all tasks. It also allows the watcher to associate a block of data with the task
by wrapping the notifier block using containerof().

Both the global, all-tasks chain and the per-task chain are called from the samefunction. The two types of chains share the same set of notification
values, however registration functions and the registered notifier blocks must
be separate.

These notifiers are only safe if notifier blocks are registered with the current
task while in the context of the current task. This ensures that there are no
races between registration, unregistration, and notification.

Signed-off-by: Matt Helsley <matthltc@xxxxxxxxxx>
Cc: Jes Sorensen <jes@xxxxxxx>
Cc: Chandra S. Seetharaman <sekharan@xxxxxxxxxx>
Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
[bits deleted]

Index: linux-2.6.17-rc6-mm2/kernel/sys.c
===================================================================
--- linux-2.6.17-rc6-mm2.orig/kernel/sys.c
+++ linux-2.6.17-rc6-mm2/kernel/sys.c
@@ -450,13 +450,41 @@ int unregister_task_watcher(struct notif
return blocking_notifier_chain_unregister(&task_watchers, nb);
}
EXPORT_SYMBOL_GPL(unregister_task_watcher);
+static inline int notify_per_task_watchers(unsigned int val,
+ struct task_struct *task)
+{
+ if (get_watch_event(val) != WATCH_TASK_INIT)
+ return raw_notifier_call_chain(&task->notify, val, task);
+ RAW_INIT_NOTIFIER_HEAD(&task->notify);
+ if (task->real_parent)
+ return raw_notifier_call_chain(&task->real_parent->notify,
+ val, task);
+}

It's possible for this task to exit without returning a result.

Peter
--
Peter Williams pwil3058@xxxxxxxxxxxxxx

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/