Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp621786pxh; Tue, 9 Nov 2021 16:19:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2iG0Uf+jecI1l/Gl0PmuyBjQU0fu8EyPr1YfkmEWV24V6bZh5EFnedp0TXJHFBQoJscpe X-Received: by 2002:a6b:d20f:: with SMTP id q15mr7710331iob.39.1636503590254; Tue, 09 Nov 2021 16:19:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636503590; cv=none; d=google.com; s=arc-20160816; b=oNC3yAewLW+HIsoK/NOxsWfpMAJfMbSS1IgV8zydZCyROL4lt2B+pi37fhqt553LYw JdCGFRlNSI4rKrgivh702HVhIjDfIQxExoLVAvWHUcENcpapPZ4dfVl9FhSVkmqmmfnW YcKBp3ubmixMYS95tNDlSTL3MglU+1ni5LpXT4p1HA88Wd8kImXZFh8gBKB17xHRU0PL dsC/uT4Dmk9Lpoq9W4AcrAno3tZrlE+hgDxJBgABZwXjX2m6k0rFUlu27AnbR3TxqPOV 0qPBGi7MJr3DMAznlBiSEvMO6OQCh2wf2aMKkYh0JxgcqU3SspMKPWRzWJDTC7Xznc+N EKlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WArqkDtu5W1DQIOZg6AY0uLA7OKIXkUD3kbNB9gSEbo=; b=IcUXwT493Bfh9obrfDh6+LXPhToTJTS3Ia0uk2kGktXczP3oPsWr18T2jRroST0lbs HIia/2LGpjlUHS881Bg8uxUgZfP/C5NCJPojCSmil2Cluq7i9uxHju/b6mJaJGEGI6U8 RlXEHBmOgolBOFA5wOIVq/Fo2MZE62ta6HJvhOsHaCp/puGkwiegL+2GMolqLKJOpxgs OCV4+GyIuKTGZaJDyot0r9GpR8gIf3SiyHSoQ/O3f1PayQLyKqwD7uOlp8b7GDOtCT83 bGsWA2hLcnFDMkhII+aJGMcPfMYmkSu6fNbI0kJeyfkncHu6KaVYFeUaP4KpH45okCaw I5Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igalia.com header.s=20170329 header.b=Qzlp7TLR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay7si34685068iob.27.2021.11.09.16.19.38; Tue, 09 Nov 2021 16:19:50 -0800 (PST) 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=@igalia.com header.s=20170329 header.b=Qzlp7TLR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244694AbhKIUty (ORCPT + 97 others); Tue, 9 Nov 2021 15:49:54 -0500 Received: from fanzine2.igalia.com ([213.97.179.56]:33712 "EHLO fanzine.igalia.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234878AbhKIUtv (ORCPT ); Tue, 9 Nov 2021 15:49:51 -0500 X-Greylist: delayed 1063 seconds by postgrey-1.27 at vger.kernel.org; Tue, 09 Nov 2021 15:49:50 EST DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=WArqkDtu5W1DQIOZg6AY0uLA7OKIXkUD3kbNB9gSEbo=; b=Qzlp7TLRgXgDaisYpJr22SvCHecuDcA9IG1lh74ZDfzrJv0E7iJEhLwMlC5N8P2LZwRNWztVoV+UHoWOv2/0dT1SJccI2Au0veyf4dhxiMUmMIfP/2UwlwOxi5HwldblBtVhLjY76ETUfEPCy6RqqS1rq9YwsoN0IHJfmJ6zos6l0ySbRVM5zGBn4cSAb6raeB036ce2Oh7KimRSCGdgFpo4KaoshJsAUaV/ieZP6S0Niwdu4jhM6smh1170Tf7V7jFJvSgjY5ytFnlttOwI+1Wos35qE+becR6oXWAd7CMbWoJznnWMSqXemOG2XWblgfATmnifWUpvsF8cwlbFWw==; Received: from 201-95-14-182.dsl.telesp.net.br ([201.95.14.182] helo=localhost) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1mkXlF-0000Lh-QE; Tue, 09 Nov 2021 21:30:30 +0100 From: "Guilherme G. Piccoli" To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-doc@vger.kernel.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, akpm@linux-foundation.org, feng.tang@intel.com, siglesias@igalia.com, kernel@gpiccoli.net, gpiccoli@igalia.com Subject: [PATCH 2/3] panic: Add option to dump all CPUs backtraces in panic_print Date: Tue, 9 Nov 2021 17:28:47 -0300 Message-Id: <20211109202848.610874-3-gpiccoli@igalia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211109202848.610874-1-gpiccoli@igalia.com> References: <20211109202848.610874-1-gpiccoli@igalia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the "panic_print" parameter/sysctl allows some interesting debug information to be printed during a panic event. This is useful for example in cases the user cannot kdump due to resource limits, or if the user collects panic logs in a serial output (or pstore) and prefers a fast reboot instead of a kdump. Happens that currently there's no way to see all CPUs backtraces in a panic using "panic_print" on architectures that support that. We do have "oops_all_cpu_backtrace" sysctl, but although partially overlapping in the functionality, they are orthogonal in nature: "panic_print" is a panic tuning (and we have panics without oopses, like direct calls to panic() or maybe other paths that don't go through oops_enter() function), and the original purpose of "oops_all_cpu_backtrace" is to provide more information on oopses for cases in which the users desire to continue running the kernel even after an oops, i.e., used in non-panic scenarios. So, we hereby introduce an additional bit for "panic_print" to allow dumping the CPUs backtraces during a panic event. Signed-off-by: Guilherme G. Piccoli --- Documentation/admin-guide/kernel-parameters.txt | 1 + Documentation/admin-guide/sysctl/kernel.rst | 1 + kernel/panic.c | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0905d2cdb2d5..569d035c4332 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3690,6 +3690,7 @@ bit 3: print locks info if CONFIG_LOCKDEP is on bit 4: print ftrace buffer bit 5: print all printk messages in buffer + bit 6: print all CPUs backtrace (if available in the arch) panic_on_taint= Bitmask for conditionally calling panic() in add_taint() Format: [,nousertaint] diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index 70b7df9b081a..1666c1a9dbba 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -796,6 +796,7 @@ bit 2 print timer info bit 3 print locks info if ``CONFIG_LOCKDEP`` is on bit 4 print ftrace buffer bit 5: print all printk messages in buffer +bit 6: print all CPUs backtrace (if available in the arch) ===== ============================================ So for example to print tasks and memory info on panic, user can:: diff --git a/kernel/panic.c b/kernel/panic.c index cefd7d82366f..5da71fa4e5f1 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -65,6 +65,7 @@ EXPORT_SYMBOL_GPL(panic_timeout); #define PANIC_PRINT_LOCK_INFO 0x00000008 #define PANIC_PRINT_FTRACE_INFO 0x00000010 #define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020 +#define PANIC_PRINT_ALL_CPU_BT 0x00000040 unsigned long panic_print; ATOMIC_NOTIFIER_HEAD(panic_notifier_list); @@ -151,6 +152,9 @@ static void panic_print_sys_info(void) if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG) console_flush_on_panic(CONSOLE_REPLAY_ALL); + if (panic_print & PANIC_PRINT_ALL_CPU_BT) + trigger_all_cpu_backtrace(); + if (panic_print & PANIC_PRINT_TASK_INFO) show_state(); -- 2.33.1