Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp609931ybm; Wed, 27 May 2020 03:44:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuB/qlhPz1z5VIfhc3EjfxawX+1/oFxC0FX4u6lXZIUxeCsQey7naD0xZS4glNRZ0Gkfkh X-Received: by 2002:a17:906:46d3:: with SMTP id k19mr5562024ejs.349.1590576257092; Wed, 27 May 2020 03:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590576257; cv=none; d=google.com; s=arc-20160816; b=qp4R+KjlLCK45jNSueoidAYbEssdFPm69Uami++F2oFfrDuTZ4GFVOapcdDvdlyCtg Cev2r18BtY7zjWH1zSH6SwisdJrxfNl4IDhulgdHWatt+tMp+5ABjnfgctMqBhpzkrG0 YKNa9AVIM0zBMUGjyZaApTu0QEgbKCbksAeD+eiJ2u9e6m3Z7goo/kOidey9fZQS7Z9K SOF8QKac+zoPr8sgDzPMw/1LHq6gfdQp61OKYFU3GyqnBEKx60nBh1xTzr5j9iQ+3XtB vsaslzV9R7tT3XmcEVwpeyaG4nbIDfDWTHJn9yhJAePJPid9iwxpXMo+qT5853dFy7Vj z1IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tSNP35QYp6xethZiWpN7Amg3X+LW4hgKA/e4KGUMccc=; b=DPIMtpqABUKrw+ZH1XOqXxGIkfw01e5acFTZrWB3okpTtLlZ2idURgPO7nxAVNXN4i 7kTKZtdiwIuQ+oQ0tYzy+HZsQElfQ86FZxNukpYmZKrUR7DiqSj7fy0kPKLRhrh20mMm x0BbjxkGq4924m7sMzfTzkE0suFTZ0Sc/BfqAqGneC3F8K469YfoqKn1eXpFsHa98PXd rN11VmuZVypniS/DOt+ep3tBtl12KQ0FGJ80y5qRU7/vkDfdh+1CnC7knSGv7Vw4r0Sp KzZeXHZiy3ZGe7RKaS4ds4UfAZyHEYGqI1f0amukDK8zQgOvYy3pFBHvEoVjx6DIKf3w A2Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G85xHZqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f8si1528272edk.160.2020.05.27.03.43.53; Wed, 27 May 2020 03:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G85xHZqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgE0G0v (ORCPT + 99 others); Wed, 27 May 2020 02:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728003AbgE0G0u (ORCPT ); Wed, 27 May 2020 02:26:50 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93F2CC061A0F for ; Tue, 26 May 2020 23:26:50 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id nu7so1115157pjb.0 for ; Tue, 26 May 2020 23:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tSNP35QYp6xethZiWpN7Amg3X+LW4hgKA/e4KGUMccc=; b=G85xHZqLsrWZHmuuol1ub48HKxIZv5mdMUnm3b8yhDQMn6qJH4go9eNLKJHEduMHCw 5oWiGqTR6R3Lvvs162rEhlcPapcPlp9s1LdpwgUxegA0hZkPCEEbHUlFw2/3jL0Cal8c Ald7vkGE8pEFiTwJftEVdcJnU4Bos8caP5Pi18190rIeTGVdbLLnGPZUA3+MpI6z86xe Axtl7GI6AkUDP+XLxRcgRSMd5a4tL7OlEiOnSwRh0YujnzdzkRNCN47W+u75SD8ENOcY 4VahJAFqcN3JceEn3SOat3kt7OqkIjCpofGgPZ+LlmUX2Fp+nhYGTkuIqsGUvUMoeVco y81w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tSNP35QYp6xethZiWpN7Amg3X+LW4hgKA/e4KGUMccc=; b=C/zc4N8+7sC3LDndOV1Tr9CJRQjCWv3B5FvdQIOni30vhPBXPXPp4LWfHEFOtxb+Sm egejEyQyI9DV8wOKTNyiDtwvRZHo+1mQMHum+rtkhr7bN4edp0eMK8enCLhSWsQnHAeR P5x7QWOCW6MfxhMNDSuOH145oi43YnWeC3C0ES4szla0+DImjmh0T7IYkrOPX9/RLnZj PAy1tYXbBTAqXgpKpwG8w3HXC03flHzsrAlBu/xsGDS0UEuiWT2V5Q6aRrK1wKLyY2mW 3Ro0NQhEzt87piD0xyF2ujzVIeNbS2KhzH09EmtDr3tvELMIivmBI74cKNmcJIx8fYwv BJUQ== X-Gm-Message-State: AOAM532xbtZJxQVOVfBJ/1m3+2kkRqMNyplHwb8bH5O+idA8scGb6/P9 TgKaosdyayWfOXRkKjuDLB5Xig== X-Received: by 2002:a17:902:b904:: with SMTP id bf4mr4500929plb.89.1590560810119; Tue, 26 May 2020 23:26:50 -0700 (PDT) Received: from localhost.localdomain ([117.252.68.136]) by smtp.gmail.com with ESMTPSA id m12sm1239121pjs.41.2020.05.26.23.26.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 May 2020 23:26:49 -0700 (PDT) From: Sumit Garg To: daniel.thompson@linaro.org Cc: kgdb-bugreport@lists.sourceforge.net, jason.wessel@windriver.com, dianders@chromium.org, pmladek@suse.com, sergey.senozhatsky@gmail.com, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH v3 3/4] kdb: Make kdb_printf robust to run in NMI context Date: Wed, 27 May 2020 11:55:58 +0530 Message-Id: <1590560759-21453-4-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590560759-21453-1-git-send-email-sumit.garg@linaro.org> References: <1590560759-21453-1-git-send-email-sumit.garg@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While rounding up CPUs via NMIs, its possible that a rounded up CPU maybe holding a console port lock leading to kgdb master CPU stuck in a deadlock during invocation of console write operations. So in order to avoid such a deadlock, enable oops_in_progress prior to invocation of console handlers. Suggested-by: Petr Mladek Signed-off-by: Sumit Garg --- kernel/debug/kdb/kdb_io.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 349dfcc..f848482 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -566,7 +566,17 @@ static void kdb_msg_write(char *msg, int msg_len) for_each_console(c) { if (!(c->flags & CON_ENABLED)) continue; + /* + * While rounding up CPUs via NMIs, its possible that + * a rounded up CPU maybe holding a console port lock + * leading to kgdb master CPU stuck in a deadlock during + * invocation of console write operations. So in order + * to avoid such a deadlock, enable oops_in_progress + * prior to invocation of console handlers. + */ + ++oops_in_progress; c->write(c, msg, msg_len); + --oops_in_progress; touch_nmi_watchdog(); } } -- 2.7.4