From patchwork Wed Mar 15 07:03:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haifeng Xu X-Patchwork-Id: 13175443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4938C6FD1D for ; Wed, 15 Mar 2023 07:03:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C9B6B007B; Wed, 15 Mar 2023 03:03:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12CFB6B007D; Wed, 15 Mar 2023 03:03:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F36BA8E0001; Wed, 15 Mar 2023 03:03:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E32686B007B for ; Wed, 15 Mar 2023 03:03:43 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A315BA3BEB for ; Wed, 15 Mar 2023 07:03:43 +0000 (UTC) X-FDA: 80570242326.25.A990601 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf17.hostedemail.com (Postfix) with ESMTP id CB7E240010 for ; Wed, 15 Mar 2023 07:03:41 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=OAZCgCrS; dmarc=pass (policy=reject) header.from=shopee.com; spf=pass (imf17.hostedemail.com: domain of haifeng.xu@shopee.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=haifeng.xu@shopee.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678863821; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=FpjEne9c/P1n+FoVmzWers86k2xzuSbdMk7FyOXv2PE=; b=i/hPgINfT/svJy6ipJ+ODG7YwGXug2qr/9np0NFCoehtU2enu9My8NuVyNYOjkyncId9uG 7XUW+ofDiVob2XckCJOYdUpB5ro1WsuYVdy/AMsBei/vLlPsLsDbdJUT7uEuZRZSM810Q7 z+HPIfhTudmvMHGRNCE2aGGMlFbYnIE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=OAZCgCrS; dmarc=pass (policy=reject) header.from=shopee.com; spf=pass (imf17.hostedemail.com: domain of haifeng.xu@shopee.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=haifeng.xu@shopee.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678863821; a=rsa-sha256; cv=none; b=LhYpeSAkuTXLCNkaxnN2n3ZR/1NgfRwFi9ZffE/X20gw7YhdgwIvUfy5f3eDvlDfwZBGuE pVw3S8AdUALGU2qn1iGgyZxuvT04+tOUV5DzX2klV7GzlQOhEY5WUPw1DhOiIFymA+SYdN Tu2v/v0aHa6Q9t2ampbtz5bgqJo7ggY= Received: by mail-pg1-f174.google.com with SMTP id s17so10230793pgv.4 for ; Wed, 15 Mar 2023 00:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1678863820; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FpjEne9c/P1n+FoVmzWers86k2xzuSbdMk7FyOXv2PE=; b=OAZCgCrSIApq/wMfToqOvFw+w05e7Doc09CdtGnAZ0mqEpgqc9uid2e5n6I0OnYyT9 ji/ZWoFjyPKcY7/Tryduo3EkyXkxZGRaqPn9K1vRTE428IXJ645jmi8fy/eGctizmUsI 2OM96XR8DgpW4U49bJKOr2G2bFqPx2YLs79ghV3qzKPfu0y6RyE9KvdZrkSjmBfelh33 46udJXAaieKWiz28NKWCbXBlq/bszTr48/Bnu1pm5jY9oE9wFL/ysK2UVjtBNKszcDRy Qx0N8asibaT2bkmmI0/4h/Q3kO6eTDxEYvST23vqHMURUUtD4DoOiCqVpcG8Dfrhz+Ru mhTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678863820; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FpjEne9c/P1n+FoVmzWers86k2xzuSbdMk7FyOXv2PE=; b=yBuNzhVLj+2aF63N8dS54GE8fkmzT3qN98hxQcJZmprzuWrqXbq02fMyOHvOG7c3py lgzGGiNA/dSKUiUZonMYXiDaj6NeRKeN68HU7fpTgnSGq6SdMOO+bF4LxVFXEZI64fmK UvymxKaLhirBLSxRFPNqgUHpoG4wiGPBMCg2w+A9yBaDTaFvjTByeAst8UjQBijgTTgf /8jVDbRUzKfHRJ7+WhbNRynrDyVLR+v57F7TQd23BZWRKuBiHfd3d8Bbkv8JL7e/GlWE vCmfFLwu2JzVAK7xgON3rZklS8PxASQQ3qKZ3Ryz9aVF2cJkw/A/+rshLsiQvDQSCf6D PBEw== X-Gm-Message-State: AO0yUKUDntv2wPw9uQLiQ1sTJwDkLeDdHSGfe2WrBnCO0hdleLdYX4Os CDv8hzfJP3MRiEjp4QcAHLGmig== X-Google-Smtp-Source: AK7set96UMPzJLhEUy2mCh6b7CazuoYGL6GJ771LlC6SyR641dqjNw7Z2Nw7HIi1VRZMtvP8oHMxWg== X-Received: by 2002:a62:5f46:0:b0:625:55e5:afe4 with SMTP id t67-20020a625f46000000b0062555e5afe4mr4396384pfb.26.1678863820478; Wed, 15 Mar 2023 00:03:40 -0700 (PDT) Received: from ubuntu-haifeng.default.svc.cluster.local ([101.127.248.173]) by smtp.gmail.com with ESMTPSA id z22-20020aa791d6000000b005ac8a51d591sm2731495pfa.21.2023.03.15.00.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 00:03:40 -0700 (PDT) From: Haifeng Xu To: mhocko@kernel.org Cc: hannes@cmpxchg.org, shakeelb@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Haifeng Xu Subject: [RFC] memcg, oom: clean up mem_cgroup_oom_synchronize Date: Wed, 15 Mar 2023 07:03:02 +0000 Message-Id: <20230315070302.268316-1-haifeng.xu@shopee.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: CB7E240010 X-Stat-Signature: fku3hbrhr4iwjfg4kz11upnmhdiu7s78 X-HE-Tag: 1678863821-665558 X-HE-Meta: U2FsdGVkX1/C+Y4fJCsWGo+pEfRwmLNQlz8dWe9qyKU5D6yG7uVAV5q6oWUo1qDiAXwu/IKcTN7/sHAsSOhjhpJyirchoN3hgHdxrFaNnH0BikN7kxUbEqRlqyErU7zB4iHxQNiwYto2/VzEs3fLJIz/HsfI3TdTs60wZTGD3kFfOHGpkDvQleEIiR/Zh5BUpHHnq+lmZ22TmMl+/4TMepJ5opXMvriz+Bl54l8NC6uVcIcWo63EMqS0Zvs3Fqu9kNsK3S8vw2xDgxBD+5vthkFGoTI/QXtc5uKT5xsCjssedVsavmGfY7FAsr+nosIE1hpVp0PdfwXZHngyhgLKB4bZ1i2ELslrrnRGhipfF+hXh0DmsqoNEs98DDCbtSatoRQoMgt3dn72GhCkVZ7iOJbkXLNuSYedC75kpie5h4QjYwJ9y1Vf0mCBVPJAj5Q6jERUNARtzxugUuM6n0xfzhZoqt57foPYHgWnsxwXS2VWBiQjxQIb+JdLRouI2hQoVsWwYiP+l66usmjgA6BM/F8frbQ49utpTDHmqMPX6vYF8atIXS8FES0EGUQ2h1sNTeDiMlXgaNdbukgSrpcVKEY82LBurQ/D2iDQVBe2nweYx9veIA3w+wARzfwyeXqhDE57C5crgOIrkM13dXkvH0xulqEP1xQOF8SqSv8TifZIqEjX2OMsO3MbRWbOw8Ade+8giGpXpfF4Dhoc+zIXwCsvCRqM6AmhDGOuBw3bHEiAHJEc8Mg2qTjd6vcOU9Ej6sOCIxaV4CdbEm0yEkwNMGtEzkeqhvPyG0YDstT7GDEgIdjewbgnZXP7+UMs9vl+ABHfFWKZ22O4vRMwt9LxnN7MS6x58uT7tM8RFulIvGlpVS99ae0oyrHmGI2KN8rv1wi7SXtEg+O1M1gudqPZ6X5Fk21IM307pFhRs1QY2iFQo9Jh+5jWnA1UckhrloNKk9zc6mTvY2IRvvFE817 mA1KS18S 6xHzvqZi1J3QoD2m4ohRLI/ooOXU50GRCd5LZKcOindIcZIB/V3REE91wsChHFr84tU/FvZN62HP1pRVedK53ptLsrT4xgy4J5+oKXLqavPQmy222mO1AtebSFujkkJ3TuE86zfEzpkBi2lYXL//xYFacS2Irrhi7FJEzy/YnL7gjoACGYz+yi4MslpWVSiH9VGx/AKTbfFALASIn0Bhj/oFusOqYITZBlEhEHa8fCaVxh/4q5Iuht6fycCixXInUCiEWa1uNNQjwuHwFCp4RqiIA3ibzEmzkE+q2IbvNGk/VJnLtVv1r8JcE6o4Smtc9XJWOzYYQz0CYjdhY/MECqGeoPFBKGJBaQP/zBksGJfVDZQZEea4EmvBSMX5nilMNl6luEYLRL41V5GNhlo/Jg0M3NVvQIhoekIFBz47DMtXr4K+iAm46pJ897BgjpQY98HjUzr4xJ8lcYYOZ69N+M4REXA== 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: Since commit 29ef680ae7c2 ("memcg, oom: move out_of_memory back to the charge path"), only oom_kill_disable is set, oom killer will be delayed to page fault path. In the charge patch, even if the oom_lock in memcg can't be acquired, the oom handing can also be invoked. In order to keep the behavior consistent with it, remove the lock check, just leave oom_kill_disable check behind in the page fault path. Furthermore, the lock contender won't be scheduled out, this doesn't fit the sixth description in commit fb2a6fc56be66 ("mm: memcg: rework and document OOM waiting and wakeup"). So remove the explicit wakeup for the lock holder. Fixes: fb2a6fc56be6 ("mm: memcg: rework and document OOM waiting and wakeup") Signed-off-by: Haifeng Xu --- mm/memcontrol.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5abffe6f8389..360fa7cf7879 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1999,7 +1999,7 @@ bool mem_cgroup_oom_synchronize(bool handle) if (locked) mem_cgroup_oom_notify(memcg); - if (locked && !memcg->oom_kill_disable) { + if (!memcg->oom_kill_disable) { mem_cgroup_unmark_under_oom(memcg); finish_wait(&memcg_oom_waitq, &owait.wait); mem_cgroup_out_of_memory(memcg, current->memcg_oom_gfp_mask, @@ -2010,15 +2010,8 @@ bool mem_cgroup_oom_synchronize(bool handle) finish_wait(&memcg_oom_waitq, &owait.wait); } - if (locked) { + if (locked) mem_cgroup_oom_unlock(memcg); - /* - * There is no guarantee that an OOM-lock contender - * sees the wakeups triggered by the OOM kill - * uncharges. Wake any sleepers explicitly. - */ - memcg_oom_recover(memcg); - } cleanup: current->memcg_in_oom = NULL; css_put(&memcg->css);