From 6c2b163c7d7c696ef89b17a0275f3cddb3d7cefb Mon Sep 17 00:00:00 2001 From: Haryslee Date: Wed, 29 Dec 2021 14:27:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=86=85=E5=AD=98=E7=94=A8=E4=BE=8B=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=B3=BB=E7=BB=9F=E5=8D=A1=E6=AD=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 背景:重复执行内存测试用例约几百次,系统大概率出现卡死现象,经分析知,系统卡在 内存spinlock锁中,CPU1在获取内存spinlock锁后打印异常信息,此时循环buffer满了, CPU0此时进入异常且尝试拿取内存spinlock锁,两个核都处于锁中断锁任务状态,CPU1 写事件触发调度打印输出失败,进而在write接口中死循环无法退出,导致两个核都卡住。 方案:在write接口中增加一个判断条件:当前核处于锁任务状态且循环buffer满了时候, 直接退出循环,丢弃打印信息(持有spinlock锁后一般禁止输出打印信息)。 close #I4F7PO Signed-off-by: Haryslee Change-Id: I3f49a1bb211821e9c5d1d220d6867962d6a45a79 --- kernel/common/los_printf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/common/los_printf.c b/kernel/common/los_printf.c index e5d0b774..8d55bb9f 100644 --- a/kernel/common/los_printf.c +++ b/kernel/common/los_printf.c @@ -47,6 +47,7 @@ #include "los_excinfo_pri.h" #endif #include "los_exc_pri.h" +#include "los_sched_pri.h" #define SIZEBUF 256 @@ -94,7 +95,7 @@ STATIC VOID ConsoleOutput(const CHAR *str, UINT32 len) for (;;) { cnt = write(STDOUT_FILENO, str + written, (size_t)toWrite); - if ((cnt < 0) || ((cnt == 0) && (OS_INT_ACTIVE)) || (toWrite == cnt)) { + if ((cnt < 0) || ((cnt == 0) && ((!OsPreemptable()) || (OS_INT_ACTIVE))) || (toWrite == cnt)) { break; } written += cnt;