From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergey Senozhatsky Subject: Re: [PATCH 00/50] Add log level to show_stack() Date: Tue, 12 Nov 2019 11:17:47 +0900 Message-ID: <20191112021747.GA68506@google.com> References: <20191106030542.868541-1-dima@arista.com> <20191106083538.z5nlpuf64cigxigh@pathway.suse.cz> <20191108103719.GB175344@google.com> <20191108130447.h3wfgo4efjkto56f@pathway.suse.cz> <20191111012336.GA85185@google.com> <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Guc/SnXr9vvX4xEx1xDqKSHQIRS7eYk0OXesgRSAh30=; b=Rz08+sZlcbNKHt dZsHPdSSooLyOZwsVJwtXKnPQZw1aWpquiL73D6SugGO9DzSse9Z58squxtElMHQuTcbgGUZN9C1u QC2hrQ4am4iZNB5aDCMaFEhzyVzAltJ1ZpVvDryYFO9PwmGD+Z+VsfPcPcY4oKvpLXY3vrWRW3i2h Xhs56ej5jc6TiUAmsgvsoVpUq2WM+vBqfWZ4GnC5un18/dkTha0J0hilSOwer/JaIlgq3B1wNOh/j qTVtp8fq+zzTSUeSj4V7jMgcHPZH8QKsGXWTNvHnLEHDBJ/zmfRNfa+uBeOm6rXPwhLCasPX6uTMP 7mtlL4nMP5e8KUHKFBzA==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IS2Rt6ZY2kbQpUl893KQNxQCDA75x7+my/1Tf7NswKk=; b=Vjlm6KDBvoD6YwvO++lGZ6lHjSc6cCAm9fWSs4JjxabSDi/CqNgEayfiCYPC9t2GLz /Uty/IrZcv04aOS3qRrPGUG7rvgiF7YDnI2Kh9DQ5F3zuIcYwKRvol7P+LJHVR2Ntpue BmenkoLlXCW6FGqP0oYogfaCGkjco6cjgwMGb8PovVw8l1XJbVJPK3lxsi28NPqBWING uoTRw1Bt7GD9J0aMH2Xm/nWO4Q+ipdt8rIvGvN7pJpIBErQgGrRImSVcDd2J/2wookMd 9Mf3+OZR0ijbdxrDUHHqzfcSZeytQjNDcnXBd9Ph8Qnd5c5vZ2BNhRMMpdwPBrRfh+x9 Q4tA== Content-Disposition: inline In-Reply-To: <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+glpr-linux-riscv=m.gmane.org@lists.infradead.org To: Dmitry Safonov Cc: Juri Lelli , Sergey Senozhatsky , linux-sh@vger.kernel.org, Catalin Marinas , Ben Segall , Guo Ren , Pavel Machek , Vincent Guittot , Paul Burton , Michael Ellerman , Geert Uytterhoeven , Mel Gorman , Jiri Slaby , Matt Turner , uclinux-h8-devel@lists.sourceforge.jp, Petr Mladek , linux-pm@vger.kernel.org, Heiko Carstens , linux-um@lists.infradead.org, Thomas Gleixner , Dietmar Eggemann , Richard Henderson , Greg Kroah-Hartman , "Rafael J. Wysocki" On (19/11/11 19:47), Dmitry Safonov wrote: [..] > I don't see how bits on task_struct or in per-cpu are easier than > supplying a log level parameter down the stack. > How would it work if sysrq_handle_crash() called by key-press? > How would that interact with deferred printing? > How would it make visible prints from current context, but not from > something that preempted it? [..] per-context log_level works pretty much the same way as per-message log_level. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // static DEFINE_PER_CPU(int, cpu_loglevels[4]); // @INITME.. LOGLEVEL_DEBUG + 1? static int __printing_context(void) { unsigned int preempt = preempt_count(); if (!(preempt & (NMI_MASK | HARDIRQ_MASK | SOFITRQ_OFFSET))) return 0; if (preempt & SOFITRQ_OFFSET) return 1; if (preempt & HARDIRQ_MASK) return 2; return 3; } static int adj_context_loglevel(int level) { int ctx = __printing_context(); int cpu_level = this_cpu_read(cpu_loglevels[ctx]); // this one is important if (level == LOGLEVEL_SCHED) return level; // we are not in emergency context if (cpu_level == LOGLEVEL_DEBUG + 1) return level; // we better not override these if (LOGLEVEL_EMERG <= level && level <= LOGLEVEL_ERR) return level; return cpu_level; } void printk_emergency_enter(int log_level) { int ctx; preempt_disable(); ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], log_level); } void printk_emergency_exit(void) { int ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], LOGLEVEL_DEBUG + 1); preempt_enable(); } void vprintk_emit(...) { level = adj_context_loglevel(level); } // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // static void __show_stack(struct task_struct *task, unsigned long *sp) { printk(); ... printk(); } void show_stack(struct task_struct *task, unsigned long *sp, int log_level) { printk_emergency_enter(log_level); __show_stack(task, sp); printk_emergency_exit(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // show_stack() never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count. printk_emergency_enter(log_level) handles every printk() that __show_stack() and friends do. Not worse than printk("%s Stack", lvl); all over the place. > What I'm going to do - is to fix all build and reported issues, I'll > send v2 this week and feel free to NAK it, I will forget about those > patches and won't be offended. Lovely. And - no, I'm not going to NAK platform specific changes. Just so you know. *All* I'm talking about is an alternative, less "go and touch a ton of platform code" approach. The argument "I patched so many files that I'm not even going to discuss anything now" is not productive, to say the least. Hope this clarifies. -ss 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=-2.1 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 2BB91C43331 for ; Tue, 12 Nov 2019 02:17:58 +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 F13F72084F for ; Tue, 12 Nov 2019 02:17:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Rz08+sZl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vjlm6KDB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F13F72084F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.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:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Guc/SnXr9vvX4xEx1xDqKSHQIRS7eYk0OXesgRSAh30=; b=Rz08+sZlcbNKHt dZsHPdSSooLyOZwsVJwtXKnPQZw1aWpquiL73D6SugGO9DzSse9Z58squxtElMHQuTcbgGUZN9C1u QC2hrQ4am4iZNB5aDCMaFEhzyVzAltJ1ZpVvDryYFO9PwmGD+Z+VsfPcPcY4oKvpLXY3vrWRW3i2h Xhs56ej5jc6TiUAmsgvsoVpUq2WM+vBqfWZ4GnC5un18/dkTha0J0hilSOwer/JaIlgq3B1wNOh/j qTVtp8fq+zzTSUeSj4V7jMgcHPZH8QKsGXWTNvHnLEHDBJ/zmfRNfa+uBeOm6rXPwhLCasPX6uTMP 7mtlL4nMP5e8KUHKFBzA==; 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 1iULki-0005Ug-TO; Tue, 12 Nov 2019 02:17:56 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iULkg-0005Tv-SH; Tue, 12 Nov 2019 02:17:56 +0000 Received: by mail-pg1-x541.google.com with SMTP id k13so10792803pgh.3; Mon, 11 Nov 2019 18:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IS2Rt6ZY2kbQpUl893KQNxQCDA75x7+my/1Tf7NswKk=; b=Vjlm6KDBvoD6YwvO++lGZ6lHjSc6cCAm9fWSs4JjxabSDi/CqNgEayfiCYPC9t2GLz /Uty/IrZcv04aOS3qRrPGUG7rvgiF7YDnI2Kh9DQ5F3zuIcYwKRvol7P+LJHVR2Ntpue BmenkoLlXCW6FGqP0oYogfaCGkjco6cjgwMGb8PovVw8l1XJbVJPK3lxsi28NPqBWING uoTRw1Bt7GD9J0aMH2Xm/nWO4Q+ipdt8rIvGvN7pJpIBErQgGrRImSVcDd2J/2wookMd 9Mf3+OZR0ijbdxrDUHHqzfcSZeytQjNDcnXBd9Ph8Qnd5c5vZ2BNhRMMpdwPBrRfh+x9 Q4tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IS2Rt6ZY2kbQpUl893KQNxQCDA75x7+my/1Tf7NswKk=; b=Txv8z1hYh7T6hjeVzAKiEHjEoEnibBjJiw9k6gGRAz9MrZ9vtEeZZnLOrO/jUK+99t dSWp/jsUklOkxZ6yTGeAwwfkG3wx2ju2605KdNbhTDAANNSw705V5RHheMXDpa+cZGPD JNlEP93uaLtTPAx1+qeo1Po/7NJi3NFrWtOZGcxUGLYCdbcRG9DCOdKJ00PrjDvKoBNf +TCDr7O1CaH6M+2jjp5CgrADayCaCpoFAdA1WnGDCd36YpMsT1/j5ob7mt3a7A3epMxt QbLc+miaGDATlvdv9Az7dcYUMP2NfbnXmFxyTnXMPb3CzkgAr41dNfTRNEXdcABQ/Awj NXVA== X-Gm-Message-State: APjAAAU21x/LiYO0lfdRLGelKRoe+KxmMJcuS6WwVi/r43dZgR6paYPx V2APodWYLqiyDcWVoROw9oo= X-Google-Smtp-Source: APXvYqzpzPbBNdkztHOhg5atVqEV6ayQFi/1XFUzsE81gTsFNG+Jay6WO4tdKRJ91MFuBRoP65cRJw== X-Received: by 2002:a65:6119:: with SMTP id z25mr32726962pgu.332.1573525071244; Mon, 11 Nov 2019 18:17:51 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:250d:e71d:5a0a:9afe]) by smtp.gmail.com with ESMTPSA id k103sm739924pje.16.2019.11.11.18.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 18:17:50 -0800 (PST) Date: Tue, 12 Nov 2019 11:17:47 +0900 From: Sergey Senozhatsky To: Dmitry Safonov Subject: Re: [PATCH 00/50] Add log level to show_stack() Message-ID: <20191112021747.GA68506@google.com> References: <20191106030542.868541-1-dima@arista.com> <20191106083538.z5nlpuf64cigxigh@pathway.suse.cz> <20191108103719.GB175344@google.com> <20191108130447.h3wfgo4efjkto56f@pathway.suse.cz> <20191111012336.GA85185@google.com> <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191111_181754_920050_FC5DE91F X-CRM114-Status: GOOD ( 16.49 ) 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 , Sergey Senozhatsky , linux-sh@vger.kernel.org, Catalin Marinas , Ben Segall , Guo Ren , Pavel Machek , Vincent Guittot , Paul Burton , Michael Ellerman , Geert Uytterhoeven , Mel Gorman , Jiri Slaby , Matt Turner , uclinux-h8-devel@lists.sourceforge.jp, Petr Mladek , linux-pm@vger.kernel.org, Heiko Carstens , linux-um@lists.infradead.org, Thomas Gleixner , Dietmar Eggemann , Richard Henderson , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, 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 , Len Brown , 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org On (19/11/11 19:47), Dmitry Safonov wrote: [..] > I don't see how bits on task_struct or in per-cpu are easier than > supplying a log level parameter down the stack. > How would it work if sysrq_handle_crash() called by key-press? > How would that interact with deferred printing? > How would it make visible prints from current context, but not from > something that preempted it? [..] per-context log_level works pretty much the same way as per-message log_level. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // static DEFINE_PER_CPU(int, cpu_loglevels[4]); // @INITME.. LOGLEVEL_DEBUG + 1? static int __printing_context(void) { unsigned int preempt = preempt_count(); if (!(preempt & (NMI_MASK | HARDIRQ_MASK | SOFITRQ_OFFSET))) return 0; if (preempt & SOFITRQ_OFFSET) return 1; if (preempt & HARDIRQ_MASK) return 2; return 3; } static int adj_context_loglevel(int level) { int ctx = __printing_context(); int cpu_level = this_cpu_read(cpu_loglevels[ctx]); // this one is important if (level == LOGLEVEL_SCHED) return level; // we are not in emergency context if (cpu_level == LOGLEVEL_DEBUG + 1) return level; // we better not override these if (LOGLEVEL_EMERG <= level && level <= LOGLEVEL_ERR) return level; return cpu_level; } void printk_emergency_enter(int log_level) { int ctx; preempt_disable(); ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], log_level); } void printk_emergency_exit(void) { int ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], LOGLEVEL_DEBUG + 1); preempt_enable(); } void vprintk_emit(...) { level = adj_context_loglevel(level); } // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // static void __show_stack(struct task_struct *task, unsigned long *sp) { printk(); ... printk(); } void show_stack(struct task_struct *task, unsigned long *sp, int log_level) { printk_emergency_enter(log_level); __show_stack(task, sp); printk_emergency_exit(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // show_stack() never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count. printk_emergency_enter(log_level) handles every printk() that __show_stack() and friends do. Not worse than printk("%s Stack", lvl); all over the place. > What I'm going to do - is to fix all build and reported issues, I'll > send v2 this week and feel free to NAK it, I will forget about those > patches and won't be offended. Lovely. And - no, I'm not going to NAK platform specific changes. Just so you know. *All* I'm talking about is an alternative, less "go and touch a ton of platform code" approach. The argument "I patched so many files that I'm not even going to discuss anything now" is not productive, to say the least. Hope this clarifies. -ss _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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=-2.1 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 4DCE8C43331 for ; Tue, 12 Nov 2019 02:18:02 +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 23A2D2084F for ; Tue, 12 Nov 2019 02:18:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gF+8J47s"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vjlm6KDB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23A2D2084F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-snps-arc-bounces+linux-snps-arc=archiver.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:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qPVjkYZGG5VWGK0JpJcTSfTAZlMtWm9VBeEks7WHmz0=; b=gF+8J47sNjDLHj Wyx+TNbkQ5JXRoQIvQgaOL2rAQBRxKZLeT6IIHNe/2Xf6lcpJIl5X0WonWjpTpxHXE0hxNpv5lU27 cNQbZuUB3ugcHMjN+sdGOiVydt/UOeSXKmVgw3VLoCSkn0VsyYrHGocy8DtTX7X01bYfde7Pk8nSC Jl+GqfFBPwb+Gb+D0poPuJL5LEnaYpzWdQMTigsOfSVjcruLQYZO/eQf+xpo5mfdVdSNj2tZWNe0B DfeYj23BpUuUqXoVlYbexmwNn6hWQjC36c2rsb9Qq7ZnMLbUoNqV+XhPt/Bh7L/cRDeKKk4JcJ+4l FstYgifHZPm1OGn40Rpg==; 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 1iULkk-0005WA-Jx; Tue, 12 Nov 2019 02:17:58 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iULkg-0005Tv-SH; Tue, 12 Nov 2019 02:17:56 +0000 Received: by mail-pg1-x541.google.com with SMTP id k13so10792803pgh.3; Mon, 11 Nov 2019 18:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IS2Rt6ZY2kbQpUl893KQNxQCDA75x7+my/1Tf7NswKk=; b=Vjlm6KDBvoD6YwvO++lGZ6lHjSc6cCAm9fWSs4JjxabSDi/CqNgEayfiCYPC9t2GLz /Uty/IrZcv04aOS3qRrPGUG7rvgiF7YDnI2Kh9DQ5F3zuIcYwKRvol7P+LJHVR2Ntpue BmenkoLlXCW6FGqP0oYogfaCGkjco6cjgwMGb8PovVw8l1XJbVJPK3lxsi28NPqBWING uoTRw1Bt7GD9J0aMH2Xm/nWO4Q+ipdt8rIvGvN7pJpIBErQgGrRImSVcDd2J/2wookMd 9Mf3+OZR0ijbdxrDUHHqzfcSZeytQjNDcnXBd9Ph8Qnd5c5vZ2BNhRMMpdwPBrRfh+x9 Q4tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IS2Rt6ZY2kbQpUl893KQNxQCDA75x7+my/1Tf7NswKk=; b=Txv8z1hYh7T6hjeVzAKiEHjEoEnibBjJiw9k6gGRAz9MrZ9vtEeZZnLOrO/jUK+99t dSWp/jsUklOkxZ6yTGeAwwfkG3wx2ju2605KdNbhTDAANNSw705V5RHheMXDpa+cZGPD JNlEP93uaLtTPAx1+qeo1Po/7NJi3NFrWtOZGcxUGLYCdbcRG9DCOdKJ00PrjDvKoBNf +TCDr7O1CaH6M+2jjp5CgrADayCaCpoFAdA1WnGDCd36YpMsT1/j5ob7mt3a7A3epMxt QbLc+miaGDATlvdv9Az7dcYUMP2NfbnXmFxyTnXMPb3CzkgAr41dNfTRNEXdcABQ/Awj NXVA== X-Gm-Message-State: APjAAAU21x/LiYO0lfdRLGelKRoe+KxmMJcuS6WwVi/r43dZgR6paYPx V2APodWYLqiyDcWVoROw9oo= X-Google-Smtp-Source: APXvYqzpzPbBNdkztHOhg5atVqEV6ayQFi/1XFUzsE81gTsFNG+Jay6WO4tdKRJ91MFuBRoP65cRJw== X-Received: by 2002:a65:6119:: with SMTP id z25mr32726962pgu.332.1573525071244; Mon, 11 Nov 2019 18:17:51 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:250d:e71d:5a0a:9afe]) by smtp.gmail.com with ESMTPSA id k103sm739924pje.16.2019.11.11.18.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 18:17:50 -0800 (PST) Date: Tue, 12 Nov 2019 11:17:47 +0900 From: Sergey Senozhatsky To: Dmitry Safonov Subject: Re: [PATCH 00/50] Add log level to show_stack() Message-ID: <20191112021747.GA68506@google.com> References: <20191106030542.868541-1-dima@arista.com> <20191106083538.z5nlpuf64cigxigh@pathway.suse.cz> <20191108103719.GB175344@google.com> <20191108130447.h3wfgo4efjkto56f@pathway.suse.cz> <20191111012336.GA85185@google.com> <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191111_181754_920050_FC5DE91F X-CRM114-Status: GOOD ( 16.49 ) X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juri Lelli , Sergey Senozhatsky , linux-sh@vger.kernel.org, Catalin Marinas , Ben Segall , Guo Ren , Pavel Machek , Vincent Guittot , Paul Burton , Michael Ellerman , Geert Uytterhoeven , Mel Gorman , Jiri Slaby , Matt Turner , uclinux-h8-devel@lists.sourceforge.jp, Petr Mladek , linux-pm@vger.kernel.org, Heiko Carstens , linux-um@lists.infradead.org, Thomas Gleixner , Dietmar Eggemann , Richard Henderson , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, 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 , Len Brown , 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org On (19/11/11 19:47), Dmitry Safonov wrote: [..] > I don't see how bits on task_struct or in per-cpu are easier than > supplying a log level parameter down the stack. > How would it work if sysrq_handle_crash() called by key-press? > How would that interact with deferred printing? > How would it make visible prints from current context, but not from > something that preempted it? [..] per-context log_level works pretty much the same way as per-message log_level. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // static DEFINE_PER_CPU(int, cpu_loglevels[4]); // @INITME.. LOGLEVEL_DEBUG + 1? static int __printing_context(void) { unsigned int preempt = preempt_count(); if (!(preempt & (NMI_MASK | HARDIRQ_MASK | SOFITRQ_OFFSET))) return 0; if (preempt & SOFITRQ_OFFSET) return 1; if (preempt & HARDIRQ_MASK) return 2; return 3; } static int adj_context_loglevel(int level) { int ctx = __printing_context(); int cpu_level = this_cpu_read(cpu_loglevels[ctx]); // this one is important if (level == LOGLEVEL_SCHED) return level; // we are not in emergency context if (cpu_level == LOGLEVEL_DEBUG + 1) return level; // we better not override these if (LOGLEVEL_EMERG <= level && level <= LOGLEVEL_ERR) return level; return cpu_level; } void printk_emergency_enter(int log_level) { int ctx; preempt_disable(); ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], log_level); } void printk_emergency_exit(void) { int ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], LOGLEVEL_DEBUG + 1); preempt_enable(); } void vprintk_emit(...) { level = adj_context_loglevel(level); } // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // static void __show_stack(struct task_struct *task, unsigned long *sp) { printk(); ... printk(); } void show_stack(struct task_struct *task, unsigned long *sp, int log_level) { printk_emergency_enter(log_level); __show_stack(task, sp); printk_emergency_exit(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // show_stack() never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count. printk_emergency_enter(log_level) handles every printk() that __show_stack() and friends do. Not worse than printk("%s Stack", lvl); all over the place. > What I'm going to do - is to fix all build and reported issues, I'll > send v2 this week and feel free to NAK it, I will forget about those > patches and won't be offended. Lovely. And - no, I'm not going to NAK platform specific changes. Just so you know. *All* I'm talking about is an alternative, less "go and touch a ton of platform code" approach. The argument "I patched so many files that I'm not even going to discuss anything now" is not productive, to say the least. Hope this clarifies. -ss _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 12 Nov 2019 11:17:47 +0900 From: Sergey Senozhatsky Subject: Re: [PATCH 00/50] Add log level to show_stack() Message-ID: <20191112021747.GA68506@google.com> References: <20191106030542.868541-1-dima@arista.com> <20191106083538.z5nlpuf64cigxigh@pathway.suse.cz> <20191108103719.GB175344@google.com> <20191108130447.h3wfgo4efjkto56f@pathway.suse.cz> <20191111012336.GA85185@google.com> <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> To: Dmitry Safonov Cc: Sergey Senozhatsky , Petr Mladek , linux-kernel@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com>, Andrew Morton , Greg Kroah-Hartman , Ingo Molnar , Jiri Slaby , Sergey Senozhatsky , Steven Rostedt , Tetsuo Handa , Albert Ou , Ben Segall , Dietmar Eggemann , Greentime Hu , Ingo Molnar , James Hogan , Juri Lelli , Mel Gorman , Michal Simek , Palmer Dabbelt , Paul Burton , Paul Walmsley , Peter Zijlstra , Ralf Baechle , Thomas Gleixner , Vincent Chen , Vincent Guittot , Will Deacon , linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, Ivan Kokshaysky , Matt Turner , Richard Henderson , linux-alpha@vger.kernel.org, Vineet Gupta , linux-snps-arc@lists.infradead.org, Russell King , linux-arm-kernel@lists.infradead.org, clang-built-linux@googlegroups.com, Catalin Marinas , Aurelien Jacquiot , Mark Salter , linux-c6x-dev@linux-c6x.org, Guo Ren , Yoshinori Sato , uclinux-h8-devel@lists.sourceforge.jp, Brian Cain , linux-hexagon@vger.kernel.org, Fenghua Yu , Tony Luck , linux-ia64@vger.kernel.org, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Ley Foon Tan , nios2-dev@lists.rocketboards.org, Jonas Bonn , Stafford Horne , Stefan Kristiansson , openrisc@lists.librecores.org, Helge Deller , "James E.J. Bottomley" , linux-parisc@vger.kernel.org, Benjamin Herrenschmidt , Michael Ellerman , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, Christian Borntraeger , Heiko Carstens , Vasily Gorbik , linux-s390@vger.kernel.org, Rich Felker , linux-sh@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org, Anton Ivanov , Jeff Dike , Richard Weinberger , linux-um@lists.infradead.org, Guan Xuetao , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org, Len Brown , Pavel Machek , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Daniel Thompson , Douglas Anderson , Jason Wessel , kgdb-bugreport@lists.sourceforge.net List-ID: On (19/11/11 19:47), Dmitry Safonov wrote: [..] > I don't see how bits on task_struct or in per-cpu are easier than > supplying a log level parameter down the stack. > How would it work if sysrq_handle_crash() called by key-press? > How would that interact with deferred printing? > How would it make visible prints from current context, but not from > something that preempted it? [..] per-context log_level works pretty much the same way as per-message log_level. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // static DEFINE_PER_CPU(int, cpu_loglevels[4]); // @INITME.. LOGLEVEL_DEBUG + 1? static int __printing_context(void) { unsigned int preempt = preempt_count(); if (!(preempt & (NMI_MASK | HARDIRQ_MASK | SOFITRQ_OFFSET))) return 0; if (preempt & SOFITRQ_OFFSET) return 1; if (preempt & HARDIRQ_MASK) return 2; return 3; } static int adj_context_loglevel(int level) { int ctx = __printing_context(); int cpu_level = this_cpu_read(cpu_loglevels[ctx]); // this one is important if (level == LOGLEVEL_SCHED) return level; // we are not in emergency context if (cpu_level == LOGLEVEL_DEBUG + 1) return level; // we better not override these if (LOGLEVEL_EMERG <= level && level <= LOGLEVEL_ERR) return level; return cpu_level; } void printk_emergency_enter(int log_level) { int ctx; preempt_disable(); ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], log_level); } void printk_emergency_exit(void) { int ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], LOGLEVEL_DEBUG + 1); preempt_enable(); } void vprintk_emit(...) { level = adj_context_loglevel(level); } // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // static void __show_stack(struct task_struct *task, unsigned long *sp) { printk(); ... printk(); } void show_stack(struct task_struct *task, unsigned long *sp, int log_level) { printk_emergency_enter(log_level); __show_stack(task, sp); printk_emergency_exit(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // show_stack() never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count. printk_emergency_enter(log_level) handles every printk() that __show_stack() and friends do. Not worse than printk("%s Stack", lvl); all over the place. > What I'm going to do - is to fix all build and reported issues, I'll > send v2 this week and feel free to NAK it, I will forget about those > patches and won't be offended. Lovely. And - no, I'm not going to NAK platform specific changes. Just so you know. *All* I'm talking about is an alternative, less "go and touch a ton of platform code" approach. The argument "I patched so many files that I'm not even going to discuss anything now" is not productive, to say the least. Hope this clarifies. -ss From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergey Senozhatsky Date: Tue, 12 Nov 2019 11:17:47 +0900 Subject: [OpenRISC] [PATCH 00/50] Add log level to show_stack() In-Reply-To: <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> References: <20191106030542.868541-1-dima@arista.com> <20191106083538.z5nlpuf64cigxigh@pathway.suse.cz> <20191108103719.GB175344@google.com> <20191108130447.h3wfgo4efjkto56f@pathway.suse.cz> <20191111012336.GA85185@google.com> <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> Message-ID: <20191112021747.GA68506@google.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: openrisc@lists.librecores.org On (19/11/11 19:47), Dmitry Safonov wrote: [..] > I don't see how bits on task_struct or in per-cpu are easier than > supplying a log level parameter down the stack. > How would it work if sysrq_handle_crash() called by key-press? > How would that interact with deferred printing? > How would it make visible prints from current context, but not from > something that preempted it? [..] per-context log_level works pretty much the same way as per-message log_level. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // static DEFINE_PER_CPU(int, cpu_loglevels[4]); // @INITME.. LOGLEVEL_DEBUG + 1? static int __printing_context(void) { unsigned int preempt = preempt_count(); if (!(preempt & (NMI_MASK | HARDIRQ_MASK | SOFITRQ_OFFSET))) return 0; if (preempt & SOFITRQ_OFFSET) return 1; if (preempt & HARDIRQ_MASK) return 2; return 3; } static int adj_context_loglevel(int level) { int ctx = __printing_context(); int cpu_level = this_cpu_read(cpu_loglevels[ctx]); // this one is important if (level == LOGLEVEL_SCHED) return level; // we are not in emergency context if (cpu_level == LOGLEVEL_DEBUG + 1) return level; // we better not override these if (LOGLEVEL_EMERG <= level && level <= LOGLEVEL_ERR) return level; return cpu_level; } void printk_emergency_enter(int log_level) { int ctx; preempt_disable(); ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], log_level); } void printk_emergency_exit(void) { int ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], LOGLEVEL_DEBUG + 1); preempt_enable(); } void vprintk_emit(...) { level = adj_context_loglevel(level); } // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // static void __show_stack(struct task_struct *task, unsigned long *sp) { printk(); ... printk(); } void show_stack(struct task_struct *task, unsigned long *sp, int log_level) { printk_emergency_enter(log_level); __show_stack(task, sp); printk_emergency_exit(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // show_stack() never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count. printk_emergency_enter(log_level) handles every printk() that __show_stack() and friends do. Not worse than printk("%s Stack", lvl); all over the place. > What I'm going to do - is to fix all build and reported issues, I'll > send v2 this week and feel free to NAK it, I will forget about those > patches and won't be offended. Lovely. And - no, I'm not going to NAK platform specific changes. Just so you know. *All* I'm talking about is an alternative, less "go and touch a ton of platform code" approach. The argument "I patched so many files that I'm not even going to discuss anything now" is not productive, to say the least. Hope this clarifies. -ss 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=-1.9 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 CF6FEC43331 for ; Tue, 12 Nov 2019 06:19:57 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 3E2B42084F for ; Tue, 12 Nov 2019 06:19:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vjlm6KDB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E2B42084F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47ByJp0W4hzF56x for ; Tue, 12 Nov 2019 17:19:54 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=sergey.senozhatsky.work@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Vjlm6KDB"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47Brxb2yF0zDqQ8 for ; Tue, 12 Nov 2019 13:17:55 +1100 (AEDT) Received: by mail-pf1-x444.google.com with SMTP id z4so12151117pfn.12 for ; Mon, 11 Nov 2019 18:17:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IS2Rt6ZY2kbQpUl893KQNxQCDA75x7+my/1Tf7NswKk=; b=Vjlm6KDBvoD6YwvO++lGZ6lHjSc6cCAm9fWSs4JjxabSDi/CqNgEayfiCYPC9t2GLz /Uty/IrZcv04aOS3qRrPGUG7rvgiF7YDnI2Kh9DQ5F3zuIcYwKRvol7P+LJHVR2Ntpue BmenkoLlXCW6FGqP0oYogfaCGkjco6cjgwMGb8PovVw8l1XJbVJPK3lxsi28NPqBWING uoTRw1Bt7GD9J0aMH2Xm/nWO4Q+ipdt8rIvGvN7pJpIBErQgGrRImSVcDd2J/2wookMd 9Mf3+OZR0ijbdxrDUHHqzfcSZeytQjNDcnXBd9Ph8Qnd5c5vZ2BNhRMMpdwPBrRfh+x9 Q4tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IS2Rt6ZY2kbQpUl893KQNxQCDA75x7+my/1Tf7NswKk=; b=Hhl6xgYQnAgRaFUKQLl9OR88Lgiu3WFRKSOQJ4nJ3FbAeVv4Mng4WP0kvRoHK1g2WB JrZcu+WJS4BwayQlfX1mtAvOFDY5fJwG48pwb/CkmEXngL6SLcqtFa06dA5j6gWo5qiJ qpm/XSTXk9jdvQPMgL3o9onIZ6b3MSNX4j9NU/DV8JKEJL5156alWAv1MZvyQWGTOcyB a80SvmMOKOoDl8QOhPYOnfC9MbvHZvYTbrtbroaePrAu/PpL9Hioq4c1cgpRRjbj46p7 hUXJUY8MarnovidbZUfb5wrK10aUyYr9ETlgXME7z7pnvtK++VSuOKInl+ofclZm3Iy5 yrLw== X-Gm-Message-State: APjAAAVOpgBTsg3QulHVudns1yC/kboKMpybdGLoi79VMoEt/4pdK7LM 9drIzOkAsgGBksW4xZnUTC8= X-Google-Smtp-Source: APXvYqzpzPbBNdkztHOhg5atVqEV6ayQFi/1XFUzsE81gTsFNG+Jay6WO4tdKRJ91MFuBRoP65cRJw== X-Received: by 2002:a65:6119:: with SMTP id z25mr32726962pgu.332.1573525071244; Mon, 11 Nov 2019 18:17:51 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:250d:e71d:5a0a:9afe]) by smtp.gmail.com with ESMTPSA id k103sm739924pje.16.2019.11.11.18.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 18:17:50 -0800 (PST) Date: Tue, 12 Nov 2019 11:17:47 +0900 From: Sergey Senozhatsky To: Dmitry Safonov Subject: Re: [PATCH 00/50] Add log level to show_stack() Message-ID: <20191112021747.GA68506@google.com> References: <20191106030542.868541-1-dima@arista.com> <20191106083538.z5nlpuf64cigxigh@pathway.suse.cz> <20191108103719.GB175344@google.com> <20191108130447.h3wfgo4efjkto56f@pathway.suse.cz> <20191111012336.GA85185@google.com> <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13e72b62-c842-8ed5-5b41-bc1692b28f53@arista.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Mailman-Approved-At: Tue, 12 Nov 2019 17:17:43 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juri Lelli , Sergey Senozhatsky , linux-sh@vger.kernel.org, Catalin Marinas , Ben Segall , Guo Ren , Pavel Machek , Vincent Guittot , Paul Burton , Geert Uytterhoeven , Mel Gorman , Jiri Slaby , Matt Turner , uclinux-h8-devel@lists.sourceforge.jp, Petr Mladek , linux-pm@vger.kernel.org, Heiko Carstens , linux-um@lists.infradead.org, Thomas Gleixner , Dietmar Eggemann , Richard Henderson , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, 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 , 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 , Len Brown , 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 Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On (19/11/11 19:47), Dmitry Safonov wrote: [..] > I don't see how bits on task_struct or in per-cpu are easier than > supplying a log level parameter down the stack. > How would it work if sysrq_handle_crash() called by key-press? > How would that interact with deferred printing? > How would it make visible prints from current context, but not from > something that preempted it? [..] per-context log_level works pretty much the same way as per-message log_level. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // static DEFINE_PER_CPU(int, cpu_loglevels[4]); // @INITME.. LOGLEVEL_DEBUG + 1? static int __printing_context(void) { unsigned int preempt = preempt_count(); if (!(preempt & (NMI_MASK | HARDIRQ_MASK | SOFITRQ_OFFSET))) return 0; if (preempt & SOFITRQ_OFFSET) return 1; if (preempt & HARDIRQ_MASK) return 2; return 3; } static int adj_context_loglevel(int level) { int ctx = __printing_context(); int cpu_level = this_cpu_read(cpu_loglevels[ctx]); // this one is important if (level == LOGLEVEL_SCHED) return level; // we are not in emergency context if (cpu_level == LOGLEVEL_DEBUG + 1) return level; // we better not override these if (LOGLEVEL_EMERG <= level && level <= LOGLEVEL_ERR) return level; return cpu_level; } void printk_emergency_enter(int log_level) { int ctx; preempt_disable(); ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], log_level); } void printk_emergency_exit(void) { int ctx = __printing_context(); this_cpu_write(cpu_loglevels[ctx], LOGLEVEL_DEBUG + 1); preempt_enable(); } void vprintk_emit(...) { level = adj_context_loglevel(level); } // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // static void __show_stack(struct task_struct *task, unsigned long *sp) { printk(); ... printk(); } void show_stack(struct task_struct *task, unsigned long *sp, int log_level) { printk_emergency_enter(log_level); __show_stack(task, sp); printk_emergency_exit(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // show_stack() never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count. printk_emergency_enter(log_level) handles every printk() that __show_stack() and friends do. Not worse than printk("%s Stack", lvl); all over the place. > What I'm going to do - is to fix all build and reported issues, I'll > send v2 this week and feel free to NAK it, I will forget about those > patches and won't be offended. Lovely. And - no, I'm not going to NAK platform specific changes. Just so you know. *All* I'm talking about is an alternative, less "go and touch a ton of platform code" approach. The argument "I patched so many files that I'm not even going to discuss anything now" is not productive, to say the least. Hope this clarifies. -ss