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=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT 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 7FDE6C433DF for ; Fri, 9 Oct 2020 09:30:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD42222276 for ; Fri, 9 Oct 2020 09:30:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD42222276 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DA2D26B005D; Fri, 9 Oct 2020 05:30:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D533D6B0068; Fri, 9 Oct 2020 05:30:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8F3F6B006C; Fri, 9 Oct 2020 05:30:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 9BA0A6B005D for ; Fri, 9 Oct 2020 05:30:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 34DF38249980 for ; Fri, 9 Oct 2020 09:30:37 +0000 (UTC) X-FDA: 77351866914.15.chess77_24056d5271df Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 0FE7A1814B0C1 for ; Fri, 9 Oct 2020 09:30:37 +0000 (UTC) X-HE-Tag: chess77_24056d5271df X-Filterd-Recvd-Size: 5175 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 9 Oct 2020 09:30:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: rcn) with ESMTPSA id 2F06428DE79 From: =?UTF-8?q?Ricardo=20Ca=C3=B1uelo?= To: akpm@linux-foundation.org Cc: kernel@collabora.com, hch@lst.de, guro@fb.com, rientjes@google.com, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, linux-mm@kvack.org Subject: [PATCH] mm, oom: enable rate-limiting controls for oom dumps Date: Fri, 9 Oct 2020 11:30:14 +0200 Message-Id: <20201009093014.9412-1-ricardo.canuelo@collabora.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 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: Add two sysctl entries (vm.oom_dump_ratelimit and vm.oom_dump_ratelimit_burst) to control the rate limiting interval and burst, respectively, of the OOM killer output (oom_kill_process()). These entries are disabled by default and can be enabled during kernel configuration with CONFIG_DUMP_RATELIMIT. They take DEFAULT_RATELIMIT_INTERVAL and DEFAULT_RATELIMIT_BURST as their default values. Signed-off-by: Ricardo Ca=C3=B1uelo --- In some setups, the amount of output that the OOM killer generates when it kills a process and dumps the list of tasks can be too large. Unfortunately, the rate-limiting used for it uses the default values for the rate limit interval and burst. This patch allows the user to configure these values. I created a new menu selection inside "printk and dmesg options" for this option. Many other parts of the kernel use either hardcoded or default values for the rate limiting parameters. If, in the future, more of these cases need to be parameterized, this new submenu can be used to hold any new config option related to rate limiting. include/linux/oom.h | 2 ++ kernel/sysctl.c | 16 ++++++++++++++++ lib/Kconfig.debug | 13 +++++++++++++ mm/oom_kill.c | 5 +++++ 4 files changed, 36 insertions(+) diff --git a/include/linux/oom.h b/include/linux/oom.h index 2db9a1432511..76c560a1a4c7 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h @@ -127,4 +127,6 @@ extern struct task_struct *find_lock_task_mm(struct t= ask_struct *p); extern int sysctl_oom_dump_tasks; extern int sysctl_oom_kill_allocating_task; extern int sysctl_panic_on_oom; +extern int sysctl_oom_dump_ratelimit; +extern int sysctl_oom_dump_ratelimit_burst; #endif /* _INCLUDE_LINUX_OOM_H */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ce75c67572b9..d348eac7e561 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2708,6 +2708,22 @@ static struct ctl_table vm_table[] =3D { .mode =3D 0644, .proc_handler =3D proc_dointvec, }, +#ifdef CONFIG_OOM_DUMP_RATELIMIT + { + .procname =3D "oom_dump_ratelimit", + .data =3D &sysctl_oom_dump_ratelimit, + .maxlen =3D sizeof(sysctl_oom_dump_ratelimit), + .mode =3D 0644, + .proc_handler =3D proc_dointvec, + }, + { + .procname =3D "oom_dump_ratelimit_burst", + .data =3D &sysctl_oom_dump_ratelimit_burst, + .maxlen =3D sizeof(sysctl_oom_dump_ratelimit_burst), + .mode =3D 0644, + .proc_handler =3D proc_dointvec, + }, +#endif { .procname =3D "overcommit_ratio", .data =3D &sysctl_overcommit_ratio, diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index fde620501707..c57233e56d01 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -195,6 +195,19 @@ config DEBUG_BUGVERBOSE of the BUG call as well as the EIP and oops trace. This aids debugging but costs about 70-100K of memory. =20 +menu "Rate limiting" + +config OOM_DUMP_RATELIMIT + bool "Enable rate limiting for OOM dumps" + default n + help + Say Y here to enable the configuration of the rate limiting of + OOM task dumps to the console through sysctl entries + vm.oom_dump_ratelimit (rate limit interval) and + vm.oom_dump_ratelimit_burst (rate limit burst). + +endmenu # "Rate limiting" + endmenu # "printk and dmesg options" =20 menu "Compile-time checks and compiler options" diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 8b84661a6410..2b3fa826a172 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -54,6 +54,8 @@ int sysctl_panic_on_oom; int sysctl_oom_kill_allocating_task; int sysctl_oom_dump_tasks =3D 1; +int sysctl_oom_dump_ratelimit =3D DEFAULT_RATELIMIT_INTERVAL; +int sysctl_oom_dump_ratelimit_burst =3D DEFAULT_RATELIMIT_BURST; =20 /* * Serializes oom killer invocations (out_of_memory()) from all contexts= to @@ -959,6 +961,9 @@ static void oom_kill_process(struct oom_control *oc, = const char *message) static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); =20 + oom_rs.interval =3D sysctl_oom_dump_ratelimit; + oom_rs.burst =3D sysctl_oom_dump_ratelimit_burst; + /* * If the task is already exiting, don't alarm the sysadmin or kill * its children or threads, just give it access to memory reserves --=20 2.18.0