diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2008-01-24 02:54:47 -0500 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-01-28 04:50:36 -0500 |
commit | fadad878cc0640cc9cd5569998bf54b693f7b38b (patch) | |
tree | 9ad8c65d458d45f970f7e78cd1512c0e7da58def | |
parent | 521f3bbdba6b92582ef8047df01b156668343542 (diff) |
kernel: add CLONE_IO to specifically request sharing of IO contexts
syslets (or other threads/processes that want io context sharing) can
set this to enforce sharing of io context.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | include/linux/sched.h | 1 | ||||
-rw-r--r-- | kernel/fork.c | 14 |
2 files changed, 11 insertions, 4 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 80837e7d527e..2d0546e884ea 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define CLONE_NEWUSER 0x10000000 /* New user namespace */ | 27 | #define CLONE_NEWUSER 0x10000000 /* New user namespace */ |
28 | #define CLONE_NEWPID 0x20000000 /* New pid namespace */ | 28 | #define CLONE_NEWPID 0x20000000 /* New pid namespace */ |
29 | #define CLONE_NEWNET 0x40000000 /* New network namespace */ | 29 | #define CLONE_NEWNET 0x40000000 /* New network namespace */ |
30 | #define CLONE_IO 0x80000000 /* Clone io context */ | ||
30 | 31 | ||
31 | /* | 32 | /* |
32 | * Scheduling policies | 33 | * Scheduling policies |
diff --git a/kernel/fork.c b/kernel/fork.c index 1987c57abb08..314f5101d2b0 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -792,15 +792,21 @@ out: | |||
792 | return error; | 792 | return error; |
793 | } | 793 | } |
794 | 794 | ||
795 | static int copy_io(struct task_struct *tsk) | 795 | static int copy_io(unsigned long clone_flags, struct task_struct *tsk) |
796 | { | 796 | { |
797 | #ifdef CONFIG_BLOCK | 797 | #ifdef CONFIG_BLOCK |
798 | struct io_context *ioc = current->io_context; | 798 | struct io_context *ioc = current->io_context; |
799 | 799 | ||
800 | if (!ioc) | 800 | if (!ioc) |
801 | return 0; | 801 | return 0; |
802 | 802 | /* | |
803 | if (ioprio_valid(ioc->ioprio)) { | 803 | * Share io context with parent, if CLONE_IO is set |
804 | */ | ||
805 | if (clone_flags & CLONE_IO) { | ||
806 | tsk->io_context = ioc_task_link(ioc); | ||
807 | if (unlikely(!tsk->io_context)) | ||
808 | return -ENOMEM; | ||
809 | } else if (ioprio_valid(ioc->ioprio)) { | ||
804 | tsk->io_context = alloc_io_context(GFP_KERNEL, -1); | 810 | tsk->io_context = alloc_io_context(GFP_KERNEL, -1); |
805 | if (unlikely(!tsk->io_context)) | 811 | if (unlikely(!tsk->io_context)) |
806 | return -ENOMEM; | 812 | return -ENOMEM; |
@@ -1176,7 +1182,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1176 | goto bad_fork_cleanup_mm; | 1182 | goto bad_fork_cleanup_mm; |
1177 | if ((retval = copy_namespaces(clone_flags, p))) | 1183 | if ((retval = copy_namespaces(clone_flags, p))) |
1178 | goto bad_fork_cleanup_keys; | 1184 | goto bad_fork_cleanup_keys; |
1179 | if ((retval = copy_io(p))) | 1185 | if ((retval = copy_io(clone_flags, p))) |
1180 | goto bad_fork_cleanup_namespaces; | 1186 | goto bad_fork_cleanup_namespaces; |
1181 | retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs); | 1187 | retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs); |
1182 | if (retval) | 1188 | if (retval) |