From patchwork Wed Apr 2 09:01:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 14035688 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 D2728C28B20 for ; Wed, 2 Apr 2025 09:01:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3710F280005; Wed, 2 Apr 2025 05:01:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F833280001; Wed, 2 Apr 2025 05:01:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17141280005; Wed, 2 Apr 2025 05:01:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DE876280001 for ; Wed, 2 Apr 2025 05:01:27 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 85B9E1614BE for ; Wed, 2 Apr 2025 09:01:28 +0000 (UTC) X-FDA: 83288510256.02.77F52D9 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by imf27.hostedemail.com (Postfix) with ESMTP id B048E40004 for ; Wed, 2 Apr 2025 09:01:26 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=quarantine); spf=pass (imf27.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743584486; a=rsa-sha256; cv=none; b=Bk2TXYyWRMAiws7sVqGk8LjZu4zx1gJYFA94tJzkxVlugliQX0icyjTnMyeJ6mqld4QzQo BK6QTzg9IyCi7fFGCiVgvvw5VMoCvVwIL1JDiKrkdPHeLcd5b6BbMmR4Q6uNH0R+Tqbv7g qg5RzdrCe+OQb0Q87pVgf/QoSEXtpsg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=quarantine); spf=pass (imf27.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743584486; 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; bh=1nAxP9Cm1Xgk9CKkL1H+osxhAxtr2UzCZivomiql3CU=; b=B29tC4YdvArusfmFKVUkkmjyJXlpKb+bse5JmVYeMN60bQsDl2sTXxIAHwEMzDD+BcdjzO plUa6SgyZ8HGLR4W1QOFwxam71sXRNMSpSHi6kSLbQYLnk6B8qpvMBOmfMPO5Yc58fy6vR biKodG3ERl2IKyjeiH4UOycylyJJy8c= Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-43cfba466b2so64446485e9.3 for ; Wed, 02 Apr 2025 02:01:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743584485; x=1744189285; 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=1nAxP9Cm1Xgk9CKkL1H+osxhAxtr2UzCZivomiql3CU=; b=vddhTISSThYvRv0w9YbJAHmKzN1FaqaxCRDDLVwZ7YzbSp/isCLq60PZqTbB8HNLGt qTixuyPBP6K5ajg1ERwTrIjB5Y/DvkCUM7Q/z9eAtp0Wct8sNgu45sSHduorZemcioTd +BbwUKGFarAPBW6sKXxyMxKLTsDTxXB6xxSWa03yweNdCiSYtEURBK4gvlyzKw2+ka+f UKFhEK/ORrkRwH+5su6/jBMWUJ3KXuKmasAQcy85xwGrWtxZbhZaoAHNSFXfY/hgQLCQ EU4i0RvNlifd+NXLIY17an58IXE62gsbyF4e1pkErqQ8kDUtDlabwKb2kGi2K6YNKnJF xgsA== X-Gm-Message-State: AOJu0YxLTjULYD71vNtpDppWKffI2UZEMINcoKTg2BXrqPiQberV+iz3 quM/JohY31X+KeKFoxTNZ20zTDfCiaLPph9RJUHROnFT4d6E74um X-Gm-Gg: ASbGncvcF+SUyf/3nOpMFrgCo+JYhKsg0JoEAF8N6V3XydpS+4aLFkfSFbSMOeyUgC2 EehoeTFT99u0XZ9t175fAuOomyAcDShP0SFts+W7bL17I+aIt4mrHc4R5Ih8eoMOV3EmWZ0snhp w+ceFGMoU2hAJbD9osrZMqDZzSK4FViuDX1ppq7frKLcFu+uidXCjJxJ3IdCRfC7C1rhVWr3Pmr TVIrCCLU4uCb+Pl360QrZZBf6pkkItEAui9GcO2y6NarJN20CIFRttkLggLW+2eI2Bh29C8Fnkq mR88tNPdrscgtvjwg/q2wyH27U/QoEsHiVvgj4RQtJugZ7bgWV7hZwX8VBgW2+PKi41AqfsnBTZ 5OV7W+GIxPGs= X-Google-Smtp-Source: AGHT+IF377z38nyMutbgU0BfWnTmCRNwm367leNG/aLpAUpSFIciSLft2x0pBCWn6VuKILiIZhmHMQ== X-Received: by 2002:a05:600c:1382:b0:43c:e7ae:4bc9 with SMTP id 5b1f17b1804b1-43db61e0348mr120742425e9.1.1743584485035; Wed, 02 Apr 2025 02:01:25 -0700 (PDT) Received: from localhost.localdomain (109-81-92-185.rct.o2.cz. [109.81.92.185]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b658b7bsm16145003f8f.20.2025.04.02.02.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 02:01:24 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: , Rik van Riel , Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , cgroups mailinglist , LKML , Michal Hocko Subject: [PATCH] memcg, oom: do not bypass oom killer for dying tasks Date: Wed, 2 Apr 2025 11:01:17 +0200 Message-ID: <20250402090117.130245-1-mhocko@kernel.org> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: B048E40004 X-Stat-Signature: ei9s4n3ghmnnb31f7wtgswbm1dcnuouy X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1743584486-907396 X-HE-Meta: U2FsdGVkX1/bpeMG0W9BE0pJQn571RJSyyski8dS7H57LNffVNpTB2wAnvY42YUF72E/6K9IXeTfvUGe4FmE8vbQmLj6iskmL31tabW0ihcmxdpAWVe3CiS5s3OhaUU0Voy2w357UFO12lfPHhTVkhR29HxCSrL2wR2/SeoHURKfRb3O5kVlXyLFTZ5bpPw1mdOfrNDqa1tcpgSzqvQBLZZKOvuWZ54q0u9mZPZUFy2hWfW9J6FMJ3/YbtY2qpiyC4J3q78AisE2n+Lsw3TIG1d5MTvwjQzwCfcsA6KVtKhx4dbHCfT9lIYUqg7BxnsGHogltjXCfrfcGfOSgFpSgqVHZszUf6cFlkZKeOW+JwPxcaT8jsUOtbDeZz0iDgiD21tpqXR/3zVp33ZY+I0374yYgEdTPYjCG5zrg+hXuJU2n7UKjTx60+rzqr6B4YFR62oDTzDj2XF4+gcVWQt/eP5Rm8uN1S9FzSZiwb6koYjX/3MaKNTq8jrxFBdwoAxQ4MV++be/72GuAZL91C+bHovLuP9VjL3aocstr2m3Iq0uc4WWJRJz/XxgRyMZ4Z42DUm5XuX141Jn5m+MH/cIZZMcb4UNNjy1hIXCZP9Yn1ubyq4MtsHPguIS6+ks6U9lzYUVWc6ZytNVVYZIxJsk4ec+3URm8j0sHS54lqB7kCiY0B5UtE2+XggyuglNCzY3PecWI2KkX9h7Ez6PeJvfuSmcZBVujYambmMF5gPZa0pPheg1sxpxE3WkZtggC158AfUQ0dzFN456jx714hzPU7hhI6s5VD99oKIh+AG/zhH/IxRChVp6oNQEN7LrtLtoml5oleq6ZgJpB3fTf9SPHQKbS6jKjzz8WVpG3Jv/477xM66Y+/FimYVeV8671NOWJeOzBCJLZxv2TSaZBJWj5U/Cv0gMYior93J3A1qySyJAZ4ji31MpQJqC5fKwfI8nxHqEzC97OQQ272hM84a cNP9/UdM vVxyiWstBwIjLHrS0SSNjpmHNWLuqTnPMdsB4OkUij/N5KFF9Hide0Ypnk6q0U61yCRUNiDWM8KXs91+EX/zMcLwxqlBlBZThIGx9SYD5pR4sWu7URQ/ANg0SfokRFW1Ov0Kf/MA6tLpFGTqyLgP/WjpUdsUsAr9ehj1UKXbLg5WVuF01AEbjmArRJIb1afadp4GVJMwe4ZlhjX4CneEBYsM5on3AHmPwHhEhrX39aKUFqEIw+kGZjp2JxMTItO4I5V7F8FNE3yoxbznxH+Dm7RwPpUpoFzETMJiRHU/7TGoKuhsOsYZBy8GekYMt1bDPCMPwb4JzC42JuscqJt9eEPUk/uuQqu5SwqJw1tfTC3m5ZkZwez7dNCLIdX+sXWEW8xLprPMLirXQpMaR5n09H+Z0DnBiBM6vCONFwSkB7ynx3wsoWr8X9yGJyhCt2uahWN2yhvZKSSTV+Os+GyWCldYv7qhIVsy9q2ymnFoAuPnB/NxuzBnXosTI3VakjLL1U+DJ 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: List-Subscribe: List-Unsubscribe: From: Michal Hocko 7775face2079 ("memcg: killed threads should not invoke memcg OOM killer") has added a bypass of the oom killer path for dying threads because a very specific workload (described in the changelog) could hit "no killable tasks" path. This itself is not fatal condition but it could be annoying if this was a common case. On the other hand the bypass has some issues on its own. Without triggering oom killer we won't be able to trigger async oom reclaim (oom_reaper) which can operate on killed tasks as well as long as they still have their mm available. This could be the case during futex cleanup when the memory as pointed out by Johannes in [1]. The said case is still not fully understood but let's drop this bypass that was mostly driven by an artificial workload and allow dying tasks to go into oom path. This will make the code easier to reason about and also help corner cases where oom_reaper could help to release memory. [1] https://lore.kernel.org/all/20241212183012.GB1026@cmpxchg.org/T/#u Suggested-by: Johannes Weiner Signed-off-by: Michal Hocko Signed-off-by: Johannes Weiner Acked-by: Shakeel Butt --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7b3503d12aaf..9c30c442e3b0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1627,7 +1627,7 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, * A few threads which were not waiting at mutex_lock_killable() can * fail to bail out. Therefore, check again after holding oom_lock. */ - ret = task_is_dying() || out_of_memory(&oc); + ret = out_of_memory(&oc); unlock: mutex_unlock(&oom_lock);