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=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 94CA1C18E5B for ; Mon, 16 Mar 2020 14:41:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6270D20658 for ; Mon, 16 Mar 2020 14:41:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="RRzmiGnt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731812AbgCPOlh (ORCPT ); Mon, 16 Mar 2020 10:41:37 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34953 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731614AbgCPOlg (ORCPT ); Mon, 16 Mar 2020 10:41:36 -0400 Received: by mail-pl1-f193.google.com with SMTP id g6so8115102plt.2 for ; Mon, 16 Mar 2020 07:41:35 -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=ooWUba+WuFM1LT+rG8Ix9OwtU31ZH6sCxTrj5FjF2+E=; b=RRzmiGntFjx3swzVfTda7U4xZacTsYm6K9zFvuZcyL1jVtrG2V+lgrSGjSTqpPDiIR bhNBPwtU23IIj81xOpKjNaymf6lt2WfyOJ4BhH93umWmwKy/QQwLly+6ZBd7ztyrGFGD gjPBVuoeOqJ4LNhi0O3L3m3NpJoUqGL25p84Xb0QsQg5gEG7U42ouuMmUyAOzd2K9gRr UNe+jUcZmr0N7Na38Uk/FPwEtlh8XN/xf6ThS12jyTwZ4XXVFAHCVpRwu2xfeg/K1os3 7YR7V/8DhUqoE2SdpZdfdr/BONtod+KRq2nxG5zLE1isiFK7x3Lv3/s6IPuRq1T8FR7/ /6rQ== 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=ooWUba+WuFM1LT+rG8Ix9OwtU31ZH6sCxTrj5FjF2+E=; b=OGKaujVtKRr4i41mGnsV74inISO0T/mdP0eBanXDkIP1SssAwkd5RL6EIZ5DS0+fO4 yQbxE/JRVVzkTVMptOg/eUv5Dze1pHOHk+In00obEPmENBQVexNIrWkcQRGlQ3ZGjwZ/ 2E4li5mslnyrrsql+zopnkcFd5Y0oEEoEhA+s42gb5IzRM47h0inobeksnXbRcvFdffA g+ehNE3wRCG0E4b1v9Cfd+pV0Mvu0oVTamonCn6CJZqM0Q5dECGKRWfTUivS9951z8jC GEIH3SDjt9C0trJaQ5qTlIi+yMLvjy6pUlxTfCUpM3BbrARzEPrfidlmccvgZyiD8smS mSHQ== X-Gm-Message-State: ANhLgQ0sa+d9r8Jc74teQiDac2qx/aPXhg7JRBJMKHbus+N2AYOmscdj vVvLw7OBSQx+egK9RhyQ8YpOG4KhScC0ng== X-Google-Smtp-Source: ADFU+vuk1Nax5JXjWEjr21XPm5/y0ppQ2bw6f25AJVd/HAFgjQBil3QYq0tzGY1BdFrIh7N2s8c0bg== X-Received: by 2002:a17:90a:c301:: with SMTP id g1mr25092050pjt.88.1584369694718; Mon, 16 Mar 2020 07:41:34 -0700 (PDT) Received: from Mindolluin.aristanetworks.com ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id i2sm81524pjs.21.2020.03.16.07.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 07:41:34 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Dmitry Safonov , Andrew Morton , Greg Kroah-Hartman , Ingo Molnar , Jiri Slaby , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Tetsuo Handa , Helge Deller , "James E.J. Bottomley" , linux-parisc@vger.kernel.org Subject: [PATCHv2 25/50] parisc: Add show_stack_loglvl() Date: Mon, 16 Mar 2020 14:38:51 +0000 Message-Id: <20200316143916.195608-26-dima@arista.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316143916.195608-1-dima@arista.com> References: <20200316143916.195608-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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. Introduce show_stack_loglvl(), that eventually will substitute show_stack(). Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: linux-parisc@vger.kernel.org [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/parisc/kernel/traps.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c index 82fc01189488..c2411de3730f 100644 --- a/arch/parisc/kernel/traps.c +++ b/arch/parisc/kernel/traps.c @@ -49,7 +49,7 @@ #include "../math-emu/math-emu.h" /* for handle_fpe() */ static void parisc_show_stack(struct task_struct *task, - struct pt_regs *regs); + struct pt_regs *regs, const char *loglvl); static int printbinary(char *buf, unsigned long x, int nbits) { @@ -155,7 +155,7 @@ void show_regs(struct pt_regs *regs) printk("%s IAOQ[1]: %pS\n", level, (void *) regs->iaoq[1]); printk("%s RP(r2): %pS\n", level, (void *) regs->gr[2]); - parisc_show_stack(current, regs); + parisc_show_stack(current, regs, KERN_DEFAULT); } } @@ -170,37 +170,43 @@ static DEFINE_RATELIMIT_STATE(_hppa_rs, } -static void do_show_stack(struct unwind_frame_info *info) +static void do_show_stack(struct unwind_frame_info *info, const char *loglvl) { int i = 1; - printk(KERN_CRIT "Backtrace:\n"); + printk("%sBacktrace:\n", loglvl); while (i <= MAX_UNWIND_ENTRIES) { if (unwind_once(info) < 0 || info->ip == 0) break; if (__kernel_text_address(info->ip)) { - printk(KERN_CRIT " [<" RFMT ">] %pS\n", - info->ip, (void *) info->ip); + printk("%s [<" RFMT ">] %pS\n", + loglvl, info->ip, (void *) info->ip); i++; } } - printk(KERN_CRIT "\n"); + printk("%s\n", loglvl); } static void parisc_show_stack(struct task_struct *task, - struct pt_regs *regs) + struct pt_regs *regs, const char *loglvl) { struct unwind_frame_info info; unwind_frame_init_task(&info, task, regs); - do_show_stack(&info); + do_show_stack(&info, loglvl); +} + +void show_stack_loglvl(struct task_struct *t, unsigned long *sp, + const char *loglvl) +{ + parisc_show_stack(t, NULL, loglvl); } void show_stack(struct task_struct *t, unsigned long *sp) { - parisc_show_stack(t, NULL); + show_stack_loglvl(t, sp, KERN_CRIT) } int is_valid_bugaddr(unsigned long iaoq) @@ -446,7 +452,7 @@ void parisc_terminate(char *msg, struct pt_regs *regs, int code, unsigned long o /* show_stack(NULL, (unsigned long *)regs->gr[30]); */ struct unwind_frame_info info; unwind_frame_init(&info, current, regs); - do_show_stack(&info); + do_show_stack(&info, KERN_CRIT); } printk("\n"); -- 2.25.1