[PATCH 2/10] m68k: introduce setup_thread_stack()/end_of_stack()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Al Viro <[email protected]> 

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 <[email protected]>
Signed-off-by: Roman Zippel <[email protected]>

---

 include/linux/sched.h |   11 +++++++++++
 kernel/fork.c         |    3 +--
 kernel/sched.c        |    4 ++--
 3 files changed, 14 insertions(+), 4 deletions(-)

Index: linux-2.6-mm/include/linux/sched.h
===================================================================
--- linux-2.6-mm.orig/include/linux/sched.h	2005-09-01 21:04:03.762273052 +0200
+++ linux-2.6-mm/include/linux/sched.h	2005-09-01 21:04:28.637998577 +0200
@@ -1211,6 +1211,17 @@ static inline void task_unlock(struct ta
 
 #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
  */
Index: linux-2.6-mm/kernel/fork.c
===================================================================
--- linux-2.6-mm.orig/kernel/fork.c	2005-09-01 21:04:03.861256043 +0200
+++ linux-2.6-mm/kernel/fork.c	2005-09-01 21:04:28.638998406 +0200
@@ -170,10 +170,9 @@ static struct task_struct *dup_task_stru
 		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);
Index: linux-2.6-mm/kernel/sched.c
===================================================================
--- linux-2.6-mm.orig/kernel/sched.c	2005-09-01 21:04:03.896250029 +0200
+++ linux-2.6-mm/kernel/sched.c	2005-09-01 21:04:28.640998062 +0200
@@ -4331,10 +4331,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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux