aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSukadev Bhattiprolu <sukadev@us.ibm.com>2007-05-11 01:23:00 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-11 11:29:35 -0400
commit820e45db2380eb1545fa2bc5d34b8b2f2933faeb (patch)
tree426e89e9205e44559d949d9cdf8bf1035bdc3710
parente713d0dab21a68500720e222fa02567fc7dfb14b (diff)
statically initialize struct pid for swapper
Statically initialize a struct pid for the swapper process (pid_t == 0) and attach it to init_task. This is needed so task_pid(), task_pgrp() and task_session() interfaces work on the swapper process also. Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Serge Hallyn <serue@us.ibm.com> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: <containers@lists.osdl.org> Acked-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/init_task.h27
-rw-r--r--include/linux/pid.h2
-rw-r--r--kernel/pid.c2
3 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 45170b2fa253..a68835fc8c04 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -88,6 +88,28 @@ extern struct nsproxy init_nsproxy;
88 88
89extern struct group_info init_groups; 89extern struct group_info init_groups;
90 90
91#define INIT_STRUCT_PID { \
92 .count = ATOMIC_INIT(1), \
93 .nr = 0, \
94 /* Don't put this struct pid in pid_hash */ \
95 .pid_chain = { .next = NULL, .pprev = NULL }, \
96 .tasks = { \
97 { .first = &init_task.pids[PIDTYPE_PID].node }, \
98 { .first = &init_task.pids[PIDTYPE_PGID].node }, \
99 { .first = &init_task.pids[PIDTYPE_SID].node }, \
100 }, \
101 .rcu = RCU_HEAD_INIT, \
102}
103
104#define INIT_PID_LINK(type) \
105{ \
106 .node = { \
107 .next = NULL, \
108 .pprev = &init_struct_pid.tasks[type].first, \
109 }, \
110 .pid = &init_struct_pid, \
111}
112
91/* 113/*
92 * INIT_TASK is used to set up the first task table, touch at 114 * INIT_TASK is used to set up the first task table, touch at
93 * your own risk!. Base=0, limit=0x1fffff (=2MB) 115 * your own risk!. Base=0, limit=0x1fffff (=2MB)
@@ -139,6 +161,11 @@ extern struct group_info init_groups;
139 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ 161 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
140 .fs_excl = ATOMIC_INIT(0), \ 162 .fs_excl = ATOMIC_INIT(0), \
141 .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ 163 .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
164 .pids = { \
165 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
166 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
167 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
168 }, \
142 INIT_TRACE_IRQFLAGS \ 169 INIT_TRACE_IRQFLAGS \
143 INIT_LOCKDEP \ 170 INIT_LOCKDEP \
144} 171}
diff --git a/include/linux/pid.h b/include/linux/pid.h
index 33d343880d89..1e0e4e3423a6 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -51,6 +51,8 @@ struct pid
51 struct rcu_head rcu; 51 struct rcu_head rcu;
52}; 52};
53 53
54extern struct pid init_struct_pid;
55
54struct pid_link 56struct pid_link
55{ 57{
56 struct hlist_node node; 58 struct hlist_node node;
diff --git a/kernel/pid.c b/kernel/pid.c
index d76f59326bd4..eb66bd2953ab 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -27,11 +27,13 @@
27#include <linux/bootmem.h> 27#include <linux/bootmem.h>
28#include <linux/hash.h> 28#include <linux/hash.h>
29#include <linux/pid_namespace.h> 29#include <linux/pid_namespace.h>
30#include <linux/init_task.h>
30 31
31#define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift) 32#define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
32static struct hlist_head *pid_hash; 33static struct hlist_head *pid_hash;
33static int pidhash_shift; 34static int pidhash_shift;
34static struct kmem_cache *pid_cachep; 35static struct kmem_cache *pid_cachep;
36struct pid init_struct_pid = INIT_STRUCT_PID;
35 37
36int pid_max = PID_MAX_DEFAULT; 38int pid_max = PID_MAX_DEFAULT;
37 39