Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3538332ybz; Mon, 20 Apr 2020 04:56:24 -0700 (PDT) X-Google-Smtp-Source: APiQypLnOA8HdE9OsTme26p0Nh70DAn8Snohb/KhUNL5+HR/6t0cqGHMgajAH7XB+IvR3R53Mgcr X-Received: by 2002:a50:d1c6:: with SMTP id i6mr13282689edg.241.1587383784365; Mon, 20 Apr 2020 04:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383784; cv=none; d=google.com; s=arc-20160816; b=LroO0gtbTisgxHrQe2uL0tfne5sR0XKWqPCjBc0rh7sqQrcqUBZkAeyi3Bvn1sxUGm aTp+c9MXgn6VfPObbPnS+31gD3VmlXRv7d9CfNHimO6vwtpbB5JIE2RUycUasKzfvfej g9qxcg3pWNzZtI25yTk1x6wI6o19WUl0Qbaxi/8ncVo398lI6Im1ErflbN7ptL1V85Nc Fpq3QW2l74LISVIPuIVWouddZd+dmIYUJKb3FvaF+5eG67sxxJpo5IqQpWRFZc7N0OJm qkxUlBOQ9Hzk5h9N6CzUjyfyRrXBiBvsPldXEbcr74a8LtJs1FwC6GGOc2NnKsCIlAVB yymg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Xz434+emhPfWjjKXYErvQLCog0qnyrqkr9U47Pj8EAE=; b=HN3HMQXHpw5FALmT6Rov7+tOIPHhQhb/klZBXjkE8aAypab/oUBWryMsMd5ovE8QqF dGFaOXVkPxJV40LIyZ9DnX6IRA2RzO8zgKZbhIpzIrQLEJ4mSDemA85l1TFWJb1ZQ7DR 9+vSJZEHLDPh90EjTH4Iy7LRPA9KYfrYoGyYYohN3jbwyMYnSop7m9NY/n4ZQpoQY0O0 WjS2iyd2oMV3kGZzZsXyFRbspJhYzx6f/8+EHoVcyWN2NYdwmLWWQwZRRsSo748aWUuV 3gq+sIZ1pnrBMRd0r+yDxUvxGz9O7Bm9hq4WRlk0eFukhmVA/NZ1Aw2Q7RUM0YyUJzGt zEjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b="eMGJ6i/T"; 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 t20si371847edy.543.2020.04.20.04.55.59; Mon, 20 Apr 2020 04:56:24 -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=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b="eMGJ6i/T"; 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 S1726844AbgDTLyz (ORCPT + 99 others); Mon, 20 Apr 2020 07:54:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726846AbgDTLyy (ORCPT ); Mon, 20 Apr 2020 07:54:54 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46059C0610D5 for ; Mon, 20 Apr 2020 04:54:54 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id s3so7674850eji.6 for ; Mon, 20 Apr 2020 04:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Xz434+emhPfWjjKXYErvQLCog0qnyrqkr9U47Pj8EAE=; b=eMGJ6i/Tp+yHljfYp7aMYd/mUsv2EnqVE+fCxu3XOH5yGdB0h61gy+ScRLFSyuRmgb qURUHX6I6Ir8eepIVf+Ri2YviGMLt6DWjxys1zOQJEVUfWPlsKPJUpkbtTkdGn4w0n0B 1MP04jnPqpFSU10941aKvkRA4UrFsDmfSRMik= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Xz434+emhPfWjjKXYErvQLCog0qnyrqkr9U47Pj8EAE=; b=lOuXHFTtQ6SrYI1VP31Ud7LwlEZCenKTn/ce986LEHCmlTZ9u4XD5QhPSr22yfl8nJ ER9iJl7ZMqTGOpXWOW07ny4sYakW751zLettyeKuEe2eJoOdOp0YGaFK7IAd/5LHL/Fz vnTA4cYzle9wmwabp0hi+HSWUtoCgbD/qsyx+R5yIWA+qGl9yrgmWRYvX2t7TeRlHhhB ADUMdk7UXkuUvKJth25o+IDSsXFFtXPsje0mxz4BRZV2oXY9d4wL/fjJ6gjfOnb+t5OM 6VEnFyYrJ0rDLYWZyFiIGjzEDjuGwW6RRS8OKCcB2AfYlJQK8OcRTTKbL8itrLNIxUKX iosg== X-Gm-Message-State: AGi0PuYBKIMsGDykXpwxEFrDDd2X1Ea6HdbmjnCrDdXQvI0uFkrnMD6Z E6AsEuiVYbnPyNSkSXeDs36NhAMfoqoR6DfNporZAuVoCuE= X-Received: by 2002:a17:906:8549:: with SMTP id h9mr15204554ejy.145.1587383692787; Mon, 20 Apr 2020 04:54:52 -0700 (PDT) MIME-Version: 1.0 References: <20200414150233.24495-1-willy@infradead.org> <20200414150233.24495-25-willy@infradead.org> <20200420114300.GB5820@bombadil.infradead.org> In-Reply-To: <20200420114300.GB5820@bombadil.infradead.org> From: Miklos Szeredi Date: Mon, 20 Apr 2020 13:54:41 +0200 Message-ID: Subject: Re: [PATCH v11 24/25] fuse: Convert from readpages to readahead To: Matthew Wilcox 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 Content-Type: text/plain; charset="UTF-8" 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 1:43 PM Matthew Wilcox wrote: > > 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. Your annoyance is perfectly understandable. This is something I noticed now, not back then. > > > > + 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. Hah, if such optimizations were worth anything with codepaths involving roundtrips to userspace... Anyway, I'll let these be, and maybe clean them up later. Acked-by: Miklos Szeredi Thanks, Miklos