aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2008-07-24 00:26:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 13:47:14 -0400
commit8b05c7e6e159d2f33c9275281b8b909a89eb7c5d (patch)
tree646edb14c42d6404e36f1602d47c639c72a8300a
parent68ad8df42e12037c3894c9706ab428bf5cd6426b (diff)
add a helper function to test if an object is on the stack
lib/debugobjects.c has a function to test if an object is on the stack. The block layer and ide needs it (they need to avoid DMA from/to stack buffers). This patch moves the function to include/linux/sched.h so that everyone can use it. lib/debugobjects.c uses current->stack but this patch uses a task_stack_page() accessor, which is a preferable way to access the stack. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Andy Whitcroft <apw@shadowen.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/sched.h7
-rw-r--r--lib/debugobjects.c4
2 files changed, 8 insertions, 3 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index dc7e592c473a..6aca4a16e377 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1983,6 +1983,13 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
1983 1983
1984#endif 1984#endif
1985 1985
1986static inline int object_is_on_stack(void *obj)
1987{
1988 void *stack = task_stack_page(current);
1989
1990 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
1991}
1992
1986extern void thread_info_cache_init(void); 1993extern void thread_info_cache_init(void);
1987 1994
1988/* set thread flags in other task's structures 1995/* set thread flags in other task's structures
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 85b18d79be89..f86196390cfd 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -226,15 +226,13 @@ debug_object_fixup(int (*fixup)(void *addr, enum debug_obj_state state),
226 226
227static void debug_object_is_on_stack(void *addr, int onstack) 227static void debug_object_is_on_stack(void *addr, int onstack)
228{ 228{
229 void *stack = current->stack;
230 int is_on_stack; 229 int is_on_stack;
231 static int limit; 230 static int limit;
232 231
233 if (limit > 4) 232 if (limit > 4)
234 return; 233 return;
235 234
236 is_on_stack = (addr >= stack && addr < (stack + THREAD_SIZE)); 235 is_on_stack = object_is_on_stack(addr);
237
238 if (is_on_stack == onstack) 236 if (is_on_stack == onstack)
239 return; 237 return;
240 238