mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Hotplug CPU prep III: daemonize idle tasks
@ 2002-05-09  8:50 Rusty Russell
  2002-05-09 12:06 ` BALBIR SINGH
  0 siblings, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2002-05-09  8:50 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

This patch introduces __daemonize(task), so idle tasks can be detached
after cloning (required for late creation of idle tasks).

This is independent of the last two patches.

Name: Daemonize idle task
Author: Rusty Russell

D: This patch allows daemonize() to be called on another process (if
D: not started yet), and calls it on the idle task.

diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5.14-dofork+clonepid/include/linux/sched.h tmp/include/linux/sched.h
--- working-2.5.14-dofork+clonepid/include/linux/sched.h	Thu May  9 18:25:21 2002
+++ tmp/include/linux/sched.h	Thu May  9 18:36:17 2002
@@ -654,7 +654,12 @@
 extern void exit_sighand(struct task_struct *);
 
 extern void reparent_to_init(void);
-extern void daemonize(void);
+extern void __daemonize(struct task_struct *);
+static inline void daemonize(void)
+{
+	__daemonize(current);
+}
+
 extern task_t *child_reaper;
 
 extern int do_execve(char *, char **, char **, struct pt_regs *);
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5.14-dofork+clonepid/kernel/exit.c tmp/kernel/exit.c
--- working-2.5.14-dofork+clonepid/kernel/exit.c	Mon Apr 29 16:00:29 2002
+++ tmp/kernel/exit.c	Thu May  9 18:36:17 2002
@@ -201,32 +201,30 @@
  *	Put all the gunge required to become a kernel thread without
  *	attached user resources in one place where it belongs.
  */
-
-void daemonize(void)
+void __daemonize(struct task_struct *tsk)
 {
 	struct fs_struct *fs;
 
-
 	/*
 	 * If we were started as result of loading a module, close all of the
 	 * user space pages.  We don't need them, and if we didn't close them
 	 * they would be locked into memory.
 	 */
-	exit_mm(current);
+	exit_mm(tsk);
 
-	current->session = 1;
-	current->pgrp = 1;
-	current->tty = NULL;
+	tsk->session = 1;
+	tsk->pgrp = 1;
+	tsk->tty = NULL;
 
 	/* Become as one with the init task */
 
-	exit_fs(current);	/* current->fs->count--; */
+	exit_fs(tsk);	/* current->fs->count--; */
 	fs = init_task.fs;
-	current->fs = fs;
+	tsk->fs = fs;
 	atomic_inc(&fs->count);
- 	exit_files(current);
-	current->files = init_task.files;
-	atomic_inc(&current->files->count);
+ 	exit_files(tsk);
+	tsk->files = init_task.files;
+	atomic_inc(&tsk->files->count);
 }
 
 /*
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5.14-dofork+clonepid/kernel/sched.c tmp/kernel/sched.c
--- working-2.5.14-dofork+clonepid/kernel/sched.c	Wed May  1 15:09:29 2002
+++ tmp/kernel/sched.c	Thu May  9 18:45:17 2002
@@ -1555,6 +1555,8 @@
 	runqueue_t *idle_rq = cpu_rq(cpu), *rq = cpu_rq(idle->thread_info->cpu);
 	unsigned long flags;
 
+	if (idle != &init_task)
+		__daemonize(idle);
 	__save_flags(flags);
 	__cli();
 	double_rq_lock(idle_rq, rq);

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] Hotplug CPU prep III: daemonize idle tasks
  2002-05-09  8:50 [PATCH] Hotplug CPU prep III: daemonize idle tasks Rusty Russell
@ 2002-05-09 12:06 ` BALBIR SINGH
  2002-05-13  2:01   ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: BALBIR SINGH @ 2002-05-09 12:06 UTC (permalink / raw)
  To: Rusty Russell, torvalds; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 4071 bytes --]

I tried a version of __daemonize in 2.4. It panics in
schedule()

        prepare_to_switch();
        {
                struct mm_struct *mm = next->mm;
                struct mm_struct *oldmm = prev->active_mm;
                if (!mm) {
                        if (next->active_mm) BUG();

I got hit by the BUG() in 2.4, I think prepare_to_switch has
moved to specific archs in 2.5. A quick look showed that
this issue no longer exists in 2.5.

Comments,
Balbir Singh.

|-----Original Message-----
|From: linux-kernel-owner@vger.kernel.org
|[mailto:linux-kernel-owner@vger.kernel.org]On Behalf Of Rusty Russell
|Sent: Thursday, May 09, 2002 2:20 PM
|To: torvalds@transmeta.com
|Cc: linux-kernel@vger.kernel.org
|Subject: [PATCH] Hotplug CPU prep III: daemonize idle tasks
|
|
|This patch introduces __daemonize(task), so idle tasks can be detached
|after cloning (required for late creation of idle tasks).
|
|This is independent of the last two patches.
|
|Name: Daemonize idle task
|Author: Rusty Russell
|
|D: This patch allows daemonize() to be called on another process (if
|D: not started yet), and calls it on the idle task.
|
|diff -urN -I \$.*\$ --exclude TAGS -X 
|/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
|working-2.5.14-dofork+clonepid/include/linux/sched.h 
|tmp/include/linux/sched.h
|--- working-2.5.14-dofork+clonepid/include/linux/sched.h	Thu 
|May  9 18:25:21 2002
|+++ tmp/include/linux/sched.h	Thu May  9 18:36:17 2002
|@@ -654,7 +654,12 @@
| extern void exit_sighand(struct task_struct *);
| 
| extern void reparent_to_init(void);
|-extern void daemonize(void);
|+extern void __daemonize(struct task_struct *);
|+static inline void daemonize(void)
|+{
|+	__daemonize(current);
|+}
|+
| extern task_t *child_reaper;
| 
| extern int do_execve(char *, char **, char **, struct pt_regs *);
|diff -urN -I \$.*\$ --exclude TAGS -X 
|/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
|working-2.5.14-dofork+clonepid/kernel/exit.c tmp/kernel/exit.c
|--- working-2.5.14-dofork+clonepid/kernel/exit.c	Mon Apr 29 
|16:00:29 2002
|+++ tmp/kernel/exit.c	Thu May  9 18:36:17 2002
|@@ -201,32 +201,30 @@
|  *	Put all the gunge required to become a kernel thread without
|  *	attached user resources in one place where it belongs.
|  */
|-
|-void daemonize(void)
|+void __daemonize(struct task_struct *tsk)
| {
| 	struct fs_struct *fs;
| 
|-
| 	/*
| 	 * If we were started as result of loading a module, close 
|all of the
| 	 * user space pages.  We don't need them, and if we didn't 
|close them
| 	 * they would be locked into memory.
| 	 */
|-	exit_mm(current);
|+	exit_mm(tsk);
| 
|-	current->session = 1;
|-	current->pgrp = 1;
|-	current->tty = NULL;
|+	tsk->session = 1;
|+	tsk->pgrp = 1;
|+	tsk->tty = NULL;
| 
| 	/* Become as one with the init task */
| 
|-	exit_fs(current);	/* current->fs->count--; */
|+	exit_fs(tsk);	/* current->fs->count--; */
| 	fs = init_task.fs;
|-	current->fs = fs;
|+	tsk->fs = fs;
| 	atomic_inc(&fs->count);
|- 	exit_files(current);
|-	current->files = init_task.files;
|-	atomic_inc(&current->files->count);
|+ 	exit_files(tsk);
|+	tsk->files = init_task.files;
|+	atomic_inc(&tsk->files->count);
| }
| 
| /*
|diff -urN -I \$.*\$ --exclude TAGS -X 
|/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
|working-2.5.14-dofork+clonepid/kernel/sched.c tmp/kernel/sched.c
|--- working-2.5.14-dofork+clonepid/kernel/sched.c	Wed May  1 
|15:09:29 2002
|+++ tmp/kernel/sched.c	Thu May  9 18:45:17 2002
|@@ -1555,6 +1555,8 @@
| 	runqueue_t *idle_rq = cpu_rq(cpu), *rq = 
|cpu_rq(idle->thread_info->cpu);
| 	unsigned long flags;
| 
|+	if (idle != &init_task)
|+		__daemonize(idle);
| 	__save_flags(flags);
| 	__cli();
| 	double_rq_lock(idle_rq, rq);
|
|--
|  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
|-
|To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
|the body of a message to majordomo@vger.kernel.org
|More majordomo info at  http://vger.kernel.org/majordomo-info.html
|Please read the FAQ at  http://www.tux.org/lkml/

[-- Attachment #2: Wipro_Disclaimer.txt --]
[-- Type: text/plain, Size: 490 bytes --]

**************************Disclaimer************************************
      


Information contained in this E-MAIL being proprietary to Wipro Limited
is 'privileged' and 'confidential' and intended for use only by the
individual or entity to which it is addressed. You are notified that any
use, copying or dissemination of the information contained in the E-MAIL
in any manner whatsoever is strictly prohibited.



 ********************************************************************

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Hotplug CPU prep III: daemonize idle tasks
  2002-05-09 12:06 ` BALBIR SINGH
@ 2002-05-13  2:01   ` Rusty Russell
  2002-05-13  6:19     ` BALBIR SINGH
  0 siblings, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2002-05-13  2:01 UTC (permalink / raw)
  To: BALBIR SINGH; +Cc: torvalds, linux-kernel

In message <AAEGIMDAKGCBHLBAACGBAELNCHAA.balbir.singh@wipro.com> you write:
> I tried a version of __daemonize in 2.4. It panics in
> schedule()
> 
>         prepare_to_switch();
>         {
>                 struct mm_struct *mm = next->mm;
>                 struct mm_struct *oldmm = prev->active_mm;
>                 if (!mm) {
>                         if (next->active_mm) BUG();
> 
> I got hit by the BUG() in 2.4, I think prepare_to_switch has
> moved to specific archs in 2.5. A quick look showed that
> this issue no longer exists in 2.5.

Uhhh... there are many other problems if you are trying to do this on
a "live" process.  idle process creation is a special case because it
has never been run yet.

This is not a generic "daemonize this task" mechanism!
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] Hotplug CPU prep III: daemonize idle tasks
  2002-05-13  2:01   ` Rusty Russell
@ 2002-05-13  6:19     ` BALBIR SINGH
  0 siblings, 0 replies; 4+ messages in thread
From: BALBIR SINGH @ 2002-05-13  6:19 UTC (permalink / raw)
  To: Rusty Russell; +Cc: torvalds, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]

Should __daemonize() check this? check if in the arguments
tsk == current or tsk == idle_task. This would prevent people
from using __daemonize() for the wrong things.

Balbir

|-----Original Message-----
|From: linux-kernel-owner@vger.kernel.org
|[mailto:linux-kernel-owner@vger.kernel.org]On Behalf Of Rusty Russell
|Sent: Monday, May 13, 2002 7:31 AM
|To: BALBIR SINGH
|Cc: torvalds@transmeta.com; linux-kernel@vger.kernel.org
|Subject: Re: [PATCH] Hotplug CPU prep III: daemonize idle tasks
|
|
|In message <AAEGIMDAKGCBHLBAACGBAELNCHAA.balbir.singh@wipro.com> you write:
|> I tried a version of __daemonize in 2.4. It panics in
|> schedule()
|>
|>         prepare_to_switch();
|>         {
|>                 struct mm_struct *mm = next->mm;
|>                 struct mm_struct *oldmm = prev->active_mm;
|>                 if (!mm) {
|>                         if (next->active_mm) BUG();
|>
|> I got hit by the BUG() in 2.4, I think prepare_to_switch has
|> moved to specific archs in 2.5. A quick look showed that
|> this issue no longer exists in 2.5.
|
|Uhhh... there are many other problems if you are trying to do this on
|a "live" process.  idle process creation is a special case because it
|has never been run yet.
|
|This is not a generic "daemonize this task" mechanism!
|Rusty.
|--
|  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
|-
|To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
|the body of a message to majordomo@vger.kernel.org
|More majordomo info at  http://vger.kernel.org/majordomo-info.html
|Please read the FAQ at  http://www.tux.org/lkml/


[-- Attachment #2: Wipro_Disclaimer.txt --]
[-- Type: text/plain, Size: 490 bytes --]

**************************Disclaimer************************************
      


Information contained in this E-MAIL being proprietary to Wipro Limited
is 'privileged' and 'confidential' and intended for use only by the
individual or entity to which it is addressed. You are notified that any
use, copying or dissemination of the information contained in the E-MAIL
in any manner whatsoever is strictly prohibited.



 ********************************************************************

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-13  6:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-09  8:50 [PATCH] Hotplug CPU prep III: daemonize idle tasks Rusty Russell
2002-05-09 12:06 ` BALBIR SINGH
2002-05-13  2:01   ` Rusty Russell
2002-05-13  6:19     ` BALBIR SINGH

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®