From patchwork Sat Apr 18 20:19:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11496971 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 F28AF14DD for ; Sat, 18 Apr 2020 20:21:04 +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 D00B621D93 for ; Sat, 18 Apr 2020 20:21:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LZGbCNUl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="UmUB6tg2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D00B621D93 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-arm-kernel-bounces+patchwork-linux-arm=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:References:In-Reply-To: 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: List-Owner; bh=UT65DJOiLKKNM56I9fMtKQ9xAknFyMsUv6Nkb2g1VuE=; b=LZGbCNUlz4J3aD B+0c3sqY2nHNcoIZLdfRJjhIiLgJvwP0FghDq0IfACs7jCQCFuz5AJow8McBoZTZbSzTR4tsE62Y5 avcf5unPJTirv72OqUkpMRjwSpBwwUlwgTAzm2WXq7pBbfwMWE60WFyGd0mCdvLRnld3ZASJ04XWv 8gV5ntKGcqiVJbOCo+qBwoAPgj5xPVXNAcb6IcRQPfAhDaH09MAQfap/8ncKn5GhaRr0AwQQ62IHj 4c1uzYe8sqMwpLXzcTJgaBXI+UADGDlxmbgPwvt+m5ornIulGcmHxfcMIUtFkfKB7K1mRPJj6PrcE 9pTmpvts08v0pP4iXvxg==; 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 1jPtxQ-0004aY-QF; Sat, 18 Apr 2020 20:20:56 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPtwW-0001Vc-H7 for linux-arm-kernel@lists.infradead.org; Sat, 18 Apr 2020 20:20:02 +0000 Received: by mail-wr1-x441.google.com with SMTP id k11so7172233wrp.5 for ; Sat, 18 Apr 2020 13:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zimCygk/GteosIyZqYA22VX02uWVm0axmp2+cSyxEk0=; b=UmUB6tg2COFkhKDuApMoEkNTExQQ8zWlCYHCTwLkIEdbL36WyQ3PYYgOKLegDh6d13 DzYw8GkhIIH0MJVWi/dBd6XYZDvflywyb0bhoIeZla+jfYR8B2tdrAMdeVXfnuujTkQN QhZADBr0lPCqEOTst6yj5MWFK/Pi6kqOKUakB7xWdpHdcXwF/eL9RIFDgnAOwuMTYziS uBj1R6ECLpqqE3PysHGFOz5Q/ZjNLmvglWySYgJUjoAEO3vO4h6QkExwulCBUDSXri1A 5+4uxdC+Bsu5JoQi5294pfVzGeRFeSpgGOYEWLGkziQnZdoymCZTDTsvOia8zJCo5dQG qt/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:in-reply-to :references:mime-version:content-transfer-encoding; bh=zimCygk/GteosIyZqYA22VX02uWVm0axmp2+cSyxEk0=; b=Ll1BIlvsCoXd3CWNeXqiXkzPGN2zfcYliNxyUD7WN9d/VkCp1Zs98DUKrWim3dN2TJ zCo2/t7uz5SHCI21aDl6ZIiwf6nZQRcia6YBiF/F4Apw3wnSMad3ew6cGpqQvxRpMdnX GSDp83+Nydg/GAslZKW7hSOWg3NP0fL6Txk3k/zdxJzWrgPSy6bxcmAWRL3HSw0xYpfA S3nC1wEpXLi02k7NrDU7R6HsUH8rTGVhZEFHg7hgfwM9yikkSdDR37l89EJEkBeWK6sQ M1o/C91pY2tZnIBByPsd6Q/AFwgOFxIQdS7Prlkqyr/0VA+y/yOXvq/Xl9Dq/LHopO+s 0OUQ== X-Gm-Message-State: AGi0PuZiIYcU+PAWzRN61BVy9CkGwLmbikqTB8wEfdqPgj4bYeB5nQ4N KbW34MG4JLRpLKBkIsAbIXAzmQ== X-Google-Smtp-Source: APiQypIULAsyj4ToagbxJztVoEGMoFCVHOReiXnPFqUE3Mk26kvhIwJXZWTW9OZPiBDfvBni1MyhFA== X-Received: by 2002:a5d:6a04:: with SMTP id m4mr11199116wru.326.1587241198993; Sat, 18 Apr 2020 13:19:58 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id m1sm31735255wro.64.2020.04.18.13.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2020 13:19:58 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv3 06/50] arm: Add loglvl to dump_backtrace() Date: Sat, 18 Apr 2020 21:19:00 +0100 Message-Id: <20200418201944.482088-7-dima@arista.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200418201944.482088-1-dima@arista.com> References: <20200418201944.482088-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200418_132000_573041_2156F810 X-CRM114-Status: GOOD ( 14.39 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 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 [2a00:1450:4864:20:0:0:0:441 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Dmitry Safonov , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Safonov <0x7f454c46@gmail.com>, Russell King , Steven Rostedt , Sergey Senozhatsky , clang-built-linux@googlegroups.com, Jiri Slaby , Andrew Morton , Will Deacon , Ingo Molnar , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently, the log-level of show_stack() depends on a platform realization. It creates situations where the headers are printed with lower log level or higher than the stacktrace (depending on a platform or user). Furthermore, it forces the logic decision from user to an architecture side. In result, some users as sysrq/kdb/etc are doing tricks with temporary rising console_loglevel while printing their messages. And in result it not only may print unwanted messages from other CPUs, but also omit printing at all in the unlucky case where the printk() was deferred. Introducing log-level parameter and KERN_UNSUPPRESSED [1] seems an easier approach than introducing more printk buffers. Also, it will consolidate printings with headers. Add log level argument to dump_backtrace() as a preparation for introducing show_stack_loglvl(). As a good side-effect __die() now prints not only "Stack:" header with KERN_EMERG, but the backtrace itself. Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: clang-built-linux@googlegroups.com [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/arm/kernel/traps.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 685e17c2e275..0f09ace18e6c 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -202,17 +202,19 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) } #ifdef CONFIG_ARM_UNWIND -static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) +static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, + const char *loglvl) { - unwind_backtrace(regs, tsk, KERN_DEFAULT); + unwind_backtrace(regs, tsk, loglvl); } #else -static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) +static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, + const char *loglvl) { unsigned int fp, mode; int ok = 1; - printk("Backtrace: "); + printk("%sBacktrace: ", loglvl); if (!tsk) tsk = current; @@ -239,13 +241,13 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) pr_cont("\n"); if (ok) - c_backtrace(fp, mode, NULL); + c_backtrace(fp, mode, loglvl); } #endif void show_stack(struct task_struct *tsk, unsigned long *sp) { - dump_backtrace(NULL, tsk); + dump_backtrace(NULL, tsk, KERN_DEFAULT); barrier(); } @@ -289,7 +291,7 @@ static int __die(const char *str, int err, struct pt_regs *regs) if (!user_mode(regs) || in_interrupt()) { dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp, THREAD_SIZE + (unsigned long)task_stack_page(tsk)); - dump_backtrace(regs, tsk); + dump_backtrace(regs, tsk, KERN_EMERG); dump_instr(KERN_EMERG, regs); }