From patchwork Mon Jan 17 15:43:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changbin Du X-Patchwork-Id: 12715544 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E00CAC433EF for ; Mon, 17 Jan 2022 15:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=nCNQqZRBmKm3sbIJ0sOsTNAXQZICszrpxzm1NoybyDY=; b=vQWAEyQ/isTO3u CMGx70tLVbmn4KsULW7/6QID8NafKpToC/+afX6CpQ4SDbqVjeoSXAq5EkvoH8Yj9aYUH/RPzB60n R1pxMRbwDY5Ez7mleF5gGZim7A7KwL4wRg/z0Zi3+xz1/JwmIQireP7eRap6Lyal1b6l4vCYe6GhA fTbyyee9Zg+Hq1F0MJWTfh4glI5T8hY8ROz0610dzT7iO/tGetcohXMDp1DYoqd9C50xkAqv1cdmG Yrz6ipywrCQhkj45AxymKDnwJCcViGdC23ci7+scsGw0nvKFtNL0HMwV9ecAkonR2bWspf9yp6b5e mm8j86KUptCFJ/q8sqyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9UAK-00FRoB-GE; Mon, 17 Jan 2022 15:43:28 +0000 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9UAI-00FRmk-Ct for linux-riscv@lists.infradead.org; Mon, 17 Jan 2022 15:43:27 +0000 Received: by mail-qv1-xf34.google.com with SMTP id 15so18693940qvp.12 for ; Mon, 17 Jan 2022 07:43:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xP9+nNeU0pPJaNyxSHM1rhH01w3/wZxyHMR8TSEhtmc=; b=HI+dCws7RQMLYP9FBlt/2mFcL0vyCtoCwfD9I0VStsOrIN6g8+Fo9xE/YelF6Pbxu3 XiFr/vbnUpBGg7toREDqQ8zDaFgRoAOqG5NzYjJDCX2HnP6Fq1POJ1aa7hBDy6HLVbqM MIWNj3C6u1IiBvd+9vOsrxLcTiJyYHZjrZEPPhIJAcX1+pyyOKg8WTdoRzGKyPQcZMLy gtn/B++uXwvZzVzljfwRvGRn3Uw3l/zbG641yc+3FPnNx8v6tuJ8mbiU9+FD0JW2fC6H BjSries8Zi7VLqiWZ6yWEChcWLiahxcOMv0MKIXzDQl9x0iGC+oey6o28L26CQchYmud 1y3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xP9+nNeU0pPJaNyxSHM1rhH01w3/wZxyHMR8TSEhtmc=; b=rdC1LQ8N05ooPFPBr1jOD/305XCAEro3AacNgyNGOfTGgSeQadNjB4bFz/BPQxoOE1 tZWatkQEr1K7ZIUporBNpy3M2uT+Bt5oSxgSeM3cfbb4hKt1tdfJj6Rv0mEha/vhOOfH A2EMeQjsmEJTX/KOsk3KlOPL6EHPC0sD5oyjruq3VcVujlCzMJwN5Lt7DOXO258Fp3R6 m3VQniWp7wOZRwAZILHeQK9e+j+cmXI8SwDoSBm9WHv3L8RxoCCPl4HUjGQD79YwBIvt reeyjQ6Ii+FIjEHqwxEQL6H+U/R0/1cMdMYITz5r2xC8ulsDL66ap7y447fXklrtMgYu DTJw== X-Gm-Message-State: AOAM530hZ2AeXkPLeskYumiGou4uQLVVmWaZEXe0io9CeWj1dkpDyBNN bARscbx9tOBuOA55/23OP6k= X-Google-Smtp-Source: ABdhPJyuIYYJkAmO78IaACd35H7++l0ftE0t2n1dbEcW++BwwQmlTQhzXYiFoGGUv/HzUQyK31Z0aQ== X-Received: by 2002:a05:6214:4001:: with SMTP id kd1mr18390236qvb.13.1642434204942; Mon, 17 Jan 2022 07:43:24 -0800 (PST) Received: from WRT-WX9.. ([207.246.89.135]) by smtp.gmail.com with ESMTPSA id i11sm3978507qti.55.2022.01.17.07.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 07:43:24 -0800 (PST) From: Changbin Du To: Greg Kroah-Hartman , Jiri Slaby Cc: Palmer Dabbelt , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Changbin Du Subject: [PATCH] sysrq: do not omit current cpu when showing backtrace of all active CPUs Date: Mon, 17 Jan 2022 23:43:00 +0800 Message-Id: <20220117154300.2808-1-changbin.du@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220117_074326_480023_B2453D13 X-CRM114-Status: GOOD ( 11.47 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The backtrace of current CPU also should be printed as it is active. This change add stack trace for current CPU and print a hint for idle CPU for the generic workqueue based printing. (x86 already does this) Now it looks like below: [ 279.401567] sysrq: Show backtrace of all active CPUs [ 279.407234] sysrq: CPU5: [ 279.407505] Call Trace: [ 279.408789] [] dump_backtrace+0x2c/0x3a [ 279.411698] [] show_stack+0x32/0x3e [ 279.411809] [] sysrq_handle_showallcpus+0x4c/0xc6 [ 279.411929] [] __handle_sysrq+0x106/0x26c [ 279.412034] [] write_sysrq_trigger+0x64/0x74 [ 279.412139] [] proc_reg_write+0x8e/0xe2 [ 279.412252] [] vfs_write+0x90/0x2be [ 279.412362] [] ksys_write+0xa6/0xce [ 279.412467] [] sys_write+0x2a/0x38 [ 279.412689] [] ret_from_syscall+0x0/0x2 [ 279.417173] sysrq: CPU6: backtrace skipped as idling [ 279.417185] sysrq: CPU4: backtrace skipped as idling [ 279.417187] sysrq: CPU0: backtrace skipped as idling [ 279.417181] sysrq: CPU7: backtrace skipped as idling [ 279.417190] sysrq: CPU1: backtrace skipped as idling [ 279.417193] sysrq: CPU3: backtrace skipped as idling [ 279.417219] sysrq: CPU2: [ 279.419179] Call Trace: [ 279.419440] [] dump_backtrace+0x2c/0x3a [ 279.419782] [] show_stack+0x32/0x3e [ 279.420015] [] showacpu+0x5c/0x96 [ 279.420317] [] flush_smp_call_function_queue+0xd6/0x218 [ 279.420569] [] generic_smp_call_function_single_interrupt+0x14/0x1c [ 279.420798] [] handle_IPI+0xaa/0x13a [ 279.421024] [] riscv_intc_irq+0x56/0x70 [ 279.421274] [] generic_handle_arch_irq+0x6a/0xfa [ 279.421518] [] ret_from_exception+0x0/0x10 [ 279.421750] [] rcu_idle_enter+0x16/0x1e Signed-off-by: Changbin Du --- drivers/tty/sysrq.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index bbfd004449b5..34cfdda4aff5 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -232,8 +232,10 @@ static void showacpu(void *dummy) unsigned long flags; /* Idle CPUs have no interesting backtrace. */ - if (idle_cpu(smp_processor_id())) + if (idle_cpu(smp_processor_id())) { + pr_info("CPU%d: backtrace skipped as idling\n", smp_processor_id()); return; + } raw_spin_lock_irqsave(&show_lock, flags); pr_info("CPU%d:\n", smp_processor_id()); @@ -260,10 +262,13 @@ static void sysrq_handle_showallcpus(int key) if (in_hardirq()) regs = get_irq_regs(); - if (regs) { - pr_info("CPU%d:\n", smp_processor_id()); + + pr_info("CPU%d:\n", smp_processor_id()); + if (regs) show_regs(regs); - } + else + show_stack(NULL, NULL, KERN_INFO); + schedule_work(&sysrq_showallcpus); } }