From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 099EEC54FCB for ; Mon, 20 Apr 2020 11:55:05 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C77B720724; Mon, 20 Apr 2020 11:55:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="Jj+cpjsR"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="DQWl+VYE"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=szeredi.hu header.i=@szeredi.hu header.b="eMGJ6i/T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C77B720724 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=szeredi.hu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jQV0y-0005Hc-9y; Mon, 20 Apr 2020 11:55:04 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jQV0x-0005HV-4A for linux-f2fs-devel@lists.sourceforge.net; Mon, 20 Apr 2020 11:55:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Xz434+emhPfWjjKXYErvQLCog0qnyrqkr9U47Pj8EAE=; b=Jj+cpjsRAgwUm8mf5Pl5IIJZwP u3sXi1xj7Wgb7sWSLJTLbvy15aBxgoUStN2Dt3r9bIBVYdalCfkpH225Pc5sgcO/pfl2zaByJMWD+ A4OwtHNSZsdOggNxSKkxRQlAPzzKYYaBdqn5MZqWbr8qgfqI1rmjXkKfRZ3BPD3PWce4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Xz434+emhPfWjjKXYErvQLCog0qnyrqkr9U47Pj8EAE=; b=DQWl+VYELYTj+umK/qFt4crgMw oUMj94kH46tWfLKGSKZqf1evo2NPeiS4RHoZOJRfWEkxMuqI2FnFNsWjqjIdeHjySi11v5AiwO7XO Jh/T3Gq1g33B9vvEU70odw5vlQxLuuAgrsYiAxnW2wy224q6QKBfJQTxpdCGSaOqJCxQ=; Received: from mail-ej1-f67.google.com ([209.85.218.67]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jQV0t-0081qD-9h for linux-f2fs-devel@lists.sourceforge.net; Mon, 20 Apr 2020 11:55:03 +0000 Received: by mail-ej1-f67.google.com with SMTP id e2so5329858eje.13 for ; Mon, 20 Apr 2020 04:54:59 -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=XdvRfRJvDDCQfL/iMiWG8ANoE/ChRo5Y3QhVXkktk6qvc+oCv2aiLcOTZL3wU2p29c oRiKVi2QY/P8uB3jVuv3zExDVcsD5c7NsfPUebJIccQWczQh4wdFkXajFmiGfD7gByKQ 1Jv74V/SG26GMqSVPBhJIQ5gUyg5c4XmALLZDMXfFSKRpGD1U5uZcIEBkpiIlyrQVyAI 8LNlOHvETf3wsH/MBxH/5ZSM5nb5dcPo/2joLF2b+74TC1G+jWCnqcPZRNNIxxWb2yQZ Mtz/syvrae0k0J+/Om+tByFYyagDUeazA8nueJU5HhzcBPfGW7U9ZE9jRiHJL6In49+h 99GA== X-Gm-Message-State: AGi0PuZeW10k0s6pJiRH1fJS84CGNrKjksYxFKUL6PyRVRYV1on0jehF /2r/3TBW+XQ2hJcogt3N2XEsf2EUepRIc1VUBCaZmg== X-Google-Smtp-Source: APiQypLbTn+lSf9tXQjoSINzOkViouA+EuTM208dkpb3K/JiwqGLK/tHyeL8eS/wVDrlTm/f0ngTgrLv3Gua9FB3DGg= 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: To: Matthew Wilcox X-Headers-End: 1jQV0t-0081qD-9h Subject: Re: [f2fs-dev] [PATCH v11 24/25] fuse: Convert from readpages to readahead X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-xfs , William Kucharski , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com, Dave Chinner , linux-fsdevel@vger.kernel.org, Andrew Morton , linux-ext4@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel