From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13377C48BDF for ; Thu, 24 Jun 2021 11:11:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6596613CE for ; Thu, 24 Jun 2021 11:11:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232420AbhFXLOK (ORCPT ); Thu, 24 Jun 2021 07:14:10 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43936 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232289AbhFXLOJ (ORCPT ); Thu, 24 Jun 2021 07:14:09 -0400 From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1624533110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=03qpuH1lkuelnu8wqylUWxMUR5FpJ2mw/6iK+juT3cw=; b=zlKanuYoRHfCjssDbaKHEfDUw3/fCs8+Z+JsELHhDrI8TMVrDQPSQ9KpkRGzq29nrXpTpw gSobo87jAHxyZ9U2QrYXMN7kKxyr1uot0Gu7D7JKN7Req/9RIAiVGsDBYHPo/b5g1P9f8u KnQ9dIFmJpppK2sBgJL4omPzXI/rR450jwiH0CO9cUyx9pHFc1PGQiEpxas0fX5v3Tb5yF KV9/S2eL7nP1fTE7EFB33ySqYqDEIe08iXGhr3Mw5UZSum+WCx+ah0jlVm8sPGC7URCMKG cBM+MoMsnBuEbLShmepwiMehB5vxbrOxVXNWfQAabOaaQvgO5G2yVK2AmgRbrg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1624533110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=03qpuH1lkuelnu8wqylUWxMUR5FpJ2mw/6iK+juT3cw=; b=Muc9gLOhcxpQnYbUeLwdhtWDfKGqbZWBoXSk+3/m0yRulV28jkHYXHMCCoyAlq29JF4cYz 5sykKer/MjXIs1Dg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E. McKenney" Subject: [PATCH printk v3 1/6] lib/nmi_backtrace: explicitly serialize banner and regs Date: Thu, 24 Jun 2021 13:17:43 +0206 Message-Id: <20210624111148.5190-2-john.ogness@linutronix.de> In-Reply-To: <20210624111148.5190-1-john.ogness@linutronix.de> References: <20210624111148.5190-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the nmi_backtrace is serialized against other CPUs because the messages are sent to the NMI buffers. Once these buffers are removed, only the dumped stack will be serialized against other CPUs (via the printk_cpu_lock). Also serialize the nmi_backtrace banner and regs using the printk_cpu_lock so that per-CPU serialization will be preserved even after the NMI buffers are removed. Signed-off-by: John Ogness --- lib/nmi_backtrace.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c index 8abe1870dba4..dae233c5f597 100644 --- a/lib/nmi_backtrace.c +++ b/lib/nmi_backtrace.c @@ -92,17 +92,24 @@ module_param(backtrace_idle, bool, 0644); bool nmi_cpu_backtrace(struct pt_regs *regs) { int cpu = smp_processor_id(); + unsigned long flags; if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) { if (!READ_ONCE(backtrace_idle) && regs && cpu_in_idle(instruction_pointer(regs))) { pr_warn("NMI backtrace for cpu %d skipped: idling at %pS\n", cpu, (void *)instruction_pointer(regs)); } else { + /* + * Allow nested NMI backtraces while serializing + * against other CPUs. + */ + printk_cpu_lock_irqsave(flags); pr_warn("NMI backtrace for cpu %d\n", cpu); if (regs) show_regs(regs); else dump_stack(); + printk_cpu_unlock_irqrestore(flags); } cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask)); return true; -- 2.20.1