Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5903459ybv; Wed, 12 Feb 2020 02:23:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwsk4Voqx+GGeszzu4oxLDI4eMw6VnPmSvEGdS1THAXP+OXnIGFHYRT/U5ZL4+llTbcQHS9 X-Received: by 2002:a9d:2c2a:: with SMTP id f39mr8537292otb.301.1581503012271; Wed, 12 Feb 2020 02:23:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581503012; cv=none; d=google.com; s=arc-20160816; b=zpWGNKLM+vn/+wmXjFClsouoW+53tRCF8TAjmvPX2FBz+gRdEbNFhAqKgUcoNbyi5J dPAGCz0RIi8pjBiVDLMsMTS/In1WM72ftWuM9XVi6h+uhsz4rOSaCr8V/yghiuEqRt/v 1lFn1LKx984hMEQhoCs9y37yVWdqs+ZPZu3U/FHSvEbKE/MyUNhpvmdSltFwbTPgaQps tufjuDvpPO0GmJRwr1zQZ+vGRLnLhpEdaKy+KYKyPtJCP7e8OY7726rRC0BnTJWgjU2O HU4HUD8H+Fqfps2S8899n3QRckhl86EbGlAlP49Yt78BnLgSVhBsgIrPkAWB/JpaKCY8 UC4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gmLNIguNDmh6f0DTZROynCzz7vf4Bzjpi1n8jn+J9tM=; b=JCFp7Edf4tRbbrabt22cwi/Qfuvl5/PQipMIxmgHMu9CzdISrAXtv32l+jXNvBmQdX yyk42jG+aEyoxtRTkV6LQJvtwvtrxFpFfiPK9h62kpgcNVOuPSOM0+uCoWSsd40uc+Xf MqE9GuJOy2ONYXG8IoeSWKjPrKApFH/a1CsKs0n4oRhET3+sKNhT3Rujdoh2AHwmemUg KFtG8pAmZy3DJlnKU2UYHr55qdRSFbEW5DHQciPlyxyWWUhXB9uCxPct8RqaKg815cGz KwazcAfhq0HeBWmjMa2Zp/On70SPU7bxQX+pTG6/2XqEAUcYZv8FOidzs4Kbj6EkUUsF PQBw== ARC-Authentication-Results: i=1; mx.google.com; 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 r3si646033otp.292.2020.02.12.02.23.19; Wed, 12 Feb 2020 02:23:32 -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; 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 S1727692AbgBLKWJ (ORCPT + 99 others); Wed, 12 Feb 2020 05:22:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:51938 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbgBLKWJ (ORCPT ); Wed, 12 Feb 2020 05:22:09 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 73FB0AC46; Wed, 12 Feb 2020 10:22:07 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id C3D541E0E01; Wed, 12 Feb 2020 11:22:06 +0100 (CET) Date: Wed, 12 Feb 2020 11:22:06 +0100 From: Jan Kara 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: <20200212102206.GE25573@quack2.suse.cz> References: <20200211001958.170261-1-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200211001958.170261-1-minchan@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 10-02-20 16:19:58, Minchan Kim wrote: > Basically, fault handler releases mmap_sem before requesting readahead > and then it is supposed to retry lookup the page from page cache with > FAULT_FLAG_TRIED so that it avoids the live lock of infinite retry. > > However, what happens if the fault handler find a page from page > cache and the page has readahead marker but are waiting under > writeback? Plus one more condition, it happens under mm_populate > which repeats faulting unless it encounters error. So let's assemble > conditions below. > > __mm_populate > for (...) > get_user_pages(faluty_address) > handle_mm_fault > filemap_fault > find a page form page(PG_uptodate|PG_readahead|PG_writeback) > it will return VM_FAULT_RETRY > continue with faulty_address > > IOW, it will repeat fault retry logic until the page will be written > back in the long run. It makes big spike latency of several seconds. > > This patch solves the issue by turning off fault retry logic in second > trial. > > Signed-off-by: Minchan Kim > --- > It was orignated from code review once I have seen several user reports > but didn't confirm yet it's the root cause. Yes, I think the immediate problem is actually elsewhere but I agree that __mm_populate() should follow the general protocol of retrying only once so your change should make it more robust. The patch looks good to me, you can add: Reviewed-by: Jan Kara Honza > > mm/gup.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/mm/gup.c b/mm/gup.c > index 1b521e0ac1de..b3f825092abf 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -1196,6 +1196,7 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors) > struct vm_area_struct *vma = NULL; > int locked = 0; > long ret = 0; > + bool tried = false; > > end = start + len; > > @@ -1226,14 +1227,18 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors) > * double checks the vma flags, so that it won't mlock pages > * if the vma was already munlocked. > */ > - ret = populate_vma_page_range(vma, nstart, nend, &locked); > + ret = populate_vma_page_range(vma, nstart, nend, > + tried ? NULL : &locked); > if (ret < 0) { > if (ignore_errors) { > ret = 0; > continue; /* continue at next VMA */ > } > break; > - } > + } else if (ret == 0) > + tried = true; > + else > + tried = false; > nend = nstart + ret * PAGE_SIZE; > ret = 0; > } > -- > 2.25.0.225.g125e21ebc7-goog > -- Jan Kara SUSE Labs, CR