From patchwork Tue Sep 24 07:43:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 13810425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98FD3CF9C6B for ; Tue, 24 Sep 2024 07:43:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A2C56B00A0; Tue, 24 Sep 2024 03:43:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 251276B00A2; Tue, 24 Sep 2024 03:43:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F2056B00A7; Tue, 24 Sep 2024 03:43:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DA2C66B00A0 for ; Tue, 24 Sep 2024 03:43:51 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 888D11C72A4 for ; Tue, 24 Sep 2024 07:43:51 +0000 (UTC) X-FDA: 82598842662.11.FBED300 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) by imf03.hostedemail.com (Postfix) with ESMTP id A9A632001C for ; Tue, 24 Sep 2024 07:43:48 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="F+qHHCL/"; spf=pass (imf03.hostedemail.com: domain of qiwuchen55@gmail.com designates 209.85.160.51 as permitted sender) smtp.mailfrom=qiwuchen55@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727163768; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=EBOy5gHyOhd9AM3jz7ucr3vlokWJoL7EJVNAm9AjtjA=; b=5apa6RiCzr8ZatteiNwg0pWHXRYYkMqcJDoFTC7ZVFpPDx1Ui/AoGVGHL48K3pydxiP7ry Dp0GcACkSpTH6KPVMIWhtSIPd4HHwcJQ8ay4+4rn1Nhl9FmfKOC2Jb90Xfq6nnig8FAiNF JLbYcalnSUV+5zhxGMb1D4VpR2J4bmM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="F+qHHCL/"; spf=pass (imf03.hostedemail.com: domain of qiwuchen55@gmail.com designates 209.85.160.51 as permitted sender) smtp.mailfrom=qiwuchen55@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727163768; a=rsa-sha256; cv=none; b=qRZiIvV2+kc2VV1jV71o7JbOuAF9ehfNqchbkGDO3ve60R92zLTVGByNrKxNqk0xldXneT qv1uFVlPXHTxWBlzILilvpIVkzgDJLKqUFNJXXGvvKcuSdIN8ThJF8KZnazpe/ZuZvg+Hd M1OKBw1g0R80DNIEkHjtYw4YC+SNCYc= Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-2689e7a941fso2655040fac.3 for ; Tue, 24 Sep 2024 00:43:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727163827; x=1727768627; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EBOy5gHyOhd9AM3jz7ucr3vlokWJoL7EJVNAm9AjtjA=; b=F+qHHCL/fEoQQ5muWVqxIUtgz0Scy/DC7jtaX3DXoqPAtstlIJlLbsNwAy2nJXgAEx hen+4Csgw5vXHs5ZyBrb0mxctKk9kMBgkK24QmJ/uqaXzDcjTe6HivLcCCRD6WmWn4v5 GmJ9AFmVsI4SsRnk0Q4m+xIqG73kwqjEWSk8+7b5QXW3NYbutWkCczDgWrGeS9EaDHLH z0wYOqGGnOne/LQGWRDhXe48HV/++RZBf29+fADGhYgQar4BsfLkXRe76oQ06/I7NHvl 2UEZH9bOXQJd7xOjtuyg5UAddDvmbf2nFUCgDcQpwcYd7a9QrBB0YEDJxL3aoCeQVpGY tpTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727163827; x=1727768627; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EBOy5gHyOhd9AM3jz7ucr3vlokWJoL7EJVNAm9AjtjA=; b=C1dEgkjNqRF+lDsxnHQNFlUDbugQYFr4RF6MXjORpGHamhBE44DkhHmP7+dUzmbH84 WagrhHYIwRt6dnspGruQ1QWV115cO9RDNW8G4I1wSZTUbI+pm9S6LKnlzihUbd5h2PaD SX3y+YxvFxzziQ6d5II/ndC4qcLw/PJjCfRHHXugTT7vFOog+dqwUUep0FdJUAlus+qf wgzAImvb93NfuXix586kK5vEKVrgXwle2Qz1fgnpn4U/Z0oVSGd/NZ2CFIYfPSgaNTtG yJ9tXKUYWRdBt2CcI76Y51PyDLczh19U4J5DX1vkpQlyr41VD1/EssDVTwJivIcAbIdV ajsA== X-Forwarded-Encrypted: i=1; AJvYcCVeQ5gdSigbm7qbjBfwIDVOtrlMra+4meR2/vPzyowiSnIo1T664g5KQdJgXcjxQUr97IyGBlbHDg==@kvack.org X-Gm-Message-State: AOJu0Yyj1nHGk3WhpmP/p95LC0z7RjZV53o96aurb/CBQZR1RrPRTYL8 5CiAxKofxvaJnqKll4RTG8Eh/q1F0LINbFWSRHyPNoJ2eD3FlHLUImrz+A== X-Google-Smtp-Source: AGHT+IEwmYtWB4OJ9uArL7Pv98Nt18qw/HYsz/16ZW/TpgqyPm3+JqwY23fcghDaSlU60D/3uBKENw== X-Received: by 2002:a05:6870:468e:b0:277:f2d5:7834 with SMTP id 586e51a60fabf-2803a5d85a6mr9223888fac.14.1727163827396; Tue, 24 Sep 2024 00:43:47 -0700 (PDT) Received: from localhost ([183.226.245.34]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71afc97c17fsm690074b3a.152.2024.09.24.00.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 00:43:46 -0700 (PDT) From: "qiwu.chen" X-Google-Original-From: "qiwu.chen" To: corbet@lwn.net, oleg@redhat.com, catalin.marinas@arm.com, will@kernel.org, paulmck@kernel.org, akpm@linux-foundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, "qiwu.chen" Subject: [PATCH v4 1/2] panic: add option to dump task maps info in panic_print Date: Tue, 24 Sep 2024 15:43:40 +0800 Message-Id: <20240924074341.37272-1-qiwu.chen@transsion.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: A9A632001C X-Stat-Signature: bsf91hyn88rstde6re1tiw7hin5gx6kp X-HE-Tag: 1727163828-997577 X-HE-Meta: U2FsdGVkX19JNc5vzalemLlQhe5E4EmtiTOLZR/314osIchzZO+0igkz6nJiFAAX/p1Q0NNcHUGsBkNQrFm8OiqSR5UidpeKtmklx1HReGvib3T+2FFVBH8vpr/vBwXrOEknsAYxNuDk4KuU+OG3y/6Is9o7cWkpdvOINpDEn3CbkvDfALI3KTgMkjzxVW4QBDc1um+0Ph3px0wUbadleRPvJTrdLbEHB4hRcfXmH2s8/r/wg0P++RAamZgWF3TABcawfqY5RalsQ3XaRbQS5i9CS0odfmrhQpioSVngDe6iKsSgnQGVBjtB8LaqB3GrriXTYx3SnpuTJslHqQ8F4NZJmL5wXVBfrasDorqChp5gogJuS8oOQ2jSugcqA/FbnJvyxNGTfmjgH/uBKkQRhQjZGoc5j/2eiM1ZfwrHQ3oz7lZafLjI0K7s7UXpdUnFbgv8JSMV57FvnOS+QX0f2wuqwgYrHeuCSJLuMOTTFGSiMV3LEL53iUlK8H0plWTZ9I/6yPIabcc+rmvRmau6IjtZeGOEOs1duXu7O1EJVg9f41dNLQLc67jkX76YPWbmvUP3Rlo6+yWR4OPF8Y7B5xO7TTVfE+oBDCWB2ZnuHQzIlPhCJpxgodYmRD6B9QVTikG41/L5Edw67DpurDonYL6+0KSbazVCeBytJz9C+lSq+Yi4INjxiIaSN1QF0ubtCjO13J3jSnwyc+g6iLcXt1Oue3FW54LG/bW5vQlnjqyqNeVTm5mzYaZ1WfdBbSGdNoAaozE1cxGhtUXMK5JXTCEMe0wSAUJHTHPdPINuj9wkdfgPvSmYKKtQm1BAQfFVAnC7TVSGJfhrwM9+efJXJ8fz/qe63MJmPjzKkJCJ42iWlFVnHmWCkkGLBS7P80jgHkyiSO8cmZGQ6aJGEyXxPcvFb4A7BCs1QAk+h1Ok/0VmDZvkrE/ZeFI9expwHHxElvvYetsPRQgTDoMXW4/ CLg2QzDQ XMp4wnLMsXhNKXT29WHOBPsrBZ2igdipylciCUVx/kSaiersVgC0K/zMnQ2QoV5l+Ob/xFG1FHfClVojgnsNJl1YhWDSTSE1gKsbphELpGO29qCEEcxD0cyNru7s+ehzbnB7rlNkoXctaABiotIq5NckD5ApwldWTdbJRpZ/AqRXrVBUZQwF4buqtc2c+WcDyQqtQ5fVHVuCJOo1oAQf03OqfAaWM/VznYosWTw0j+xbtoQYgp/cfoP76B2nvCQhzPK4efR0whaREghPObJsvWtDxjHggUrMzWqAZa4KQVti7KrJ0D9ISYwA4HrDmHfQxdsKgKpAoUrD4sZYrylmpXpee6cdTN6i7xFQsuxR6BiRPtSHVUQN9phF9c62EHsMtNGP0Ys7YZl/08WdlWaJb/gnC8g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently, it's hard to debug panic issues caused by kill init, since there is no debug info from user mode in current panic msg such as the user_regs and maps info. This patch adds an option to dump task maps info in panic_print. - changes history: v3: https://lore.kernel.org/all/20240922095504.7182-1-qiwu.chen@transsion.com/ https://lore.kernel.org/all/20240922095504.7182-2-qiwu.chen@transsion.com/ v2: https://lore.kernel.org/all/20231110031553.33186-1-qiwu.chen@transsion.com/ v1: https://lore.kernel.org/all/20231110022720.GA3087@rlk/ Signed-off-by: qiwu.chen --- .../admin-guide/kernel-parameters.txt | 1 + Documentation/admin-guide/sysctl/kernel.rst | 1 + fs/proc/task_mmu.c | 3 +- include/linux/mm.h | 4 ++ kernel/panic.c | 52 +++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 8337d0fed311..f76709deef6c 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4253,6 +4253,7 @@ bit 5: print all printk messages in buffer bit 6: print all CPUs backtrace (if available in the arch) bit 7: print only tasks in uninterruptible (blocked) state + bit 8: print task maps info *Be aware* that this option may print a _lot_ of lines, so there are risks of losing older messages in the log. Use this option carefully, maybe worth to setup a diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index f8bc1630eba0..558e365b76a9 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -872,6 +872,7 @@ bit 4 print ftrace buffer bit 5 print all printk messages in buffer bit 6 print all CPUs backtrace (if available in the arch) bit 7 print only tasks in uninterruptible (blocked) state +bit 8 print task maps info ===== ============================================ So for example to print tasks and memory info on panic, user can:: diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index ade74a396968..37169ae36542 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -240,7 +240,7 @@ static int do_maps_open(struct inode *inode, struct file *file, sizeof(struct proc_maps_private)); } -static void get_vma_name(struct vm_area_struct *vma, +void get_vma_name(struct vm_area_struct *vma, const struct path **path, const char **name, const char **name_fmt) @@ -300,6 +300,7 @@ static void get_vma_name(struct vm_area_struct *vma, return; } } +EXPORT_SYMBOL(get_vma_name); static void show_vma_header_prefix(struct seq_file *m, unsigned long start, unsigned long end, diff --git a/include/linux/mm.h b/include/linux/mm.h index 13bff7cf03b7..2fa403aae1de 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3566,6 +3566,10 @@ static inline bool range_in_vma(struct vm_area_struct *vma, #ifdef CONFIG_MMU pgprot_t vm_get_page_prot(unsigned long vm_flags); void vma_set_page_prot(struct vm_area_struct *vma); +void get_vma_name(struct vm_area_struct *vma, + const struct path **path, + const char **name, + const char **name_fmt); #else static inline pgprot_t vm_get_page_prot(unsigned long vm_flags) { diff --git a/kernel/panic.c b/kernel/panic.c index 753d12f4dc8f..2217e1d0ad44 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -77,6 +77,8 @@ EXPORT_SYMBOL_GPL(panic_timeout); #define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020 #define PANIC_PRINT_ALL_CPU_BT 0x00000040 #define PANIC_PRINT_BLOCKED_TASKS 0x00000080 +#define PANIC_PRINT_TASK_MAPS_INFO 0x00000100 + unsigned long panic_print; ATOMIC_NOTIFIER_HEAD(panic_notifier_list); @@ -208,6 +210,53 @@ void nmi_panic(struct pt_regs *regs, const char *msg) } EXPORT_SYMBOL(nmi_panic); +/* + * This function is called in panic proccess if the PANIC_PRINT_TASK_MAPS_INFO + * flag is specified in panic_print, which is helpful to debug panic issues due + * to an unhandled falut in user mode such as kill init. + */ +static void dump_task_maps_info(struct task_struct *tsk) +{ + struct pt_regs *user_ret = task_pt_regs(tsk); + struct mm_struct *mm = tsk->mm; + struct vm_area_struct *vma; + + if (!mm || !user_mode(user_ret)) + return; + + pr_info("Dump task %s:%d maps start\n", tsk->comm, task_pid_nr(tsk)); + mmap_read_lock(mm); + VMA_ITERATOR(vmi, mm, 0); + for_each_vma(vmi, vma) { + int flags = vma->vm_flags; + unsigned long long pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT; + const struct path *path; + const char *name_fmt, *name; + char name_buf[SZ_256]; + + get_vma_name(vma, &path, &name, &name_fmt); + if (path) { + name = d_path(path, name_buf, sizeof(name_buf)); + name = IS_ERR(name) ? "?" : name; + } else if (name || name_fmt) { + snprintf(name_buf, sizeof(name_buf), name_fmt ?: "%s", name); + name = name_buf; + } + + if (name) + pr_info("%08lx-%08lx %c%c%c%c %08llx %s\n", + vma->vm_start, vma->vm_end, + flags & VM_READ ? 'r' : '-', + flags & VM_WRITE ? 'w' : '-', + flags & VM_EXEC ? 'x' : '-', + flags & VM_MAYSHARE ? 's' : 'p', + pgoff, name); + + } + mmap_read_unlock(mm); + pr_info("Dump task %s:%d maps end\n", tsk->comm, task_pid_nr(tsk)); +} + static void panic_print_sys_info(bool console_flush) { if (console_flush) { @@ -233,6 +282,9 @@ static void panic_print_sys_info(bool console_flush) if (panic_print & PANIC_PRINT_BLOCKED_TASKS) show_state_filter(TASK_UNINTERRUPTIBLE); + + if (panic_print & PANIC_PRINT_TASK_MAPS_INFO) + dump_task_maps_info(current); } void check_panic_on_warn(const char *origin) From patchwork Tue Sep 24 07:43:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 13810426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5241CF9C71 for ; Tue, 24 Sep 2024 07:43:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EC8A6B0088; Tue, 24 Sep 2024 03:43:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66FCF6B00A7; Tue, 24 Sep 2024 03:43:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EA5D6B00AB; Tue, 24 Sep 2024 03:43:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2C8BB6B00A7 for ; Tue, 24 Sep 2024 03:43:58 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E92831A1841 for ; Tue, 24 Sep 2024 07:43:57 +0000 (UTC) X-FDA: 82598842914.06.A0FA4D1 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf14.hostedemail.com (Postfix) with ESMTP id 0FF5E10000F for ; Tue, 24 Sep 2024 07:43:55 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=gbCWDKmJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of qiwuchen55@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=qiwuchen55@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727163801; a=rsa-sha256; cv=none; b=3nY7LhlkaUOzF3Qe12szvjUKFDVecdWBI0jkaXL0eb/5H4IW8HU9Yzhvr9Lti38jt6eCW0 EZ1MmfLAtuObfiTBz2SwYMWjPnZmzyMJiIdKeOOd1URlqHjKn7e619SwDjVEpgLpW0kxTN OIH32Xj1o65RLyoatAoLvYWgA22cQsA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=gbCWDKmJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of qiwuchen55@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=qiwuchen55@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727163801; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sveNCmO55zA73Cq65R0Q3qE+br1KOMYEKyeAeW0hpMA=; b=DndwDKyf+INFsRZ9JOgejsoUEZkTGAe0WxmiB7hAZ3k+oC26z2+DgFLRyWvybyEAwebdo9 x2IBSJb66sp/Tr8F0moBm1g97xYwxZSMMEQSzK4SwPdaoUSIPY/0d1KdlTwNpgm1XEGbxM NKOiCQQV68AaEqCxoXH4mTIcybuMUvI= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-20551e2f1f8so60029635ad.2 for ; Tue, 24 Sep 2024 00:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727163835; x=1727768635; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sveNCmO55zA73Cq65R0Q3qE+br1KOMYEKyeAeW0hpMA=; b=gbCWDKmJt6S/C45FCX9zJXwsVVT0bh4lCOpPLQeNr6xBIVYJyKj8JJq/UwUqfyrTpO PKjvEgG8QzphkHDyCGC/3372smG6yKoGTFDz/IHMdxhkB6wLxoVhEAv2Nq38wRfYaTij zQpIlmezq64hYrPMvBEZjZ36wJWIVdM8g7CSoVd1gXwm02vG7Vft25vNQ/hsfINZr5En Ztvz2VtyJRlmFAOX0Yzo/9BprTkDNsYAvHApXhwq6d591uHlODG8lyUZI11bFHrVL2UV cqKKZ63tNsmN8B/TLk2oL75IvLuzOcP+nOAyhuwBGfxcPLx2WlPrFHwP105qz8J7gk0v meug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727163835; x=1727768635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sveNCmO55zA73Cq65R0Q3qE+br1KOMYEKyeAeW0hpMA=; b=ct+YIaJFfJPZS7rIdr8H0mF9oLTvFOynSYpRMObT3Ic9hilSloJ7ZiL9E8DWLvWQP9 kuyQXoyAaWQxj2+PF+N2Q6a0FDWTKtfj7HdbE6lDTPylML5nEIjaahDghPQljmxRobtx ZVk5OJ3AvCUGaTavHVP+TCD/1pDbVmmHQOitM0U+CpjPFX7W86/ogqZWtopskE1tGsBq e58GS4Ssi5eim7mrQOLa2KSdszRwKzBbG3IiM7VoUrJsd4Kif42YawAhaBf2p1USi17o R6VLrvYbEJ9uC3KmRrEVA6YrDPlK81o0hmnGWPdEZfID0yQXjshgpPV+Gf6PYMuhCkBY yJQg== X-Forwarded-Encrypted: i=1; AJvYcCWXfon8Ec6Skp1x/BQXC+T1a3FqbBM4iL/EgHs3/QhVAzAv1KBq4MtfXkgWAiu+fbYkYFvBFScThg==@kvack.org X-Gm-Message-State: AOJu0YxSWUqr2L19NH7Yg5NllRoGD6tR0nr1PTwAAn8wfGDgwTpj5cvI mAk5GktF5c/7ngHU5fgmQI9k9rNTxsiXile04X8M5polCwU8r1T/ X-Google-Smtp-Source: AGHT+IGkboJEphLTV+FMa306u2HDfgQ+BFBgzuEmyLxUgIiH1SucNTTRvao0wYxNex2p4+02OD3TWg== X-Received: by 2002:a17:903:1c9:b0:206:99a8:525f with SMTP id d9443c01a7336-208d8338b2dmr265597905ad.4.1727163834623; Tue, 24 Sep 2024 00:43:54 -0700 (PDT) Received: from localhost ([183.226.245.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20af1819289sm5672595ad.214.2024.09.24.00.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 00:43:54 -0700 (PDT) From: "qiwu.chen" X-Google-Original-From: "qiwu.chen" To: corbet@lwn.net, oleg@redhat.com, catalin.marinas@arm.com, will@kernel.org, paulmck@kernel.org, akpm@linux-foundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, "qiwu.chen" Subject: [PATCH v4 2/2] arm64: show signal info for global init Date: Tue, 24 Sep 2024 15:43:41 +0800 Message-Id: <20240924074341.37272-2-qiwu.chen@transsion.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240924074341.37272-1-qiwu.chen@transsion.com> References: <20240924074341.37272-1-qiwu.chen@transsion.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 0FF5E10000F X-Rspamd-Server: rspam01 X-Stat-Signature: 3zyc4ry7a75gbjjj1o41ybhr8emubtj9 X-HE-Tag: 1727163835-84300 X-HE-Meta: U2FsdGVkX1/rZej/uV/x/ssVU+rLakyXSlUBqK/AQN6+4bDDKuKaMHFRoiIDcUXQvEpth3UWs9oEDCTRpTW6D9lV0cyJQosnCmcGaTwWQIS5eDosa7rizSuNEhrPIFyRCE7O8e/AZ1MqOd6O0MSgpC5HHlQOfVoc/0/WF4YYdGBAUC39Ps8lmm2nHCQ8pc9ENZth+arINXNUrsv7kE158i3jodGSGWODjjrkp7oEh9NZpRRMfGlP8j0vucU4nMwch9uxDlYikn3n4EKY+YPVlMDhJFEEA4FBu2KkSb2FXeCqrMrg+ljfnPvDCFR1ewAjbvCJrmLDXJdD0KxzA6P2s3RXVVEl8FMpOC5SRd/5YllUQWw68MPauznC0TsOKnqlMBsJdj54Aw8dKASgxYEcX6I3oMYH8VOJuFG55WEfQe5/MRIVIBuxRtMLdcnJFYTcoKyCvkjViGHA1BtGPbkTGIyMUh5829peW06g2mZTW4apxBn+gG70vKGSGxwW0D7BjL5sdlciYBXg5ROmNF5C8XX1YauwkH8V4xdPwqvpRs+EkbK22gCKePmyU0DacUMICIfjG8waWWjUektC4GSAnAAKVQ7t1pVD3LdUplUNkUZPXhGW7XIjz0NxqLrw1i5ScIheNC8B9VFticqgDWvgyu81mUGByKY+hDAqACW3lwut9QVIn1lcDGc4rCJQc+PKyPsntcmWtQjlXez1a7EkVm+fHhWJvTfnD+K/hKDBBFteqXOwFrxwKUxQXPAXceXz8zbxHra/lQ7jQRxx4NMmHCznxqQFxUOBQSEyefg79DYJTJfnsSJjc6VA/zX78etFxuSytysZzNFflbUXHUEZYx2G1rlBeq1l8hX/chTGMqsKaiq/EfnxiPw+pC3P7ySEv1w5n+grskSODd0ZGCI4HBYYbBnENbR2lCWP+7JexbrU5QmzZeCru9MVwKjkqnJKMhdmX0ijGu2HhNYoqYN oo7SREwh kgGkmG/2D7gF4wh7/s5dK797ywPIccSmsWKySTdI35EDbOQPsaxB2ahO9sVoVAPuWtwMzLoBdy0Azdgfv50QlYjfMTDxIM2X+cMTbhGpw0WbTJTWswp5/zzGYs6ns8zv47TfeKGulqOp7jxCvTu3OPe91aDJjT2Ku5EszDSyK6CytwFSHkrPJ89LxAGIv5tDjjT5zwfFu0r+hTfMWO5XGBsUOwMOvQfLmNH9CLTdEDcdV2aAsEdnqX5425DpfHfFWZLJSSlG+ZmKSZ/OgflPSvuWryVjpPmLlh19dxARBUKZwzV+CwUGu+Iaip9BgPxR/QoatqNotb8IBQQ7jC/EJw9MpMz4Q5+HYsGRgzZr2/h95PWY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently, it's hard to debug panic issues caused by kill init on arm64, since there is no debug info from user mode in current panic msg such as the user_regs and maps info. This patch shows signal info sent to the global init, which will be helpful for debugging kill init issue caused by unhandled exception from user mode. - changes history: v3: https://lore.kernel.org/all/20240922095504.7182-1-qiwu.chen@transsion.com/ https://lore.kernel.org/all/20240922095504.7182-2-qiwu.chen@transsion.com/ v2: https://lore.kernel.org/all/20231110031553.33186-1-qiwu.chen@transsion.com/ v1: https://lore.kernel.org/all/20231110022720.GA3087@rlk/ Signed-off-by: qiwu.chen --- arch/arm64/kernel/traps.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 563cbce11126..3150fb84195f 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -247,12 +247,20 @@ static void arm64_show_signal(int signo, const char *str) unsigned long esr = tsk->thread.fault_code; struct pt_regs *regs = task_pt_regs(tsk); + /* + * The signal sent to the global init needs to be shown, + * which is useful for debugging kill init issue. + */ + if (unlikely(is_global_init(tsk))) + goto dump; + /* Leave if the signal won't be shown */ if (!show_unhandled_signals || !unhandled_signal(tsk, signo) || !__ratelimit(&rs)) return; +dump: pr_info("%s[%d]: unhandled exception: ", tsk->comm, task_pid_nr(tsk)); if (esr) pr_cont("%s, ESR 0x%016lx, ", esr_get_class_string(esr), esr);