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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65DD4C77B60 for ; Fri, 28 Apr 2023 19:53:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 60D416B0071; Fri, 28 Apr 2023 15:53:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BD2E6B0072; Fri, 28 Apr 2023 15:53:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 484BC6B0074; Fri, 28 Apr 2023 15:53:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3A5BF6B0071 for ; Fri, 28 Apr 2023 15:53:15 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F0A1FA036E for ; Fri, 28 Apr 2023 19:53:14 +0000 (UTC) X-FDA: 80731848708.24.795D5B6 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf22.hostedemail.com (Postfix) with ESMTP id F32CFC001B for ; Fri, 28 Apr 2023 19:53:11 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=npyE6eF0; spf=pass (imf22.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682711592; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=R13CCZGmdVZQALWoQMd60dH9ElExko1Eub7aPwH25KY=; b=oRN9ucTBOq9H+B7hQddOmdIanxPjLqxgT/FmnztX6zP4+41W9Prnd9LJZGa92UcgrwFjDO wzBmdoRq1L3xw1MbRji8enV+Mtg03hcW72a6IOIMf/rfFytq+tSjA3IsnUVyFa2FzdgeHh con/PTqnmuJN8S2ZyzlbAlrDXJqKSQo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682711592; a=rsa-sha256; cv=none; b=OfwU5N+6H1PHC6WSxp4BMzId1kurpMnxhZQxfmM5lBdzOkaDPVdZPZwbz38zT++kz899rR Z18Y6z9DPCih5u3zh+brF2fG9w4WxvgYCv89UJy+ztb6DdBTCRaUKHHb5zOlkWeug8SndS GjDc+x0tiYaPR6dQKWLDXjquf27I8Yo= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=npyE6eF0; spf=pass (imf22.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5C38221F7F; Fri, 28 Apr 2023 19:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1682711590; h=from:from:reply-to: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=R13CCZGmdVZQALWoQMd60dH9ElExko1Eub7aPwH25KY=; b=npyE6eF0XGe3ir5+fr8sYcVotlvYtnVR2B5dDcuFPwhqqnD8QY56mawVv9UOvFebOkdXpW w+JHnSaqJYoHIcSF8qlifa1EmqbkOsMstqMUbkPsuszaU8HKMFXPGuvbUc2t6zf7JWEXNH n5yR3qVSWWdm2h5SgTnPBmD1BXs+NK0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3B2A31390E; Fri, 28 Apr 2023 19:53:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pX9yCyYkTGSjVAAAMHmgww (envelope-from ); Fri, 28 Apr 2023 19:53:10 +0000 Date: Fri, 28 Apr 2023 21:53:09 +0200 From: Michal Hocko To: Hui Wang Cc: Gao Xiang , linux-mm@kvack.org, akpm@linux-foundation.org, surenb@google.com, colin.i.king@gmail.com, shy828301@gmail.com, hannes@cmpxchg.org, vbabka@suse.cz, hch@infradead.org, mgorman@suse.de, Phillip Lougher Subject: Re: [PATCH 1/1] mm/oom_kill: trigger the oom killer if oom occurs without __GFP_FS Message-ID: References: <20230426051030.112007-1-hui.wang@canonical.com> <20230426051030.112007-2-hui.wang@canonical.com> <68b085fe-3347-507c-d739-0dc9b27ebe05@linux.alibaba.com> <4aa48b6a-362d-de1b-f0ff-9bb8dafbdcc7@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4aa48b6a-362d-de1b-f0ff-9bb8dafbdcc7@canonical.com> X-Rspam-User: X-Rspamd-Queue-Id: F32CFC001B X-Rspamd-Server: rspam09 X-Stat-Signature: 1gjww6xn9oj4fcka37jtqwiy6qrbzajw X-HE-Tag: 1682711591-740662 X-HE-Meta: U2FsdGVkX184JpQIbzV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Fu3Unk8aK0TGSSPo6MrmI59QH1fdocLa6eMJSM7IAqLR2MbgHsQEbpG4ihRQq0CEFEzHSA00EHBZb/7Hm0a78AiLq7vhSSsReo9nQ+qRlzKJQJ42DFUrdkRX+sr2KpNm0LmdDp3Lts6h3dv7VStOnJrWH+5p5plAOw0S8M9OI9pVMIH54= 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 Thu 27-04-23 11:47:10, Hui Wang wrote: [...] > So Michal, > > Don't know if you read the "[PATCH 0/1] mm/oom_kill: system enters a state > something like hang when running stress-ng", do you know why out_of_memory() > will return immediately if there is no __GFP_FS, could we drop these lines > directly: > >     /* >      * The OOM killer does not compensate for IO-less reclaim. >      * pagefault_out_of_memory lost its gfp context so we have to >      * make sure exclude 0 mask - all other users should have at least >      * ___GFP_DIRECT_RECLAIM to get here. But mem_cgroup_oom() has to >      * invoke the OOM killer even if it is a GFP_NOFS allocation. >      */ >     if (oc->gfp_mask && !(oc->gfp_mask & __GFP_FS) && !is_memcg_oom(oc)) >         return true; The comment is rather hard to grasp without an intimate knowledge of the memory reclaim. The primary reason is that the allocation context without __GFP_FS (and also __GFP_IO) cannot perform a full memory reclaim because fs or the storage subsystem might be holding locks required for the memory reclaim. This means that a large amount of reclaimable memory is out of sight of the specific direct reclaim context. If we allowed oom killer to trigger we could invoke the oom killer while there is a lot of otherwise reclaimable memory. As you can imagine not something many users would appreciate as the oom kill is a very disruptive operation. In this case we rely on kswapd or other GFP_KERNEL like allocation context to make forward instead. If there is really nothing reclaimable then the oom killer would eventually hit from elsewhere. HTH -- Michal Hocko SUSE Labs