Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3730479rdg; Wed, 18 Oct 2023 04:37:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8vXn9h7IoKnQbDjFDUeH0BjXR8I1Cw1ao2eyT7+bQ9/2de88kUH31hTtQDoKP2oZnmTT3 X-Received: by 2002:a05:6870:15:b0:1e9:c252:4853 with SMTP id a21-20020a056870001500b001e9c2524853mr4957436oaa.5.1697629052864; Wed, 18 Oct 2023 04:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697629052; cv=none; d=google.com; s=arc-20160816; b=iGOARbPLcPCiyHvm5IF9ycdNko8TB9BrHZ6lR4k/R3uC1ZXmyJb3YA5ic6zqokum+D HCQxjNQvkJ9lqBvDCanCszwQQjticLU1HNfgyC7jWblw1SmqZLiIgk6tZcCfkZI0qm14 nGR0xbOUPR0j6faFh5IvSbCBdaiUJYmSUrO8aQRpdn2z7xyhNfWJ7LtmJ3J7qx5/gDwc tcM1k2OokKCHPZp/Kcqf0Ro8q6NoNhZMERblcl7EU3kUpX5/NEo6izxdjI/Rb3MM2Ztm cHB2Ierr2Vc75ImAqWJlaldGSJA/V3I+JR+ikGd94JS0ARpPamuJ0CbTnk9FkgyfcCoc wqBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fIRiXBPL7Hak/bdjYHHvjv0yyYXIySVMFM3XCbnxNDU=; fh=xE6HsrCrJ0l1/B5ObOEIPq65/KzhLSxyPFF1T9PU3Gs=; b=rC/jthcf55i4YWTM46MwDB3t0SjKnMsJNNMpuRqW+txqCN1/pe73XAQFYB5ESTK6K4 4iY0UpZJW0dhnqj1GH/JvoyGyd3FIUebJXG6ZxtlBO0OH8baku7AikgmWA/Iv0RBhpf0 mWA/m5hvWWQsnANpoXftKmhIw46EKkADMQTgl+DEezCXb+b4JlzNhNE1uiM1kvgbxLdy frbVWsLNl2wOH/yqBH2LZzfPMiA1hUKazqQP0GovxYDQ0RWI5WaR7kWIBR8QG5Q4Yr+q UVBCEW5l0vHG5nmpcCfStj2kc1BPj8hECbhQU3nE7F2mKGurCv+y+lk69DWcXQmANCcF CsKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=oy+2Yhqs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id t4-20020a63f344000000b005778df5647dsi1860299pgj.401.2023.10.18.04.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 04:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=oy+2Yhqs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 89110817296C; Wed, 18 Oct 2023 04:37:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229690AbjJRLhV (ORCPT + 99 others); Wed, 18 Oct 2023 07:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjJRLhU (ORCPT ); Wed, 18 Oct 2023 07:37:20 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15080FE for ; Wed, 18 Oct 2023 04:37:18 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 359921FD6F; Wed, 18 Oct 2023 11:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1697629036; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fIRiXBPL7Hak/bdjYHHvjv0yyYXIySVMFM3XCbnxNDU=; b=oy+2Yhqsw+VpnlGmcnaP87XLdexh64fnz9buU1Ckkiaif84HeGj3ahsDJL39+5S/vNpuZp dHzuNmsJiyDADqBNF8YpuYBlBBnj+OzalbRRtx1NZpJDRULQ5KFQuG4C5V3HH27lnpYJS4 CYX1LAJM/fsLXH56OxvsB1666mr/BhY= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1709A13915; Wed, 18 Oct 2023 11:37:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MGCbAmzDL2UhdQAAMHmgww (envelope-from ); Wed, 18 Oct 2023 11:37:16 +0000 Date: Wed, 18 Oct 2023 13:37:15 +0200 From: Michal Hocko To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , Christian Brauner , Suren Baghdasaryan , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/oom_killer: simplify OOM killer info dump helper Message-ID: <3hjarpoab5paboraql2ibgqb7hexj2n2fog7rctwgintrvlu24@kwljdjthirws> References: <20231016113103.86477-1-ryncsn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231016113103.86477-1-ryncsn@gmail.com> Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 1.50 X-Spamd-Result: default: False [1.50 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_SPAM(5.10)[100.00%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[6]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 04:37:30 -0700 (PDT) On Mon 16-10-23 19:31:03, Kairui Song wrote: > 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 Thanks! > --- > 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 > -- > 2.42.0 -- Michal Hocko SUSE Labs