From patchwork Wed Nov 6 03:04:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11229145 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7582D1864 for ; Wed, 6 Nov 2019 03:06:13 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 42119222C5 for ; Wed, 6 Nov 2019 03:06:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WGYB9+F2"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="jzPQRDte" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42119222C5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=OW3IewmgUXhKRZakS5eUrxYav2QCCddfHJfgxzYxKbw=; b=WGYB9+F2gzddiZ 7T7QIUXyF3IZRI4MrELPSEZz6W3MqoRiVxi+mehPLzbhfGlpJagdennGzprpsCKZQOyfTR+mdnWD5 8QtqBZogtx0G46B0k0EkOmwhnoP4Kwws653iNqAS+VpPZ7wMgQhuJQLQQoXypgAl/vXeV+tmk8k4r MukuU6oTuKxWeuM619oalziHiWPryttWqMPNbeqSK3ZtAgAU5OEGrGpQamii8yaWv3uIz0bIBGnAg cGbzr9X8A0ht/LTA8DJ4o6sX0toFnvNrsJ8BHqlsuIauO8DH2lID4cRb0ckthYTp1xUnOcz3UahiS O4ZBIpVa8+JK+xGJWJpg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSBe8-0001Y9-RZ; Wed, 06 Nov 2019 03:06:12 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSBe2-0001W9-EI for linux-riscv@lists.infradead.org; Wed, 06 Nov 2019 03:06:11 +0000 Received: by mail-pf1-x443.google.com with SMTP id v19so17725066pfm.3 for ; Tue, 05 Nov 2019 19:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3HFF42qAlT7r/F7ag4hs7rtX/wyMvbKmMS4A+1JVsNY=; b=jzPQRDteEKLSK+teW/BPCLuUNhzX+YedPCS0VMKC5t4V2QYvlXkd1vPenipmQTZyTw 3Yekw/TiAg2bTGkes+EeYjWfJTtTdO4lNmADuMWQkIfwlPGSD8GbzD1jIeGCEOZ/wtIK 9BG0YtSeheW28n/lckqNpHRSoqie2dxnkWfwzYe4N6rtCNCjhPrcZNGQWCljuyxNSSKW ajag+TfWgkzWjN52U/kITaNzjyIv76ALkLycWweJsTJsycW4TEktNyqW0d9+4zQ50nvY sCJHjuHmCGDlR7HGbex6H6CBAFAQZeiGnLamEhJ+m/4nJStHQQLUsDkg8IAtf7J71rpV z1+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3HFF42qAlT7r/F7ag4hs7rtX/wyMvbKmMS4A+1JVsNY=; b=XR9Apjxw95JkDi1lAXyKM3lPQ6hPKmj3SeI9PniaDAxpLBvQDysMZd1dI5hL0swEF2 3jbBddMHUihHbUixOltAdzgJzKs1Y2TMubB9W6XfbnPSZ7ZCyhccym00sm0EcO9MaPu/ s48fiUyb/42iW81dR28EWX6ieH5tpifQJOAcpefQ+JxQAi7IDZI8Cp/RocCFOwv59R2S 1uAeRLea8avcZBWWChdaNa+nTU6jqnIzbQ0i5CZYOUzPVB6oRkt2A8frEmNDtdRSHsUN 4W2lwDPkPGuk+KmlUacObEOgS7ctgQ10S1/EdzDx0JNXV/5s7KW0H6ccbb4gW/WfuJD0 dziw== X-Gm-Message-State: APjAAAXEOhCMw2JQCKgDus4sO4nu6UqcMNWh/bdDFjDDcwe07dNN5sl9 1uhiU5rpEFA+0uMuBf5nLiUJiQ== X-Google-Smtp-Source: APXvYqxrU/o2u+W+LjbyrqgvqKLS4IcNyOfN+iGwfuy9ybggQe5do2mvirQJdBY9Nvj+dqVorGUqMQ== X-Received: by 2002:a17:90a:ff04:: with SMTP id ce4mr558301pjb.133.1573009564730; Tue, 05 Nov 2019 19:06:04 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id k24sm19570487pgl.6.2019.11.05.19.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 19:06:03 -0800 (PST) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCH 00/50] Add log level to show_stack() Date: Wed, 6 Nov 2019 03:04:51 +0000 Message-Id: <20191106030542.868541-1-dima@arista.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191105_190607_364679_BC2299F6 X-CRM114-Status: GOOD ( 16.09 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juri Lelli , linux-sh@vger.kernel.org, Catalin Marinas , Ben Segall , Guo Ren , Pavel Machek , Vincent Guittot , Paul Burton , Dmitry Safonov , Michael Ellerman , Geert Uytterhoeven , Mel Gorman , Jiri Slaby , Matt Turner , uclinux-h8-devel@lists.sourceforge.jp, Len Brown , linux-pm@vger.kernel.org, Heiko Carstens , linux-um@lists.infradead.org, Thomas Gleixner , Dietmar Eggemann , Richard Henderson , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ralf Baechle , Paul Mackerras , Andrew Morton , linux-ia64@vger.kernel.org, Tetsuo Handa , James Hogan , "James E.J. Bottomley" , Max Filippov , Vincent Chen , Ingo Molnar , linux-s390@vger.kernel.org, linux-c6x-dev@linux-c6x.org, Yoshinori Sato , linux-hexagon@vger.kernel.org, Helge Deller , linux-xtensa@linux-xtensa.org, Vasily Gorbik , Aurelien Jacquiot , linux-m68k@lists.linux-m68k.org, Stafford Horne , linux-arm-kernel@lists.infradead.org, Chris Zankel , Tony Luck , Douglas Anderson , Benjamin Herrenschmidt , Dmitry Safonov <0x7f454c46@gmail.com>, Will Deacon , Daniel Thompson , Brian Cain , Christian Borntraeger , kgdb-bugreport@lists.sourceforge.net, linux-snps-arc@lists.infradead.org, Fenghua Yu , Borislav Petkov , Jeff Dike , Steven Rostedt , Ivan Kokshaysky , Greentime Hu , Guan Xuetao , linux-parisc@vger.kernel.org, linux-alpha@vger.kernel.org, Ley Foon Tan , "David S. Miller" , Rich Felker , Petr Mladek , Peter Zijlstra , "H. Peter Anvin" , sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, Anton Ivanov , Jonas Bonn , Richard Weinberger , x86@kernel.org, Russell King , clang-built-linux@googlegroups.com, Ingo Molnar , Mark Salter , Albert Ou , Stefan Kristiansson , openrisc@lists.librecores.org, Paul Walmsley , Michal Simek , Vineet Gupta , linux-mips@vger.kernel.org, Sergey Senozhatsky , Palmer Dabbelt , Jason Wessel , nios2-dev@lists.rocketboards.org, linuxppc-dev@lists.ozlabs.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org Add log level argument to show_stack(). Done in three stages: 1. Introducing show_stack_loglvl() for every architecture 2. Migrating old users with an explicit log level 3. Renaming show_stack_loglvl() into show_stack() Justification: o It's a design mistake to move a business-logic decision into platform realization detail. o I have currently two patches sets that would benefit from this work: Removing console_loglevel jumps in sysrq driver [1] Hung task warning before panic [2] - suggested by Tetsuo (but he probably didn't realise what it would involve). o While doing (1), (2) the backtraces were adjusted to headers and other messages for each situation - so there won't be a situation when the backtrace is printed, but the headers are missing because they have lesser log level (or the reverse). o As the result in (2) plays with console_loglevel for kdb are removed. The least important for upstream, but maybe still worth to note that every company I've worked in so far had an off-list patch to print backtrace with the needed log level (but only for the architecture they cared about). If you have other ideas how you will benefit from show_stack() with a log level - please, reply to this cover letter. Ok, to the scary part: I've tested it on x86_64 and build tested on a couple of architectures. Though, I can't cover all platforms so I hope I'll have a couple of reports and than it'll soak in linux-next for some time. In my opinion the variety of architectures shouldn't stop general improvements. Cc: Andrew Morton Cc: Greg Kroah-Hartman Cc: Ingo Molnar Cc: Jiri Slaby Cc: Petr Mladek Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: Tetsuo Handa Thanks, Dmitry [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u [2]: https://lkml.kernel.org/r/41fd7652-df1f-26f6-aba0-b87ebae07db6@i-love.sakura.ne.jp Dmitry Safonov (50): kallsyms/printk: Add loglvl to print_ip_sym() alpha: Add show_stack_loglvl() arc: Add show_stack_loglvl() arm/asm: Add loglvl to c_backtrace() arm: Add loglvl to unwind_backtrace() arm: Add loglvl to dump_backtrace() arm: Wire up dump_backtrace_{entry,stm} arm: Add show_stack_loglvl() arm64: Add loglvl to dump_backtrace() arm64: Add show_stack_loglvl() c6x: Add show_stack_loglvl() csky: Add show_stack_loglvl() h8300: Add show_stack_loglvl() hexagon: Add show_stack_loglvl() ia64: Pass log level as arg into ia64_do_show_stack() ia64: Add show_stack_loglvl() m68k: Add show_stack_loglvl() microblaze: Add loglvl to microblaze_unwind_inner() microblaze: Add loglvl to microblaze_unwind() microblaze: Add show_stack_loglvl() mips: Add show_stack_loglvl() nds32: Add show_stack_loglvl() nios2: Add show_stack_loglvl() openrisc: Add show_stack_loglvl() parisc: Add show_stack_loglvl() powerpc: Add show_stack_loglvl() riscv: Add show_stack_loglvl() s390: Add show_stack_loglvl() sh: Add loglvl to dump_mem() sh: Remove needless printk() sh: Add loglvl to printk_address() sh: Add loglvl to show_trace() sh: Add show_stack_loglvl() sparc: Add show_stack_loglvl() um/sysrq: Remove needless variable sp um: Add show_stack_loglvl() unicore32: Remove unused pmode argument in c_backtrace() unicore32: Add loglvl to c_backtrace() unicore32: Add show_stack_loglvl() x86: Add missing const qualifiers for log_lvl x86: Add show_stack_loglvl() xtensa: Add loglvl to show_trace() xtensa: Add show_stack_loglvl() sysrq: Use show_stack_loglvl() x86/amd_gart: Print stacktrace for a leak with KERN_ERR power: Use show_stack_loglvl() kdb: Don't play with console_loglevel sched: Print stack trace with KERN_INFO kernel: Use show_stack_loglvl() kernel: Rename show_stack_loglvl() => show_stack() arch/alpha/kernel/traps.c | 22 +++++++-------- arch/arc/include/asm/bug.h | 3 ++- arch/arc/kernel/stacktrace.c | 17 +++++++----- arch/arc/kernel/troubleshoot.c | 2 +- arch/arm/include/asm/bug.h | 3 ++- arch/arm/include/asm/traps.h | 3 ++- arch/arm/include/asm/unwind.h | 3 ++- arch/arm/kernel/traps.c | 40 ++++++++++++++++------------ arch/arm/kernel/unwind.c | 7 ++--- arch/arm/lib/backtrace-clang.S | 9 +++++-- arch/arm/lib/backtrace.S | 14 +++++++--- arch/arm64/include/asm/stacktrace.h | 3 ++- arch/arm64/kernel/process.c | 2 +- arch/arm64/kernel/traps.c | 19 ++++++------- arch/c6x/kernel/traps.c | 18 +++++++------ arch/csky/kernel/dumpstack.c | 9 ++++--- arch/csky/kernel/ptrace.c | 4 +-- arch/h8300/kernel/traps.c | 12 ++++----- arch/hexagon/kernel/traps.c | 25 ++++++++--------- arch/ia64/include/asm/ptrace.h | 1 - arch/ia64/kernel/mca.c | 2 +- arch/ia64/kernel/process.c | 17 ++++++------ arch/m68k/kernel/traps.c | 13 ++++----- arch/microblaze/include/asm/unwind.h | 3 ++- arch/microblaze/kernel/stacktrace.c | 4 +-- arch/microblaze/kernel/traps.c | 12 ++++----- arch/microblaze/kernel/unwind.c | 37 ++++++++++++++----------- arch/mips/kernel/traps.c | 35 ++++++++++++------------ arch/nds32/kernel/traps.c | 15 ++++++----- arch/nios2/kernel/traps.c | 17 ++++++------ arch/openrisc/kernel/traps.c | 12 +++++---- arch/parisc/kernel/traps.c | 24 ++++++++--------- arch/powerpc/kernel/process.c | 15 ++++++----- arch/powerpc/kernel/stacktrace.c | 2 +- arch/riscv/kernel/stacktrace.c | 9 ++++--- arch/s390/kernel/dumpstack.c | 11 ++++---- arch/sh/include/asm/kdebug.h | 6 +++-- arch/sh/include/asm/processor_32.h | 2 +- arch/sh/kernel/dumpstack.c | 36 ++++++++++++------------- arch/sh/kernel/process_32.c | 2 +- arch/sh/kernel/process_64.c | 3 +-- arch/sh/kernel/traps.c | 4 +-- arch/sh/mm/fault.c | 2 +- arch/sparc/kernel/process_32.c | 10 +++---- arch/sparc/kernel/process_64.c | 2 +- arch/um/drivers/mconsole_kern.c | 2 +- arch/um/kernel/sysrq.c | 23 ++++++++-------- arch/unicore32/kernel/setup.h | 2 +- arch/unicore32/kernel/traps.c | 34 +++++++++++------------ arch/unicore32/lib/backtrace.S | 24 +++++++++++------ arch/x86/include/asm/stacktrace.h | 2 +- arch/x86/kernel/amd_gart_64.c | 2 +- arch/x86/kernel/dumpstack.c | 9 ++++--- arch/xtensa/kernel/traps.c | 26 ++++++++++-------- drivers/base/power/main.c | 2 +- drivers/tty/sysrq.c | 2 +- include/linux/kallsyms.h | 4 +-- include/linux/sched/debug.h | 3 ++- kernel/debug/kdb/kdb_bt.c | 11 +++----- kernel/locking/lockdep.c | 4 +-- kernel/locking/rtmutex-debug.c | 2 +- kernel/sched/core.c | 6 ++--- kernel/trace/ftrace.c | 8 +++--- lib/dump_stack.c | 2 +- 64 files changed, 368 insertions(+), 311 deletions(-)