diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-21 19:55:31 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-30 13:35:55 -0400 |
commit | 2aa3a7f8660355c3dddead17e224545c1a3d5a5f (patch) | |
tree | d106fcaeb6b66e09591cf8ec28c836be93f4d837 | |
parent | a4d94ff8aa864c05b33c2de1f8c5d0176d7a4b63 (diff) |
preparation for generic kernel_thread()
Let architectures select GENERIC_KERNEL_THREAD and have their copy_thread()
treat NULL regs as "it came from kernel_thread(), sp argument contains
the function new thread will be calling and stack_size - the argument for
that function". Switching the architectures begins shortly...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | arch/Kconfig | 3 | ||||
-rw-r--r-- | include/linux/sched.h | 3 | ||||
-rw-r--r-- | kernel/fork.c | 13 |
3 files changed, 18 insertions, 1 deletions
diff --git a/arch/Kconfig b/arch/Kconfig index 72f2fa189cc5..d397e11d167d 100644 --- a/arch/Kconfig +++ b/arch/Kconfig | |||
@@ -258,6 +258,9 @@ config ARCH_WANT_OLD_COMPAT_IPC | |||
258 | select ARCH_WANT_COMPAT_IPC_PARSE_VERSION | 258 | select ARCH_WANT_COMPAT_IPC_PARSE_VERSION |
259 | bool | 259 | bool |
260 | 260 | ||
261 | config GENERIC_KERNEL_THREAD | ||
262 | bool | ||
263 | |||
261 | config HAVE_ARCH_SECCOMP_FILTER | 264 | config HAVE_ARCH_SECCOMP_FILTER |
262 | bool | 265 | bool |
263 | help | 266 | help |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 23bddac4bad8..34da9340c6a4 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2325,6 +2325,9 @@ extern int do_execve(const char *, | |||
2325 | const char __user * const __user *, struct pt_regs *); | 2325 | const char __user * const __user *, struct pt_regs *); |
2326 | extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); | 2326 | extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); |
2327 | struct task_struct *fork_idle(int); | 2327 | struct task_struct *fork_idle(int); |
2328 | #ifdef CONFIG_GENERIC_KERNEL_THREAD | ||
2329 | extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | ||
2330 | #endif | ||
2328 | 2331 | ||
2329 | extern void set_task_comm(struct task_struct *tsk, char *from); | 2332 | extern void set_task_comm(struct task_struct *tsk, char *from); |
2330 | extern char *get_task_comm(char *to, struct task_struct *tsk); | 2333 | extern char *get_task_comm(char *to, struct task_struct *tsk); |
diff --git a/kernel/fork.c b/kernel/fork.c index 2c8857e12855..a42c62a8eb24 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1609,7 +1609,7 @@ long do_fork(unsigned long clone_flags, | |||
1609 | * requested, no event is reported; otherwise, report if the event | 1609 | * requested, no event is reported; otherwise, report if the event |
1610 | * for the type of forking is enabled. | 1610 | * for the type of forking is enabled. |
1611 | */ | 1611 | */ |
1612 | if (likely(user_mode(regs)) && !(clone_flags & CLONE_UNTRACED)) { | 1612 | if (!(clone_flags & CLONE_UNTRACED) && likely(user_mode(regs))) { |
1613 | if (clone_flags & CLONE_VFORK) | 1613 | if (clone_flags & CLONE_VFORK) |
1614 | trace = PTRACE_EVENT_VFORK; | 1614 | trace = PTRACE_EVENT_VFORK; |
1615 | else if ((clone_flags & CSIGNAL) != SIGCHLD) | 1615 | else if ((clone_flags & CSIGNAL) != SIGCHLD) |
@@ -1659,6 +1659,17 @@ long do_fork(unsigned long clone_flags, | |||
1659 | return nr; | 1659 | return nr; |
1660 | } | 1660 | } |
1661 | 1661 | ||
1662 | #ifdef CONFIG_GENERIC_KERNEL_THREAD | ||
1663 | /* | ||
1664 | * Create a kernel thread. | ||
1665 | */ | ||
1666 | pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) | ||
1667 | { | ||
1668 | return do_fork(flags|CLONE_VM|CLONE_UNTRACED, (unsigned long)fn, NULL, | ||
1669 | (unsigned long)arg, NULL, NULL); | ||
1670 | } | ||
1671 | #endif | ||
1672 | |||
1662 | #ifndef ARCH_MIN_MMSTRUCT_ALIGN | 1673 | #ifndef ARCH_MIN_MMSTRUCT_ALIGN |
1663 | #define ARCH_MIN_MMSTRUCT_ALIGN 0 | 1674 | #define ARCH_MIN_MMSTRUCT_ALIGN 0 |
1664 | #endif | 1675 | #endif |