Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3531501ybz; Mon, 20 Apr 2020 04:46:45 -0700 (PDT) X-Google-Smtp-Source: APiQypJGMTK+eAJ7ZBvv/WxfNXFkz+L+H8E1KL8mcDsWn5gLAhU13a7s/BioSZIeLTDlOFJuWddQ X-Received: by 2002:a17:906:1603:: with SMTP id m3mr16262416ejd.205.1587383205501; Mon, 20 Apr 2020 04:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383205; cv=none; d=google.com; s=arc-20160816; b=zPMpaHgrr9Pw1rvckX0drFFR2umy4PdG04Ou0qdVwWSWhebDEW/zJz14ozdm6Ct6yl Q9mIswx4u4aycOYaqZsHnj6jtC+rJt9FFVlSEGmG85RpHHu9P++NZGMlIMHp86m5kmkH fk82c/CdE49RB/iO/c6fuk9zGZkXWRyokHJA9hL1oKoDPyjr4PIzbN75N0DQ8Q/Wt+AM 8eeGh96KSr1gyXmufft0lLTVqkDvs4FQBZ/jG9+aD6dO2fvsFKaI3lMpsSR0IwhfVpHa eyjHixicGzi2hZNbxvqHtv2HwZ2Q1kkcuo0dG88qjFkmSVLxtcLCjzS2X48E+oi+FgoI 3xlg== 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=y3v9H7gulitO+Y85OVNVzldz0TRWO8cQsHtyyEuI5ig=; b=RPnZ4xcA16uX0sbnba021VeebDEk5JZx5KHXCoc54rszJRz6DUV1xHnLxHLodk2kKU hX9MFsmPceeENEeCd7rIdus5Aj8Svh5w38oGOWNFtvRdkOXF1vwlsBVDuajgSHH+cUUp mUpVLH59G69tIySZih+lZMtzpVT7HwEubknp8yo/ly2uVQRByJouADJAv5/bvPaZ84vF KKjLtjGVvxh+jv2o10TtWUWySjECrUUtcX/VG/za9fZbGpweTDS+0lTw8ENheoEZlA6D Teqzkj/idBIWCyQpzQrNS57RK2QV8lKKi9un+UlM3fn2eJ8vwHChGN3/sOpPXSRFKLlC t8Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=g7JEJ58U; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq2si394855ejb.426.2020.04.20.04.46.21; Mon, 20 Apr 2020 04:46:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=g7JEJ58U; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbgDTLnH (ORCPT + 99 others); Mon, 20 Apr 2020 07:43:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726387AbgDTLnG (ORCPT ); Mon, 20 Apr 2020 07:43:06 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FFFEC061A0C; Mon, 20 Apr 2020 04:43:06 -0700 (PDT) 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=y3v9H7gulitO+Y85OVNVzldz0TRWO8cQsHtyyEuI5ig=; b=g7JEJ58UfwyeWV04dJy7haqXcR FkY7TCFjfydjy7CUKLk2sKTRTGMeWlNvIH6QaFdDcJ6LNamrUKqVtRcrYX13W0QaBjHoZgQRwTrWr pFMw6Zh2CU0LWD4TLAEVKbFuQrrB+5ujPnG45zzsqeSt+qZFmCfJvo+ZWZer92aHWA9AX6zXTHxmR SZTQ0uswpYDxkQli+e+cy4XXvjLfdwzNe85/eZjU4D+5T9gllu2ggGK4e+wrNS8ioWTjEeUaLiDp9 BBpgydRU02eR0+H8csye5k3wOpZi5BcrTH2LP3QdS1jLAlgaTQNjvb0utJkJEpp5gVZ/qj8/l1oQZ Kc/2zb2Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQUpI-0006Jo-4N; Mon, 20 Apr 2020 11:43:00 +0000 Date: Mon, 20 Apr 2020 04:43:00 -0700 From: Matthew Wilcox To: Miklos Szeredi Cc: Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, ocfs2-devel@oss.oracle.com, linux-xfs , Dave Chinner , William Kucharski Subject: Re: [PATCH v11 24/25] fuse: Convert from readpages to readahead Message-ID: <20200420114300.GB5820@bombadil.infradead.org> References: <20200414150233.24495-1-willy@infradead.org> <20200414150233.24495-25-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Apr 20, 2020 at 01:14:17PM +0200, Miklos Szeredi wrote: > > + for (;;) { > > + struct fuse_io_args *ia; > > + struct fuse_args_pages *ap; > > + > > + nr_pages = readahead_count(rac) - nr_pages; > > Hmm. I see what's going on here, but it's confusing. Why is > __readahead_batch() decrementing the readahead count at the start, > rather than at the end? > > At the very least it needs a comment about why nr_pages is calculated this way. Because usually that's what we want. See, for example, fs/mpage.c: while ((page = readahead_page(rac))) { prefetchw(&page->flags); args.page = page; args.nr_pages = readahead_count(rac); args.bio = do_mpage_readpage(&args); put_page(page); } fuse is different because it's trying to allocate for the next batch, not for the batch we're currently on. I'm a little annoyed because I posted almost this exact loop here: https://lore.kernel.org/linux-fsdevel/CAJfpegtrhGamoSqD-3Svfj3-iTdAbfD8TP44H_o+HE+g+CAnCA@mail.gmail.com/ and you said "I think that's fine", modified only by your concern for it not being obvious that nr_pages couldn't be decremented by __readahead_batch(), so I modified the loop slightly to assign to nr_pages. The part you're now complaining about is unchanged. > > + if (nr_pages > max_pages) > > + nr_pages = max_pages; > > + if (nr_pages == 0) > > + break; > > + ia = fuse_io_alloc(NULL, nr_pages); > > + if (!ia) > > + return; > > + ap = &ia->ap; > > + nr_pages = __readahead_batch(rac, ap->pages, nr_pages); > > + for (i = 0; i < nr_pages; i++) { > > + fuse_wait_on_page_writeback(inode, > > + readahead_index(rac) + i); > > What's wrong with ap->pages[i]->index? Are we trying to wean off using ->index? It saves reading from a cacheline? I wouldn't be surprised if the compiler hoisted the read from rac->_index to outside the loop and just iterated from rac->_index to rac->_index + nr_pages.