Re: 2.6.7-mm6

From: Nick Piggin
Date: Thu Jul 08 2004 - 21:46:38 EST


David S. Miller wrote:
On Wed, 7 Jul 2004 09:35:10 +0200
Ingo Molnar <mingo@xxxxxxx> wrote:


the patch below should solve this. Is it safe on sparc to do a
fork_by_hand() like this?


If the regs are garbage, copy_thread() will explode as it tries
to interpret the stack pointer in that regs value.

The parent's regs (stored in current_thread_info() at trap time,
and also needed by copy_thread() processing) will also be garbage
since we're avoiding the fork syscall trap.

In short, this won't work :)

This is why I use kernel_thread(). Why is that so bad?


We could make CLONE_IDLETASK clones not do the wakeup?

Ingo? I guess an alternative is to have the arch explicitly
make a call to dequeue it.



---

linux-2.6-npiggin/kernel/fork.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)

diff -puN kernel/fork.c~kernelthread-idle-fix kernel/fork.c
--- linux-2.6/kernel/fork.c~kernelthread-idle-fix 2004-07-09 12:42:02.000000000 +1000
+++ linux-2.6-npiggin/kernel/fork.c 2004-07-09 12:43:11.000000000 +1000
@@ -1215,11 +1215,13 @@ long do_fork(unsigned long clone_flags,
set_tsk_thread_flag(p, TIF_SIGPENDING);
}

- if (!(clone_flags & CLONE_STOPPED))
- wake_up_new_task(p, clone_flags);
- else
- p->state = TASK_STOPPED;
- ++total_forks;
+ if (likely(!(clone_flags & CLONE_IDLETASK))) {
+ if (!(clone_flags & CLONE_STOPPED))
+ wake_up_new_task(p, clone_flags);
+ else
+ p->state = TASK_STOPPED;
+ ++total_forks;
+ }

if (unlikely (trace)) {
current->ptrace_message = pid;

_