lkml.org 
[lkml]   [2020]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] sched/headers: don't count canary as free space on stack.
Date
currently if all stack is used except canary and thread_info space,
stack usage prints about free space.

[11.7426] X (1260) used greatest stack depth: 4 bytes left

It is because canary is accounted as usable stack, so removing
that from accounting.

[12.8717] X (1270) used greatest stack depth: 0 bytes left

Signed-off-by: vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
---
include/linux/sched/task_stack.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h
index 2413427..3174938 100644
--- a/include/linux/sched/task_stack.h
+++ b/include/linux/sched/task_stack.h
@@ -100,10 +100,11 @@ static inline unsigned long stack_not_used(struct task_struct *p)
# endif
} while (!*n);

+ /* Don't count canary as usable stack */
# ifdef CONFIG_STACK_GROWSUP
- return (unsigned long)end_of_stack(p) - (unsigned long)n;
+ return (unsigned long)end_of_stack(p) - (unsigned long)(n + 1);
# else
- return (unsigned long)n - (unsigned long)end_of_stack(p);
+ return (unsigned long)(n - 1) - (unsigned long)end_of_stack(p);
# endif
}
#endif
--
1.9.1
\
 
 \ /
  Last update: 2020-04-27 12:18    [W:0.036 / U:5.612 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site