From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@linux-foundation.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Davide Libenzi <davidel@xmailserver.org>,
Ingo Molnar <mingo@elte.hu>,
Linus Torvalds <torvalds@linux-foundation.org>,
Robin Holt <holt@sgi.com>, Roland McGrath <roland@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Subject: [RFC, PATCH 2/3] implement CLONE_KERNEL_THREAD flag
Date: Sun, 8 Apr 2007 19:55:13 +0400 [thread overview]
Message-ID: <20070408155513.GA129@tv-sign.ru> (raw)
For review only.
We have some problems with the kernel threads parented to /sbin/init, see
http://marc.info/?t=117580282200003&r=1
http://marc.info/?t=95299284800003&r=1
A task created with CLONE_KERNEL_THREAD will have swapper as its parent.
Note that this is only the first step, we can extend the meaning of this
flag to also use init_task for copy_mm/copy_files/etc.
arch/sparc/kernel/process.c
arch/sparc64/kernel/process.c
arch/m68knommu/kernel/process.c
arch/m68k/kernel/process.c
arch/alpha/kernel/entry.S
arch/h8300/kernel/process.c
arch/v850/kernel/process.c
arch/frv/kernel/kernel_thread.S
arch/frv/kernel/kernel_thread.S
arch/powerpc/kernel/misc_32.S
arch/powerpc/kernel/misc_64.S
implement kthread_create() via sys_clone(). This means that these arches can't
take advantage of CLONE_KERNEL_THREAD, it will be filtered out by sys_clone().
This patch breaks arch/ia64/, its sys_clone() was not converted by the previous
patch, so user-space can do sys_clone(CLONE_KERNEL_THREAD).
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
include/linux/sched.h | 5 ++++-
kernel/fork.c | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
--- 2.6.21-rc5-mm4/include/linux/sched.h~2_IMPL 2007-04-07 22:07:50.000000000 +0400
+++ 2.6.21-rc5-mm4/include/linux/sched.h 2007-04-08 18:53:51.000000000 +0400
@@ -28,7 +28,10 @@
#define CLONE_NEWIPC 0x08000000 /* New ipcs */
/* user-space visible */
-#define SYS_CLONE_MASK (~0x0)
+#define SYS_CLONE_MASK (~(CLONE_KERNEL_THREAD))
+
+/* for in kernel use only */
+#define CLONE_KERNEL_THREAD 0x20000000 /* hide from init */
/*
* Scheduling policies
--- 2.6.21-rc5-mm4/kernel/fork.c~2_IMPL 2007-04-07 23:56:08.000000000 +0400
+++ 2.6.21-rc5-mm4/kernel/fork.c 2007-04-08 18:55:42.000000000 +0400
@@ -1159,7 +1159,8 @@ static struct task_struct *copy_process(
p->parent_exec_id = p->self_exec_id;
/* ok, now we should be set up.. */
- p->exit_signal = (clone_flags & CLONE_THREAD) ? -1 : (clone_flags & CSIGNAL);
+ p->exit_signal = (clone_flags & (CLONE_THREAD|CLONE_KERNEL_THREAD))
+ ? -1 : (clone_flags & CSIGNAL);
p->pdeath_signal = 0;
p->exit_state = 0;
@@ -1196,6 +1197,8 @@ static struct task_struct *copy_process(
/* CLONE_PARENT re-uses the old parent */
if (clone_flags & (CLONE_PARENT|CLONE_THREAD))
p->parent = current->parent;
+ else if (unlikely(clone_flags & CLONE_KERNEL_THREAD))
+ p->parent = &init_task;
else
p->parent = current;
reply other threads:[~2007-04-08 15:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070408155513.GA129@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=davidel@xmailserver.org \
--cc=ebiederm@xmission.com \
--cc=holt@sgi.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®