From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id A24388E0001 for ; Mon, 17 Dec 2018 09:41:12 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id a2so10781612pgt.11 for ; Mon, 17 Dec 2018 06:41:12 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a13si11934874pfd.3.2018.12.17.06.41.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Dec 2018 06:41:11 -0800 (PST) Date: Mon, 17 Dec 2018 06:41:01 -0800 From: Matthew Wilcox Subject: Re: [PATCH] squashfs: enable __GFP_FS in ->readpage to prevent hang in mem alloc Message-ID: <20181217144101.GN10600@bombadil.infradead.org> References: <20181204020840.49576-1-houtao1@huawei.com> <20181215143824.GJ10600@bombadil.infradead.org> <69457a5a-79c9-4950-37ae-eff7fa4f949a@huawei.com> <20181217035157.GK10600@bombadil.infradead.org> <20181217093337.GC30879@dhcp22.suse.cz> <00ff5d2d-a50f-4730-db8a-cea3d7a3eef7@I-love.SAKURA.ne.jp> <20181217122546.GL10600@bombadil.infradead.org> <20181217141044.GP30879@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181217141044.GP30879@dhcp22.suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Tetsuo Handa , Hou Tao , phillip@squashfs.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org On Mon, Dec 17, 2018 at 03:10:44PM +0100, Michal Hocko wrote: > On Mon 17-12-18 04:25:46, Matthew Wilcox wrote: > > It's worth noticing that squashfs _is_ in fact holding a page locked in > > squashfs_copy_cache() when it calls grab_cache_page_nowait(). I'm not > > sure if this will lead to trouble or not because I'm insufficiently > > familiar with the reclaim path. > > Hmm, this is more interesting then. If there is any memcg accounted > allocation down that path _and_ the squashfs writeout can lock more > pages and mark them writeback before they are really sent to the storage > then we have a problem. See [1] > > [1] http://lkml.kernel.org/r/20181213092221.27270-1-mhocko@kernel.org Squashfs is read only, so it'll never have dirty pages and never do writeout. But ... maybe the GFP flags being used for grab_cache_page_nowait() are wrong. It does, after all, say "nowait". Perhaps it shouldn't be trying direct reclaim at all, but rather fail earlier. Like this: +++ b/mm/filemap.c @@ -1550,6 +1550,8 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, gfp_mask |= __GFP_WRITE; if (fgp_flags & FGP_NOFS) gfp_mask &= ~__GFP_FS; + if (fgp_flags & FGP_NOWAIT) + gfp_mask &= ~__GFP_DIRECT_RECLAIM; page = __page_cache_alloc(gfp_mask); if (!page)