Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6223808pxv; Thu, 29 Jul 2021 09:13:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWIaYdcdjmUOyRVJuwDbxVQSypGAhInNjMQ1XfeLFWWu41hO8YSgVzRAFgZ4IwvNLawqL3 X-Received: by 2002:a17:906:9c84:: with SMTP id fj4mr5161562ejc.264.1627575197399; Thu, 29 Jul 2021 09:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627575197; cv=none; d=google.com; s=arc-20160816; b=SLwn/U5Q1EYaGzOX7NGrfr0TT2zkTQ/uRpq+7h30UDE7+TwqPMIQkEQ/h8VDNJVQNp 8O8Ns3OAxdVtTw1tYsJmlcpeKvTgmjMh4pM7/o88ct1RbhbIjksYwLZZ+511ubqzqTYY X/9+ykfYLm6aVZjJVB+5Ovn0T/K1PsmvvJuXwkyWLxewBoy7yTxQCo4ijbTtLVv4AeaB Dg/LydVvMdXNGQ6F0k4JV3E35hHNOwD9C0/LD5ktod6NFUFMAXL3bneHoyXEv4grKJ4j wgh7WrBNhp90Shtq7jJVZVQwb/kmbtfEtqqaKDFyivk0vs7V70ed3fKcv2x+6BhrYtaq bEcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=lq/O8Y0CB9RHKdJxxOQdFWMqsh1BnqsluCSel35j/Ws=; b=YTvWl67JPT2VwVLvKdF6LOapucMYWZ3HvjJ3DzhshwGC+to7a9QPihhzipfmfhOyH/ LrYVL5cdApjTtpprMBJXodvixPdmo0ChbEOCQ4A+Of++6Lti20sUB4wCDNlxuCGlJjET jtogprOIOjmjSGC8bHznBcEdwKSRAtTuKQ9MDMWV4upPZ3z70vytHT7sxKK/3UKj4sSD OQY1iTbju00Hg/JEOz+Ir0QXVSkI1+q3xF3JkPZx2pqLNMvuqy+HXYXixQrgUhMnVdqk 20+ruEHTtiJycynQBLqKpjFMi8wZq2tqAmvwULjORMVbbsUoYYLtkxPdfI+lRT95029k pfCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=sSu76YsV; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Qg4MWPER; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 s25si3315000edy.21.2021.07.29.09.12.21; Thu, 29 Jul 2021 09:13:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=sSu76YsV; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Qg4MWPER; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232997AbhG2QLb (ORCPT + 99 others); Thu, 29 Jul 2021 12:11:31 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:48680 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234248AbhG2QJw (ORCPT ); Thu, 29 Jul 2021 12:09:52 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 156D122270; Thu, 29 Jul 2021 16:09:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627574942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lq/O8Y0CB9RHKdJxxOQdFWMqsh1BnqsluCSel35j/Ws=; b=sSu76YsVtqBJq5/Bguo2I/CH0YFJ/DjJgd3sR7TZ2DA/9jv8pxNb4fOGXp00TGv6AvdpQP 0TG7+P31Ox7BlQlAw1sNQ35ypEOw2iL1eqE5Gn6rLEXoIgbwz0Y+fyeENataIlBgUU/1y0 dKuHTwBDnDgpD2ujb+ksJ+WfMhdsEKw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627574942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lq/O8Y0CB9RHKdJxxOQdFWMqsh1BnqsluCSel35j/Ws=; b=Qg4MWPER216A8pfT5Bwdf8hoai1JgM7ZGugt/w3qMT0FdASkrxZU7BjskWfAz4XponrUDh /Xz3gbeKaOtkCwBA== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id A052213357; Thu, 29 Jul 2021 16:09:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id 5jqyF53SAmEgOgAAGKfGzw (envelope-from ); Thu, 29 Jul 2021 16:09:01 +0000 Date: Thu, 29 Jul 2021 11:08:59 -0500 From: Goldwyn Rodrigues To: Matthew Wilcox Cc: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-nfs@vger.kernel.org Subject: Re: [PATCH] fs: reduce pointers while using file_ra_state_init() Message-ID: <20210729160859.sfdypnrti5hxk6fg@fiona> References: <20210726164647.brx3l2ykwv3zz7vr@fiona> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 18:19 26/07, Matthew Wilcox wrote: > On Mon, Jul 26, 2021 at 11:46:47AM -0500, Goldwyn Rodrigues wrote: > > Simplification. > > > > file_ra_state_init() take struct address_space *, just to use inode > > pointer by dereferencing from mapping->host. > > > > The callers also derive mapping either by file->f_mapping, or > > even file->f_mapping->host->i_mapping. > > > > Change file_ra_state_init() to accept struct inode * to reduce pointer > > dereferencing, both in the callee and the caller. > > > > Signed-off-by: Goldwyn Rodrigues > > Reviewed-by: Matthew Wilcox (Oracle) > > (some adjacent comments) > > > diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c > > index 4806295116d8..c43bf9915cda 100644 > > --- a/fs/btrfs/free-space-cache.c > > +++ b/fs/btrfs/free-space-cache.c > > @@ -351,7 +351,7 @@ static void readahead_cache(struct inode *inode) > > if (!ra) > > return; > > > > - file_ra_state_init(ra, inode->i_mapping); > > + file_ra_state_init(ra, inode); > > last_index = (i_size_read(inode) - 1) >> PAGE_SHIFT; > > > > page_cache_sync_readahead(inode->i_mapping, ra, NULL, 0, last_index); > > Why does btrfs allocate a file_ra_state using kmalloc instead of > on the stack? > > > +++ b/include/linux/fs.h > > @@ -3260,7 +3260,7 @@ extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, > > > > > > extern void > > -file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); > > +file_ra_state_init(struct file_ra_state *ra, struct inode *inode); > > This should move to pagemap.h (and lose the extern). > I'd put it near the definition of VM_READAHEAD_PAGES. > > > diff --git a/mm/readahead.c b/mm/readahead.c > > index d589f147f4c2..3541941df5e7 100644 > > --- a/mm/readahead.c > > +++ b/mm/readahead.c > > @@ -31,9 +31,9 @@ > > * memset *ra to zero. > > */ > > void > > -file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping) > > +file_ra_state_init(struct file_ra_state *ra, struct inode *inode) > > { > > - ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages; > > + ra->ra_pages = inode_to_bdi(inode)->ra_pages; > > ra->prev_pos = -1; > > } > > EXPORT_SYMBOL_GPL(file_ra_state_init); > > I'm not entirely sure why this function is out-of-line, tbh. > Would it make more sense for it to be static inline in a header? Which one? pagemap.h or fs.h does not know of inode_to_bdi(), should linux/backing-dev.h be included? -- Goldwyn