Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3361250pxb; Mon, 17 Jan 2022 18:35:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyY7b5lQZJgdZF2T4jjmmrNplO9wcbto1CrXqGqtfRqAuXOhRRuREx/wPpCNRCSnGBjAIoH X-Received: by 2002:a17:902:9305:b0:14a:db23:eb5d with SMTP id bc5-20020a170902930500b0014adb23eb5dmr536625plb.73.1642473355056; Mon, 17 Jan 2022 18:35:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642473355; cv=none; d=google.com; s=arc-20160816; b=ezfzU8fV+HPfthT6ibJy6x/w1ZRaEgTJ050zjRxVxqqMCfW0oavwiZnEDOOG7mU2Xz 8fUCDhRgVvZjtpgPFGET2OVYjcBZY6VTPpnXomzLP43X0N1fZqmg39wxqUxiwDcOuhSC VMdguUK5gXj0vp1FRQv84Ht1GWUOpdgyWQIlsG+GavqMmZwWtbq2XauKEozmkDouLh9c RARwF4StKS+uOB/5+/+uvhRkYDuCxf4e9gagCFysawkacGcPYSzlI4znic6jUT2yyD4i WE5AXBVaEqWFRK0KV4Cp9FVbK4Gh2NK9kQFGT0B7qR5efehY6r9N9PG+eHegqxg+stJh bF6g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xP9+nNeU0pPJaNyxSHM1rhH01w3/wZxyHMR8TSEhtmc=; b=Xdh+aU8OnoBFGn9vLfdxlXdvhwXVZ0xKxWA6k5vMxuhUe4F6HNJH6ATibToZkqZPqu OoTc3wg28YOXxSVyY7j/xV1+YWvNZP0MxWvAfP33OXpsE2gNb0BBNkDAnamOchhfoWq2 yFR5zF1E1MlTzu+t1WkZSsnpQ3phlORQrgbqD/P1HEEsddAUeEmfU1QachX62VBYgv4H mGhwNyVRR4emuWeefTpvdxHQsxUra5+QoLaP2Jzw8cD7d5FNaQw1+77NMao1fKh1tOcb ss9deaPJUb7+FrDxIuJF74AqTzMuHEtbRoxsjSqom1q2YKG9qeVGrieYkJftkAYbJovS Qadg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HI+dCws7; 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 s139si16508823pgs.318.2022.01.17.18.35.43; Mon, 17 Jan 2022 18:35:55 -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=@gmail.com header.s=20210112 header.b=HI+dCws7; 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 S240604AbiAQPn0 (ORCPT + 99 others); Mon, 17 Jan 2022 10:43:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237299AbiAQPnZ (ORCPT ); Mon, 17 Jan 2022 10:43:25 -0500 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4FF2C061574 for ; Mon, 17 Jan 2022 07:43:25 -0800 (PST) Received: by mail-qv1-xf36.google.com with SMTP id l13so17226878qvz.10 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=nvkFN96tRHNvbWQstXFs3TgUafgsZh2bynoSlnSjVixAjNCjc9UhVKO7gX9EykxBsO YlkXdMC8ErYVA4laLJlgr1I+j1AalarIhDiIw3PifW7ls6Ap2Rxvyg8Jjz5lkfK2ECDL MecttCRFPLabqoDagscB8IesEZtNHFMKCueBN3U2oNE62EQnHf1RPLCXUlYI3hh3tKTM Z+txJ43Jd2R5kFQLB2HGIx/jRl4uzCMMct/w420UKSByfzF6zKzon8VB3crxXjWUNEZF Mve35gUTLSfWWqZv+SMP3RrK3FD7LiLfuBDQz/5uHuo3OWQ1R5SSNmRSyKafMLpfoNvY LigA== X-Gm-Message-State: AOAM533gsB6MxQkloMjT8XmQm674jYKl4c9IxbiroinbysFomHlzR4a4 svj9xC/gM2hV2hDMgW/dB7qP+9rPtT2eBMcG 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); } } -- 2.32.0