[PATCH 6/10] add stack field to task_struct

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

 



This adds a new field stack to task_struct. Its value is identical to thread_info,
but on m68k it doesn't point to the thread_info. This allows to convert direct accesses
to the thread_info field to either convert to using the stack field, end_of_stack()
or task_thread_info().

Signed-off-by: Roman Zippel <[email protected]>

---

 include/asm-m68k/thread_info.h |    4 ++--
 include/linux/init_task.h      |    1 +
 include/linux/sched.h          |    5 +++--
 kernel/fork.c                  |    1 +
 4 files changed, 7 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:33.241207651 +0200
+++ linux-2.6-mm/include/linux/sched.h	2005-09-01 21:04:41.963708999 +0200
@@ -662,6 +662,7 @@ struct mempolicy;
 struct task_struct {
 	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
 	struct thread_info *thread_info;
+	void *stack;
 	atomic_t usage;
 	unsigned long flags;	/* per process flags, defined below */
 	unsigned long ptrace;
@@ -1211,7 +1212,7 @@ static inline void task_unlock(struct ta
 
 #ifndef __HAVE_THREAD_FUNCTIONS
 
-#define task_thread_info(task) (task)->thread_info
+#define task_thread_info(task) ((struct thread_info *)(task)->stack)
 
 static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
 {
@@ -1221,7 +1222,7 @@ static inline void setup_thread_stack(st
 
 static inline unsigned long *end_of_stack(struct task_struct *p)
 {
-	return (unsigned long *)(p->thread_info + 1);
+	return (unsigned long *)(task_thread_info(p) + 1);
 }
 
 #endif
Index: linux-2.6-mm/include/linux/init_task.h
===================================================================
--- linux-2.6-mm.orig/include/linux/init_task.h	2005-09-01 13:21:50.000000000 +0200
+++ linux-2.6-mm/include/linux/init_task.h	2005-09-01 21:04:41.987704876 +0200
@@ -81,6 +81,7 @@ extern struct group_info init_groups;
 {									\
 	.state		= 0,						\
 	.thread_info	= &init_thread_info,				\
+	.stack		= &init_stack,					\
 	.usage		= ATOMIC_INIT(2),				\
 	.flags		= 0,						\
 	.lock_depth	= -1,						\
Index: linux-2.6-mm/kernel/fork.c
===================================================================
--- linux-2.6-mm.orig/kernel/fork.c	2005-09-01 21:04:28.638998406 +0200
+++ linux-2.6-mm/kernel/fork.c	2005-09-01 21:04:41.988704704 +0200
@@ -172,6 +172,7 @@ static struct task_struct *dup_task_stru
 
 	*tsk = *orig;
 	tsk->thread_info = ti;
+	tsk->stack = ti;
 	setup_thread_stack(tsk, orig);
 
 	/* One for us, one for whoever does the "release_task()" (usually parent) */
Index: linux-2.6-mm/include/asm-m68k/thread_info.h
===================================================================
--- linux-2.6-mm.orig/include/asm-m68k/thread_info.h	2005-09-01 21:04:39.711096024 +0200
+++ linux-2.6-mm/include/asm-m68k/thread_info.h	2005-09-01 21:04:41.988704704 +0200
@@ -42,11 +42,11 @@ struct thread_info {
 #define __HAVE_THREAD_FUNCTIONS
 
 #define setup_thread_stack(p, org) ({			\
-	*(struct task_struct **)(p)->thread_info = (p);	\
+	*(struct task_struct **)(p)->stack = (p);	\
 	task_thread_info(p)->task = (p);		\
 })
 
-#define end_of_stack(p) ((unsigned long *)(p)->thread_info + 1)
+#define end_of_stack(p) ((unsigned long *)(p)->stack + 1)
 
 /* entry.S relies on these definitions!
  * bits 0-7 are tested at every exception exit
-
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