public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.5] [PATCH] convert UML to new do_fork() API
@ 2003-05-20  9:32 Oleg Drokin
  0 siblings, 0 replies; only message in thread
From: Oleg Drokin @ 2003-05-20  9:32 UTC (permalink / raw)
  To: linux-kernel, torvalds, jdike

Hello!

   The patch below converts UML to use do_fork() according to new API
   and it also now uses copy_process/wake_up_forked_process to create
   idle threads in SMP mode.
   I verified that it boots and works fine in UP (tt and skas mode) and in SMP
   with more than one virtual CPU.

   Please apply.

Bye,
    Oleg

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1106  -> 1.1107 
#	arch/um/kernel/smp.c	1.14    -> 1.15   
#	arch/um/kernel/process_kern.c	1.18    -> 1.19   
#	arch/um/kernel/syscall_kern.c	1.8     -> 1.9    
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/05/20	green@angband.namesys.com	1.1107
# UML: adopt to new do_fork() API
# --------------------------------------------
#
diff -Nru a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
--- a/arch/um/kernel/process_kern.c	Tue May 20 13:22:37 2003
+++ b/arch/um/kernel/process_kern.c	Tue May 20 13:22:37 2003
@@ -104,13 +104,12 @@
 
 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
 {
-	struct task_struct *p;
-
+	long err;
 	current->thread.request.u.thread.proc = fn;
 	current->thread.request.u.thread.arg = arg;
-	p = do_fork(CLONE_VM | flags, 0, NULL, 0, NULL, NULL);
-	if(IS_ERR(p)) panic("do_fork failed in kernel_thread");
-	return(p->pid);
+	err = do_fork(CLONE_VM | flags, 0, NULL, 0, NULL, NULL);
+	if(err < 0) panic("do_fork failed in kernel_thread, errno %d", errno);
+	return(err);
 }
 
 void switch_mm(struct mm_struct *prev, struct mm_struct *next, 
diff -Nru a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c
--- a/arch/um/kernel/smp.c	Tue May 20 13:22:37 2003
+++ b/arch/um/kernel/smp.c	Tue May 20 13:22:37 2003
@@ -140,8 +140,8 @@
 
         current->thread.request.u.thread.proc = idle_proc;
         current->thread.request.u.thread.arg = (void *) cpu;
-	new_task = do_fork(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL, NULL);
-	if(IS_ERR(new_task)) panic("do_fork failed in idle_thread");
+	new_task = copy_process(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL, NULL);
+	if(IS_ERR(new_task)) panic("copy_process failed in idle_thread");
 
 	cpu_tasks[cpu] = ((struct cpu_task) 
 		          { .pid = 	new_task->thread.mode.tt.extern_pid,
@@ -150,6 +150,7 @@
 	CHOOSE_MODE(write(new_task->thread.mode.tt.switch_pipe[1], &c, 
 			  sizeof(c)),
 		    ({ panic("skas mode doesn't support SMP"); }));
+	wake_up_forked_process(new_task);
 	return(new_task);
 }
 
diff -Nru a/arch/um/kernel/syscall_kern.c b/arch/um/kernel/syscall_kern.c
--- a/arch/um/kernel/syscall_kern.c	Tue May 20 13:22:37 2003
+++ b/arch/um/kernel/syscall_kern.c	Tue May 20 13:22:37 2003
@@ -35,32 +35,32 @@
 
 long sys_fork(void)
 {
-	struct task_struct *p;
+	long pid;
 
 	current->thread.forking = 1;
-        p = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
+        pid = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
 	current->thread.forking = 0;
-	return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
+	return(pid);
 }
 
 long sys_clone(unsigned long clone_flags, unsigned long newsp)
 {
-	struct task_struct *p;
+	long pid;
 
 	current->thread.forking = 1;
-	p = do_fork(clone_flags, newsp, NULL, 0, NULL, NULL);
+	pid = do_fork(clone_flags, newsp, NULL, 0, NULL, NULL);
 	current->thread.forking = 0;
-	return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
+	return(pid);
 }
 
 long sys_vfork(void)
 {
-	struct task_struct *p;
+	long pid;
 
 	current->thread.forking = 1;
-	p = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL, NULL);
+	pid = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL, NULL);
 	current->thread.forking = 0;
-	return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
+	return(pid);
 }
 
 /* common code for old and new mmaps */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-20 11:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-20  9:32 [2.5] [PATCH] convert UML to new do_fork() API Oleg Drokin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox