All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] sched/headers: don't count canary as free space on stack.
       [not found] <CGME20200427101650epcas5p136af5c6e82d4dd69ea0d34920568bfed@epcas5p1.samsung.com>
@ 2020-04-27 10:16 ` Maninder Singh
  0 siblings, 0 replies; only message in thread
From: Maninder Singh @ 2020-04-27 10:16 UTC (permalink / raw)
  To: mingo; +Cc: linux-kernel, v.narang, a.sahrawat, Maninder Singh

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-27 10:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200427101650epcas5p136af5c6e82d4dd69ea0d34920568bfed@epcas5p1.samsung.com>
2020-04-27 10:16 ` [PATCH 1/1] sched/headers: don't count canary as free space on stack Maninder Singh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.