summaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-09-21 19:55:31 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-30 13:35:55 -0400
commit2aa3a7f8660355c3dddead17e224545c1a3d5a5f (patch)
treed106fcaeb6b66e09591cf8ec28c836be93f4d837 /kernel/fork.c
parenta4d94ff8aa864c05b33c2de1f8c5d0176d7a4b63 (diff)
downloadlinux-stable-2aa3a7f8660355c3dddead17e224545c1a3d5a5f.tar.gz
linux-stable-2aa3a7f8660355c3dddead17e224545c1a3d5a5f.tar.bz2
linux-stable-2aa3a7f8660355c3dddead17e224545c1a3d5a5f.zip
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>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c13
1 files changed, 12 insertions, 1 deletions
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,
* requested, no event is reported; otherwise, report if the event
* for the type of forking is enabled.
*/
- if (likely(user_mode(regs)) && !(clone_flags & CLONE_UNTRACED)) {
+ if (!(clone_flags & CLONE_UNTRACED) && likely(user_mode(regs))) {
if (clone_flags & CLONE_VFORK)
trace = PTRACE_EVENT_VFORK;
else if ((clone_flags & CSIGNAL) != SIGCHLD)
@@ -1659,6 +1659,17 @@ long do_fork(unsigned long clone_flags,
return nr;
}
+#ifdef CONFIG_GENERIC_KERNEL_THREAD
+/*
+ * Create a kernel thread.
+ */
+pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
+{
+ return do_fork(flags|CLONE_VM|CLONE_UNTRACED, (unsigned long)fn, NULL,
+ (unsigned long)arg, NULL, NULL);
+}
+#endif
+
#ifndef ARCH_MIN_MMSTRUCT_ALIGN
#define ARCH_MIN_MMSTRUCT_ALIGN 0
#endif