Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp243954ybk; Tue, 19 May 2020 21:26:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztDkV25UfKYtyiSpDC6SoFbDY1x5viB154IB1EjnxTnKzxT0i2SuBqvzwyK67baeRmcuM0 X-Received: by 2002:a17:906:fb15:: with SMTP id lz21mr2116913ejb.538.1589948768717; Tue, 19 May 2020 21:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589948768; cv=none; d=google.com; s=arc-20160816; b=sTcsifWaME0yczCcwNYwl3j43RHnLdRn7hBUWOY2GH6r7edx64t6j78Cn1PxoobO5l DtoMI9W4EJfkXugjj7A6wrLw7FjP4qcOkrjkb6gfnrjczTZc3wkRL29szj+PvA5tyeGC lVUoEmd90rhqnfyGnd2wbPG83qG/gTVsXiO2XHeHi1G5ry9llo6CLJcFVQZW/JTg8rx8 HnUqkOOd+IN/PuJIy1o2U52Wh5w0iww7D5YJhgomZkbGTOHu3V/WTBLX73ymo69rvU8z ji3722kvNDh9IB4UOSnCbWc25EKlYypMCeCX7o+924E+3wFDVoyDAQmm6QkXXSqMd4dX xePw== 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:date:from :dkim-signature; bh=wLtepNIIFtYJeYE+BCKW9s6RSwXADFckBZfwuNyokFI=; b=z5BYtlJCUU19Ux6RHI7rGB8ZgXQtO6EadhNnLAbB83miK+vnaP+38D+pXRU3vn3OgH mtR79rwGnEzoy4104x/iI/XiGZh2IB569+j/R1mX7qkkdb/TKEqH7WCikgfDUkH7O6o8 5bLA7MMwSdQT+0H5TytwWJv4VQLvhn/PkznZkWUCW4B77yEl5h+Vm+KesCeUD+FP9Six FdH/b/nityBKXmds4Pwtf8fSrK0oVXup3Ikit8/Yna1DEnAnDhyy/l20g9PY1ddtmCx2 Xmfyd2MRDyKtRTVjFxX7iX8/loK4hoh8qieWj2jNJ4cWVzeaQSKZbF97Q0oDM+p2cYPG STVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Lnio8fro; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce16si794234edb.576.2020.05.19.21.25.26; Tue, 19 May 2020 21:26:08 -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=@gmail.com header.s=20161025 header.b=Lnio8fro; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726520AbgETEVG (ORCPT + 99 others); Wed, 20 May 2020 00:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725785AbgETEVF (ORCPT ); Wed, 20 May 2020 00:21:05 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA27EC061A0E for ; Tue, 19 May 2020 21:21:05 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id x10so808555plr.4 for ; Tue, 19 May 2020 21:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wLtepNIIFtYJeYE+BCKW9s6RSwXADFckBZfwuNyokFI=; b=Lnio8froYfGjhcDR8Oi4V/zbk2yJKl56gLzvoSzlT7BVfoF8DlqX2jBG5i8AiHHOB/ xZ+q9j9M++RPnht2msBmEJIwIZywFCYVY0lfOkwGW/Yc2StACazmKT0tl1s2yfxuEhOA +l2rMXpxit2HfCkDqm953gSguskXH/UOpd43cQjZ9cJYpl2Em6J6iw5o9jhnqmAaNSr4 PP+4c4qoi2mGZPJd+wpo11evo6JIFpGXBFaKc8viSXvi1YUZ2/AgROj0EoMVD3aS484W pFVU5LwL3WEEu8wnYBeslmWBMvNhYMXY0ZclBohCJYYlwUH1JecgAElKOSgnuHEHH7Or 5cVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wLtepNIIFtYJeYE+BCKW9s6RSwXADFckBZfwuNyokFI=; b=DVZ9JqEFyHBScIlRANWMFwNpCW2Zt+oDju4Sr8oyJnmn6G14k7KAVMIZ9RagCme+pr vNPOuuxHulz6PIq2S+XTmAYdQuhtvyYrdnVl9olDZ3vpP1sQUS0owoSmI2bbwfuSVQlT SLOhM2ABT4KmzgFg0K4p+ydNP1bW+acmmhDeZmFnVSJYZcqFLU8vk3ebCfnhj5rekCR9 5yX4wBa9rwC+hzZLF9Y/Q8MPSG2IFZ+s2JJj1ZXEj7f/wsDkuEfjURSzGevN7i0NNCAP whochsRenGGR1hkYV+YPN949fCRjqaq7oxTy4v1VLoNlDaBlhUs2rHrrIoGfZtD6No9e JMJg== X-Gm-Message-State: AOAM532jW4vW9ahfYPoAdphEx+fJZMNBRpDyalgo/ovwElSvwuZmjta5 XsV6CCsSVMcFMxraCRSicXo= X-Received: by 2002:a17:902:8f8e:: with SMTP id z14mr2577787plo.230.1589948465026; Tue, 19 May 2020 21:21:05 -0700 (PDT) Received: from localhost ([2409:10:2e40:5100:6e29:95ff:fe2d:8f34]) by smtp.gmail.com with ESMTPSA id 141sm832943pfz.171.2020.05.19.21.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 21:21:04 -0700 (PDT) From: Sergey Senozhatsky X-Google-Original-From: Sergey Senozhatsky Date: Wed, 20 May 2020 13:21:02 +0900 To: Petr Mladek Cc: Daniel Thompson , Sergey Senozhatsky , Sumit Garg , Jason Wessel , Douglas Anderson , kgdb-bugreport@lists.sourceforge.net, Linux Kernel Mailing List , Arnd Bergmann , Andrew Morton , Peter Zijlstra , Steven Rostedt , John Ogness Subject: Re: [PATCH] printk/kdb: Redirect printk messages into kdb in any context Message-ID: <20200520042102.GA938@jagdpanzerIV.localdomain> References: <1589273314-12060-1-git-send-email-sumit.garg@linaro.org> <20200512142533.ta4uejwmq5gchtlx@holly.lan> <20200514084230.GO17734@linux-b0ei> <20200515085021.GS17734@linux-b0ei> <20200515103308.GD42471@jagdpanzerIV.localdomain> <20200515134806.5cw4xxnxw7k3223l@holly.lan> <20200518092139.GK7340@linux-b0ei> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200518092139.GK7340@linux-b0ei> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (20/05/18 11:21), Petr Mladek wrote: [..] > > > Is this guaranteed that we never execute this path from NMI? > > Good question! > > > Absolutely not. > > > > The execution context for kdb is pretty much unique... we are running a > > debug mode with all CPUs parked in a holding loop with interrupts > > disabled. One CPU is at an unknown exception state and the others are > > either handling an IRQ or NMI depending on architecture[1]. > > This is similar to the situation in panic() when other CPUs are > stopped. It is more safe when the CPUs are stopped using IRQ. > There is higher danger of a deadlock when NMI is used. > > bust_spinlock() is used in panic() to increase the chance to go over > the deadlock and actually see the messages. It is not enough when > more locks are used by the console (VT/TTY is good example). And > it is not guaranteed that the console will still work after > the hack is disabled by bust_spinlocks(0). Good point. It's not guaranteed to help, but bust_spinlocks() does help in general, many serial drivers do check oops_in_progress and use a deadlock safe approach when locking port lock. I don't see bust_spinlocks() being used in kdb, so it probably better start doing so (along with general for_each_console() loop improvements, like checking if console is enabled/available/etc). [..] > > > If so, can this please be added to the commit message? A more > > > detailed commit message will help a lot. > > What about? > > "KDB has to get messages on consoles even when the system is stopped. > It uses kdb_printf() internally and calls console drivers on its own. > > It uses a hack to reuse an existing code. It sets "kdb_trap_printk" > global variable to redirect even the normal printk() into the > kdb_printf() variant. > > The variable "kdb_trap_printk" is checked in printk_default() and > it is ignored when printk is redirected to printk_safe in NMI context. > Solve this by moving the check into printk_func(). > > It is obvious that it is not fully safe. But it does not make things > worse. The console drivers are already called in this context by > kdb_printf() direct calls." This looks more informative indeed. Thanks! -ss