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=-8.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 EB8B5C433E3 for ; Tue, 14 Jul 2020 14:30:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 90C452083B for ; Tue, 14 Jul 2020 14:30:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="IE8CQ4st" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90C452083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chrisdown.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0C91F6B0002; Tue, 14 Jul 2020 10:30:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 052536B0003; Tue, 14 Jul 2020 10:30:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5C646B0005; Tue, 14 Jul 2020 10:30:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id CEA036B0002 for ; Tue, 14 Jul 2020 10:30:25 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8DA2F246B for ; Tue, 14 Jul 2020 14:30:25 +0000 (UTC) X-FDA: 77036916810.19.frogs38_2710ddc26ef1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 568041ACC32 for ; Tue, 14 Jul 2020 14:30:23 +0000 (UTC) X-HE-Tag: frogs38_2710ddc26ef1 X-Filterd-Recvd-Size: 4483 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jul 2020 14:30:22 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id bm28so15401392edb.2 for ; Tue, 14 Jul 2020 07:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DwoqQiQgz2icOHfm2Qdts4XWsM9VKDGxbpW+Umz3xCk=; b=IE8CQ4st2EimgM7j7DI5EQo+VsGYw6M9IU6tjoh+cxXr/zCnq7ZW9B2TgVNpbPslix lrskPomXUpMfOQwMNdrswRAwEIGXzrwXjRD7bU12YitNijR5MTuM9lhLpAIWR8E5Nb2i W5Y0+9mS+NUiU3Ahif/iCJWZgyrK+VmeOphTg= 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:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DwoqQiQgz2icOHfm2Qdts4XWsM9VKDGxbpW+Umz3xCk=; b=egIBExa1CTjlWmRTFpq5qGQhEzcIggmNL4c4mcHKKd2p+tUmMJ8/M60kVxHv1lZIcP wYLxzmoy0eHtYuBFGxGmy2j/1s65H2ZDK6mXN/DnMr6izjLJFC09a+oAUotItTCsBWOZ NQjHMBjqf+9vhCxO7bhGuyp3y4mc9OBop6Gea/n/UlQd0+DMRi7vXymY3dbkJK8YEK4a XH4FHrUN3jaaLzrnYTN0JoAK8lfzkCUorid8br9Mw15QSTqIM0xFps/JyeMS3TkYnIEK 47WIerDbkzy8lpA8yuAeUkNWKN2iK04aEX1mSdJ3Si5ah62cAs+NsYnEX6tuACKek6Zt BTKA== X-Gm-Message-State: AOAM531PPdlcptQ/sak5z1HlMj/ij05QY1lsSwEjPYYKQQURMSxLfHFJ sqz+HKs27Ux3UcL3TQ7dm3Hthw== X-Google-Smtp-Source: ABdhPJyzdYcvNYjJylELeSQTto32b4hz3CxPOyB0+LwLpeXsA0UhrUqMbJOthF2WUp/adGrJKlEZIw== X-Received: by 2002:aa7:da06:: with SMTP id r6mr4881802eds.189.1594737021484; Tue, 14 Jul 2020 07:30:21 -0700 (PDT) Received: from localhost ([2620:10d:c093:400::5:6f85]) by smtp.gmail.com with ESMTPSA id cd11sm12592317ejb.57.2020.07.14.07.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 07:30:19 -0700 (PDT) Date: Tue, 14 Jul 2020 15:30:18 +0100 From: Chris Down To: Yafang Shao Cc: mhocko@kernel.org, penguin-kernel@i-love.sakura.ne.jp, rientjes@google.com, akpm@linux-foundation.org, hannes@cmpxchg.org, linux-mm@kvack.org Subject: Re: [PATCH v2] memcg, oom: check memcg margin for parallel oom Message-ID: <20200714143018.GB2080@chrisdown.name> References: <1594735034-19190-1-git-send-email-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1594735034-19190-1-git-send-email-laoar.shao@gmail.com> User-Agent: Mutt/1.14.6 (2020-07-11) X-Rspamd-Queue-Id: 568041ACC32 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: Yafang Shao writes: >Memcg oom killer invocation is synchronized by the global oom_lock and >tasks are sleeping on the lock while somebody is selecting the victim or >potentially race with the oom_reaper is releasing the victim's memory. >This can result in a pointless oom killer invocation because a waiter >might be racing with the oom_reaper > > P1 oom_reaper P2 > oom_reap_task mutex_lock(oom_lock) > out_of_memory # no victim because we have one already > __oom_reap_task_mm mute_unlock(oom_lock) > mutex_lock(oom_lock) > set MMF_OOM_SKIP > select_bad_process > # finds a new victim > >The page allocator prevents from this race by trying to allocate after >the lock can be acquired (in __alloc_pages_may_oom) which acts as a last >minute check. Moreover page allocator simply doesn't block on the >oom_lock and simply retries the whole reclaim process. > >Memcg oom killer should do the last minute check as well. Call >mem_cgroup_margin to do that. Trylock on the oom_lock could be done as >well but this doesn't seem to be necessary at this stage. > >[mhocko@kernel.org: commit log] >Suggested-by: Michal Hocko >Signed-off-by: Yafang Shao >Cc: Michal Hocko >Cc: Tetsuo Handa >Cc: David Rientjes >Cc: Johannes Weiner Good catch, thanks. Acked-by: Chris Down