+ task-watchers-add-support-for-per-task-watchers.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     Task watchers: add support for per-task watchers

has been added to the -mm tree.  Its filename is

     task-watchers-add-support-for-per-task-watchers.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: Task watchers: add support for per-task watchers
From: Matt Helsley <matthltc@xxxxxxxxxx>


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
same function.  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>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 include/linux/init_task.h |    2 ++
 include/linux/notifier.h  |    2 ++
 include/linux/sched.h     |    2 ++
 kernel/sys.c              |   30 +++++++++++++++++++++++++++++-
 4 files changed, 35 insertions(+), 1 deletion(-)

diff -puN include/linux/init_task.h~task-watchers-add-support-for-per-task-watchers include/linux/init_task.h
--- a/include/linux/init_task.h~task-watchers-add-support-for-per-task-watchers
+++ a/include/linux/init_task.h
@@ -5,6 +5,7 @@
 #include <linux/rcupdate.h>
 #include <linux/utsname.h>
 #include <linux/ipc.h>
+#include <linux/notifier.h>
 
 #define INIT_FDTABLE \
 {							\
@@ -136,6 +137,7 @@ extern struct group_info init_groups;
 	.cpu_timers	= INIT_CPU_TIMERS(tsk.cpu_timers),		\
 	.fs_excl	= ATOMIC_INIT(0),				\
 	.pi_lock	= SPIN_LOCK_UNLOCKED,				\
+	.notify		= RAW_NOTIFIER_INIT(tsk.notify),		\
 	INIT_RT_MUTEXES(tsk)						\
 }
 
diff -puN include/linux/notifier.h~task-watchers-add-support-for-per-task-watchers include/linux/notifier.h
--- a/include/linux/notifier.h~task-watchers-add-support-for-per-task-watchers
+++ a/include/linux/notifier.h
@@ -156,6 +156,8 @@ extern int raw_notifier_call_chain(struc
 
 extern int register_task_watcher(struct notifier_block *nb);
 extern int unregister_task_watcher(struct notifier_block *nb);
+extern int register_per_task_watcher(struct notifier_block *nb);
+extern int unregister_per_task_watcher(struct notifier_block *nb);
 #define WATCH_FLAGS_MASK		((-1) ^ 0x0FFFFUL)
 #define get_watch_event(v)		({ ((v) & ~WATCH_FLAGS_MASK); })
 #define get_watch_flags(v) 		({ ((v) & WATCH_FLAGS_MASK); })
diff -puN include/linux/sched.h~task-watchers-add-support-for-per-task-watchers include/linux/sched.h
--- a/include/linux/sched.h~task-watchers-add-support-for-per-task-watchers
+++ a/include/linux/sched.h
@@ -975,6 +975,8 @@ struct task_struct {
 	atomic_t fs_excl;	/* holding fs exclusive resources */
 	struct rcu_head rcu;
 
+	struct raw_notifier_head notify; /* generic per-task notifications */
+
 	/*
 	 * cache last used pipe for splice
 	 */
diff -puN kernel/sys.c~task-watchers-add-support-for-per-task-watchers kernel/sys.c
--- a/kernel/sys.c~task-watchers-add-support-for-per-task-watchers
+++ a/kernel/sys.c
@@ -449,9 +449,37 @@ int unregister_task_watcher(struct notif
 }
 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);
+}
+
+int register_per_task_watcher(struct notifier_block *nb)
+{
+	return raw_notifier_chain_register(&current->notify, nb);
+}
+EXPORT_SYMBOL_GPL(register_per_task_watcher);
+
+int unregister_per_task_watcher(struct notifier_block *nb)
+{
+	return raw_notifier_chain_unregister(&current->notify, nb);
+}
+EXPORT_SYMBOL_GPL(unregister_per_task_watcher);
+
 int notify_watchers(unsigned long val, void *v)
 {
-	return blocking_notifier_call_chain(&task_watchers, val, v);
+	int retval;
+
+	retval = blocking_notifier_call_chain(&task_watchers, val, v);
+	if (retval & NOTIFY_STOP_MASK)
+		return retval;
+	return notify_per_task_watchers(val, v);
 }
 
 static int set_one_prio(struct task_struct *p, int niceval, int error)
_

Patches currently in -mm which might be from matthltc@xxxxxxxxxx are

process-events-header-cleanup.patch
process-events-license-change.patch
remove-unecessary-null-check-in-kernel-acctc.patch
mark-profile-notifier-blocks-__read_mostly.patch
task-watchers-task-watchers.patch
task-watchers-task-watchers-tidy.patch
task-watchers-register-process-events-task-watcher.patch
task-watchers-refactor-process-events.patch
task-watchers-make-process-events-configurable-as.patch
task-watchers-allow-task-watchers-to-block.patch
task-watchers-register-audit-task-watcher.patch
task-watchers-register-per-task-delay-accounting.patch
task-watchers-register-profile-as-a-task-watcher.patch
task-watchers-add-support-for-per-task-watchers.patch
task-watchers-register-semundo-task-watcher.patch
task-watchers-register-per-task-semundo-watcher.patch
ipc-replace-kmalloc-and-memset-in-get_undo_list-with-kzalloc.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux