Isolate the explicit usage of signal->pgrp
authorPavel Emelyanov <xemul@openvz.org>
Fri, 19 Oct 2007 06:40:39 +0000 (23:40 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 19 Oct 2007 18:53:43 +0000 (11:53 -0700)
The pgrp field is not used widely around the kernel so it is now marked as
deprecated with appropriate comment.

The initialization of INIT_SIGNALS is trimmed because
a) they are set to 0 automatically;
b) gcc cannot properly initialize two anonymous (the second one
   is the one with the session) unions. In this particular case
   to make it compile we'd have to add some field initialized
   right before the .pgrp.

This is the same patch as the 1ec320afdc9552c92191d5f89fcd1ebe588334ca one
(from Cedric), but for the pgrp field.

Some progress report:

We have to deprecate the pid, tgid, session and pgrp fields on struct
task_struct and struct signal_struct.  The session and pgrp are already
deprecated.  The tgid value is close to being such - the worst known usage
in in fs/locks.c and audit code.  The pid field deprecation is mainly
blocked by numerous printk-s around the kernel that print the tsk->pid to
log.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/init_task.h
include/linux/sched.h
kernel/exit.c
kernel/fork.c
kernel/sys.c

index 5ac5945..cae35b6 100644 (file)
@@ -67,9 +67,6 @@
        .posix_timers    = LIST_HEAD_INIT(sig.posix_timers),            \
        .cpu_timers     = INIT_CPU_TIMERS(sig.cpu_timers),              \
        .rlim           = INIT_RLIMITS,                                 \
-       .pgrp           = 0,                                            \
-       .tty_old_pgrp   = NULL,                                         \
-       { .__session      = 0},                                         \
 }
 
 extern struct nsproxy init_nsproxy;
index 4bbbe12..13df99f 100644 (file)
@@ -429,7 +429,17 @@ struct signal_struct {
        cputime_t it_prof_incr, it_virt_incr;
 
        /* job control IDs */
-       pid_t pgrp;
+
+       /*
+        * pgrp and session fields are deprecated.
+        * use the task_session_Xnr and task_pgrp_Xnr routines below
+        */
+
+       union {
+               pid_t pgrp __deprecated;
+               pid_t __pgrp;
+       };
+
        struct pid *tty_old_pgrp;
 
        union {
@@ -1196,6 +1206,11 @@ static inline void set_task_session(struct task_struct *tsk, pid_t session)
        tsk->signal->__session = session;
 }
 
+static inline void set_task_pgrp(struct task_struct *tsk, pid_t pgrp)
+{
+       tsk->signal->__pgrp = pgrp;
+}
+
 static inline struct pid *task_pid(struct task_struct *task)
 {
        return task->pids[PIDTYPE_PID].pid;
@@ -1268,7 +1283,7 @@ static inline pid_t task_tgid_vnr(struct task_struct *tsk)
 
 static inline pid_t task_pgrp_nr(struct task_struct *tsk)
 {
-       return tsk->signal->pgrp;
+       return tsk->signal->__pgrp;
 }
 
 pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
index 68d2703..6838d4d 100644 (file)
@@ -306,7 +306,7 @@ void __set_special_pids(pid_t session, pid_t pgrp)
        }
        if (task_pgrp_nr(curr) != pgrp) {
                detach_pid(curr, PIDTYPE_PGID);
-               curr->signal->pgrp = pgrp;
+               set_task_pgrp(curr, pgrp);
                attach_pid(curr, PIDTYPE_PGID, find_pid(pgrp));
        }
 }
index 240aa66..9d40367 100644 (file)
@@ -1293,13 +1293,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
                        if (clone_flags & CLONE_NEWPID) {
                                p->nsproxy->pid_ns->child_reaper = p;
                                p->signal->tty = NULL;
-                               p->signal->pgrp = p->pid;
+                               set_task_pgrp(p, p->pid);
                                set_task_session(p, p->pid);
                                attach_pid(p, PIDTYPE_PGID, pid);
                                attach_pid(p, PIDTYPE_SID, pid);
                        } else {
                                p->signal->tty = current->signal->tty;
-                               p->signal->pgrp = task_pgrp_nr(current);
+                               set_task_pgrp(p, task_pgrp_nr(current));
                                set_task_session(p, task_session_nr(current));
                                attach_pid(p, PIDTYPE_PGID,
                                                task_pgrp(current));
index 2befc29..304b541 100644 (file)
@@ -977,7 +977,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
                detach_pid(p, PIDTYPE_PGID);
                pid = find_vpid(pgid);
                attach_pid(p, PIDTYPE_PGID, pid);
-               p->signal->pgrp = pid_nr(pid);
+               set_task_pgrp(p, pid_nr(pid));
        }
 
        err = 0;