From patchwork Sun Nov 15 16:52:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Su X-Patchwork-Id: 11906511 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B51614C0 for ; Sun, 15 Nov 2020 17:07:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EAD93238E6 for ; Sun, 15 Nov 2020 17:07:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="ho6GsUr8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAD93238E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DE73F6B0036; Sun, 15 Nov 2020 12:07:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D96216B005D; Sun, 15 Nov 2020 12:07:56 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CABC86B0068; Sun, 15 Nov 2020 12:07:56 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0202.hostedemail.com [216.40.44.202]) by kanga.kvack.org (Postfix) with ESMTP id 9B0356B0036 for ; Sun, 15 Nov 2020 12:07:56 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 420313620 for ; Sun, 15 Nov 2020 17:07:56 +0000 (UTC) X-FDA: 77487284952.12.drop92_1807b8b27322 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 22FCB18055196 for ; Sun, 15 Nov 2020 17:07:56 +0000 (UTC) X-Spam-Summary: 1,0,0,d834711021a97cfc,d41d8cd98f00b204,sh_def@163.com,,RULES_HIT:41:69:355:379:582:800:960:968:973:988:989:1152:1260:1277:1312:1313:1314:1345:1437:1516:1518:1519:1535:1543:1593:1594:1595:1596:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3872:4321:4419:4605:5007:6261:6653:7875:8660:9592:10004:10400:11026:11232:11334:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:13148:13230:13439:13895:14096:14097:14181:14394:14721:21080:21451:21627:21795:21939:21990:30051:30054:30075,0,RBL:220.181.12.18:@163.com:.lbl8.mailshell.net-66.100.201.100 62.50.2.100;04yf5sucnwjir1hjws9zhj7m1hs7jycayaprppmhseebcn7weij7dyj9gbupfay.p76rk154mfxdkkg9w9w4axdxj3u644m9cnte1rezdrg3owmanup39fmed1b9fbr.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:71,LUA_SUMMARY:none X-HE-Tag: drop92_1807b8b27322 X-Filterd-Recvd-Size: 5385 Received: from m12-18.163.com (m12-18.163.com [220.181.12.18]) by imf24.hostedemail.com (Postfix) with SMTP for ; Sun, 15 Nov 2020 17:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=eUxBN 17tBg7g8E/CnvCpJYdFtBdlxX5nDDJwk3YrJZg=; b=ho6GsUr8/kghdZMblx5mP DSyHMzXf5XGqJ6n2iGq5k4tKrc7V1Pc4fvKGzdAzhKLtOtv08nVQangXxRBNmKXu 3k0zmfv8O3YbZyK6Yncryw202u2yKwCIbtxip7zNs7pPuyvHF8F6DrdOVTU+T9+W Ni7v4Q32/iOoLnEdAyLW/Y= Received: from localhost (unknown [101.86.213.176]) by smtp14 (Coremail) with SMTP id EsCowAA3Cvi3XLFfkhEBEQ--.55110S2; Mon, 16 Nov 2020 00:52:07 +0800 (CST) Date: Mon, 16 Nov 2020 00:52:07 +0800 From: Hui Su To: hughd@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: sh_def@163.com Subject: [PATCH v3] mm/shmem.c: make shmem_mapping() inline Message-ID: <20201115165207.GA265355@rlk> MIME-Version: 1.0 Content-Disposition: inline X-CM-TRANSID: EsCowAA3Cvi3XLFfkhEBEQ--.55110S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZrWxAry7GFWDAF1rZF4UCFg_yoWrXF13pF 4DAw45GF48XryFgayxZaykZryYga1kGay0yry3W3sayFn8Gry7tF1jkr1Yvry5Ary8J3y2 qrWjkry5Ww1UtrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRyv3nUUUUU= X-Originating-IP: [101.86.213.176] X-CM-SenderInfo: xvkbvvri6rljoofrz/xtbByxfdX1PAPrl5jQAAs+ 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: 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)