From patchwork Mon Oct 16 11:31:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13423079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1160CDB465 for ; Mon, 16 Oct 2023 11:31:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1DBC8D0062; Mon, 16 Oct 2023 07:31:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECCE78D0001; Mon, 16 Oct 2023 07:31:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D95058D0062; Mon, 16 Oct 2023 07:31:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CA43C8D0001 for ; Mon, 16 Oct 2023 07:31:31 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A052D1CB648 for ; Mon, 16 Oct 2023 11:31:31 +0000 (UTC) X-FDA: 81351109182.01.4B6A46F Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf24.hostedemail.com (Postfix) with ESMTP id CD532180035 for ; Mon, 16 Oct 2023 11:31:29 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=UAK17UTt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697455889; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=EpO7UHWG7x+hFB0wfvrXA05ahh/RMkrbYcf924Z7adc=; b=XtjjEQ/ildCSUgMjixgD/SBcgh0kE3VvKPFGskmCxwqPEPBzmlpH+qjAv8ioKPaAiSrzxS UpE/MZuy7e59sEXC22oQrqeOEM9fntuaUCoZEZ31ys5XREfQYkEBclQ7KH0KSGn5eOVD1q OAsckBNc3XsG+Ba+zgxJKMOvi1dkP8s= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=UAK17UTt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697455889; a=rsa-sha256; cv=none; b=NeOPU4SjJDIoIFQJL7KCpAYxMPqtf5kvqE1nrHTk7cweke6UxEFIHXhNKy2/jjQXiErWDT jxzosO5fO9DQDRc8TksaN4cn2Q7UglR1+3QtugYV/RPGpbwJt11ZFX2BzqCjwBLynqeMj/ i9hyiX1B+AUU1h8GRiN0Fd42inRHn/k= Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-5a9bc2ec556so1844450a12.0 for ; Mon, 16 Oct 2023 04:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697455888; x=1698060688; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=EpO7UHWG7x+hFB0wfvrXA05ahh/RMkrbYcf924Z7adc=; b=UAK17UTtnEy5xAtApa+Tea1Pu7ffImtS8Cq6H7vWaDpP0J2t/sSW7aAyNTD410zWBo 4j7zMmIDqjbL9pzoiHjuiiLjZeZSQxKjLOmabFMg8aUe7Zh/TeKXWEXxBcaaZAXyRrS6 id58twQb/SnWmZXMcEwf1yiOa2ThynX1xrUaw8AShSxbnUJKlCD59eAVcQw4yvMfpohM 88ZadrdG7mspyDGU3nbInEmu5GxrHzku4qMcsqkkxzU/WaySX3bPFp8Umb61h9Hy0rJ1 Jc7wk/SK6uo2teuZufWAb2VNkGxnBK2lttxNfH65XFXARjANLvdPelSw8XQFmAWnMZj7 QylA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697455888; x=1698060688; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EpO7UHWG7x+hFB0wfvrXA05ahh/RMkrbYcf924Z7adc=; b=Ym9dTBw8cRg20rZVPiSeduWJbVVnEQ1v6xOQmEl6OEbjsl5xqXVg/A+toUhRIXTZN5 0tAQADc6Dbr9T/2mL/MtgrEONrEwFYidArZVtiKs7r4feqpdlVqceaLosSZQ5YHlW2eP mN8p+O7J8ieaznF1w00emoCBI3GxQL9/UdSvDs2ZEK6XhHvNnxTEyjN+qYzVgRVly+AG V7a+rQGai3ZXkMLFy+zdAMCfiZC4ncpmYl2BScPqUOpGdZrjGtD5r+HkhFaDiBRU46Jv FfY11Zwo6E+aNFJHyCLbfZAPxCE4BCPvirkkcocvkDPWY4FL32enuFSPU89uwTsq6FVu Bbew== X-Gm-Message-State: AOJu0YzuGjz7F7rVSOj+9oJ6EhhWLxum8k4NS9bP6GMLCfArKNSuQT2Z 2gYHS/gGR7SFQheo7Em7ZZH7jI9oC9mlBF7n X-Google-Smtp-Source: AGHT+IGsJwcM79xIzMPvgvu/0hugjG+89HhYNiH7N/zVvPvIm2thCm/8iFKgqbhaYhK4LAd00bMyXA== X-Received: by 2002:a17:90a:17a8:b0:27d:52b:99ac with SMTP id q37-20020a17090a17a800b0027d052b99acmr11613237pja.7.1697455887828; Mon, 16 Oct 2023 04:31:27 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([103.7.29.31]) by smtp.gmail.com with ESMTPSA id nt3-20020a17090b248300b00262ca945cecsm4523868pjb.54.2023.10.16.04.31.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 16 Oct 2023 04:31:27 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Christian Brauner , Michal Hocko , Suren Baghdasaryan , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH] mm/oom_killer: simplify OOM killer info dump helper Date: Mon, 16 Oct 2023 19:31:03 +0800 Message-ID: <20231016113103.86477-1-ryncsn@gmail.com> X-Mailer: git-send-email 2.42.0 Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CD532180035 X-Stat-Signature: utwfc5bmjaaoze7ekkiycxap944cx7g6 X-HE-Tag: 1697455889-676939 X-HE-Meta: U2FsdGVkX1+YSzhVd6xRfk2mYfxtcg0FrEHPD0bum/pmZne9NjVOJBbFf058EoaB+MEzD+L92zBEfT+zHnfVUopilRoqQYSH2BVkPaXl8AyhL0+Zh0l3YIG3zNC6xcduJJPxk+hCSFyzd2K00kNSndjEEfq9cWvv4muiNAS23hoh9Niq1kKHa5C731/icbQWmR6Wt+V1/oUtdiuMlaYKFPA+XTmjSjMwz/UBGRq/FANG2SVtpqU2V0rIuSPST0Bd1t+wOKxPtXbMc8TL4DB594EIxQ6NqSOH1SH5lTL/+hwNesFANCLMePoi8ug7NrcD4PtKrbY3Q0Ah9TOZ3aQVc4FghZpjbX5W08ZoSfeGNuXojtHT0CMy5gZj05rwqK0KuUPdSQ22AqDIe6ZsmzYIAr5WkPWA+ca/z3bd7R+pnIMO1Yf0Sb/sPsD7k6dFwVFGZtbJ7QWXonVnKprZvS0wx8G0IV9YZt/Eu0d8zRtXvfS1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QbYhMcnMtVmBi5iuZxINlAShGRt9DU/H+iLNHFMFfSKxRZzuUZbI1eN8UyQ/monDgKr69515PtIatrNZNRcj7zFHbdYwskboMCwTI3hlSi+BTo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000017, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Kairui Song There is only one caller wants to dump the kill victim info, so just let it call the standalone helper, no need to make the generic info dump helper take an extra argument for that. Result of bloat-o-meter: ./scripts/bloat-o-meter ./mm/oom_kill.old.o ./mm/oom_kill.o add/remove: 0/0 grow/shrink: 1/2 up/down: 131/-142 (-11) Function old new delta oom_kill_process 412 543 +131 out_of_memory 1422 1418 -4 dump_header 562 424 -138 Total: Before=21514, After=21503, chg -0.05% Signed-off-by: Kairui Song Acked-by: Michal Hocko --- mm/oom_kill.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 44bde56ecd02..9e6071fde34a 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -437,7 +437,7 @@ static void dump_tasks(struct oom_control *oc) } } -static void dump_oom_summary(struct oom_control *oc, struct task_struct *victim) +static void dump_oom_victim(struct oom_control *oc, struct task_struct *victim) { /* one line summary of the oom killer context. */ pr_info("oom-kill:constraint=%s,nodemask=%*pbl", @@ -449,7 +449,7 @@ static void dump_oom_summary(struct oom_control *oc, struct task_struct *victim) from_kuid(&init_user_ns, task_uid(victim))); } -static void dump_header(struct oom_control *oc, struct task_struct *p) +static void dump_header(struct oom_control *oc) { pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n", current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order, @@ -467,8 +467,6 @@ static void dump_header(struct oom_control *oc, struct task_struct *p) } if (sysctl_oom_dump_tasks) dump_tasks(oc); - if (p) - dump_oom_summary(oc, p); } /* @@ -1029,8 +1027,10 @@ static void oom_kill_process(struct oom_control *oc, const char *message) } task_unlock(victim); - if (__ratelimit(&oom_rs)) - dump_header(oc, victim); + if (__ratelimit(&oom_rs)) { + dump_header(oc); + dump_oom_victim(oc, victim); + } /* * Do we need to kill the entire memory cgroup? @@ -1072,7 +1072,7 @@ static void check_panic_on_oom(struct oom_control *oc) /* Do not panic for oom kills triggered by sysrq */ if (is_sysrq_oom(oc)) return; - dump_header(oc, NULL); + dump_header(oc); panic("Out of memory: %s panic_on_oom is enabled\n", sysctl_panic_on_oom == 2 ? "compulsory" : "system-wide"); } @@ -1155,7 +1155,7 @@ bool out_of_memory(struct oom_control *oc) select_bad_process(oc); /* Found nothing?!?! */ if (!oc->chosen) { - dump_header(oc, NULL); + dump_header(oc); pr_warn("Out of memory and no killable processes...\n"); /* * If we got here due to an actual allocation at the