mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
sched: add STACK_USAGE_SAFE_PERCENT for stack overflow check
Change-Id: Ia70e243b36401e28c31fcd7e1b480b79374c27ef Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
@@ -1758,6 +1758,18 @@ config STACK_COLORATION
|
|||||||
|
|
||||||
Only supported by a few architectures.
|
Only supported by a few architectures.
|
||||||
|
|
||||||
|
config STACK_USAGE_SAFE_PERCENT
|
||||||
|
int "Stack usage safe precent"
|
||||||
|
default 0
|
||||||
|
range 0 100
|
||||||
|
depends on STACK_COLORATION
|
||||||
|
---help---
|
||||||
|
Stack usage precent = up_check_tcbstack() * 100 / tcb->adj_stack_size,
|
||||||
|
this should lower then STACK_USAGE_SAFE_PERCENT.
|
||||||
|
Idle thread will timely check stack usage when this marco value > 0.
|
||||||
|
|
||||||
|
N.B. This feature should not be used in production code.
|
||||||
|
|
||||||
config STACK_CANARIES
|
config STACK_CANARIES
|
||||||
bool "Compiler stack canaries"
|
bool "Compiler stack canaries"
|
||||||
depends on ARCH_HAVE_STACKCHECK
|
depends on ARCH_HAVE_STACKCHECK
|
||||||
|
|||||||
@@ -800,7 +800,7 @@ void nx_start(void)
|
|||||||
sinfo("CPU0: Beginning Idle Loop\n");
|
sinfo("CPU0: Beginning Idle Loop\n");
|
||||||
for (; ; )
|
for (; ; )
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_STACK_COLORATION) && defined(CONFIG_DEBUG_MM)
|
#if defined(CONFIG_STACK_COLORATION) && CONFIG_STACK_USAGE_SAFE_PERCENT > 0
|
||||||
|
|
||||||
/* Check stack in idle thread */
|
/* Check stack in idle thread */
|
||||||
|
|
||||||
@@ -812,7 +812,8 @@ void nx_start(void)
|
|||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
tcb = g_pidhash[i].tcb;
|
tcb = g_pidhash[i].tcb;
|
||||||
if (tcb && up_check_tcbstack_remain(tcb) <= 0)
|
if (tcb && (up_check_tcbstack(tcb) * 100 / tcb->adj_stack_size
|
||||||
|
> CONFIG_STACK_USAGE_SAFE_PERCENT))
|
||||||
{
|
{
|
||||||
_alert("Stack check failed, pid %d, name %s\n",
|
_alert("Stack check failed, pid %d, name %s\n",
|
||||||
tcb->pid, tcb->name);
|
tcb->pid, tcb->name);
|
||||||
|
|||||||
Reference in New Issue
Block a user