aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-02-08 07:19:09 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:27 -0500
commit8520d7c7f8611216e3b270becec95bb35b6899d4 (patch)
tree77001e6830bb415590067e9d4be24cd8bdd36219
parente4cc0a9c876d4d4eadaef97a2bff4a199946d202 (diff)
teach set_special_pids() to use struct pid
Change set_special_pids() to work with struct pid, not pid_t from global name space. This again speedups and imho cleanups the code, also a preparation for the next patch. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/sched.h2
-rw-r--r--init/main.c2
-rw-r--r--kernel/exit.c30
-rw-r--r--kernel/sys.c2
4 files changed, 18 insertions, 18 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8a4812c1c038..d1c9b7f1d51e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1632,7 +1632,7 @@ extern struct task_struct *find_task_by_vpid(pid_t nr);
1632extern struct task_struct *find_task_by_pid_ns(pid_t nr, 1632extern struct task_struct *find_task_by_pid_ns(pid_t nr,
1633 struct pid_namespace *ns); 1633 struct pid_namespace *ns);
1634 1634
1635extern void __set_special_pids(pid_t session, pid_t pgrp); 1635extern void __set_special_pids(struct pid *pid);
1636 1636
1637/* per-UID process charging. */ 1637/* per-UID process charging. */
1638extern struct user_struct * alloc_uid(struct user_namespace *, uid_t); 1638extern struct user_struct * alloc_uid(struct user_namespace *, uid_t);
diff --git a/init/main.c b/init/main.c
index 2a78932f6c07..9a5b18c0a63d 100644
--- a/init/main.c
+++ b/init/main.c
@@ -833,7 +833,7 @@ static int __init kernel_init(void * unused)
833 */ 833 */
834 init_pid_ns.child_reaper = current; 834 init_pid_ns.child_reaper = current;
835 835
836 __set_special_pids(1, 1); 836 __set_special_pids(task_pid(current));
837 cad_pid = task_pid(current); 837 cad_pid = task_pid(current);
838 838
839 smp_prepare_cpus(setup_max_cpus); 839 smp_prepare_cpus(setup_max_cpus);
diff --git a/kernel/exit.c b/kernel/exit.c
index 42a8713b2050..96716fd22373 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -293,26 +293,27 @@ static void reparent_to_kthreadd(void)
293 switch_uid(INIT_USER); 293 switch_uid(INIT_USER);
294} 294}
295 295
296void __set_special_pids(pid_t session, pid_t pgrp) 296void __set_special_pids(struct pid *pid)
297{ 297{
298 struct task_struct *curr = current->group_leader; 298 struct task_struct *curr = current->group_leader;
299 pid_t nr = pid_nr(pid);
299 300
300 if (task_session_nr(curr) != session) { 301 if (task_session(curr) != pid) {
301 detach_pid(curr, PIDTYPE_SID); 302 detach_pid(curr, PIDTYPE_SID);
302 set_task_session(curr, session); 303 attach_pid(curr, PIDTYPE_SID, pid);
303 attach_pid(curr, PIDTYPE_SID, find_pid(session)); 304 set_task_session(curr, nr);
304 } 305 }
305 if (task_pgrp_nr(curr) != pgrp) { 306 if (task_pgrp(curr) != pid) {
306 detach_pid(curr, PIDTYPE_PGID); 307 detach_pid(curr, PIDTYPE_PGID);
307 set_task_pgrp(curr, pgrp); 308 attach_pid(curr, PIDTYPE_PGID, pid);
308 attach_pid(curr, PIDTYPE_PGID, find_pid(pgrp)); 309 set_task_pgrp(curr, nr);
309 } 310 }
310} 311}
311 312
312static void set_special_pids(pid_t session, pid_t pgrp) 313static void set_special_pids(struct pid *pid)
313{ 314{
314 write_lock_irq(&tasklist_lock); 315 write_lock_irq(&tasklist_lock);
315 __set_special_pids(session, pgrp); 316 __set_special_pids(pid);
316 write_unlock_irq(&tasklist_lock); 317 write_unlock_irq(&tasklist_lock);
317} 318}
318 319
@@ -383,7 +384,11 @@ void daemonize(const char *name, ...)
383 */ 384 */
384 current->flags |= PF_NOFREEZE; 385 current->flags |= PF_NOFREEZE;
385 386
386 set_special_pids(1, 1); 387 if (current->nsproxy != &init_nsproxy) {
388 get_nsproxy(&init_nsproxy);
389 switch_task_namespaces(current, &init_nsproxy);
390 }
391 set_special_pids(find_pid(1));
387 proc_clear_tty(current); 392 proc_clear_tty(current);
388 393
389 /* Block and flush all signals */ 394 /* Block and flush all signals */
@@ -398,11 +403,6 @@ void daemonize(const char *name, ...)
398 current->fs = fs; 403 current->fs = fs;
399 atomic_inc(&fs->count); 404 atomic_inc(&fs->count);
400 405
401 if (current->nsproxy != init_task.nsproxy) {
402 get_nsproxy(init_task.nsproxy);
403 switch_task_namespaces(current, init_task.nsproxy);
404 }
405
406 exit_files(current); 406 exit_files(current);
407 current->files = init_task.files; 407 current->files = init_task.files;
408 atomic_inc(&current->files->count); 408 atomic_inc(&current->files->count);
diff --git a/kernel/sys.c b/kernel/sys.c
index e13bc518b444..c326d6dceee3 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1065,7 +1065,7 @@ asmlinkage long sys_setsid(void)
1065 goto out; 1065 goto out;
1066 1066
1067 group_leader->signal->leader = 1; 1067 group_leader->signal->leader = 1;
1068 __set_special_pids(pid_nr(sid), pid_nr(sid)); 1068 __set_special_pids(sid);
1069 1069
1070 spin_lock(&group_leader->sighand->siglock); 1070 spin_lock(&group_leader->sighand->siglock);
1071 group_leader->signal->tty = NULL; 1071 group_leader->signal->tty = NULL;