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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 263B2C47094 for ; Mon, 7 Jun 2021 20:22:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C9C8E60FE9 for ; Mon, 7 Jun 2021 20:22:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9C8E60FE9 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 6AC246B006E; Mon, 7 Jun 2021 16:22:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 682EB6B0070; Mon, 7 Jun 2021 16:22:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 523D56B0071; Mon, 7 Jun 2021 16:22:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id 2382F6B006E for ; Mon, 7 Jun 2021 16:22:03 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id ABA3B181AF5D8 for ; Mon, 7 Jun 2021 20:22:02 +0000 (UTC) X-FDA: 78228049284.10.E191375 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 19302801A2D0 for ; Mon, 7 Jun 2021 20:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623097261; 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=4jHAMDLlGs26bSzH0EU/HKABFBJg5gt0hKx9CLuP/cc=; b=J+yw9i28imFDhdstS3RJn/hSsHQIgKhTZzMF6/hEPanXPMlvfzVjH1rusOpxXg0DdfeHM5 CuwgyC4hzbIzg517GMDK6EdQHB/joasR2ISk589cka+8vjs0ZenvXkXazVjfCVLlx89BWJ 1J0HrmKzEM1aklbn+ulJKx1I7DVXBRQ= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-6yER6tECPBqm0c9wUxIJDQ-1; Mon, 07 Jun 2021 15:18:41 -0400 X-MC-Unique: 6yER6tECPBqm0c9wUxIJDQ-1 Received: by mail-qk1-f198.google.com with SMTP id y5-20020a37af050000b02903a9c3f8b89fso13336759qke.2 for ; Mon, 07 Jun 2021 12:18:41 -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=4jHAMDLlGs26bSzH0EU/HKABFBJg5gt0hKx9CLuP/cc=; b=SKQ3Gcp7rmycQtjczm9OjTiFunt4EuLD4CuAU/UfJhHd1rl/y/WclEB07DM+mkAPTB Ulg6jTpuw9REHfO5ZP6w2WmzLRDkSwISYplALk4kDhtj/F5tsfne4vO+AtWXpn7I761K aCEQPljRNvWOFVwPED62hWKvgUn8SFiRguk4sfvTeDBmgyXLPoJoJjNxaCxkmFE62gWr 9LJngjPWRWYAP2YK/wGk5qgjpUydxUYS/MbPru5LC/wacyhIZgn/SsIw4F9NkyvM2o0D pSSJXBuTiaycHsvtyxEHrajHEl19ewWPoY5LZy0m0fOagUZw8Cxt9U/7a0Amg+4OOwyL cQFQ== X-Gm-Message-State: AOAM531o9ce6hqRnttU022HNQxT6z3vWeSFPOLdkNJAWHKzJBHJOq/HW fSQ6lTRqAiwS6UV7e0p3gHt5crvlYhbE3EwN8/S1UtxqiuEdT/0GbBGvSNap1QfrhP/CNySfKSW n4IYMbZ/UTn8= X-Received: by 2002:a05:622a:1751:: with SMTP id l17mr3658206qtk.35.1623093520523; Mon, 07 Jun 2021 12:18:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFsfKEokNa3CNprmhCHqjeCDn2h/x/3OTEZAnrZ9lOae/RDFBNo5Tmaul5x2KfbnUkQJlhhg== X-Received: by 2002:a05:622a:1751:: with SMTP id l17mr3658191qtk.35.1623093520279; Mon, 07 Jun 2021 12:18:40 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id z12sm2571178qtq.25.2021.06.07.12.18.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Jun 2021 12:18:39 -0700 (PDT) From: Waiman Long X-Google-Original-From: Waiman Long Subject: Re: [RFC PATCH] mm/oom_kill: allow oom kill allocating task for non-global case To: Michal Hocko , Waiman Long Cc: Shakeel Butt , Aaron Tomlin , Linux MM , Andrew Morton , Vlastimil Babka , LKML References: <20210607163103.632681-1-atomlin@redhat.com> Message-ID: <6d23ce58-4c4b-116a-6d74-c2cf4947492b@redhat.com> Date: Mon, 7 Jun 2021 15:18:38 -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: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J+yw9i28; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of llong@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=llong@redhat.com X-Rspamd-Server: rspam02 X-Stat-Signature: ikzjdh4doxqio9u7ara1i4pi3rspzb4p X-Rspamd-Queue-Id: 19302801A2D0 X-HE-Tag: 1623097264-538541 Content-Transfer-Encoding: quoted-printable 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/7/21 3:04 PM, Michal Hocko wrote: > On Mon 07-06-21 14:51:05, 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 =3D 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 !=3D OOM_SCORE_ADJ_MIN) = { >>>>> get_task_struct(current); >>>>> oc->chosen =3D 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 dominati= ng >>>> 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 kill= ing >> 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 hap= pens >> only within the memcg context, not in a global OOM situation. This pat= ch is >> to allow this process to be killed under this circumstance. > Do you have the oom report? I do not see why the allocating task hasn't > been chosen. A partial OOM report below: [ 8221.433608] memory: usage 21280kB, limit 204800kB, failcnt 49116 =C2=A0 : [ 8227.239769] [ pid ]=C2=A0=C2=A0 uid=C2=A0 tgid total_vm=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 rss pgtables_bytes=20 swapents oom_score_adj name [ 8227.242495] [1611298]=C2=A0=C2=A0=C2=A0=C2=A0 0 1611298=C2=A0=C2=A0=C2= =A0 35869=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 635 167936=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=20 0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -1000 conmon [ 8227.242518] [1702509]=C2=A0=C2=A0=C2=A0=C2=A0 0 1702509=C2=A0=C2=A0=C2= =A0 35869=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 701 176128=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=20 0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -1000 conmon [ 8227.242522] [1703345] 1001050000 1703294=C2=A0=C2=A0 183440=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0=20 2125824=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 999 node [ 8227.242706] Out of memory and no killable processes... [ 8227.242731] node invoked oom-killer: gfp_mask=3D0x6000c0(GFP_KERNEL),=20 nodemask=3D(null), order=3D0, oom_score_adj=3D999 [ 8227.242732] node=20 cpuset=3Dcrio-b8ac7e23f7b520c0365461defb66738231918243586e287bfb9e206bb3a= 0227a.scope=20 mems_allowed=3D0-1 So in this case, node cannot kill itself and no other processes are=20 available to be killed. Cheers, Longman