Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp5142806pjo; Tue, 11 Feb 2020 04:48:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyhtAhcrmusJQ7YQMu5990LaR6ytoRwJKetzYzRdUYfOHSAMN4fiGgr81MQDqh7g2ZKi7my X-Received: by 2002:aca:5295:: with SMTP id g143mr2643572oib.25.1581425320904; Tue, 11 Feb 2020 04:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581425320; cv=none; d=google.com; s=arc-20160816; b=K5w+IS9+NdrbQUbUQUnd0/cReA/dDMqNhRw4RV0gScHVOwdCb4wu85ldPDInkDdChx CXo5T8Pi+7pXmwdzf12D1II2pkLJE9TEsxqAt+1YleWp+i1xb1gyEwJa/YiHiu0FntBN pB474vJHysso7wmk4sGW23xVysQ2Na49tY2s+CWYX8NL+qDP1/mTMQhsu8c0IB7uI3nY fJ4k4IViBflJdZ6zzWyQgWuMrUGvrjKWHC9HoP+Uk24nAAwHFVuTegEixT3/M3KEszgA p02J5NrK4dYGhNJV2Uxb1+jAJK5IksHdL3A4k85pixmYNXmwCR+s77ba19p5R+0W71F7 BVdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Rju0YMUliA+K5t2+7HZEye0ub0QWZvZnf/MHQT2LoNY=; b=GX8I8TZXieKGSyBKsvrP2lji38m4IcFfYx843M7AFQBWFyktk5A7rErPVlFyy5mK0L r+QAtZgtIOHtBOOlQ3w3akPLihyu1HvM8d4e6YVYe1S70hWgzcuIFxgv+vAnC+xcNpA+ ZndMcsBx/oC4nO1N6YATFXYSfxcRzb4/jUrww33C/bMXvdP+QwZBJCdtMohQf6twZ0F9 f32htKCxbbspSvbt95zpTpllP2TePXHUGKgru47mCwH6sASR+s68pBf+f09eq1EtIttp 5yUj58lo76UN4OfUp5ZXX9ZFv2przZ2PdoLCoHL2whILBL4NzK8SLn1bIYAc0ZH942xN YIng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=K5QSdqCI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si1846728otp.258.2020.02.11.04.48.29; Tue, 11 Feb 2020 04:48:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=K5QSdqCI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728764AbgBKMX1 (ORCPT + 99 others); Tue, 11 Feb 2020 07:23:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:50436 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728567AbgBKMX1 (ORCPT ); Tue, 11 Feb 2020 07:23:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Rju0YMUliA+K5t2+7HZEye0ub0QWZvZnf/MHQT2LoNY=; b=K5QSdqCIgc+e9Hb2+rNsp40BvP aokArzKbETkw17m3M38rq1DB4eL2mvo7aF9TSt/vcbNIce7g9jWAOQGyfwJ0r/8Ec5mateJ6+XUXU 2YnhpGl5EVMBeqR2Qw9ZvS1dNTP2FcDp9drpoN+3y/HbiBawT51JZMA7ynDN4e5G4eOiTGfsZ+RGe jl/iGjqKRmbWu7vp2PFvaqesoLXCO3nrNrnKRf64ebQR35LzAjuQKrd/oq0J3YXJ1NqiLJI6bBBap XTSwZhF6Y1JgAX6FEXAkE5E2zOayLSsIioZohrxOBLdhdaqrx5Pz6YUwncWkB/lldUiXrTTC11jvu g2I/jAvg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1UZX-0001WR-Ib; Tue, 11 Feb 2020 12:23:23 +0000 Date: Tue, 11 Feb 2020 04:23:23 -0800 From: Matthew Wilcox To: Minchan Kim Cc: Andrew Morton , linux-mm , Josef Bacik , Johannes Weiner , Jan Kara , LKML Subject: Re: [PATCH] mm: fix long time stall from mm_populate Message-ID: <20200211122323.GS8731@bombadil.infradead.org> References: <20200211001958.170261-1-minchan@kernel.org> <20200211011021.GP8731@bombadil.infradead.org> <20200211035004.GA242563@google.com> <20200211035412.GR8731@bombadil.infradead.org> <20200211042536.GB242563@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200211042536.GB242563@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 10, 2020 at 08:25:36PM -0800, Minchan Kim wrote: > On Mon, Feb 10, 2020 at 07:54:12PM -0800, Matthew Wilcox wrote: > > On Mon, Feb 10, 2020 at 07:50:04PM -0800, Minchan Kim wrote: > > > On Mon, Feb 10, 2020 at 05:10:21PM -0800, Matthew Wilcox wrote: > > > > On Mon, Feb 10, 2020 at 04:19:58PM -0800, Minchan Kim wrote: > > > > > filemap_fault > > > > > find a page form page(PG_uptodate|PG_readahead|PG_writeback) > > > > > > > > Uh ... That shouldn't be possible. > > > > > > Please see shrink_page_list. Vmscan uses PG_reclaim to accelerate > > > page reclaim when the writeback is done so the page will have both > > > flags at the same time and the PG reclaim could be regarded as > > > PG_readahead in fault conext. > > > > What part of fault context can make that mistake? The snippet I quoted > > below is from page_cache_async_readahead() where it will clearly not > > make that mistake. There's a lot of code here; please don't presume I > > know all the areas you're talking about. > > Sorry about being not clear. I am saying filemap_fault -> > do_async_mmap_readahead > > Let's assume the page is hit in page cache and vmf->flags is !FAULT_FLAG > TRIED so it calls do_async_mmap_readahead. Since the page has PG_reclaim > and PG_writeback by shrink_page_list, it goes to > > do_async_mmap_readahead > if (PageReadahead(page)) > fpin = maybe_unlock_mmap_for_io(); > page_cache_async_readahead > if (PageWriteback(page)) > return; > ClearPageReadahead(page); <- doesn't reach here until the writeback is clear > > So, mm_populate will repeat the loop until the writeback is done. > It's my just theory but didn't comfirm it by the testing. > If I miss something clear, let me know it. Ah! Surely the right way to fix this is ... +++ b/mm/filemap.c @@ -2420,7 +2420,7 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf, return fpin; if (ra->mmap_miss > 0) ra->mmap_miss--; - if (PageReadahead(page)) { + if (!PageWriteback(page) && PageReadahead(page)) { fpin = maybe_unlock_mmap_for_io(vmf, fpin); page_cache_async_readahead(mapping, ra, file, page, offset, ra->ra_pages);