Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp171673ybr; Fri, 22 May 2020 03:57:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykq1kD1MyURRqCO5L3tcIN1TQVREQHXwaxHZiTz2oDnZhnHfknesv1J4y9QznaHLmOMUOd X-Received: by 2002:a05:6402:2058:: with SMTP id bc24mr2512231edb.134.1590145022890; Fri, 22 May 2020 03:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590145022; cv=none; d=google.com; s=arc-20160816; b=pqAfStqQxpUzBkEkw4reUaH7BW6IQBFZkIwqndbaWqkSk/MpMYYqPpHUvsdWf4SdAC 8sNsJ0EfmnELNXnxj7TI4/bMd8hi/3kq3P8hni6BHxSJHGjjo5fYKVMdrAbNF9PXljeL m+3ho4FfKVhNTN5k5jADj1TEomYVAbDv8QmJLnG0vYjg9dUZ7jcCbR7Nr1Oskk6RU56i sgLKtXdF+naDFqA+kD84U33CPFxzwtAvi5Gp+k3Mz/PYV6DVNGt83USNd6XcT7yN3a+u Fd2FimO8UmtjfU0ocuQZ8BLSBjdNIWovSKWjipLy1K3yiI2T9ee4zYUEM5EnnjYH4ZGb yw0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lvdyN6G4YtegRjCLgqlMGLFPk+ZDJ/sCDCmfREQfAYs=; b=DkZKL/wU0+bBwzWao1vUBAx1TcFzF+zXsDiLGM3wxO+IpNVx3FtXdqyESv4oa5o1n5 lu1oAl9085tUwGh7pOiscJh8QSflz3esIN6Eaja/P3MHX6OROcGoRQE4EKw1EJxvawJY +FoE9LW4tmfbqBi09CG06SkL1X+X3Cd465d6uh1a62WXVZr5cxjvvDh/9amYFcfqJjta BNz25NQsPflxEym+9NlH2yuEj+b6m/ok79AyE65gPZcIfNwvMGfY9OB4HKyFBk0j+ksN UN+hBbJcc8jYRsw4F5G6/09qP2/TM5+NfYiAOp1lXkLTWGZqUBqW7UPbeXiRvYCW2alv sqJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MPxzew+B; 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 c3si4855383eja.251.2020.05.22.03.56.37; Fri, 22 May 2020 03:57:02 -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=MPxzew+B; 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 S1728672AbgEVKwq (ORCPT + 99 others); Fri, 22 May 2020 06:52:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEVKwp (ORCPT ); Fri, 22 May 2020 06:52:45 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1D2C061A0E for ; Fri, 22 May 2020 03:52:43 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id o14so12120881ljp.4 for ; Fri, 22 May 2020 03:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lvdyN6G4YtegRjCLgqlMGLFPk+ZDJ/sCDCmfREQfAYs=; b=MPxzew+BaJxir4dgUA9o3HVns9qarZ9K7auFqYfINS40vfUiTt5MGzXN89nhppJNYJ VXK84TbQdyf9b9ZMY/doS6mNQTxnNFkzKdaJLxwhbg4QtliRkgK1mFk4lbpnGkJee1rM z3KtLboDvdRLZmsjPO/CoqfBS0lfkYrih6HoozgVE4yNkryPhKUPZOYm2H+nzdVABzSW IHONB44yeoX5H69Mqcba1tKOVZvWspsLvgnJI6wtxjD+qMAhPF7s0x6pAVW2OY2KCds6 jOZV7sBzFKh0dJE5AOR8RQAGZgIgCuJsnTwipnt2wXrlZK1qJDWEKO6jlr5Bp7r8O+fn hn/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lvdyN6G4YtegRjCLgqlMGLFPk+ZDJ/sCDCmfREQfAYs=; b=iE4eVPLFTddFXozdfOC54WK+HuKDMR3jYHmpEmb0DSdeH2CMMHpPoG5jPn1sGQ0V2t t5dwMMhfLcSfCS1MclHTXLdP4t+4n82jaaFPYN2C5fKqS+iYVNAWeE2X3LJpdX+J9yI3 WyCeb6YfOnsd+XD3yIAKUwmTiYkVnri3bJiV0WGRlNEkhrmouwjXJCaor4lql05AP3S7 WfW2aRkLzg9D2b0fKVY+MB0ykb+hlBmZm9Wwve/PE5tHSyM9Ez/MBjuMCn0TORtZdf5V XuH/OEQZtw5/pcnNd71CzvP0e2umUwNMyxzZdRp+XN1Cf/2CroRVS0+mM/r4El6JiTyH nDsA== X-Gm-Message-State: AOAM533w/vRhlPlLvvHid/uLnPmVgls3IUKDAYsYlhOY8o8SFwFiKj4m DzgSyoJQTc99EsTepVXVhVZk4NPzWMeWX3sH6zVs/Q== X-Received: by 2002:a2e:7504:: with SMTP id q4mr4798745ljc.339.1590144762130; Fri, 22 May 2020 03:52:42 -0700 (PDT) MIME-Version: 1.0 References: <1590141746-23559-1-git-send-email-sumit.garg@linaro.org> <20200522103823.uwb6jpjwpzhhjwwt@holly.lan> In-Reply-To: <20200522103823.uwb6jpjwpzhhjwwt@holly.lan> From: Sumit Garg Date: Fri, 22 May 2020 16:22:30 +0530 Message-ID: Subject: Re: [PATCH] kdb: Make kdb_printf robust to run in NMI context To: Daniel Thompson Cc: kgdb-bugreport@lists.sourceforge.net, Jason Wessel , Douglas Anderson , Petr Mladek , Sergey Senozhatsky , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 May 2020 at 16:08, Daniel Thompson wrote: > > On Fri, May 22, 2020 at 03:32:26PM +0530, Sumit Garg wrote: > > 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, invoke bust_spinlocks() prior to invocation > > of console handlers. > > > > Also, add a check for console port to be enabled prior to invocation of > > corresponding handler. > > > > Suggested-by: Petr Mladek > > Suggested-by: Sergey Senozhatsky > > Signed-off-by: Sumit Garg > > --- > > kernel/debug/kdb/kdb_io.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c > > index 924bc92..e32ece6 100644 > > --- a/kernel/debug/kdb/kdb_io.c > > +++ b/kernel/debug/kdb/kdb_io.c > > @@ -699,7 +699,11 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) > > } > > } > > for_each_console(c) { > > + if (!(c->flags & CON_ENABLED)) > > + continue; > > + bust_spinlocks(1); > > c->write(c, cp, retlen - (cp - kdb_buffer)); > > + bust_spinlocks(0); > > I think it might actually be better to directly manipulate oops_in_progress > here. > Okay will directly manipulate oops_in_progress here. > bust_spinlocks(0) will call unblank_screen() and console_unblank() and > I don't think calling these is worth the risk (and whilst kicking klogd > is safe I think its also not required). Makes sense. -Sumit > > > Daniel. > > > > > touch_nmi_watchdog(); > > } > > } > > @@ -761,7 +765,11 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) > > } > > } > > for_each_console(c) { > > + if (!(c->flags & CON_ENABLED)) > > + continue; > > + bust_spinlocks(1); > > c->write(c, moreprompt, strlen(moreprompt)); > > + bust_spinlocks(0); > > touch_nmi_watchdog(); > > } > > > > -- > > 2.7.4 > >