Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2013980ybz; Sat, 18 Apr 2020 13:24:16 -0700 (PDT) X-Google-Smtp-Source: APiQypIk5SEoJn/fBWcpf1+3lFSVIfXD+Pgkl9VRRMRRujICAtOp/fDSaMHZxmSC7zONi9qXPq8m X-Received: by 2002:a17:906:4c98:: with SMTP id q24mr8895821eju.140.1587241456810; Sat, 18 Apr 2020 13:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587241456; cv=none; d=google.com; s=arc-20160816; b=BJ3FgmU8RWXEeQalMQoqdA5IkKj2dKiN20ygrXDGPdDvlthbj86z/b7JVEnK/Xywzh 54pLAlbkcdV5Cnk/WI0VAIiT1026DJFSu14ZJFt4gR+cCnDpNgqXdGIi+sYcY/JLb38/ uZAErpguso1CubQ7BOTwA3IabcLrSjdk4CLnMVKsXqzImiMONAvehp5hBFdmX13FaYZ8 pYPK+EBgtJNHOeQ2oRaeo+8eW3Cq2nVCLF1LxmYiBtyvdCVmI//6uF4w1zerbOncXaPb 023N1nZoEoZb1fsFl2AlPQ9zejLVu/Cu+MjEYRX2Kp/SLlgxBg3Oyc+s3Vw7x1MNgfET oblA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WC9mNKw2+5FlWy70C2k6LiZDHHegVmgpkuPg2LNTGBE=; b=fTYFk7IBI5qogCTvx2T2fue9KOEenJHiXnWuJnLf+8pRjFrD8GrWqhk2aAekaAj8oz ClCOMd82FQt43sVuqg7kcLqX4tQWBIBQx6vVtfVJB8DFnNTWdIRlXpXV9KNUu8G9381M WawjNtJLOpsiAh6FNZyS5bF2LerNsU0rFgVbOliCT0pueYl+yZ4VuPbKYiXEyUGVJx0d gs7PbJ7MawwvirX43TsWnTC6uATXXJVC7+IAScw7YT0FBhu+QWKHR+v1T+Uy4l1VW+PX ckGBv2NC17PF3WsDUCCfPYedkoVuUkSWNM+cQo2ylBFg8hkgIdyS7FMYwuzKAh8eKQ8n 5IXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=UO2w4Cj3; 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=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z12si18759780edp.162.2020.04.18.13.23.54; Sat, 18 Apr 2020 13:24:16 -0700 (PDT) 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=@arista.com header.s=googlenew header.b=UO2w4Cj3; 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=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728528AbgDRUWI (ORCPT + 99 others); Sat, 18 Apr 2020 16:22:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728519AbgDRUUY (ORCPT ); Sat, 18 Apr 2020 16:20:24 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E6BFC061A0F for ; Sat, 18 Apr 2020 13:20:24 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id x25so6515115wmc.0 for ; Sat, 18 Apr 2020 13:20:24 -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=WC9mNKw2+5FlWy70C2k6LiZDHHegVmgpkuPg2LNTGBE=; b=UO2w4Cj3iPpGEhYraPmiWwMT5uPdUROXDJll3KIy+0nF+WxGWWg0rYDy8pfhM1h5N2 emtYe29zAqphH15dijSwzJKANF4v8bW+VYmlvnETClN6aPBqcADSkjqrBmpDj65LHqFG 5yAjLKErTCBfC81JtV22IrdOJTCZw/J3unKEG7bs9T8ue4Awd7JEqnf7w5oxjW+XEBU6 DRYInxBWbi+Uw7/ckjJ/JaCrUyinm2j33Lkpbgiu0ByjY+8VE7FrT4WENtp9wFFZyJRM 1H0Knd/lRrOYydUd0x2sK9KoMAhiKgLwHQZQpsSjtxLtstfCEwbwpyJa3CJ+VRl72PJi w0dg== 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=WC9mNKw2+5FlWy70C2k6LiZDHHegVmgpkuPg2LNTGBE=; b=THnoOZVH7LTB1ANNZB19yPKQUZm0d+1pmED0hl3fMJg7Ntfaqnk7GBKBHFtslRjzDM 6ZuoztHWmrg1r0HUnbkCaguQkzkjBrJj3VlBIbmxY3kr/DhX82ieVEwrKNCoagbMY/fa k2tAY7aX+o4paFHX564+WGYmtG4tzlCJyPCc1D+g8Ve42GfAuS32hRe3DwR1QiT+6sDv LfM6iFF1Sn0kE/s1Pl/yzz8aGQxARmR5INICsn8SfIwXLQkWq1U6mbsIfmBVXBiagUjX uVp01FtQRy4ktoudssDHECXjVr1dkmpjNtHJmgWs95aLXU8b0wJtZL/jura5/DvZ0G6a PgBg== X-Gm-Message-State: AGi0PuYT8NmYDPPcvngtP4ww99eg963K05rOFhchLokgcGo60b1CAytQ kLPjcGbfTfkNORo8WlvHudVbxyAKXDQ= X-Received: by 2002:a05:600c:2046:: with SMTP id p6mr9573267wmg.177.1587241222874; Sat, 18 Apr 2020 13:20:22 -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.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2020 13:20:22 -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 , Jonas Bonn , Stafford Horne , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCHv3 24/50] openrisc: Add show_stack_loglvl() Date: Sat, 18 Apr 2020 21:19:18 +0100 Message-Id: <20200418201944.482088-25-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 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: Jonas Bonn Cc: Stafford Horne Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/openrisc/kernel/traps.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c index c11aa2e17ce0..3b7978a22d68 100644 --- a/arch/openrisc/kernel/traps.c +++ b/arch/openrisc/kernel/traps.c @@ -41,18 +41,26 @@ unsigned long __user *lwa_addr; void print_trace(void *data, unsigned long addr, int reliable) { - pr_emerg("[<%p>] %s%pS\n", (void *) addr, reliable ? "" : "? ", + const char *loglvl = data; + + printk("%s[<%p>] %s%pS\n", loglvl, (void *) addr, reliable ? "" : "? ", (void *) addr); } /* displays a short stack trace */ -void show_stack(struct task_struct *task, unsigned long *esp) +void show_stack_loglvl(struct task_struct *task, unsigned long *esp, + const char *loglvl) { if (esp == NULL) esp = (unsigned long *)&esp; - pr_emerg("Call trace:\n"); - unwind_stack(NULL, esp, print_trace); + printk("%sCall trace:\n", loglvl); + unwind_stack((void *)loglvl, esp, print_trace); +} + +void show_stack(struct task_struct *task, unsigned long *esp) +{ + show_stack_loglvl(task, esp, KERN_EMERG); } void show_registers(struct pt_regs *regs) -- 2.26.0