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=-3.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 E07B0C2BA19 for ; Fri, 24 Apr 2020 00:56:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 967FA2074F for ; Fri, 24 Apr 2020 00:56:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NqsYGdZl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 967FA2074F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5AF188E0005; Thu, 23 Apr 2020 20:56:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55F058E0003; Thu, 23 Apr 2020 20:56:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 477508E0005; Thu, 23 Apr 2020 20:56:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 309358E0003 for ; Thu, 23 Apr 2020 20:56:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DF877824805A for ; Fri, 24 Apr 2020 00:56:54 +0000 (UTC) X-FDA: 76740933948.20.salt31_76865ef63b049 X-HE-Tag: salt31_76865ef63b049 X-Filterd-Recvd-Size: 10228 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Apr 2020 00:56:54 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id w4so8617184ioc.6 for ; Thu, 23 Apr 2020 17:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3Bw0eD4ceE/FzaHgY78UlhdiLOY+eYVZTifJcWLKy9U=; b=NqsYGdZl2lXNbmiePjzA8/L1/+eiYjOili786g0ILe8toRZXvM4hDkkupZtuuAcvHy vywy1Lyh4D4Qg79c4e2xUpDTXYUlbSWbhWX22c6s+XTgOTlEAG7zy89CEENuTgjeVS53 kPXuST4ufNOq2dWFcggQaWizfjJBccsVMJt85KJFn6Q+KpE6J4c2jFCErynaPRttWKG8 U1LW3lAcHwJgz3bR3re9kBqxsXvswIM/4xSEJUQLWAlzp/03bPYxdp9lt5dgB7yiSNfO cVNWv5g+Qkd2bLuJViy67AHmKtn/doe7SuGTQklJJUvIcAHgvLhMsLXgxy+UwkdD9iYN W22g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3Bw0eD4ceE/FzaHgY78UlhdiLOY+eYVZTifJcWLKy9U=; b=a+NwczBrE8zRRM1Ednr+XTFq+uZpBlX1KDu0FmScJNtnsBbHFD/0pzDufOxPwaNl8K Dha7bMLsON/OaiLsYnJk83oXlZ+d3jxSfUFBXUvlp4yjlSTMUWFO5c60bvMQMFCN7Ub4 6qfuB9ikv4ZWBzV5BIU2NI0e3C48KeaZWxp/HRcmZoNJMmZloPQFD8dMe1IFAEbXU721 jszAbRI+Mlk6kvzgOqwVqzOE49+ALaaV++hDhXQBWE3K4TnTKyMQsuFpSWc0gvmOJv0J ImjDsdG/LmArxzMsGqEgBi8IaovZvwsIijGwul1EmziYSy04+y1RuB/qVa5dGM7dOPTr tUSA== X-Gm-Message-State: AGi0PuY5O+vLJlROGsK5xkuPvR0em2rUNWxtYKRpQsOygFvJGojm4iFe b1eWPjDN3Coq073/QdcXf/zORiuf9ZV9O+aIOcI= X-Google-Smtp-Source: APiQypKNx/pVyZ3csV2IneWY0k+sudPtvS/pbtvRBhJ8ilK6nSg99zf78W/VfD0sQ+2B3+acRcqwxYVMdb1p3jn9H30= X-Received: by 2002:a05:6602:199:: with SMTP id m25mr6376107ioo.13.1587689813769; Thu, 23 Apr 2020 17:56:53 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Yafang Shao Date: Fri, 24 Apr 2020 08:56:17 +0800 Message-ID: Subject: Re: [nacked] mm-oom-avoid-printk-iteration-under-rcu.patch removed from -mm tree To: Tetsuo Handa Cc: Michal Hocko , Andrew Morton , Roman Gushchin , linux-mm , David Rientjes , Shakeel Butt , Sergey Senozhatsky , Petr Mladek , Steven Rostedt Content-Type: text/plain; charset="UTF-8" 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 Thu, Apr 23, 2020 at 9:28 PM Tetsuo Handa wrote: > > 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 > > > > 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" > > +/* 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 c= ode > * 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; > */ > > 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; > } > > text_len -=3D 2; > @@ -2453,7 +2457,8 @@ void console_unlock(void) > break; > > 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 print= ed > * directly to the console when we received it, a= nd > 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; > } > > - pr_info("[%7d] %5d %5d %8lu %8lu %8ld %8lu %5hd %s\n", > + pr_info(KERN_NO_CONSOLES "[%7d] %5d %5d %8lu %8lu %8ld %8lu = %5hd %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 s= wapents 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= pgtables_bytes swapents oom_score_adj name\n"); > > if (is_memcg_oom(oc)) > mem_cgroup_scan_tasks(oc->memcg, dump_task, oc); > > I suggest to set KERN_NO_CONSOLES by default but the user can tune it back to the original behavior. I'm not a fan of sysctl, but if there's no better chioce, enhancing vm.oom_dump_tasks seems a possible solution. --=20 Thanks Yafang