From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B02F2C433DF for ; Tue, 9 Jun 2020 04:31:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6F9BB20801 for ; Tue, 9 Jun 2020 04:31:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="kpCNsGyB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F9BB20801 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 17A536B009C; Tue, 9 Jun 2020 00:31:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12BBC6B009E; Tue, 9 Jun 2020 00:31:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9B906B009F; Tue, 9 Jun 2020 00:31:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0166.hostedemail.com [216.40.44.166]) by kanga.kvack.org (Postfix) with ESMTP id CC8406B009C for ; Tue, 9 Jun 2020 00:31:56 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 900FD181ABEAD for ; Tue, 9 Jun 2020 04:31:56 +0000 (UTC) X-FDA: 76908400632.11.bomb19_481609226dbf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 6BA97180FB3C8 for ; Tue, 9 Jun 2020 04:31:56 +0000 (UTC) X-HE-Tag: bomb19_481609226dbf X-Filterd-Recvd-Size: 4748 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Jun 2020 04:31:55 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B316207F9; Tue, 9 Jun 2020 04:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591677115; bh=noygOI39jPKeeOYO4FilLVGR7IxFHO4O1/l7FiAurAc=; h=Date:From:To:Subject:In-Reply-To:From; b=kpCNsGyBZsAJnXo/x1JBfMVZ7JiZawEetF4PZOQcCJ8ZdkJEFZDBX0S1aQwo0sdpy RwrXQcpo98h682wMhABQNop4qNd4w7A4sTOcyx9gmhyNwf5ssQ33P4IIpCOtdECJ/h U+5LQRSFJH3UJfTEZtREf0Ql/h+Uo6NgycJN4WYE= Date: Mon, 08 Jun 2020 21:31:54 -0700 From: Andrew Morton To: akpm@linux-foundation.org, dima@arista.com, gxt@pku.edu.cn, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 39/93] unicore32: add show_stack_loglvl() Message-ID: <20200609043154.kR7DP9iIq%akpm@linux-foundation.org> In-Reply-To: <20200608212922.5b7fa74ca3f4e2444441b7f9@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 6BA97180FB3C8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Dmitry Safonov Subject: unicore32: add show_stack_loglvl() 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. Introduce show_stack_loglvl(), that eventually will substitute show_stack(). As a nice side-effect - print backtrace in __die() with the same log level as the rest of function. [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Link: http://lkml.kernel.org/r/20200418201944.482088-40-dima@arista.com Signed-off-by: Dmitry Safonov Cc: Guan Xuetao Signed-off-by: Andrew Morton --- arch/unicore32/kernel/traps.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) --- a/arch/unicore32/kernel/traps.c~unicore32-add-show_stack_loglvl +++ a/arch/unicore32/kernel/traps.c @@ -135,12 +135,13 @@ static void dump_instr(const char *lvl, set_fs(fs); } -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; int ok = 1; - printk(KERN_DEFAULT "Backtrace: "); + printk("%sBacktrace: ", loglvl); if (!tsk) tsk = current; @@ -153,25 +154,31 @@ static void dump_backtrace(struct pt_reg asm("mov %0, fp" : "=r" (fp) : : "cc"); if (!fp) { - printk("no frame pointer"); + printk("%sno frame pointer", loglvl); ok = 0; } else if (verify_stack(fp)) { - printk("invalid frame pointer 0x%08x", fp); + printk("%sinvalid frame pointer 0x%08x", loglvl, fp); ok = 0; } else if (fp < (unsigned long)end_of_stack(tsk)) - printk("frame pointer underflow"); - printk("\n"); + printk("%sframe pointer underflow", loglvl); + printk("%s\n", loglvl); if (ok) - c_backtrace(fp, KERN_DEFAULT); + c_backtrace(fp, loglvl); } -void show_stack(struct task_struct *tsk, unsigned long *sp) +void show_stack_loglvl(struct task_struct *tsk, unsigned long *sp, + const char *loglvl) { - dump_backtrace(NULL, tsk); + dump_backtrace(NULL, tsk, loglvl); barrier(); } +void show_stack(struct task_struct *tsk, unsigned long *sp) +{ + show_stack_loglvl(tsk, sp, KERN_DEFAULT) +} + static int __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs) { @@ -196,7 +203,7 @@ static int __die(const char *str, int er if (!user_mode(regs) || in_interrupt()) { dump_mem(KERN_EMERG, "Stack: ", regs->UCreg_sp, THREAD_SIZE + (unsigned long)task_stack_page(tsk)); - dump_backtrace(regs, tsk); + dump_backtrace(regs, tsk, KERN_EMERG); dump_instr(KERN_EMERG, regs); } _