Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp288319ybg; Wed, 3 Jun 2020 00:27:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1aIs6BqylbexaFL2C8ykjlTm7vBX8c9P3KUweMhNNXEiUoHw1JIAZ2dwarmKEiL1FAVzG X-Received: by 2002:a17:906:f115:: with SMTP id gv21mr20451459ejb.340.1591169271656; Wed, 03 Jun 2020 00:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591169271; cv=none; d=google.com; s=arc-20160816; b=r7pHfi+n2rpUTsGcC9eKrCEy1cBCXhsqhRsFdPkDuwK9qihPc6wF1EpWwegkmh9NBq rez4Wl3Qs2cM3r8QesaxG3sDaJGlBX/uge788BpILwzx5wsVVK1XIZ/ovL61mpZRXTHp LFNS0CV9E7NH1aC1KrDDJo0ZdHzElEIKwjV3qDMClJWMraRd+kqxAOsz1bLgcK69o1gt MFvKZQIcb69Fv74DatyNav6tWn5RNpkXs7Wgk7uw35mZP6LGZl2/vKJFkBiDU9qJBgRA BAojHaqqFFjIYp1dDxAxjMVrJpCkz6Ce7I/yiR8uSPBQxhdNUqt8tqAJOFoZB8xVw2fp q1Dw== 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=epHTx4WtH5eVO53u9vYRGtnDvl2Fou6agb9RgeFaY18=; b=VSyxZvslpBZuha2b3dyygzNg6A94KulP9762FVq6Tja/okEse+Jqy00DrM0Bz9ee49 7JIW0xVGmzKlC/36eOANy5UgrNcWpv/V+rlcCWJj/Asn6ni6wsUeRwdoHtwWMx66pd/H h7YGrnU1W2troFnqdWGNbIAlJA0h6RDaKeKTIYbcBD7DT6KPk8vNzVpspBwsbAFow3ar UEDKIUn2L0NvekLVKNm6ZbFT8+fYsywmO4++u7W8ZOactvdzkZQ8mt3w77H9h8GWC7hg g/pFWtds4PvDce04wQiCqFTFC0qHFAr7RlrW9epg9BZrchZwRVVtnGVqG5zWwTjsDk17 LjDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CDPwO3ol; 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 q12si724687edc.303.2020.06.03.00.27.29; Wed, 03 Jun 2020 00:27:51 -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=CDPwO3ol; 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 S1726202AbgFCHWz (ORCPT + 99 others); Wed, 3 Jun 2020 03:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726024AbgFCHWx (ORCPT ); Wed, 3 Jun 2020 03:22:53 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6484EC05BD43 for ; Wed, 3 Jun 2020 00:22:53 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id j1so864775pfe.4 for ; Wed, 03 Jun 2020 00:22:53 -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=epHTx4WtH5eVO53u9vYRGtnDvl2Fou6agb9RgeFaY18=; b=CDPwO3olv9s5zteGYUfVc+sp3PPPJPLARUW/0rVxq1+Ly8PTZYNTR2mW3V2vZmsLiT 3oAMpGGkbkfHTmeJlqmXYWVqv+T3LSm8sk0Qx1h+VYo3kBBoWeyhjdKvwlQo/3jUlCrW 0ttOmubv94mXOn3Yyl/JahnMEW2Sk4SvsuahvpEihKkHm1Ci7nGsbhs2eWHxRWT3ar8H lAoF0PK0LLTzSTDLIX0NKc4v3lVMpP9I7hfAR1t57cPwBtKiglm+xeqlwoEkpzgF2Lmi QPCkwbuBYt7tpDeHN7sZa2qWc3ua/uLsB+hsIW6e0xDasBj+32acrZyV0pl5oMp0Ba/Z u3LA== 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=epHTx4WtH5eVO53u9vYRGtnDvl2Fou6agb9RgeFaY18=; b=rUHEDLkf/JefDNtUnsOdA5EZOoRS44fP86DFm7M2S4WZdulUAmKBJhtOlZA+K7J0TF eUjvun1qzbLd1l/FCZXhTqM9p9lrfH9gwRFDuZkrZsd9sk7+xTWkx8qYUWIbljKwvSbg nr5qh9dSqau1hjtmYlnzB9NgPtAr/Qhz6cnq/I4w2+fJGej0Fr0J/6Xl+GRYGa918KMs Sxdtlw//k5Sdt5melRPKQD5PZm6ZXS/FpCa8DhMiKUhb1gL3S3x1x/8IfKrhZ/DOH1X2 iku6M1Pf0dIr7Jjlh5pQ4VCqtiSCD1aKiseNcF7HPgDdhgFegX47PB9Fcz77viKNPqC7 b72w== X-Gm-Message-State: AOAM533lIlhv6j/sSbJez0vqP0mqcaeQubCPju2ERrDDr2VY3JS6uM8v 2Fh2flwTRfKLQRXrVJYBNFOMPg== X-Received: by 2002:a17:90a:2686:: with SMTP id m6mr4101227pje.11.1591168972877; Wed, 03 Jun 2020 00:22:52 -0700 (PDT) Received: from localhost.localdomain ([117.252.66.248]) by smtp.gmail.com with ESMTPSA id j17sm1407272pjy.22.2020.06.03.00.22.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jun 2020 00:22:52 -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, gregkh@linuxfoundation.org, jslaby@suse.com, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH v5 3/4] kdb: Make kdb_printf() console handling more robust Date: Wed, 3 Jun 2020 12:52:14 +0530 Message-Id: <1591168935-6382-4-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591168935-6382-1-git-send-email-sumit.garg@linaro.org> References: <1591168935-6382-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. A similar deadlock could also be possible while using synchronous breakpoints. So in order to avoid such a deadlock, set oops_in_progress to encourage the console drivers to disregard their internal spin locks: in the current calling context the risk of deadlock is a bigger problem than risks due to re-entering the console driver. We operate directly on oops_in_progress rather than using bust_spinlocks() because the calls bust_spinlocks() makes on exit are not appropriate for this calling context. Suggested-by: Petr Mladek Signed-off-by: Sumit Garg Reviewed-by: Douglas Anderson --- kernel/debug/kdb/kdb_io.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 58b7d25..0e4f2ed 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -562,7 +562,18 @@ static void kdb_msg_write(const char *msg, int msg_len) for_each_console(c) { if (!(c->flags & CON_ENABLED)) continue; + /* + * Set oops_in_progress to encourage the console drivers to + * disregard their internal spin locks: in the current calling + * context the risk of deadlock is a bigger problem than risks + * due to re-entering the console driver. We operate directly on + * oops_in_progress rather than using bust_spinlocks() because + * the calls bust_spinlocks() makes on exit are not appropriate + * for this calling context. + */ + ++oops_in_progress; c->write(c, msg, msg_len); + --oops_in_progress; touch_nmi_watchdog(); } } -- 2.7.4