aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2009-04-02 19:58:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-02 22:05:02 -0400
commit1b0f7ffd0ea27cd3a0b9ca04e3df9522048c32a3 (patch)
treea8c27acdf95f55f93fe86661c6cba4cd36c8e4f1
parent52ee2dfdd4f51cf422ea6a96a0846dc94244aa37 (diff)
pids: kill signal_struct-> __pgrp/__session and friends
We are wasting 2 words in signal_struct without any reason to implement task_pgrp_nr() and task_session_nr(). task_session_nr() has no callers since 2e2ba22ea4fd4bb85f0fa37c521066db6775cbef, we can remove it. task_pgrp_nr() is still (I believe wrongly) used in fs/autofsX and fs/coda. This patch reimplements task_pgrp_nr() via task_pgrp_nr_ns(), and kills __pgrp/__session and the related helpers. The change in drivers/char/tty_io.c is cosmetic, but hopefully makes sense anyway. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Alan Cox <number6@the-village.bc.nu> [tty parts] Cc: Cedric Le Goater <clg@fr.ibm.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Pavel Emelyanov <xemul@openvz.org> Cc: Serge Hallyn <serue@us.ibm.com> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/tty_io.c4
-rw-r--r--include/linux/sched.h43
-rw-r--r--kernel/exit.c10
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/sys.c4
5 files changed, 12 insertions, 51 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index a44b701c5bba..66b99a2049e3 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2681,7 +2681,7 @@ void __do_SAK(struct tty_struct *tty)
2681 /* Kill the entire session */ 2681 /* Kill the entire session */
2682 do_each_pid_task(session, PIDTYPE_SID, p) { 2682 do_each_pid_task(session, PIDTYPE_SID, p) {
2683 printk(KERN_NOTICE "SAK: killed process %d" 2683 printk(KERN_NOTICE "SAK: killed process %d"
2684 " (%s): task_session_nr(p)==tty->session\n", 2684 " (%s): task_session(p)==tty->session\n",
2685 task_pid_nr(p), p->comm); 2685 task_pid_nr(p), p->comm);
2686 send_sig(SIGKILL, p, 1); 2686 send_sig(SIGKILL, p, 1);
2687 } while_each_pid_task(session, PIDTYPE_SID, p); 2687 } while_each_pid_task(session, PIDTYPE_SID, p);
@@ -2691,7 +2691,7 @@ void __do_SAK(struct tty_struct *tty)
2691 do_each_thread(g, p) { 2691 do_each_thread(g, p) {
2692 if (p->signal->tty == tty) { 2692 if (p->signal->tty == tty) {
2693 printk(KERN_NOTICE "SAK: killed process %d" 2693 printk(KERN_NOTICE "SAK: killed process %d"
2694 " (%s): task_session_nr(p)==tty->session\n", 2694 " (%s): task_session(p)==tty->session\n",
2695 task_pid_nr(p), p->comm); 2695 task_pid_nr(p), p->comm);
2696 send_sig(SIGKILL, p, 1); 2696 send_sig(SIGKILL, p, 1);
2697 continue; 2697 continue;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 49df878a0cad..206ac003e8c0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -547,25 +547,8 @@ struct signal_struct {
547 547
548 struct list_head cpu_timers[3]; 548 struct list_head cpu_timers[3];
549 549
550 /* job control IDs */
551
552 /*
553 * pgrp and session fields are deprecated.
554 * use the task_session_Xnr and task_pgrp_Xnr routines below
555 */
556
557 union {
558 pid_t pgrp __deprecated;
559 pid_t __pgrp;
560 };
561
562 struct pid *tty_old_pgrp; 550 struct pid *tty_old_pgrp;
563 551
564 union {
565 pid_t session __deprecated;
566 pid_t __session;
567 };
568
569 /* boolean value for session group leader */ 552 /* boolean value for session group leader */
570 int leader; 553 int leader;
571 554
@@ -1469,16 +1452,6 @@ static inline int rt_task(struct task_struct *p)
1469 return rt_prio(p->prio); 1452 return rt_prio(p->prio);
1470} 1453}
1471 1454
1472static inline void set_task_session(struct task_struct *tsk, pid_t session)
1473{
1474 tsk->signal->__session = session;
1475}
1476
1477static inline void set_task_pgrp(struct task_struct *tsk, pid_t pgrp)
1478{
1479 tsk->signal->__pgrp = pgrp;
1480}
1481
1482static inline struct pid *task_pid(struct task_struct *task) 1455static inline struct pid *task_pid(struct task_struct *task)
1483{ 1456{
1484 return task->pids[PIDTYPE_PID].pid; 1457 return task->pids[PIDTYPE_PID].pid;
@@ -1552,11 +1525,6 @@ static inline pid_t task_tgid_vnr(struct task_struct *tsk)
1552} 1525}
1553 1526
1554 1527
1555static inline pid_t task_pgrp_nr(struct task_struct *tsk)
1556{
1557 return tsk->signal->__pgrp;
1558}
1559
1560static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk, 1528static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
1561 struct pid_namespace *ns) 1529 struct pid_namespace *ns)
1562{ 1530{
@@ -1569,11 +1537,6 @@ static inline pid_t task_pgrp_vnr(struct task_struct *tsk)
1569} 1537}
1570 1538
1571 1539
1572static inline pid_t task_session_nr(struct task_struct *tsk)
1573{
1574 return tsk->signal->__session;
1575}
1576
1577static inline pid_t task_session_nr_ns(struct task_struct *tsk, 1540static inline pid_t task_session_nr_ns(struct task_struct *tsk,
1578 struct pid_namespace *ns) 1541 struct pid_namespace *ns)
1579{ 1542{
@@ -1585,6 +1548,12 @@ static inline pid_t task_session_vnr(struct task_struct *tsk)
1585 return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL); 1548 return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
1586} 1549}
1587 1550
1551/* obsolete, do not use */
1552static inline pid_t task_pgrp_nr(struct task_struct *tsk)
1553{
1554 return task_pgrp_nr_ns(tsk, &init_pid_ns);
1555}
1556
1588/** 1557/**
1589 * pid_alive - check that a task structure is not stale 1558 * pid_alive - check that a task structure is not stale
1590 * @p: Task structure to be checked. 1559 * @p: Task structure to be checked.
diff --git a/kernel/exit.c b/kernel/exit.c
index 384f09caf2ef..3bec141c82f6 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -357,16 +357,12 @@ static void reparent_to_kthreadd(void)
357void __set_special_pids(struct pid *pid) 357void __set_special_pids(struct pid *pid)
358{ 358{
359 struct task_struct *curr = current->group_leader; 359 struct task_struct *curr = current->group_leader;
360 pid_t nr = pid_nr(pid);
361 360
362 if (task_session(curr) != pid) { 361 if (task_session(curr) != pid)
363 change_pid(curr, PIDTYPE_SID, pid); 362 change_pid(curr, PIDTYPE_SID, pid);
364 set_task_session(curr, nr); 363
365 } 364 if (task_pgrp(curr) != pid)
366 if (task_pgrp(curr) != pid) {
367 change_pid(curr, PIDTYPE_PGID, pid); 365 change_pid(curr, PIDTYPE_PGID, pid);
368 set_task_pgrp(curr, nr);
369 }
370} 366}
371 367
372static void set_special_pids(struct pid *pid) 368static void set_special_pids(struct pid *pid)
diff --git a/kernel/fork.c b/kernel/fork.c
index adbea16ec649..f74458231449 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1265,8 +1265,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1265 p->signal->leader_pid = pid; 1265 p->signal->leader_pid = pid;
1266 tty_kref_put(p->signal->tty); 1266 tty_kref_put(p->signal->tty);
1267 p->signal->tty = tty_kref_get(current->signal->tty); 1267 p->signal->tty = tty_kref_get(current->signal->tty);
1268 set_task_pgrp(p, task_pgrp_nr(current));
1269 set_task_session(p, task_session_nr(current));
1270 attach_pid(p, PIDTYPE_PGID, task_pgrp(current)); 1268 attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
1271 attach_pid(p, PIDTYPE_SID, task_session(current)); 1269 attach_pid(p, PIDTYPE_SID, task_session(current));
1272 list_add_tail_rcu(&p->tasks, &init_task.tasks); 1270 list_add_tail_rcu(&p->tasks, &init_task.tasks);
diff --git a/kernel/sys.c b/kernel/sys.c
index 37f458e6882a..742cefa527e6 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1013,10 +1013,8 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid)
1013 if (err) 1013 if (err)
1014 goto out; 1014 goto out;
1015 1015
1016 if (task_pgrp(p) != pgrp) { 1016 if (task_pgrp(p) != pgrp)
1017 change_pid(p, PIDTYPE_PGID, pgrp); 1017 change_pid(p, PIDTYPE_PGID, pgrp);
1018 set_task_pgrp(p, pid_nr(pgrp));
1019 }
1020 1018
1021 err = 0; 1019 err = 0;
1022out: 1020out: