From patchwork Wed Dec 13 21:58:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13491929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C9DAC4332F for ; Wed, 13 Dec 2023 21:59:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E8898D0064; Wed, 13 Dec 2023 16:59:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 570798D0062; Wed, 13 Dec 2023 16:59:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 374CC8D0064; Wed, 13 Dec 2023 16:59:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 23F968D0062 for ; Wed, 13 Dec 2023 16:59:03 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E840F1A0116 for ; Wed, 13 Dec 2023 21:59:02 +0000 (UTC) X-FDA: 81563160924.24.865ECC4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id B167514001A for ; Wed, 13 Dec 2023 21:59:00 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=J+8Kg4JE; dmarc=none; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702504741; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cycVRug3BXZ7xnSyei6e0LRSUicnPdbBpgBQ/Dl2tkc=; b=CgWfG/kkdHl8RliHI+vpbGmKKmyqtL9mod1p0q12TvN8Pj955OpXlB23VhdDt8vKXIzdHZ TXMHqZUzoyroYjUrffLeFz8Xsag7QAnFOH6kXz1ZIBXbghJiN7kLvBnevVpPl8mX2KTfu5 2VJSqlT8gFi164eo9OttJsyRP0H1oEA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=J+8Kg4JE; dmarc=none; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702504741; a=rsa-sha256; cv=none; b=mruYEsIuL0HiEhnUvGmC1ZzDUqD4XiQ2fGwnzohZngkiMAIO479f3/b3KSpTipdoehRtwO ZW5PRAouJHnMwN0PBr/LJdjplronTX3wG3H3O8/3Zi33wWwhYdZiydVt580uORpPnBTqI8 yccKdhm1SZF4tusA6wuvsxcd+8zSpeI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=cycVRug3BXZ7xnSyei6e0LRSUicnPdbBpgBQ/Dl2tkc=; b=J+8Kg4JE6iq6EkIJUz+R2TIZmr ihtRoobszxm3k98bukYMYbxRLgncWKf74COSc0hOmqTRS3mJrWkgB8biMqy9KWOanBqtJOAgBq6t9 DnmN1Wsx/JmtTfkNfRYAnuAXFq6NX02GjBQU1p10kxEQFyVhcvFb74QiC0eaBywuLtFkEnPp7LHqq +bXZBJwlG5LDgarDVnFidW477Qpf1P0FJnUke0oHJIlHk7OFyi7JzjX9oK9gowhs7BSOhBxFdN9l1 Req6S8DBJI9VFTZweIBYPJkBxdFP3F2BEwlq4T07w+Etd0iPffzM1cd62b2qpb7TUZfmh/DoKJIPF VBhGvBbA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rDXFd-002oiZ-TR; Wed, 13 Dec 2023 21:58:45 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 09/13] mm: Convert swap_page_sector() to swap_folio_sector() Date: Wed, 13 Dec 2023 21:58:38 +0000 Message-Id: <20231213215842.671461-10-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231213215842.671461-1-willy@infradead.org> References: <20231213215842.671461-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B167514001A X-Stat-Signature: fah3yb5qfub19smiccb3fjtq6a3tnmbq X-HE-Tag: 1702504740-27090 X-HE-Meta: U2FsdGVkX1/8nF/o9Y7oJgfOJqx1E6OVtPWHxfbn6VrU8Bz4SD153ymXKbLzmm4SXWG41J5hJX5e5QSzV8G7q4eLR7fMIjiX7QJY7Zo4pS/7vO0ZV3gwQb95U9Ah+BXB9RR3JGQ066YiYUyT+iqf0tfkuNI4tosiPP4tlewoyCTAR9a1PpGqr1ZLuOcUeJNiUkhLNN1E+f3yMlY5PhQiBAiitvqYzqFBs9UsawlWyMtTHyEobXHt25wosw4cJl5G8gUifB/MUKAlOhHeFYifKSY03fNcyMYm7A3V3rD4NNKh9ezmAxW3zSNkmHHv/9dSHA6ag++jLOvrA/u5P1yVeE8z0txEBJZkagvdI4j8nnTNQiSLx3UAA9GKo/otxowiGccE9tpF0tLj1mKylDsSAj/G+VxL3UyMgFZFVnv2mhVuT4ZWS0mZGbuJglQW+k/gIO7VuAu9l2n856nEvkFmWg8YC8nlXqtGiebnNkzDfNMrR4+qaveBmVqysjHgzXuaP5Q2GEQNhG4I3Tf8hG3k0D1n8tMuTt/lL4P7gh2GjBd1yNWhH2FwIN6agB2RuvgwyQFHDDMFQnvw6t8lpwWXI3W6D3WHXOMEZsvaa/yFuKdTep0JXFUNW5UKgNRfgQNXF6OLLFVxGk4hTzIq+ddzlopMOWeevwPcbcuGNc5o3sMXDXSgcQNVgmZtghDpAxULwVyd2YbR/0jG0DE0AZ6YsBqJjLStqbVT4gFqMNoOHuWjlt/vI8CzP/F1zmx2re4Y/QNVQ03e8YLxx98Az5u3St97MeHpT4ObVab6lqfvJGm1C4ZePWOp4Ehf/DF9HVXwZasjw48hNkafdhAkLW3fzBHHomY+BTN2EfyfYZFju5eVny2gXtZlu1EI7xOvtQduyHELENYR4UaXdPjPwtaEqWdRv0Jaohf/RHBDt/T8nx45t45j/YHnGDfsTckkIxxi2Gsoc2yzUg3LyXqf0cO KMyVQrVK NiDBdbljIm9d5knLe7/aUpqpksbVQGyFjDskFdY567Rl9EpmBFoIcbXgcmJ7zEM/A1EUAhKtgcoDltgo6NajoSjxTeztPp6IW3E1x5hJxnOR0S5gqM53FVohECyLDpS89zRBjBcf6u5nb0ajZGSKiRPPPhXdU3K66ogh9Ypfyl6ZYe8OtVQD9ZwEuTa9h48itGIKn7UOCU2R90Qq8RVMz6/b47YP6aJCmFy2/ 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: List-Subscribe: List-Unsubscribe: All callers have a folio, so pass it in. Saves a couple of calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/swap.h | 2 +- mm/page_io.c | 8 ++++---- mm/swapfile.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index edc0f2c8ce01..77c43715ad5b 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -493,7 +493,7 @@ struct backing_dev_info; extern int init_swap_address_space(unsigned int type, unsigned long nr_pages); extern void exit_swap_address_space(unsigned int type); extern struct swap_info_struct *get_swap_device(swp_entry_t entry); -sector_t swap_page_sector(struct page *page); +sector_t swap_folio_sector(struct folio *folio); static inline void put_swap_device(struct swap_info_struct *si) { diff --git a/mm/page_io.c b/mm/page_io.c index e18afcd9c19a..6736c56526bf 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -334,7 +334,7 @@ static void swap_writepage_bdev_sync(struct folio *folio, bio_init(&bio, sis->bdev, &bv, 1, REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc)); - bio.bi_iter.bi_sector = swap_page_sector(&folio->page); + bio.bi_iter.bi_sector = swap_folio_sector(folio); bio_add_folio_nofail(&bio, folio, folio_size(folio), 0); bio_associate_blkg_from_page(&bio, folio); @@ -355,7 +355,7 @@ static void swap_writepage_bdev_async(struct folio *folio, bio = bio_alloc(sis->bdev, 1, REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc), GFP_NOIO); - bio->bi_iter.bi_sector = swap_page_sector(&folio->page); + bio->bi_iter.bi_sector = swap_folio_sector(folio); bio->bi_end_io = end_swap_bio_write; bio_add_folio_nofail(bio, folio, folio_size(folio), 0); @@ -461,7 +461,7 @@ static void swap_readpage_bdev_sync(struct folio *folio, struct bio bio; bio_init(&bio, sis->bdev, &bv, 1, REQ_OP_READ); - bio.bi_iter.bi_sector = swap_page_sector(&folio->page); + bio.bi_iter.bi_sector = swap_folio_sector(folio); bio_add_folio_nofail(&bio, folio, folio_size(folio), 0); /* * Keep this task valid during swap readpage because the oom killer may @@ -480,7 +480,7 @@ static void swap_readpage_bdev_async(struct folio *folio, struct bio *bio; bio = bio_alloc(sis->bdev, 1, REQ_OP_READ, GFP_KERNEL); - bio->bi_iter.bi_sector = swap_page_sector(&folio->page); + bio->bi_iter.bi_sector = swap_folio_sector(folio); bio->bi_end_io = end_swap_bio_read; bio_add_folio_nofail(bio, folio, folio_size(folio), 0); count_vm_event(PSWPIN); diff --git a/mm/swapfile.c b/mm/swapfile.c index 1501bc956456..b22c47b11d65 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -227,14 +227,14 @@ offset_to_swap_extent(struct swap_info_struct *sis, unsigned long offset) BUG(); } -sector_t swap_page_sector(struct page *page) +sector_t swap_folio_sector(struct folio *folio) { - struct swap_info_struct *sis = page_swap_info(page); + struct swap_info_struct *sis = swp_swap_info(folio->swap); struct swap_extent *se; sector_t sector; pgoff_t offset; - offset = __page_file_index(page); + offset = swp_offset(folio->swap); se = offset_to_swap_extent(sis, offset); sector = se->start_block + (offset - se->start_page); return sector << (PAGE_SHIFT - 9);