... used greatest stack depth: xxx bytes left

配置项:CONFIG_DEBUG_STACK_USAGE
代码位置:kernel/exit.c
功能:将让内核监视栈的使用(打印最大栈深度),并通过sysrq按键输出一些统计信息。

#ifdef CONFIG_DEBUG_STACK_USAGE
static void check_stack_usage(void)
{
    
    
	static DEFINE_SPINLOCK(low_water_lock);
	static int lowest_to_date = THREAD_SIZE;
	unsigned long free;

	free = stack_not_used(current);

	if (free >= lowest_to_date)
		return;

	spin_lock(&low_water_lock);
	if (free < lowest_to_date) {
    
    
		pr_info("%s (%d) used greatest stack depth: %lu bytes left\n",
			current->comm, task_pid_nr(current), free);
		lowest_to_date = free;
	}
	spin_unlock(&low_water_lock);
}
#else
static inline void check_stack_usage(void) {
    
    }
#endif

猜你喜欢

转载自blog.csdn.net/furongwei123/article/details/122665542
今日推荐