Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1110724pxy; Sun, 1 Aug 2021 13:03:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNsFi84t6YcVk6SiNU4DVIIFmQhTZDtboM90KaucuNwDX4TjVVZAvQAUKlHJf3cvMIJuP7 X-Received: by 2002:a17:906:4894:: with SMTP id v20mr12096136ejq.207.1627848184750; Sun, 01 Aug 2021 13:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627848184; cv=none; d=google.com; s=arc-20160816; b=B4mCkQDPg4ov+EzeELiVdUB8+LuEFFHw3hdI1sSCaKIZwRzQkHNM25Kdj171xXWJ9r 8wD0RI3VpMHcE8aqc8NOgepUdh73qZWR9R9Ys/4NM4yB4QzrdG2PPHs9S9s/bxijabY/ 6h3jYslQdlU8apfdiclpR+c1pgcC+3GYXhqSOOFZO6Wb22yemlft1D6dRW0UEaHLDjNR nx46lEphBMoWMg9GwuHFR+R33dj4eZZay5R0mX5P12xw1k910Y//9cdDrGv7WzV/Osk2 uohDc/Vi3cFm3tJobwJ6CYlJzOikx2PsYXAmepjD/0dtA0/pFlXb8sFdCJdVR15d5IlU K/aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=P+Keefqstv9F9KqwpqETp7eZtvTQKoAdBV6iY9Sb4P4=; b=OEJABDtZY7N1milvHKlWktCiSssMED8hwXR7b9KLXb8lebrWK6ply4/R/Fz22xFI4c 2MTzWE+GgvplwvxYLQ6a2v6NtU3BEmiib43Zfd/NHSzZaQ/luVaHMnlBJ3ZJs9mRA9JE McYs2XJpZ9SWuVZsrvJ0GU+ZcK2CTg6EBEtnDkI/AuGeUh6ncLb8mL48N8ob7V88OQer /VdnnMC8QaG22C3sYKMmNTzbTlSFvs/smxNdivgZvuYvzxkBqjZVob8k8BqoKIh9Foll XhROr/xPtCGWyHQwmE5NL+VuG80Vo23qB9uXepdsAXhCJ7RYFw7PyLid4FVNMPXNWDgb Gc1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="o9Z3/wzG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si8153547ejz.566.2021.08.01.13.02.38; Sun, 01 Aug 2021 13:03:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="o9Z3/wzG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229759AbhHAUBZ (ORCPT + 99 others); Sun, 1 Aug 2021 16:01:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:58608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhHAUBZ (ORCPT ); Sun, 1 Aug 2021 16:01:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BD40960295; Sun, 1 Aug 2021 20:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1627848075; bh=eoI/lcpTJDM3BlN7k4F+GYLHJpUesmWkh7ZzPTwAucY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=o9Z3/wzGq/uvJ2DnqAIVbljcfylaXEPGbNUzxMGwzl++/PbCsuvsxQlKorhZkRGH5 iL0Her5jHsMK07Xb6CnxWFMv6LBFXW8MRBt9NroPc6pXCM/NTW/Xay2zfv+aLc9udq Nkv6RAkO28r6puTmeS7dAzTOS983KHUa8LRjrTYI= Date: Sun, 1 Aug 2021 13:01:15 -0700 From: Andrew Morton To: Aaron Tomlin Cc: linux-mm@kvack.org, mhocko@suse.com, penguin-kernel@i-love.sakura.ne.jp, rientjes@google.com, llong@redhat.com, neelx@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] mm/oom_kill: show oom eligibility when displaying the current memory state of all tasks Message-Id: <20210801130115.da6d5cd1d635b21315bcd995@linux-foundation.org> In-Reply-To: <20210730162002.279678-1-atomlin@redhat.com> References: <20210730162002.279678-1-atomlin@redhat.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Jul 2021 17:20:02 +0100 Aaron Tomlin wrote: > Changes since v2: > - Use single character (e.g. 'R' for MMF_OOM_SKIP) as suggested > by Tetsuo Handa > - Add new header to oom_dump_tasks documentation > - Provide further justification > > > The output generated by dump_tasks() can be helpful to determine why > there was an OOM condition and which rogue task potentially caused it. > Please note that this is only provided when sysctl oom_dump_tasks is > enabled. > > At the present time, when showing potential OOM victims, we do not > exclude any task that are not OOM eligible e.g. those that 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 be misleading) to the > viewer. 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. > > This patch provides a clear indication with regard to the OOM ineligibility > (and why) of each displayed task with the addition of a new column namely > "oom_skipped". An example is provided below: > > [ 5084.524970] [ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj oom_skipped name > [ 5084.526397] [660417] 0 660417 35869 683 167936 0 -1000 M conmon > [ 5084.526400] [660452] 0 660452 175834 472 86016 0 -998 pod > [ 5084.527460] [752415] 0 752415 35869 650 172032 0 -1000 M conmon > [ 5084.527462] [752575] 1001050000 752575 184205 11158 700416 0 999 npm > [ 5084.527467] [753606] 1001050000 753606 183380 46843 2134016 0 999 node > [ 5084.527581] Memory cgroup out of memory: Killed process 753606 (node) total-vm:733520kB, anon-rss:161228kB, file-rss:26144kB, shmem-rss:0kB, UID:1001050000 > > So, a single character 'M' is for OOM_SCORE_ADJ_MIN, 'R' MMF_OOM_SKIP and > 'V' for in_vfork(). > > index 003d5cc3751b..4c79fa00ddb3 100644 > --- a/Documentation/admin-guide/sysctl/vm.rst > +++ b/Documentation/admin-guide/sysctl/vm.rst > @@ -650,8 +650,9 @@ oom_dump_tasks > Enables a system-wide task dump (excluding kernel threads) to be produced > when the kernel performs an OOM-killing and includes such information as > pid, uid, tgid, vm size, rss, pgtables_bytes, swapents, oom_score_adj > -score, and name. This is helpful to determine why the OOM killer was > -invoked, to identify the rogue task that caused it, and to determine why > +score, oom eligibility status and name. This is helpful to determine why > +the OOM killer was invoked, to identify the rogue task that caused it, and > +to determine why It would be better if the meaning of 'M', 'R' and 'V' were described here. > the OOM killer chose the task it did to kill. > > +/** > + * 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 * const is_task_oom_eligible(struct task_struct *p) Name seems inappropriate. task_oom_eligibility()? > +{ > + long adj; > + > + adj = (long)p->signal->oom_score_adj; > + if (adj == OOM_SCORE_ADJ_MIN) > + return "M"; > + else if (test_bit(MMF_OOM_SKIP, &p->mm->flags) > + return "R"; > + else if (in_vfork(p)) > + return "V"; > + else > + return ""; > +}