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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 54048C48BE0 for ; Fri, 11 Jun 2021 17:42:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CBC08613D3 for ; Fri, 11 Jun 2021 17:42:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CBC08613D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0B0FE6B0036; Fri, 11 Jun 2021 13:42:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0610F6B006C; Fri, 11 Jun 2021 13:42:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1D286B006E; Fri, 11 Jun 2021 13:42:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id AAB856B0036 for ; Fri, 11 Jun 2021 13:42:54 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 46939824999B for ; Fri, 11 Jun 2021 17:42:54 +0000 (UTC) X-FDA: 78242163468.16.1FB4BE9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 15FAFE000240 for ; Fri, 11 Jun 2021 17:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623433373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tq2VBJnTIL88nOgXkv2qw+Gup4yecCG4S2LWVtxNUDY=; b=b+V//17w8r096DG/JkY7dGDw/dvlXHh8uqWGCPpEnVh52PSMvB5ZXpQ2Jqy1RRcScGZvKU 4NJ/5GmFEVXroSACWlW+xh3By7rbXYyJSKl6cnI/gs6KlYfMnQrp8khv15XiwpUkhrIevk IOYNoG0IIsGRGanjYJjSB4b4YURLC8M= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-357-UJKrZ00xOPCnUW0WEVXzbg-1; Fri, 11 Jun 2021 13:42:52 -0400 X-MC-Unique: UJKrZ00xOPCnUW0WEVXzbg-1 Received: by mail-qv1-f69.google.com with SMTP id jm5-20020ad45ec50000b0290219dc9a1ab8so12606863qvb.21 for ; Fri, 11 Jun 2021 10:42:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Tq2VBJnTIL88nOgXkv2qw+Gup4yecCG4S2LWVtxNUDY=; b=LSKUs55axfyQsEQd60aGhJMxK+sbFXPiKGkKmAEOXjEv8dBHV2WZn6R7LEZJgSlyHH AAIZyPMI/nGR9I2N9N/Pyqh2JIH4euLKTo3w3cA1L+WsINWhZmE71EveyfMjTAPEv1SX biLRFRJ8rZN/Wo3ovlBHL/sB/Ot3wdUrz+58eN74m+bXRLz+h0ZsV/bxIP5I7BxpzomX hcZcJKD5B3X/bKI4kTdQMJvluoEadSla/UflrPT2XXpu1IWKo91yFIe9b8TiQ5PZuakL VQVcGG0jZuR/luSN5aWVL9dfU/CkuVVUrt1rP56jOXLNUAehmyCNxKz8LOt6ogIOOGR2 0nRA== X-Gm-Message-State: AOAM530meqNtFortWhfh3BIJVZ2CZLVmWT9BHnCEvAoE5ud7xS1EfyUn R0DBiE4Kgg68UaOTYu9pdDrmqN2v7rfV8Y7NGEjenizHp5A/Xu6WV7+tr3Fk5Ib3oHCkVj3U2/W pd9GWLHfR8XY= X-Received: by 2002:a05:6214:485:: with SMTP id ay5mr6025820qvb.6.1623433371727; Fri, 11 Jun 2021 10:42:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw79EIrxZh/eiep6ybHh0EA4qzUqCVzfw/jlsk5p45EmzeUqCeC8P5eD5hAcohWzas3AXoHGQ== X-Received: by 2002:a05:6214:485:: with SMTP id ay5mr6025805qvb.6.1623433371505; Fri, 11 Jun 2021 10:42:51 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id f5sm4679772qkm.124.2021.06.11.10.42.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Jun 2021 10:42:50 -0700 (PDT) From: Waiman Long X-Google-Original-From: Waiman Long Subject: Re: [RFC PATCH] mm/oom_kill: show oom eligibility when displaying the current memory state of all tasks To: Aaron Tomlin , linux-mm@kvack.org Cc: 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 References: <20210611171940.960887-1-atomlin@redhat.com> Message-ID: Date: Fri, 11 Jun 2021 13:42:49 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210611171940.960887-1-atomlin@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 15FAFE000240 X-Stat-Signature: 7magt4d9ojy8149apjrxnk56ic91ucwa Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="b+V//17w"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf30.hostedemail.com: domain of llong@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=llong@redhat.com X-HE-Tag: 1623433369-45531 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 6/11/21 1:19 PM, Aaron Tomlin wrote: > At the present time, when showing potential OOM victims, we do not > exclude tasks which already have MMF_OOM_SKIP set; it is possible that > the last OOM killable victim was already OOM killed, yet the OOM > reaper failed to reclaim memory and set MMF_OOM_SKIP. > This can be confusing/or perhaps even misleading, to the reader of the > OOM report. Now, we already unconditionally display a task's > oom_score_adj_min value that can be set to OOM_SCORE_ADJ_MIN which is > indicative of an "unkillable" task i.e. is not eligible. > > This patch provides a clear indication with regard to the OOM > eligibility of each displayed task. > > Signed-off-by: Aaron Tomlin > --- > mm/oom_kill.c | 31 +++++++++++++++++++++++++++---- > 1 file changed, 27 insertions(+), 4 deletions(-) > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > index eefd3f5fde46..70781d681a6e 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) > +{ > + long adj; > + > + adj = (long)p->signal->oom_score_adj; > + if (adj == OOM_SCORE_ADJ_MIN) > + return "no: oom score"; > + else if (test_bit(MMF_OOM_SKIP, &p->mm->flags) > + return "no: oom reaped"; > + else if (in_vfork(p)) > + return "no: in vfork"; > + else > + return "yes"; > +} > + > /* 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 %-15s %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), > 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 eligible 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"); A minor nit: "oom eligible?" has 13 characters. The field width is 15. Maybe you should pad 2 more spaces to make the proper alignment. Cheers, Longman