diff options
author | Al Viro <viro@parcelfarce.linux.theplanet.co.uk> | 2005-11-13 19:06:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-13 21:14:13 -0500 |
commit | 10ebffde3d3916026974352b7900e44afe2b243f (patch) | |
tree | ac88fa33694f5bea1b6958e1e56bcd4c9b95b002 | |
parent | a1261f54611ec4ad6a7ab7080f86747e3ac3685b (diff) |
[PATCH] m68k: introduce setup_thread_stack() and end_of_stack()
encapsulates the rest of arch-dependent operations with thread_info access.
Two new helpers - setup_thread_stack() and end_of_stack(). For normal case
the former consists of copying thread_info of parent to new thread_info and
the latter returns pointer immediately past the end of thread_info.
Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | include/linux/sched.h | 11 | ||||
-rw-r--r-- | kernel/fork.c | 3 | ||||
-rw-r--r-- | kernel/sched.c | 4 |
3 files changed, 14 insertions, 4 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index f8650314ba2f..e4681256e43e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1235,6 +1235,17 @@ static inline void task_unlock(struct task_struct *p) | |||
1235 | 1235 | ||
1236 | #define task_thread_info(task) (task)->thread_info | 1236 | #define task_thread_info(task) (task)->thread_info |
1237 | 1237 | ||
1238 | static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org) | ||
1239 | { | ||
1240 | *task_thread_info(p) = *task_thread_info(org); | ||
1241 | task_thread_info(p)->task = p; | ||
1242 | } | ||
1243 | |||
1244 | static inline unsigned long *end_of_stack(struct task_struct *p) | ||
1245 | { | ||
1246 | return (unsigned long *)(p->thread_info + 1); | ||
1247 | } | ||
1248 | |||
1238 | /* set thread flags in other task's structures | 1249 | /* set thread flags in other task's structures |
1239 | * - see asm/thread_info.h for TIF_xxxx flags available | 1250 | * - see asm/thread_info.h for TIF_xxxx flags available |
1240 | */ | 1251 | */ |
diff --git a/kernel/fork.c b/kernel/fork.c index 7ef352ce347b..2c70c9cdf5dc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -171,10 +171,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
171 | return NULL; | 171 | return NULL; |
172 | } | 172 | } |
173 | 173 | ||
174 | *ti = *orig->thread_info; | ||
175 | *tsk = *orig; | 174 | *tsk = *orig; |
176 | tsk->thread_info = ti; | 175 | tsk->thread_info = ti; |
177 | ti->task = tsk; | 176 | setup_thread_stack(tsk, orig); |
178 | 177 | ||
179 | /* One for us, one for whoever does the "release_task()" (usually parent) */ | 178 | /* One for us, one for whoever does the "release_task()" (usually parent) */ |
180 | atomic_set(&tsk->usage,2); | 179 | atomic_set(&tsk->usage,2); |
diff --git a/kernel/sched.c b/kernel/sched.c index 831f7e9d8f1c..6f46c94cc29e 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -4327,10 +4327,10 @@ static void show_task(task_t *p) | |||
4327 | #endif | 4327 | #endif |
4328 | #ifdef CONFIG_DEBUG_STACK_USAGE | 4328 | #ifdef CONFIG_DEBUG_STACK_USAGE |
4329 | { | 4329 | { |
4330 | unsigned long *n = (unsigned long *) (p->thread_info+1); | 4330 | unsigned long *n = end_of_stack(p); |
4331 | while (!*n) | 4331 | while (!*n) |
4332 | n++; | 4332 | n++; |
4333 | free = (unsigned long) n - (unsigned long)(p->thread_info+1); | 4333 | free = (unsigned long)n - (unsigned long)end_of_stack(p); |
4334 | } | 4334 | } |
4335 | #endif | 4335 | #endif |
4336 | printk("%5lu %5d %6d ", free, p->pid, p->parent->pid); | 4336 | printk("%5lu %5d %6d ", free, p->pid, p->parent->pid); |