Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp460872ybm; Fri, 29 May 2020 04:32:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3FUp+6AEM8I6uMyyXN+t7uwZ4B9I26l1r3DasosSmDcZxs5gDdVftYjVldHwZtMKfS5Yq X-Received: by 2002:a17:906:9a02:: with SMTP id ai2mr6945785ejc.97.1590751975372; Fri, 29 May 2020 04:32:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590751975; cv=none; d=google.com; s=arc-20160816; b=WOuppk9+yf4HWJGsPRYsMHO9VWrlW4dO2oDUdOyeUdbaN7QtvV6xoSRWX5PdY0sEvv zbghbC9prsumnFfXByOMOh2X5zqUfcVzmVFzQT+HogiFWRWUb68rd5/ofQJod6AuIYZC rhCI+YlBGFBpekBP1iucbFaupHwMdMOaK36K2ZfC9LhjMhBwzysidkSZwfhaN6q0LbLh ecYryCU72KZVu7i9MniwFkOJrYmt1N1cwFhQ19GUs0ZOPMk38P+kv35GK47ibuWSfycH s46T6Y8I10kBdMHH3mliq2I9FpVBDt+hjiPeNduAP/gbODm0DzdqqPlBRP7m+L6KgUyH HY+g== 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=swXPGMrzCEsQLDtOomMfEMI5zRSTvjf8q0XZ57NNdwQ=; b=ZeCEULFvD4k/siovu8NhPXLWLRJ5h0Yp44hR3Ysqzj724pgcDAmBXThLAXlcFvzclt 6B54RKk3AcI3CYUHkMKlPCnfPRyjvzNtc7UFUrhm2PuoRyA/rKnCucCFaZtwIth4RBxX ireyjTbfW1i69gEyy7k4/ArPAkeHBjdfIhdLtOuay95pyOCdCb74vzUV/7jJXV14BXtY +ByqibQEdetD5w35kXNnOtEFeeBQfHWhfvey3f7x8zRiU2W7N6QJwlC39wd/Sgp7KMNw tQXfEYfU5FDWDmpKA8VqJfSxBQxT5NXANgooyLjm0EwJuNL/ddVfF42hnJN8TCr0cijy an2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cTntY+QP; 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 gf6si5160131ejb.338.2020.05.29.04.32.31; Fri, 29 May 2020 04:32:55 -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=cTntY+QP; 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 S1726712AbgE2L1h (ORCPT + 99 others); Fri, 29 May 2020 07:27:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbgE2L1g (ORCPT ); Fri, 29 May 2020 07:27:36 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD230C03E969 for ; Fri, 29 May 2020 04:27:36 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id g5so1236382pfm.10 for ; Fri, 29 May 2020 04:27:36 -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=swXPGMrzCEsQLDtOomMfEMI5zRSTvjf8q0XZ57NNdwQ=; b=cTntY+QP7be+KCZ3TmD3G+ZmCEJTyACPPKqh2zbGHf6TTf1vlDeMuZgJO3O+/yLT/b VrWg+hXVkn98YCY8v/zOyzKGb9uN5TU0eVylsq9kNnKyREVfvU1B0zeNuxnC835XV2aL 8jFexlrTTmbsOccFNv6Me65nM5nD/oh6a0T6rK4v5PJW0nc3ZZ51yUe0cT5YB14f0pw5 nocjZCF2mLqp9UVZMNqHIT8aeScGfMaD+OOi3KltXiQBPya9SX2387AetuSs0d9FjhoO ugRvO7m/rWHwQ14gklIx1bqhblOgnwhMHTIZLyZNZOed1HNYmgCoHaZOHyg4j8v1GMO2 dDfQ== 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=swXPGMrzCEsQLDtOomMfEMI5zRSTvjf8q0XZ57NNdwQ=; b=mRNenQ++obzn+PIRqP9bCMdQ1aRvZJT/4oMRZUpeVIPdPeqtaXX848zuR01y1tZzMR yWAp7OtKI8kxj4PQmOdunwaOgDWc1OD9xGWlisOM7q3kIqzVU0S5FJApUz5XOsmyB3uP p3AALKS59fLxlpzDkeMTj9WoKfuI2V9mzUTNS57ifRbb9C/WPdZ4x2WLfMzX5ecoLW56 Lt3nfBUC4d1sLNcclkPzuCmk0EZA0+yGPtVqQOqt+vG4upaA3i/GIrfgPeR4Bg+0qMQE BgPse7P1q005nOpeAO7v63JHDZX/SrjUYQigBzVn0oFKgfW0kFvd/TCH53TUkn/4lNec aFvQ== X-Gm-Message-State: AOAM531kc3JrCS2tF2kgU970qaQ2DOg2nbE2Tc365syUan6L/y90MWjH cU8Whv/mP1OlkFeoOa08Jlr9uw== X-Received: by 2002:aa7:9a0e:: with SMTP id w14mr8332032pfj.288.1590751656230; Fri, 29 May 2020 04:27:36 -0700 (PDT) Received: from localhost.localdomain ([117.252.66.248]) by smtp.gmail.com with ESMTPSA id w190sm7016741pfw.35.2020.05.29.04.27.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2020 04:27:35 -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 v4 3/4] kdb: Make kdb_printf() console handling more robust Date: Fri, 29 May 2020 16:56:46 +0530 Message-Id: <1590751607-29676-4-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590751607-29676-1-git-send-email-sumit.garg@linaro.org> References: <1590751607-29676-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 --- 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 fad38eb..9e5a40d 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -566,7 +566,18 @@ static void kdb_msg_write(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