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=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 97F77C54FCB for ; Thu, 23 Apr 2020 13:28:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3D79A2073A for ; Thu, 23 Apr 2020 13:28:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D79A2073A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=i-love.sakura.ne.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C94FC8E0005; Thu, 23 Apr 2020 09:28:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C44ED8E0003; Thu, 23 Apr 2020 09:28:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5B498E0005; Thu, 23 Apr 2020 09:28:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 9F2148E0003 for ; Thu, 23 Apr 2020 09:28:48 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4A273824805A for ; Thu, 23 Apr 2020 13:28:48 +0000 (UTC) X-FDA: 76739199936.03.anger78_4cac90ac48651 X-HE-Tag: anger78_4cac90ac48651 X-Filterd-Recvd-Size: 7912 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Apr 2020 13:28:46 +0000 (UTC) Received: from fsav108.sakura.ne.jp (fsav108.sakura.ne.jp [27.133.134.235]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 03NDS1Z7065890; Thu, 23 Apr 2020 22:28:01 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav108.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav108.sakura.ne.jp); Thu, 23 Apr 2020 22:28:01 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav108.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 03NDS0NV065883 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Apr 2020 22:28:01 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [nacked] mm-oom-avoid-printk-iteration-under-rcu.patch removed from -mm tree To: Michal Hocko , Yafang Shao Cc: Andrew Morton , Roman Gushchin , linux-mm , David Rientjes , Shakeel Butt , Sergey Senozhatsky , Petr Mladek , Steven Rostedt References: <20200417152637.GQ26707@dhcp22.suse.cz> <68371d79-dfae-e9b9-38df-dbb916607a82@i-love.sakura.ne.jp> <20200420073305.GD27314@dhcp22.suse.cz> <041d4158-f3dc-a5b5-546e-dd3f71f67b5f@i-love.sakura.ne.jp> <20200422065950.GA30312@dhcp22.suse.cz> <0aa5e490-c5b8-dc5c-334e-9a8d37da215c@i-love.sakura.ne.jp> <20200423073438.GC4206@dhcp22.suse.cz> <20200423110707.GD4206@dhcp22.suse.cz> From: Tetsuo Handa Message-ID: Date: Thu, 23 Apr 2020 22:28:00 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200423110707.GD4206@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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: On 2020/04/23 20:07, Michal Hocko wrote: > The existing loglevels we use are not really carved in stone and we can > prioritize some more than others. dump_tasks is KERN_INFO already and > this is quite a low priority so you shouldn't really miss much when > omitting it. But I wouldn't mind making it KERN_DEBUG. Do you mean - pr_info("[%7d] %5d %5d %8lu %8lu %8ld %8lu %5hd %s\n", + pr_debug("[%7d] %5d %5d %8lu %8lu %8ld %8lu %5hd %s\n", in order to suppress printing to consoles? Wow! That will also suppress saving to log files because syslog daemon is likely configured not to sav= e KERN_DEBUG level messages. >> - tune the dump_tasks specifically =EF=BC=88vm.oom_dump_tasks=EF=BC=89 >> All the consumers are effected. >> The logfile is fast enough, so we expect that these dump_tasks could >> be printed into the logfile. >> The console is so slow that we don't want to print into it. >> A possilbe way to fix it is improve vm.oom_dump_tasks. >> vm.oom_dump_tasks : 1 - dump into all consumers >> 2 - don't dump into console >> 0 - don't dump into any of >=20 > How would that be implemented. I do not know of a way to tell printk > which consoles to use for the output. Anyway, isn't this something > that can be configured on the printk level. In other words send only > important information to slow consoles? Last year I proposed https://lkml.kernel.org/r/1550896930-12324-1-git-send-email-penguin-kerne= l@I-love.SAKURA.ne.jp and Sergey Senozhatsky commented "This is a bit of a strange issue, to be honest. If OOM prints too many messages then we might want to do some work on the OOM side." . I was thinking that printing to consoles is a requirement for oom_dump_= tasks . If we can agree with not printing dump_tasks() output to consoles, a triv= ial patch shown below will solve the problem. Those who cannot run syslog dae= mon in userspace might disagree, but this will be the simplest answer. include/linux/kern_levels.h | 3 +++ include/linux/printk.h | 1 + kernel/printk/printk.c | 7 ++++++- mm/oom_kill.c | 7 ++++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/linux/kern_levels.h b/include/linux/kern_levels.h index bf2389c26ae3..cd69a9cb3c2a 100644 --- a/include/linux/kern_levels.h +++ b/include/linux/kern_levels.h @@ -23,6 +23,9 @@ */ #define KERN_CONT KERN_SOH "c" =20 +/* Annotation for "don't print to consoles". */ +#define KERN_NO_CONSOLES KERN_SOH "S" + /* integer equivalents of KERN_ */ #define LOGLEVEL_SCHED -2 /* Deferred messages from sched code * are set to this special level */ diff --git a/include/linux/printk.h b/include/linux/printk.h index e061635e0409..da338b81c2e1 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -19,6 +19,7 @@ static inline int printk_get_level(const char *buffer) switch (buffer[1]) { case '0' ... '7': case 'c': /* KERN_CONT */ + case 'S': /* KERN_NO_CONSOLES */ return buffer[1]; } } diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 9a9b6156270b..ed51641af087 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -361,6 +361,7 @@ static int console_msg_format =3D MSG_FORMAT_DEFAULT; */ =20 enum log_flags { + LOG_NO_CONSOLES =3D 1, /* don't print to consoles */ LOG_NEWLINE =3D 2, /* text ended with a newline */ LOG_CONT =3D 8, /* text is a fragment of a continuation line */ }; @@ -1959,6 +1960,9 @@ int vprintk_store(int facility, int level, break; case 'c': /* KERN_CONT */ lflags |=3D LOG_CONT; + break; + case 'S': /* KERN_NO_CONSOLES */ + lflags |=3D LOG_NO_CONSOLES; } =20 text_len -=3D 2; @@ -2453,7 +2457,8 @@ void console_unlock(void) break; =20 msg =3D log_from_idx(console_idx); - if (suppress_message_printing(msg->level)) { + if ((msg->flags & LOG_NO_CONSOLES) || + suppress_message_printing(msg->level)) { /* * Skip record we have buffered and already printed * directly to the console when we received it, and diff --git a/mm/oom_kill.c b/mm/oom_kill.c index dfc357614e56..0b487c13a2c9 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -400,7 +400,7 @@ static int dump_task(struct task_struct *p, void *arg= ) return 0; } =20 - pr_info("[%7d] %5d %5d %8lu %8lu %8ld %8lu %5hd %s\n", + pr_info(KERN_NO_CONSOLES "[%7d] %5d %5d %8lu %8lu %8ld %8lu %5h= d %s\n", task->pid, from_kuid(&init_user_ns, task_uid(task)), task->tgid, task->mm->total_vm, get_mm_rss(task->mm), mm_pgtables_bytes(task->mm), @@ -423,8 +423,9 @@ static int dump_task(struct task_struct *p, void *arg= ) */ static void dump_tasks(struct oom_control *oc) { - pr_info("Tasks state (memory values in pages):\n"); - pr_info("[ pid ] uid tgid total_vm rss pgtables_bytes swapent= s oom_score_adj name\n"); + pr_info_once("Tasks state is sent to syslog.\n"); + pr_info(KERN_NO_CONSOLES "Tasks state (memory values in pages):\n"); + pr_info(KERN_NO_CONSOLES "[ pid ] uid tgid total_vm rss pgtab= les_bytes swapents oom_score_adj name\n"); =20 if (is_memcg_oom(oc)) mem_cgroup_scan_tasks(oc->memcg, dump_task, oc);