From 6258ff00348b2c5ea1bbee95b06c173fbdc99adc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 13 Nov 2005 16:06:56 -0800 Subject: [PATCH] --- yaml --- r: 14054 b: refs/heads/master c: 10ebffde3d3916026974352b7900e44afe2b243f h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/linux/sched.h | 11 +++++++++++ trunk/kernel/fork.c | 3 +-- trunk/kernel/sched.c | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 662dd120ded8..335408bcad2b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a1261f54611ec4ad6a7ab7080f86747e3ac3685b +refs/heads/master: 10ebffde3d3916026974352b7900e44afe2b243f diff --git a/trunk/include/linux/sched.h b/trunk/include/linux/sched.h index f8650314ba2f..e4681256e43e 100644 --- a/trunk/include/linux/sched.h +++ b/trunk/include/linux/sched.h @@ -1235,6 +1235,17 @@ static inline void task_unlock(struct task_struct *p) #define task_thread_info(task) (task)->thread_info +static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org) +{ + *task_thread_info(p) = *task_thread_info(org); + task_thread_info(p)->task = p; +} + +static inline unsigned long *end_of_stack(struct task_struct *p) +{ + return (unsigned long *)(p->thread_info + 1); +} + /* set thread flags in other task's structures * - see asm/thread_info.h for TIF_xxxx flags available */ diff --git a/trunk/kernel/fork.c b/trunk/kernel/fork.c index 7ef352ce347b..2c70c9cdf5dc 100644 --- a/trunk/kernel/fork.c +++ b/trunk/kernel/fork.c @@ -171,10 +171,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) return NULL; } - *ti = *orig->thread_info; *tsk = *orig; tsk->thread_info = ti; - ti->task = tsk; + setup_thread_stack(tsk, orig); /* One for us, one for whoever does the "release_task()" (usually parent) */ atomic_set(&tsk->usage,2); diff --git a/trunk/kernel/sched.c b/trunk/kernel/sched.c index 831f7e9d8f1c..6f46c94cc29e 100644 --- a/trunk/kernel/sched.c +++ b/trunk/kernel/sched.c @@ -4327,10 +4327,10 @@ static void show_task(task_t *p) #endif #ifdef CONFIG_DEBUG_STACK_USAGE { - unsigned long *n = (unsigned long *) (p->thread_info+1); + unsigned long *n = end_of_stack(p); while (!*n) n++; - free = (unsigned long) n - (unsigned long)(p->thread_info+1); + free = (unsigned long)n - (unsigned long)end_of_stack(p); } #endif printk("%5lu %5d %6d ", free, p->pid, p->parent->pid);