Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1110501ybl; Sat, 18 Jan 2020 19:03:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyZR0KfUv92Bf5bC7ZdcRfhxNLGyeE2LQMv8Coj8HaFUliBC+CBDbRq40LBXgohhfcoKDan X-Received: by 2002:a54:4895:: with SMTP id r21mr9032795oic.107.1579403004387; Sat, 18 Jan 2020 19:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579403004; cv=none; d=google.com; s=arc-20160816; b=TFimwY7W9Vt83emoWaRWZ0zEJagC5MpIavz8tvnXM5ZWPk7NcTutF9u2TOquOFqn3h iQU63grYiYl/MSFAPVgvKy6TGn1ZgfYI/8aqwtot3ogRbHZ0B89e8gV6csDMgpczYodZ nrtjM5dd4DfAOefhg5OCx5oSCjdooVuy2g+UN2DJgbLS6A/PHQbanEGcAyM3WULlSjcc IFiZHQ28UgbXnh7Xj/7CA88BZVeId1uP5axBx4W50sDlecBP+IryYrJFpIEuvv1b5ti3 cTC02JOfu/yieDemL/7QX/xGzb6Ipce22ZUF0PpAD+fQmuw5cLmxGpX/0y4pDCbtOemZ fuyA== 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=qHiZwlJS6uftYCFx/Un78yqu4V/Fq+STxxZTRS3+lak=; b=MrS/OMegVNMWGijXD8wQdZLfCTMvTbIxtlSYCCn1p7Xg5fgd4UzH2Can57z5ziRgT0 toitnpaCtPvFl85/CyzGSh5zDJo4tqiTjK5Be7FSrBUZa4tLUS4KYe3mWhEO/73p/gwe P+TlowZb3zg93UIIRmizkxjZuxEGmMvp1aMz0EnpIM0yJHJc9g2O1jNIhLGaDpEiBKJc ojsv9JGTIADYK7+4kFwnHT4j9vhn7D+nCCzqlLOyQFnR7KPCx8swPoA5cZDyuw5Wv7gD gMVFQs1KCzHjXtC5lLwCtvJD5QGBzvUDimbpQD8u5eDmBgVrphjjcHUP43fVH986jg1B BMCg== 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 i8si17106186otp.254.2020.01.18.19.03.12; Sat, 18 Jan 2020 19:03:24 -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 S1728750AbgASDCR (ORCPT + 99 others); Sat, 18 Jan 2020 22:02:17 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:2930 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727403AbgASDCR (ORCPT ); Sat, 18 Jan 2020 22:02:17 -0500 Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.57]) by Forcepoint Email with ESMTP id D0202295F3B082559A47; Sun, 19 Jan 2020 11:02:12 +0800 (CST) Received: from dggeme762-chm.china.huawei.com (10.3.19.108) by DGGEMM403-HUB.china.huawei.com (10.3.20.211) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 19 Jan 2020 11:02:11 +0800 Received: from architecture4 (10.160.196.180) by dggeme762-chm.china.huawei.com (10.3.19.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Sun, 19 Jan 2020 11:02:10 +0800 Date: Sun, 19 Jan 2020 11:01:25 +0800 From: Gao Xiang To: "yukuai (C)" CC: Matthew Wilcox , , , , , , , , Subject: Re: [RFC] iomap: fix race between readahead and direct write Message-ID: <20200119030123.GA223124@architecture4> References: <20200116063601.39201-1-yukuai3@huawei.com> <20200118230826.GA5583@bombadil.infradead.org> <20200119014213.GA16943@bombadil.infradead.org> <64d617cc-e7fe-6848-03bb-aab3498c9a07@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <64d617cc-e7fe-6848-03bb-aab3498c9a07@huawei.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [10.160.196.180] X-ClientProxiedBy: dggeme711-chm.china.huawei.com (10.1.199.107) To dggeme762-chm.china.huawei.com (10.3.19.108) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 19, 2020 at 10:51:37AM +0800, yukuai (C) wrote: > > > Then, there might be a problem in your implementation. > if 'use_list' is set to true here: > + bool use_list = mapping->a_ops->readpages; > > Your code do not call add_to_page_cache_lru for the page. IMO, if use_list == true, it will call read_pages -> .readpages and go just like the current implementation. ->.readahead is just alloc_page and then add_to_page_cache_lru right after in time and in principle it saves some extra page allocation. Thanks, Gao Xiang > + if (use_list) { > + page->index = page_offset; > + list_add(&page->lru, &page_pool); > + } else if (!add_to_page_cache_lru(page, mapping, page_offset, > + gfp_mask)) { > + if (nr_pages) > + read_pages(mapping, filp, &page_pool, > + page_offset - nr_pages, > + nr_pages); > + nr_pages = 0; > + continue; > + } >