task ornaments (253p6)
Subsystems (6)
PATCH 1/1 task ornaments (253p6)
Hi Linus,
Given application of the syscall latency patch #1, the attached patch adds task ornaments to 2.5.3-pre6, which:
* permit notification of certain major process events (such as signals, exec, fork/clone, exit, syscall entry/exit).
* will permit ptrace() stuff to be done without task reparenting.
* will make it easier to produce a Wine support module.
* may make it possible to abstract out the parent signal notification.
* ([email protected] has also expressed interest with respect to tux).
* ([email protected] has also expressed interest with respect to the linux ABI stuff).
Most notable are the changes to the following files:
include/linux/sched.h
include/linux/taskornament.h
kernel/taskornament.c
David
arch/i386/kernel/ptrace.c +5 -3
@@ -13,6 +13,7 @@#include <linux/errno.h> #include <linux/ptrace.h> #include <linux/user.h> +#include <linux/taskornament.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
@@ -456,9 +457,12 @@ __attribute__((regparm (3 )))void do_syscall_trace (struct pt_regs *regs,int entryexit) { +task_ornament_notify_syscall (regs,entryexit); +if ((current->ptrace & (PT_PTRACED |PT_SYSCALLTRACE )) != (PT_PTRACED |PT_SYSCALLTRACE ))return ; +/* the 0x80 provides a way for the tracing parent to distinguish between a syscall stop and SIGTRAP delivery */ current->exit_code = SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
@@ -484,7 +488,5 @@void do_notify_resume (struct pt_regs *regs,sigset_t *oldset,struct task_work work_pending) { -/* deal with pending signal delivery */ -if (work_pending.sigpending) -do_signal (regs,oldset); +task_ornament_notify_resume (regs,oldset,work_pending); }
arch/i386/kernel/signal.c +22 -0
@@ -20,6 +20,7 @@#include <linux/stddef.h> #include <linux/tty.h> #include <linux/personality.h> +#include <linux/taskornament.h> #include <asm/ucontext.h> #include <asm/uaccess.h> #include <asm/i387.h>
@@ -606,6 +607,27 @@if (!signr)break ; +if (!list_empty (¤t->ornaments)) { +int action =task_ornament_notify_signal (signr,&info); +switch (action) { +case 0 :/* no action */ +break ; +case -1 :/* cancelled */ +continue ; + +default : +/* change of signal +* - if the (new) signal is now blocked, requeue it +*/ + signr = action; +if (sigismember (¤t->blocked,signr)) { +send_sig_info (signr,&info,current); +continue ; + } +break ; + } + } +if ((current->ptrace &PT_PTRACED ) && signr !=SIGKILL ) {/* Let the debugger run. */ current->exit_code = signr;
fs/exec.c +4 -0
@@ -35,6 +35,7 @@#include <linux/highmem.h> #include <linux/spinlock.h> #include <linux/personality.h> +#include <linux/taskornament.h> #define __NO_VERSION__#include <linux/module.h>
@@ -548,6 +549,9 @@if (retval) goto mmap_failed;/* This is the point of no return */ +if (!list_empty (¤t->ornaments)) +task_ornament_notify_execve (); +release_old_signals (oldsig); current->sas_ss_sp = current->sas_ss_size =0 ;
fs/proc/base.c +19 -0
@@ -26,6 +26,7 @@#include <linux/seq_file.h> #include <linux/namespace.h> #include <linux/mm.h> +#include <linux/taskornament.h> /* * For hysterical raisins we keep the same inumbers as in the old procfs.
@@ -289,6 +290,19 @@ release: mounts_release, }; +static ssize_t pid_taskornlist_read (struct file * file,char * buf, +size_t count,loff_t *ppos) +{ +struct inode *inode = file->f_dentry->d_inode; +struct task_struct *task = inode->u.proc_i.task; + +return proc_pid_read_taskornlist (task, file, buf, count, ppos); +} + +static struct file_operations proc_taskornlist_operations = { + read: pid_taskornlist_read, +}; +#define PROC_BLOCK_SIZE (3*1024)/* 4K page size but our output routines use some slack for overruns */ static ssize_t proc_info_read(struct file * file, char * buf,
@@ -541,6 +555,7 @@PROC_PID_MAPS ,PROC_PID_CPU ,PROC_PID_MOUNTS , +PROC_PID_TASKORN , PROC_PID_FD_DIR = 0x8000, /* 0x8000-0xffff */ };
@@ -557,6 +572,7 @@#endif E (PROC_PID_MAPS ,"maps" ,S_IFREG |S_IRUGO ),E (PROC_PID_MEM ,"mem" ,S_IFREG |S_IRUSR |S_IWUSR ), +E (PROC_PID_TASKORN ,"ornaments" ,S_IFREG |S_IRUGO ),E (PROC_PID_CWD ,"cwd" ,S_IFLNK |S_IRWXUGO ),E (PROC_PID_ROOT ,"root" ,S_IFLNK |S_IRWXUGO ), E(PROC_PID_EXE, "exe", S_IFLNK|S_IRWXUGO),
@@ -920,6 +936,9 @@ inode->i_op = &proc_mem_inode_operations; inode->i_fop = &proc_mem_operations;break ; +case PROC_PID_TASKORN : + inode->i_fop = &proc_taskornlist_operations; +break ;case PROC_PID_MOUNTS : inode->i_fop = &proc_mounts_operations;break ;
include/linux/init_task.h +1 -0
@@ -86,6 +86,7 @@ pending: { NULL, &tsk.pending.head, {{0}}}, \ blocked: {{0}}, \ alloc_lock: SPIN_LOCK_UNLOCKED, \ + ornaments: LIST_HEAD_INIT(tsk.ornaments), \ journal_info: NULL, \ }
include/linux/sched.h +3 -0
@@ -364,6 +364,9 @@/* Protection of (de-)allocation: mm, files, fs, tty */ spinlock_t alloc_lock; +/* Task ornaments */ +struct list_head ornaments;/* modify: hold alloc_lock and sigmask_lock */ +/* journalling filesystem info */ void *journal_info; };
include/linux/taskornament.h +192 -0
192 lines not on this page · raw message
kernel/Makefile +2 -2
@@ -10,12 +10,12 @@ O_TARGET := kernel.o export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o \ - printk.o + printk.o taskornament.o obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \ module.o exit.o itimer.o info.o time.o softirq.o resource.o \ sysctl.o acct.o capability.o ptrace.o timer.o user.o \ - signal.o sys.o kmod.o context.o + signal.o sys.o kmod.o context.o taskornament.o obj-$(CONFIG_UID16) += uid16.o obj-$(CONFIG_MODULES) += ksyms.o
kernel/exit.c +2 -1
@@ -18,6 +18,7 @@#include <linux/acct.h> #endif #include <linux/file.h> +#include <linux/taskornament.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
@@ -461,7 +462,6 @@* as a result of our exiting, and if they have any stopped * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2) */ -write_lock_irq (&tasklist_lock); current->state =TASK_ZOMBIE ;do_notify_parent (current, current->exit_signal);
@@ -533,6 +533,7 @@if (tsk->binfmt && tsk->binfmt->module)__MOD_DEC_USE_COUNT (tsk->binfmt->module); +exit_task_ornaments (code); tsk->exit_code = code;exit_notify ();schedule ();
kernel/fork.c +10 -0
@@ -22,6 +22,7 @@#include <linux/namespace.h> #include <linux/personality.h> #include <linux/file.h> +#include <linux/taskornament.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
@@ -676,6 +677,13 @@if (retval) goto bad_fork_cleanup_namespace; p->semundo =NULL ; + +/* +* tell attached ornaments that they may want to duplicate themselves +*/ +INIT_LIST_HEAD (&p->ornaments); +if (!list_empty (¤t->ornaments)) +task_ornament_notify_fork (p,clone_flags);/* Our parent execution domain becomes current domain These must match for thread signalling to apply */
@@ -828,4 +836,6 @@ SLAB_HWCACHE_ALIGN, NULL, NULL);if (!mm_cachep)panic ("vma_init: Cannot alloc mm_struct SLAB cache" ); + +task_ornament_init (); }
kernel/taskornament.c +695 -0
695 lines not on this page · raw message