Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp416901ybr; Fri, 22 May 2020 09:37:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9OQpNpvxUC5ni4bj46DK3VvHpRZW3OsN4EvrclhZhfV1rW/0ar69SPmnOrGcia54k9v6+ X-Received: by 2002:a05:6402:306a:: with SMTP id bs10mr3716330edb.227.1590165441094; Fri, 22 May 2020 09:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590165441; cv=none; d=google.com; s=arc-20160816; b=IByxEWrnBWxVoug/A0Ple9u+I5fAz1+9Q8EHBPCS6L4HkvffVNr49uQP5QLbv2nZQg XbJph+yTKGJXegmHgEifngyJHywXnCzxS6BsuGZc+d2LiIkII46x+MBQPShUNPvp4K5h J48QiIxafFLguBEjolKgxVva6AmVJ+1MnktF7snGAbdjCxIboAhHpn3aQCWx3Zv4EIg3 Kbd1whJ4LS+g0jjd+ztvlPI2BE9w9gW1XXWPtBTi0VVl51jJAJbyxNvphcVoSNJXftB0 kIL0iw2p8fWUx2Umv51YcXlQc+UjPxb1bhhaVRIhb1TiEH4yrvnjpqa13viHdOeOe+j9 2Gxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=aJwZ3Ckwgo1m0H1dH17N6VKfpW1UDHWvmlrmQBPFQ0Y=; b=UWKX5ILxwv8Y+TzpL+4SM0sVYqwoJIzlFv4LOJWD744YKk95kPgefd7mKlv3jhuIRp nJoH8jjYyBW7EzR7MBXv6ImJh2TW8MTaN0gVbzY1ZZmmVbF2sAD4Eqjdx5My2Ux6nc5u emY7lJmYLeJST6gWsGqwI9cdSHy2fMmnmkQswcNVxfCQqhtVlrReXmPVfzLhRml99c9s 54UX6CrMy7mq43pTcaAmcgcui0oiVQCPNlUd4VCEeJVBrJn+cngeJ2IbM/uUdMjmGrpJ 3xqqlFBEVwPW6ahVDYF0ofG9QKiBSnQV48rS46DnAG/9pBZwahROt5f5OKhuC1H0qAbb +F/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eoBQcU/h"; 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 d13si5269995edt.406.2020.05.22.09.36.58; Fri, 22 May 2020 09:37:21 -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="eoBQcU/h"; 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 S1730644AbgEVQfN (ORCPT + 99 others); Fri, 22 May 2020 12:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbgEVQfM (ORCPT ); Fri, 22 May 2020 12:35:12 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B521C061A0E for ; Fri, 22 May 2020 09:35:12 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id i15so10728087wrx.10 for ; Fri, 22 May 2020 09:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=aJwZ3Ckwgo1m0H1dH17N6VKfpW1UDHWvmlrmQBPFQ0Y=; b=eoBQcU/hPq3Tho3ql0eupAFwWPYksaNn6M2AuoyE02KKzBjkGj4EkJUbuiCDBACi8S VehjIN4LHqNY7n6zJoEB5evLeJSLObftp8ANDCZn/KRJaNZvDkb7usMJF2Rs3VEreeM8 u7vZiGnBXD/FNIETzkdaKLfPi8NQTvQNIpqWrtvFt/DBDIlRm6zc1rZpqu1da1Bkm3ti TNjn4IAPotifhxTXaOUcj5QCH+Q0BqDvHQdZuKcCG4HuE8KuhuRpuY3USOtRrLDnt2JS kg+ZF3b1ac4jdtQ40LZzTCvRrKGz6G/Uymr4+sFH6n3X4t1RgNCKPPAgkGCuz2jXjYuy sDww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aJwZ3Ckwgo1m0H1dH17N6VKfpW1UDHWvmlrmQBPFQ0Y=; b=sCa2FW93LNdvBrXkHgzWMYSB+bywTsZxgXesQcjCc80aMLcpBcj0k28jE1z4+MPaMH 3b1Rs47ik2C8zsgzh0Zsv86RFI6Zoc/RjrOAcgEyl+VQ6H4iM9rPfHFkA/990hxm7BfU bpNAE1OQ8c/kMNIdQWlhoHaDXjJxEdjthIi1nloZiP4ZuRuFIHMxiue108uKv5TUmkvk YJCI3OV5h2H1U5PJnmE9trovzzm63breBHYYPlCQCPLQXLKq6j4Fv5uWpZFP0bqcbIVi kVAVLWQ7FsYfKJVvP7Rk+X4ZlVSD7QwwV7bpNtIRx1ChRmXJBmSa4qArNlvJLjpOTFO1 BKSg== X-Gm-Message-State: AOAM530HxPfEZCJDr81VilixX/OANbfYgzmSrB2yleDtMj00F56qoIxu EltqY9oun2fTJymKXho5Cp9fwHqwEXU= X-Received: by 2002:a05:6000:1107:: with SMTP id z7mr3908152wrw.93.1590165311120; Fri, 22 May 2020 09:35:11 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id p9sm9916855wrj.29.2020.05.22.09.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 09:35:10 -0700 (PDT) Date: Fri, 22 May 2020 17:35:08 +0100 From: Daniel Thompson To: Sumit Garg 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 Subject: Re: [PATCH v2] kdb: Make kdb_printf robust to run in NMI context Message-ID: <20200522163508.e7476dd2vulntppc@holly.lan> References: <1590158027-15254-1-git-send-email-sumit.garg@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1590158027-15254-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 On Fri, May 22, 2020 at 08:03:47PM +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. Perhaps this should have been two patches. In fact, to be honest, I'd suggest combining all the patches to improve kdb console handling (including a fixed version of the RFC) into a single patch set. > Suggested-by: Petr Mladek > Suggested-by: Sergey Senozhatsky > Signed-off-by: Sumit Garg > --- > > Changes in v2: > - Use oops_in_progress directly instead of bust_spinlocks(). > > 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..3a5a068 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; > + ++oops_in_progress; Given the subtly of what is going on I think we need some comments in the code on what we are doing and why. > c->write(c, cp, retlen - (cp - kdb_buffer)); > + --oops_in_progress; > 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; > + ++oops_in_progress; > c->write(c, moreprompt, strlen(moreprompt)); > + --oops_in_progress; > touch_nmi_watchdog(); As with the other patches maybe the first patch in the set should be factoring out the common code before making changes to it. Daniel.