From patchwork Tue May 5 11:55:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11528873 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 315311668 for ; Tue, 5 May 2020 11:56:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F2B91206B8 for ; Tue, 5 May 2020 11:56:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2B91206B8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 14DCA8E00C1; Tue, 5 May 2020 07:56:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0D5AE8E0058; Tue, 5 May 2020 07:56:09 -0400 (EDT) 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 F2ADC8E00C0; Tue, 5 May 2020 07:56:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id D540D8E0058 for ; Tue, 5 May 2020 07:56:08 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8605F181AC9CB for ; Tue, 5 May 2020 11:56:08 +0000 (UTC) X-FDA: 76782512016.17.jump10_6fbe827582a41 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30012:30054,0,RBL:45.249.212.191:@huawei.com:.lbl8.mailshell.net-64.95.201.95 62.18.2.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:25,LUA_SUMMARY:none X-HE-Tag: jump10_6fbe827582a41 X-Filterd-Recvd-Size: 4219 Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 May 2020 11:56:07 +0000 (UTC) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CED93E741FB0B5C9C388; Tue, 5 May 2020 19:56:03 +0800 (CST) Received: from DESKTOP-C3MD9UG.china.huawei.com (10.166.215.55) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Tue, 5 May 2020 19:55:56 +0800 From: Zhen Lei To: Minchan Kim , Nitin Gupta , "Sergey Senozhatsky" , Jens Axboe , linux-block , Andrew Morton , linux-mm , Alasdair Kergon , Mike Snitzer , dm-devel , Song Liu , linux-raid , linux-kernel CC: Zhen Lei Subject: [PATCH 2/4] mm/swap: use SECTORS_PER_PAGE_SHIFT to clean up code Date: Tue, 5 May 2020 19:55:41 +0800 Message-ID: <20200505115543.1660-3-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200505115543.1660-1-thunder.leizhen@huawei.com> References: <20200505115543.1660-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.166.215.55] X-CFilter-Loop: Reflected 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: 1. Replace "PAGE_SHIFT - 9" with SECTORS_PER_PAGE_SHIFT Signed-off-by: Zhen Lei --- mm/page_io.c | 4 ++-- mm/swapfile.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index b1d4f4558e6b..51f25238fd9a 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -38,7 +38,7 @@ static struct bio *get_swap_bio(gfp_t gfp_flags, bio->bi_iter.bi_sector = map_swap_page(page, &bdev); bio_set_dev(bio, bdev); - bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9; + bio->bi_iter.bi_sector <<= SECTORS_PER_PAGE_SHIFT; bio->bi_end_io = end_io; bio_add_page(bio, page, PAGE_SIZE * hpage_nr_pages(page), 0); @@ -266,7 +266,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) static sector_t swap_page_sector(struct page *page) { - return (sector_t)__page_file_index(page) << (PAGE_SHIFT - 9); + return (sector_t)__page_file_index(page) << SECTORS_PER_PAGE_SHIFT; } static inline void count_swpout_vm_event(struct page *page) diff --git a/mm/swapfile.c b/mm/swapfile.c index 5871a2aa86a5..0871023c0166 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -177,8 +177,8 @@ static int discard_swap(struct swap_info_struct *si) /* Do not discard the swap header page! */ se = first_se(si); - start_block = (se->start_block + 1) << (PAGE_SHIFT - 9); - nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9); + start_block = (se->start_block + 1) << SECTORS_PER_PAGE_SHIFT; + nr_blocks = ((sector_t)se->nr_pages - 1) << SECTORS_PER_PAGE_SHIFT; if (nr_blocks) { err = blkdev_issue_discard(si->bdev, start_block, nr_blocks, GFP_KERNEL, 0); @@ -188,8 +188,8 @@ static int discard_swap(struct swap_info_struct *si) } for (se = next_se(se); se; se = next_se(se)) { - start_block = se->start_block << (PAGE_SHIFT - 9); - nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9); + start_block = se->start_block << SECTORS_PER_PAGE_SHIFT; + nr_blocks = (sector_t)se->nr_pages << SECTORS_PER_PAGE_SHIFT; err = blkdev_issue_discard(si->bdev, start_block, nr_blocks, GFP_KERNEL, 0); @@ -240,8 +240,8 @@ static void discard_swap_cluster(struct swap_info_struct *si, start_page += nr_blocks; nr_pages -= nr_blocks; - start_block <<= PAGE_SHIFT - 9; - nr_blocks <<= PAGE_SHIFT - 9; + start_block <<= SECTORS_PER_PAGE_SHIFT; + nr_blocks <<= SECTORS_PER_PAGE_SHIFT; if (blkdev_issue_discard(si->bdev, start_block, nr_blocks, GFP_NOIO, 0)) break;