瀏覽代碼

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>
FUJITA Tomonori 17 年之前
父節點
當前提交
8b05c7e6e1
共有 2 個文件被更改,包括 8 次插入3 次删除
  1. 7 0
      include/linux/sched.h
  2. 1 3
      lib/debugobjects.c

+ 7 - 0
include/linux/sched.h

@@ -1983,6 +1983,13 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
 
 
 #endif
 #endif
 
 
+static inline int object_is_on_stack(void *obj)
+{
+	void *stack = task_stack_page(current);
+
+	return (obj >= stack) && (obj < (stack + THREAD_SIZE));
+}
+
 extern void thread_info_cache_init(void);
 extern void thread_info_cache_init(void);
 
 
 /* set thread flags in other task's structures
 /* set thread flags in other task's structures

+ 1 - 3
lib/debugobjects.c

@@ -226,15 +226,13 @@ debug_object_fixup(int (*fixup)(void *addr, enum debug_obj_state state),
 
 
 static void debug_object_is_on_stack(void *addr, int onstack)
 static void debug_object_is_on_stack(void *addr, int onstack)
 {
 {
-	void *stack = current->stack;
 	int is_on_stack;
 	int is_on_stack;
 	static int limit;
 	static int limit;
 
 
 	if (limit > 4)
 	if (limit > 4)
 		return;
 		return;
 
 
-	is_on_stack = (addr >= stack && addr < (stack + THREAD_SIZE));
-
+	is_on_stack = object_is_on_stack(addr);
 	if (is_on_stack == onstack)
 	if (is_on_stack == onstack)
 		return;
 		return;