Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp618693ybz; Fri, 24 Apr 2020 06:30:42 -0700 (PDT) X-Google-Smtp-Source: APiQypKnL1VahHvMLkxGg50XSyHYMZ1wKGtgJWhlS/1BD4bJIY3yuIs/+TWX4xIg2wCX+cI1v0CA X-Received: by 2002:a17:906:6d95:: with SMTP id h21mr7141088ejt.66.1587735041934; Fri, 24 Apr 2020 06:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587735041; cv=none; d=google.com; s=arc-20160816; b=i5tin8uvoh9H4D435oX21qo4bYrIyWXDU5DklLA08ZDYWmtwf2rj5tJ2T8w4O39W4i WallWbuY5wKOK+GmBhfH4j4O0OyLMM+YrPsZolb5g1i5VSV9zESkcMDlX7QIcqDctE49 8UAcMS4PtDH7sKgJUf0eda2fL0jxSIPyXPjzwviic/jm+VKpH2TzloaRO+j6SLVoNsGI fTN+0j0kjV1+17/XLob44HJHAyLgXFe2VzGhr+2mTq9yn6ldADJME6H5lSOHfzsV+20l jlk7Cqun42ovU5yV4J2bMdA0SCcGUUsD1Q/ghSD1qZnBJppVWbYcjA4GhzBu1+JGQLyJ 7vDg== 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:subject:cc:to:from:date; bh=3KLBS1OJReftftQTSAa61IEHPIZSeo8Q5Kt7u8BBano=; b=Se2X2MZZg3SCM5Eil2ITew+uVgYyXxxe5tMwT74XPU6wgs7cCIsgFppCxphjNf33lr i/ESUcMTbQqFUQ8RV+8tGm5Qu2JvVEy6qyToJcWzIHehCd08IeSYq6GEyAx19PRFBURJ uPZRxYUlJf5ZB8riIaduqCt37/NEBHDLH1Uj/tjySdPkByDMmEha4BwN1pzEdI2oEtGM /JyVbtjBSi+ginRcj6Fxu13u+NXlPlHOoLWbxaBDh5vdnGTdhgkkcS/m6VrJxd9DNerd 1FWlTYh7/C91Nbzg471FUEazJLCrnupqnZxpe1tzyPOcl3JL0kRNklnuH5Tk2LZYp2R4 UGYw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si3089625ejt.267.2020.04.24.06.30.16; Fri, 24 Apr 2020 06:30:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726813AbgDXN2T (ORCPT + 99 others); Fri, 24 Apr 2020 09:28:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:40034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726301AbgDXN2T (ORCPT ); Fri, 24 Apr 2020 09:28:19 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 C91E8205C9; Fri, 24 Apr 2020 13:28:17 +0000 (UTC) Date: Fri, 24 Apr 2020 09:28:16 -0400 From: Steven Rostedt To: Tetsuo Handa Cc: Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Dmitry Safonov , Michal Hocko , Yafang Shao Subject: Re: [PATCH] printk: Add loglevel for "do not print to consoles". Message-ID: <20200424092816.62a61b1d@gandalf.local.home> In-Reply-To: <20200424024239.63607-1-penguin-kernel@I-love.SAKURA.ne.jp> References: <20200424024239.63607-1-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 Apr 2020 11:42:39 +0900 Tetsuo Handa wrote: > Since dump_tasks() is capable of generating thousands of printk() lines, > it can significantly delay solving OOM situation by killing a process > via the OOM killer. There is /proc/sys/vm/oom_dump_tasks which allows > suppressing dump_tasks(), but those who diagnose the reason of OOM need > dump_tasks() in order to understand memory usage as of invocation of the > OOM killer. Therefore, setting /proc/sys/vm/oom_dump_tasks to 0 cannot be > an option. Also, since userspace syslog daemon is likely configured not > to save low (e.g. KERN_DEBUG) loglevels, reducing loglevel used by > dump_tasks() cannot be an option. We want to maintain current loglevels > in order to allow saving kernel messages to log files while we also want > to avoid delays caused by printing to consoles due to maintaining current > loglevels. > > While an attempt to make printk() asynchronous (i.e. defer printing to > consoles) and an attempt to make printk() to print to only selected > consoles (i.e. don't print unimportant messages to slow consoles) are > in progress, there are printk() callers where saving to log files is > useful for later analysis but printing to consoles for immediate > notification makes little sense. Two examples of such printk() callers > will be the OOM killer and memory allocation failure messages. Therefore, > this patch introduces a loglevel KERN_NO_CONSOLES which prevents all > consoles from printing such messages. > > Since both KERN_NO_CONSOLES messages and !KERN_NO_CONSOLES messages are > stored into common printk buffer, KERN_NO_CONSOLES messages will be > retrievable from the vmcore file even if something bad (e.g. NULL pointer > dereference) followed. Therefore, as long as a system is configured for > later analysis, ability to suppress printing to consoles will be useful. > Since Dmitry Safonov is working on adding loglevel argument to > show_stack(), we will in near future be able to control whether > dump_stack() output is important enough to immediately print to consoles, > by adding loglevel argument to dump_stack(). > Please no. What I would suggest doing is create your own buffer to store the output. Then use the seq_buf() operations and such to print to that buffer, and then be able to read that output from something like a debug filesystem, or some user space daemon that will write to syslog. I do not want 'silent' writes to the printk buffer. It's bad enough that it gets blown away by systemd. -- Steve