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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 51394C48BE8 for ; Sun, 13 Jun 2021 23:47:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D2E6161370 for ; Sun, 13 Jun 2021 23:47:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2E6161370 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3D1506B0036; Sun, 13 Jun 2021 19:47:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3805E6B006E; Sun, 13 Jun 2021 19:47:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 248D56B0070; Sun, 13 Jun 2021 19:47:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id E5FAB6B0036 for ; Sun, 13 Jun 2021 19:47:52 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4C874A8D7 for ; Sun, 13 Jun 2021 23:47:52 +0000 (UTC) X-FDA: 78250340784.09.D42F617 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf17.hostedemail.com (Postfix) with ESMTP id 5A2A841AD7B6 for ; Sun, 13 Jun 2021 23:47:46 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id z3-20020a17090a3983b029016bc232e40bso9093071pjb.4 for ; Sun, 13 Jun 2021 16:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=4++lM/c5yuFezao0v/U58iKYZqak4/2YPsi6jthi/MU=; b=u8qk9ovErk+yiRsO1K7EN2usvRMWNFKFdUfVoGMl1WvFo6M7EsTp2V//cxltF69Via IQltky9u/ZvWFmfRgky/wUTBjPx3AWS036M8pvXCnmVNzgKX7KDNn18Z3MEGiXO374vj 4L+MC1GFlhcqDTbCCzNn0HZmKfisGY/fBokJTP696RN244cMyn+tEspvbOf5DIboi1Hb nCmT1/dDqq5wRp3KIf4/wVvRzTW1mm3SODX1WxfYVrWwueDL/Hrz1nq5EsBeDRCJcsWr VFIrnUzBmjQ6KYukM19zW8HlkBVQMnBFFrzSS+luS/Y2ORVllbkjUD7+3CN6n7NhLgpd uiqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=4++lM/c5yuFezao0v/U58iKYZqak4/2YPsi6jthi/MU=; b=F8MwBgED+OG2BC8md3x4mI5VEt3D2yp7Zo1wSwhFJz93K0HQSfhKYJoI5aCotltul6 S+IqeTny8B+tFwkjxlvYVyd3FcrvRzeTklo0+YDX9zT8ieY3G4fEa0CWdFh5ikmoChsy 6HSFMef+gujDN+xnxNrAIJA2PO74E8GbcGby2y64YZrz5dOIKyYHqMh7Sw7yK5iniuX1 2JIgs87AGAaDJVwiS06gOo36j8cKQ8w2CPJXTCULrTyUWrRsFUhA/SA4wZvW2iYJFFKn SkPZYhq6Ddr22wy+3jAesVj7hTrWN2JxcaLHpXZgn5WFhi1J5eZYZVbmyNBOcqieG7h3 q0rw== X-Gm-Message-State: AOAM531hTMypDWxcFnlFAVIn6ErHdLSue69NYpZP0+qVTQkS9hgfuYB2 9roWaeZchtHJCVSw9VmQLUlPDA== X-Google-Smtp-Source: ABdhPJyL3rXVwtBroZkchCFGQh1DDDu76JX+VN/SjqFUHcThf3l8wb3D04Gb3OX6YXdk8pQf3m05Vw== X-Received: by 2002:a17:90b:3696:: with SMTP id mj22mr21233255pjb.124.1623628070809; Sun, 13 Jun 2021 16:47:50 -0700 (PDT) Received: from [2620:15c:17:3:da04:749c:4915:4eee] ([2620:15c:17:3:da04:749c:4915:4eee]) by smtp.gmail.com with ESMTPSA id t14sm11208701pgm.9.2021.06.13.16.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 16:47:50 -0700 (PDT) Date: Sun, 13 Jun 2021 16:47:49 -0700 (PDT) From: David Rientjes To: Aaron Tomlin cc: linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com, penguin-kernel@i-love.sakura.ne.jp, llong@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/oom_kill: show oom eligibility when displaying the current memory state of all tasks In-Reply-To: <20210612204634.1102472-1-atomlin@redhat.com> Message-ID: <6fc8beef-4dbb-b49a-4653-90fe564941a6@google.com> References: <20210612204634.1102472-1-atomlin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=u8qk9ovE; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of rientjes@google.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=rientjes@google.com X-Stat-Signature: 3kuaiy48muf53dgk4y1cj6dua3gf4439 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5A2A841AD7B6 X-HE-Tag: 1623628066-951500 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, 12 Jun 2021, Aaron Tomlin wrote: > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > index eefd3f5fde46..094b7b61d66f 100644 > --- a/mm/oom_kill.c > +++ b/mm/oom_kill.c > @@ -160,6 +160,27 @@ static inline bool is_sysrq_oom(struct oom_control *oc) > return oc->order == -1; > } > > +/** > + * is_task_eligible_oom - determine if and why a task cannot be OOM killed > + * @tsk: task to check > + * > + * Needs to be called with task_lock(). > + */ > +static const char * is_task_oom_eligible(struct task_struct *p) You should be able to just return a char. > +{ > + long adj; > + > + adj = (long)p->signal->oom_score_adj; > + if (adj == OOM_SCORE_ADJ_MIN) > + return "S"; The value is already printed in the task dump, this doesn't look to add any information. > + else if (test_bit(MMF_OOM_SKIP, &p->mm->flags) > + return "R"; We should be doing the task dump only when we're killing a victim (unless we're panicking), so something else has been chosen. Since we would have oom killed a process with MMF_OOM_SKIP already, can we simply choose to not print a line for this process? > + else if (in_vfork(p)) > + return "V"; Is this a transition state that we can simply disregard from the output as well unless/until it becomes eligible? > + else > + return ""; > +} > + > /* return true if the task is not adequate as candidate victim task. */ > static bool oom_unkillable_task(struct task_struct *p) > { > @@ -401,12 +422,13 @@ 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("[%7d] %5d %5d %8lu %8lu %8ld %8lu %5hd %13s %s\n", 13 characters for one char output? > 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), > get_mm_counter(task->mm, MM_SWAPENTS), > - task->signal->oom_score_adj, task->comm); > + task->signal->oom_score_adj, is_task_oom_eligible(task), > + task->comm); > task_unlock(task); > > return 0; > @@ -420,12 +442,13 @@ static int dump_task(struct task_struct *p, void *arg) > * memcg, not in the same cpuset, or bound to a disjoint set of mempolicy nodes > * are not shown. > * State information includes task's pid, uid, tgid, vm size, rss, > - * pgtables_bytes, swapents, oom_score_adj value, and name. > + * pgtables_bytes, swapents, oom_score_adj value, oom eligibility status > + * and name. > */ > 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 swapents oom_score_adj name\n"); > + pr_info("[ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj oom eligible? name\n"); Field names are single words. > > if (is_memcg_oom(oc)) > mem_cgroup_scan_tasks(oc->memcg, dump_task, oc);