public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Drokin <green@namesys.com>
To: linux-kernel@vger.kernel.org, torvalds@transmeta.com, jdike@karaya.com
Subject: [2.5] [PATCH] convert UML to new do_fork() API
Date: Tue, 20 May 2003 13:32:58 +0400	[thread overview]
Message-ID: <20030520093258.GA12880@namesys.com> (raw)

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 */

                 reply	other threads:[~2003-05-20 11:27 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=20030520093258.GA12880@namesys.com \
    --to=green@namesys.com \
    --cc=jdike@karaya.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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