Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp93769ybs; Tue, 26 May 2020 04:37:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEMnP/cTunTix3uhAReDj2D41cjIr94t3+/nXUT40oaQ2KdWQOUsftPmX+K92yMwTHAC8p X-Received: by 2002:a17:906:2503:: with SMTP id i3mr721021ejb.293.1590493072444; Tue, 26 May 2020 04:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590493072; cv=none; d=google.com; s=arc-20160816; b=Y05fnAu7Ntwv1jfMwTpu9syaJSAo5hQ1554z6qXKhswvxTwHkG/HoqWV0QUDSzCEXh XiJ6Bn0wz6wAwNKeSX9SVd/t/wkRgixFjbQb+owccmzyXZinMime0PNym6rVQtC1UebG dEgH93g+nc82IHqmcq0BiaZJY7+D+jCI23+drlUZFPxHmYzUWkGU3I3HfZX5GVmZiF1T o5bohrwtKDvLhMmJXgOQaIAP0wgVsaz+7lW/RzTDC/60LjE3WuKYj36wCsaYaREd3gJO XTknRdZKTl6WIBUAUQEgeLIK9eAam1Hr75QwnGHMAc3HRlbWkgNfOR1MfzPCBgV1zwEp 5hXA== 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=Hls7pMjgRAEJPr8FkQn95q9jMKxanllQ2tD+H93l8Ao=; b=uM5sANKg7RUz89vtf0FG2tDnA0fW3E6IsNWouLRzFjIcZx2xWXTdiF608fXa6CPTlB gsJWhjHZYOTBiyL8T81MnEvntdgtMoGIDuqtpONq5PGqLo6YGwogPhBOfkrQv7lzwnn2 1aPVFVEp4RMzdxRUBIZuXNOwndeOscDSvfi0njBEMbyJMx35LBTkvJIUDzCelilaZu3n IdwVRzNLmHmnAL2Lm/eCPhAC14+J+FwtZ7vwmZQ2eowDRdL8gs91v4RevOhzttHP/w1R EdulCY9Gd8IVXQVVBQXHmi4p6+FZZNOubgvMKEnBxeetuoKunL/wgyiOJ+fgNdl+8XmX cyZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kDjv/fMk"; 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 s24si10437240ejz.736.2020.05.26.04.37.29; Tue, 26 May 2020 04:37:52 -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="kDjv/fMk"; 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 S1731689AbgEZH5l (ORCPT + 99 others); Tue, 26 May 2020 03:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731406AbgEZH5l (ORCPT ); Tue, 26 May 2020 03:57:41 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9FCFC03E97E for ; Tue, 26 May 2020 00:57:40 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id 202so11772838lfe.5 for ; Tue, 26 May 2020 00:57:40 -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=Hls7pMjgRAEJPr8FkQn95q9jMKxanllQ2tD+H93l8Ao=; b=kDjv/fMk4zgd/uMy9GdPdkzKw0FjIFNyX/DkJ4TIntG9UIvqr1brnF9lwO3ja/jq/6 e4PJsah91HXN5L/KlNXp8fdfOHtc8tjtjwf4r26+Wavaw/NVBpFwSmXcilVjDl+HMJD5 bNV3kMcbws6HVRsXjDGSB752UfhZFX6DlovpnRRUzCRsSNfJdNoATpsAAZM+8LC9LCbx xNcEzner0LDPChpzlIY2cZzLOC7EdU/hC+GEeSsHVxEdirao42Wpxo+X0V4pqNrOnUbm fgc+Gc5ZvIy2whtYwMU25POFzrlACuxrRehyrXpKGz+RR0BrbBfXyHjyFKVR1xSgtqhb bG3A== 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=Hls7pMjgRAEJPr8FkQn95q9jMKxanllQ2tD+H93l8Ao=; b=MVtXxtqCDn2T1bLLMKE9Ij79wl4LknxkgmvOO3UrIF7K2OAUZ4cNxH6MeOEA0wJNjU 1lENQHQH6eKi6ssrWbxv+b5bhmYNu7t4CCJBS9OqAitJn0ITRpbtmGCy3Hf/9o0Y6FX6 KP9VTpzk8xJkjnka7VkoVLTFKxKIiaDaRyPd/9op79j6exMju5cwcyZcOq3AoVkCvViK SNAYfMNAqp1DFSNoFMvHekVM42tq3cBB+rTgcB7FZWMXURM79ubobOKuwBj8KQ+9ItcC kqIz5MJQe/6wQHevQ5x3rTa/zXLaucPhV4xMn+t6oeHGLc/xottC/7xT/O7DsTu4kebB hwdg== X-Gm-Message-State: AOAM530664DiY5XRXSlq6xMJSIi+ZAOQrE0a77NtrbslE/9yzYR6fsvm WoP8FQb9BPrZIKP6N9iRNpC83F15A+FqF6cj6+7NFw== X-Received: by 2002:ac2:560f:: with SMTP id v15mr16647030lfd.160.1590479859340; Tue, 26 May 2020 00:57:39 -0700 (PDT) MIME-Version: 1.0 References: <1590158027-15254-1-git-send-email-sumit.garg@linaro.org> <20200522163508.e7476dd2vulntppc@holly.lan> In-Reply-To: <20200522163508.e7476dd2vulntppc@holly.lan> From: Sumit Garg Date: Tue, 26 May 2020 13:27:28 +0530 Message-ID: Subject: Re: [PATCH v2] 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 22:05, Daniel Thompson wrote: > > 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. > Okay, will split this patch into two. > 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. Yeah it makes sense to have a combined patch set to improve kdb console handling. But I posted the RFC patch separately as I expected comments and discussions to come up with an accepted approach. So let me wait for an agreement on RFC patch after which I can include that patch in this 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. Sure, will add comments. > > > > 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. Sure, will factor out common code as initial patch. -Sumit > > > Daniel.