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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 9C379C47094 for ; Mon, 7 Jun 2021 19:05:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7202A61185 for ; Mon, 7 Jun 2021 19:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbhFGTHC (ORCPT ); Mon, 7 Jun 2021 15:07:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbhFGTHA (ORCPT ); Mon, 7 Jun 2021 15:07:00 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61BC3C061766 for ; Mon, 7 Jun 2021 12:05:00 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id e2so23689131ljk.4 for ; Mon, 07 Jun 2021 12:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=584/gWVYBmFQLj3IQ5zyJ4dNtEgEGoArMTADKdS4gTk=; b=p3L92naUFwi467EouA6JNCUQ4u8umdXEj3NG5PyEzPzphb+xmuCHY/zFXNnB+bKsOw zPVvblzivgT2Q68UNRrqJWbfJtnXmsLY1VDwKjpyK+9wECPAohRm0SbjJ6Q9RKPu6Vyl gS+z01ttu3j4Z34XZxiub1BSXOTC4sTCvxfn5i84oEB4nWYdXBSV1i5r6CiTZMf/foB5 PEMDjSNA2Lg8m0BQBDTGsHMYrZ2DCz9paW5JRhHHhU1KBzzL2jhyLo3hBAl+QT9ic7O2 S8M4oObpIxS86CoxCQMgOwX3JSwwRn+tnV+wx8DF/8Fh2rKLusj+dGL/G74ubmv2Os79 UNYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=584/gWVYBmFQLj3IQ5zyJ4dNtEgEGoArMTADKdS4gTk=; b=qzIYTQ0cEkCF5j8H5LXKC80QRojVIX0bJykqidL03vKYo1wPpHUDGmHcmKisSTHdnl UR2o9KHjCcigQ6WcvzivvjbLU5t9rGR2jLM5HcMqjhZTlIwkSn+VnvHFl15cH1oeXOz6 87vawi3WiLw5LUMW+7pcogHALQDzVNN8WSx0IA4FQkeeYbe4YJ/8yhFAP69oOYHRt01I aqyHqKB4wVQNtTgWkFHTFY5MZrnq+xo/B9ZE0l4mDpXbfCyfASxYtURl/jWxHkpD616c tnBFBqFTFexjkNhN5ba4/388JAyliTDCZt8QPUsvlTpbpBrforyFz1Ja2eAaX78l9Ul+ T5jg== X-Gm-Message-State: AOAM531UF94p0Qn77NATTcN1+1gU5xszAmjacXU1YIY9r4JBmQ41pNwx ZRpH1yN5YHxA1rPXGqFDhT38vVnAst/bcSOfri4gLjLPzOKHMA== X-Google-Smtp-Source: ABdhPJzEwN4BlseyqFQcJajb/NDLov6wrlyFqwxTzjDUEUqd3pWDJjwZZIfZBi8HNeR0LzFyGqbeh6qhJTEc6fBoBko= X-Received: by 2002:a05:651c:b1f:: with SMTP id b31mr16143742ljr.0.1623092698491; Mon, 07 Jun 2021 12:04:58 -0700 (PDT) MIME-Version: 1.0 References: <20210607163103.632681-1-atomlin@redhat.com> In-Reply-To: From: Shakeel Butt Date: Mon, 7 Jun 2021 12:04:47 -0700 Message-ID: Subject: Re: [RFC PATCH] mm/oom_kill: allow oom kill allocating task for non-global case To: Waiman Long Cc: Aaron Tomlin , Linux MM , Andrew Morton , Vlastimil Babka , Michal Hocko , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 7, 2021 at 11:51 AM Waiman Long wrote: > > On 6/7/21 2:43 PM, Shakeel Butt wrote: > > On Mon, Jun 7, 2021 at 9:45 AM Waiman Long wrote: > >> On 6/7/21 12:31 PM, Aaron Tomlin wrote: > >>> At the present time, in the context of memcg OOM, even when > >>> sysctl_oom_kill_allocating_task is enabled/or set, the "allocating" > >>> task cannot be selected, as a target for the OOM killer. > >>> > >>> This patch removes the restriction entirely. > >>> > >>> Signed-off-by: Aaron Tomlin > >>> --- > >>> mm/oom_kill.c | 6 +++--- > >>> 1 file changed, 3 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c > >>> index eefd3f5fde46..3bae33e2d9c2 100644 > >>> --- a/mm/oom_kill.c > >>> +++ b/mm/oom_kill.c > >>> @@ -1089,9 +1089,9 @@ bool out_of_memory(struct oom_control *oc) > >>> oc->nodemask = NULL; > >>> check_panic_on_oom(oc); > >>> > >>> - if (!is_memcg_oom(oc) && sysctl_oom_kill_allocating_task && > >>> - current->mm && !oom_unkillable_task(current) && > >>> - oom_cpuset_eligible(current, oc) && > >>> + if (sysctl_oom_kill_allocating_task && current->mm && > >>> + !oom_unkillable_task(current) && > >>> + oom_cpuset_eligible(current, oc) && > >>> current->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) { > >>> get_task_struct(current); > >>> oc->chosen = current; > >> To provide more context for this patch, we are actually seeing that in a > >> customer report about OOM happened in a container where the dominating > >> task used up most of the memory and it happened to be the task that > >> triggered the OOM with the result that no killable process could be > >> found. > > Why was there no killable process? What about the process allocating > > the memory or is this remote memcg charging? > > It is because the other processes have a oom_adjust_score of -1000. So > they are non-killable. Anyway, they don't consume that much memory and > killing them won't free up that much. > > The other process that uses most of the memory is the one that trigger > the OOM kill in the first place because the memory limit has been > reached in new memory allocation. Based on the current logic, this > process cannot be killed at all even if we set the > oom_kill_allocating_task to 1 if the OOM happens only within the memcg > context, not in a global OOM situation. I am not really against the patch but I am still not able to understand why select_bad_process() was not able to select the current process. mem_cgroup_scan_tasks() traverses all the processes in the target memcg hierarchy, so why the current was skipped. > This patch is to allow this > process to be killed under this circumstance. > > Cheers, > Longman > 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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 5E3E4C47094 for ; Mon, 7 Jun 2021 21:50:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EE917610A2 for ; Mon, 7 Jun 2021 21:50:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE917610A2 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 81F556B006C; Mon, 7 Jun 2021 17:50:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CE126B006E; Mon, 7 Jun 2021 17:50:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 647AC6B0070; Mon, 7 Jun 2021 17:50:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id 3458D6B006C for ; Mon, 7 Jun 2021 17:50:24 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CD3F51AEE4 for ; Mon, 7 Jun 2021 21:50:23 +0000 (UTC) X-FDA: 78228271926.26.A8DC8B3 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by imf17.hostedemail.com (Postfix) with ESMTP id 2BA1440002A4 for ; Mon, 7 Jun 2021 21:50:18 +0000 (UTC) Received: by mail-lf1-f45.google.com with SMTP id j2so1128514lfg.9 for ; Mon, 07 Jun 2021 14:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=584/gWVYBmFQLj3IQ5zyJ4dNtEgEGoArMTADKdS4gTk=; b=p3L92naUFwi467EouA6JNCUQ4u8umdXEj3NG5PyEzPzphb+xmuCHY/zFXNnB+bKsOw zPVvblzivgT2Q68UNRrqJWbfJtnXmsLY1VDwKjpyK+9wECPAohRm0SbjJ6Q9RKPu6Vyl gS+z01ttu3j4Z34XZxiub1BSXOTC4sTCvxfn5i84oEB4nWYdXBSV1i5r6CiTZMf/foB5 PEMDjSNA2Lg8m0BQBDTGsHMYrZ2DCz9paW5JRhHHhU1KBzzL2jhyLo3hBAl+QT9ic7O2 S8M4oObpIxS86CoxCQMgOwX3JSwwRn+tnV+wx8DF/8Fh2rKLusj+dGL/G74ubmv2Os79 UNYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=584/gWVYBmFQLj3IQ5zyJ4dNtEgEGoArMTADKdS4gTk=; b=dQ0AxrKbbQ16P+1FUv+sJiuTSwTmYr+6Tyf850+5Hyk3OY9rNsglbeedGGEt8TojiW XkFYYSGepu5oWqIFurDyUfOP+f/NM8Td34DOPhb9hsnOmLGUoCagf3nMUCs5hzep8ncM 8pS7WMpLD+B6WPB+gI+n/Dk3nzdIJhkNXlER5NlB9eHdl1ecsYsQUWmqt7sGjGEZecV7 M+nbv3hnvckx1q0fpC+5xOAgrfN+N1C5CEcWmgdT9ca4rZrSjQOIPdqJC82f3o+bDN9/ YGJELQP+3d/Q/A+l72VyvsloDUaeCIgDJtDgf5Gu8VK42lIGOSaJZ/S2waH2+FNgT/Cn E9CQ== X-Gm-Message-State: AOAM530hmYOBYC4QxYGOcKUXDYNBXjy/0whWaz3h71tAOTLOyoCg668g WlYO4NN5gDWiENESxphXUMtfknv81ltqhuuGTfCD1niS+5AdEg== X-Google-Smtp-Source: ABdhPJzEwN4BlseyqFQcJajb/NDLov6wrlyFqwxTzjDUEUqd3pWDJjwZZIfZBi8HNeR0LzFyGqbeh6qhJTEc6fBoBko= X-Received: by 2002:a05:651c:b1f:: with SMTP id b31mr16143742ljr.0.1623092698491; Mon, 07 Jun 2021 12:04:58 -0700 (PDT) MIME-Version: 1.0 References: <20210607163103.632681-1-atomlin@redhat.com> In-Reply-To: From: Shakeel Butt Date: Mon, 7 Jun 2021 12:04:47 -0700 Message-ID: Subject: Re: [RFC PATCH] mm/oom_kill: allow oom kill allocating task for non-global case To: Waiman Long Cc: Aaron Tomlin , Linux MM , Andrew Morton , Vlastimil Babka , Michal Hocko , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2BA1440002A4 X-Stat-Signature: 69j1uagtd1ic5uyx4an95awwg14fery3 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=p3L92naU; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of shakeelb@google.com designates 209.85.167.45 as permitted sender) smtp.mailfrom=shakeelb@google.com X-HE-Tag: 1623102618-111855 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 Mon, Jun 7, 2021 at 11:51 AM Waiman Long wrote: > > On 6/7/21 2:43 PM, Shakeel Butt wrote: > > On Mon, Jun 7, 2021 at 9:45 AM Waiman Long wrote: > >> On 6/7/21 12:31 PM, Aaron Tomlin wrote: > >>> At the present time, in the context of memcg OOM, even when > >>> sysctl_oom_kill_allocating_task is enabled/or set, the "allocating" > >>> task cannot be selected, as a target for the OOM killer. > >>> > >>> This patch removes the restriction entirely. > >>> > >>> Signed-off-by: Aaron Tomlin > >>> --- > >>> mm/oom_kill.c | 6 +++--- > >>> 1 file changed, 3 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c > >>> index eefd3f5fde46..3bae33e2d9c2 100644 > >>> --- a/mm/oom_kill.c > >>> +++ b/mm/oom_kill.c > >>> @@ -1089,9 +1089,9 @@ bool out_of_memory(struct oom_control *oc) > >>> oc->nodemask = NULL; > >>> check_panic_on_oom(oc); > >>> > >>> - if (!is_memcg_oom(oc) && sysctl_oom_kill_allocating_task && > >>> - current->mm && !oom_unkillable_task(current) && > >>> - oom_cpuset_eligible(current, oc) && > >>> + if (sysctl_oom_kill_allocating_task && current->mm && > >>> + !oom_unkillable_task(current) && > >>> + oom_cpuset_eligible(current, oc) && > >>> current->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) { > >>> get_task_struct(current); > >>> oc->chosen = current; > >> To provide more context for this patch, we are actually seeing that in a > >> customer report about OOM happened in a container where the dominating > >> task used up most of the memory and it happened to be the task that > >> triggered the OOM with the result that no killable process could be > >> found. > > Why was there no killable process? What about the process allocating > > the memory or is this remote memcg charging? > > It is because the other processes have a oom_adjust_score of -1000. So > they are non-killable. Anyway, they don't consume that much memory and > killing them won't free up that much. > > The other process that uses most of the memory is the one that trigger > the OOM kill in the first place because the memory limit has been > reached in new memory allocation. Based on the current logic, this > process cannot be killed at all even if we set the > oom_kill_allocating_task to 1 if the OOM happens only within the memcg > context, not in a global OOM situation. I am not really against the patch but I am still not able to understand why select_bad_process() was not able to select the current process. mem_cgroup_scan_tasks() traverses all the processes in the target memcg hierarchy, so why the current was skipped. > This patch is to allow this > process to be killed under this circumstance. > > Cheers, > Longman >