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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 0B5DCC63798 for ; Fri, 27 Nov 2020 17:44:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7837E22201 for ; Fri, 27 Nov 2020 17:44:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7837E22201 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A8DBA6B0070; Fri, 27 Nov 2020 12:44:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3C936B0071; Fri, 27 Nov 2020 12:44:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92D186B0072; Fri, 27 Nov 2020 12:44:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0036.hostedemail.com [216.40.44.36]) by kanga.kvack.org (Postfix) with ESMTP id 799E06B0070 for ; Fri, 27 Nov 2020 12:44:21 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3914C180AD811 for ; Fri, 27 Nov 2020 17:44:21 +0000 (UTC) X-FDA: 77530922322.03.coil22_1113be727389 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 00DDD28A4EA for ; Fri, 27 Nov 2020 17:44:20 +0000 (UTC) X-HE-Tag: coil22_1113be727389 X-Filterd-Recvd-Size: 5249 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Nov 2020 17:44:20 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 30D0CAC55; Fri, 27 Nov 2020 17:44:19 +0000 (UTC) Subject: Re: [PATCH v3] mm/shmem.c: make shmem_mapping() inline To: Hui Su , hughd@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20201115165207.GA265355@rlk> From: Vlastimil Babka Message-ID: <89b2b0f5-a502-bd56-0234-bfcd72ef8765@suse.cz> Date: Fri, 27 Nov 2020 18:44:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201115165207.GA265355@rlk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 11/15/20 5:52 PM, Hui Su wrote: > shmem_mapping() isn't worth an out-of-line call > from any callsite. > > So make it inline by > - make shmem_aops global > - export shmem_aops > - inline the shmem_mapping() > > and replace the direct call 'shmem_aops' with shmem_mapping() > in shmem.c. > > v1->v2: > remove the inline for func declaration in shmem_fs.h > > v2->v3: > make shmem_aops global, and export it to modules. > > Signed-off-by: Hui Su Acked-by: Vlastimil Babka > --- > include/linux/shmem_fs.h | 6 +++++- > mm/shmem.c | 16 ++++++---------- > 2 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h > index a5a5d1d4d7b1..d82b6f396588 100644 > --- a/include/linux/shmem_fs.h > +++ b/include/linux/shmem_fs.h > @@ -67,7 +67,11 @@ extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr, > unsigned long len, unsigned long pgoff, unsigned long flags); > extern int shmem_lock(struct file *file, int lock, struct user_struct *user); > #ifdef CONFIG_SHMEM > -extern bool shmem_mapping(struct address_space *mapping); > +extern const struct address_space_operations shmem_aops; > +static inline bool shmem_mapping(struct address_space *mapping) > +{ > + return mapping->a_ops == &shmem_aops; > +} > #else > static inline bool shmem_mapping(struct address_space *mapping) > { > diff --git a/mm/shmem.c b/mm/shmem.c > index 537c137698f8..b7361fce50bc 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -246,7 +246,7 @@ static inline void shmem_inode_unacct_blocks(struct inode *inode, long pages) > } > > static const struct super_operations shmem_ops; > -static const struct address_space_operations shmem_aops; > +const struct address_space_operations shmem_aops; > static const struct file_operations shmem_file_operations; > static const struct inode_operations shmem_inode_operations; > static const struct inode_operations shmem_dir_inode_operations; > @@ -1152,7 +1152,7 @@ static void shmem_evict_inode(struct inode *inode) > struct shmem_inode_info *info = SHMEM_I(inode); > struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); > > - if (inode->i_mapping->a_ops == &shmem_aops) { > + if (shmem_mapping(inode->i_mapping)) { > shmem_unacct_size(info->flags, inode->i_size); > inode->i_size = 0; > shmem_truncate_range(inode, 0, (loff_t)-1); > @@ -1858,7 +1858,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, > } > > /* shmem_symlink() */ > - if (mapping->a_ops != &shmem_aops) > + if (!shmem_mapping(mapping)) > goto alloc_nohuge; > if (shmem_huge == SHMEM_HUGE_DENY || sgp_huge == SGP_NOHUGE) > goto alloc_nohuge; > @@ -2352,11 +2352,6 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode > return inode; > } > > -bool shmem_mapping(struct address_space *mapping) > -{ > - return mapping->a_ops == &shmem_aops; > -} > - > static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, > pmd_t *dst_pmd, > struct vm_area_struct *dst_vma, > @@ -3865,7 +3860,7 @@ static void shmem_destroy_inodecache(void) > kmem_cache_destroy(shmem_inode_cachep); > } > > -static const struct address_space_operations shmem_aops = { > +const struct address_space_operations shmem_aops = { > .writepage = shmem_writepage, > .set_page_dirty = __set_page_dirty_no_writeback, > #ifdef CONFIG_TMPFS > @@ -3877,6 +3872,7 @@ static const struct address_space_operations shmem_aops = { > #endif > .error_remove_page = generic_error_remove_page, > }; > +EXPORT_SYMBOL(shmem_aops); > > static const struct file_operations shmem_file_operations = { > .mmap = shmem_mmap, > @@ -4312,7 +4308,7 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, > struct page *page; > int error; > > - BUG_ON(mapping->a_ops != &shmem_aops); > + BUG_ON(!shmem_mapping(mapping)); > error = shmem_getpage_gfp(inode, index, &page, SGP_CACHE, > gfp, NULL, NULL, NULL); > if (error) >