From patchwork Fri Nov 18 02:14:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047662 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 51EAEC43217 for ; Fri, 18 Nov 2022 02:14:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B03306B0072; Thu, 17 Nov 2022 21:14:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB2ED6B0073; Thu, 17 Nov 2022 21:14:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92D158E0001; Thu, 17 Nov 2022 21:14:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7D4496B0072 for ; Thu, 17 Nov 2022 21:14:19 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4F8FA1206DE for ; Fri, 18 Nov 2022 02:14:19 +0000 (UTC) X-FDA: 80144943438.29.6FDEF82 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf15.hostedemail.com (Postfix) with ESMTP id EA161A0008 for ; Fri, 18 Nov 2022 02:14:18 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id b62so3842574pgc.0 for ; Thu, 17 Nov 2022 18:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GVrcoUJXUK5/CKXbx6RN1zNp+2tpY9S51Tzzec48Gqs=; b=n+Zt6yJQR92KB0fxPR6JDUPzt9F3OC7xN7d8TnHtDCtwQLEicxkN8AsPcz0XtVoJa4 31sCY92jqlh5RBzjlzyVg5uS6DpdFBKpL3omU61y59YOI39fVFqerM6mVELkA3Xgv4gy 7dApw1AZp9Slmg5yw8FQBVK1RvQMmiKb/vL1R/XTtdUCYoccS7C4/wZwnCBlKNX2rPYR m38H8Vz1NqMXZQ6ZW2ZT03fEuOEposzfd8sraCtZnNiF3Jq/L3MJr9Hh42zEIJ32Jt6N PX3faosRjh6ClTura9m0asWyYaN8wAXgIsaDlBON0BEKQdRvqBZPBe/n3JKHZgGm8uRu Pycw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GVrcoUJXUK5/CKXbx6RN1zNp+2tpY9S51Tzzec48Gqs=; b=dA266WiosXFfywemhQH9UwrCH6NJnhXxlRIopv6L3mPVFJ/scWPVCLxQRbIeEBfqhx IJ7uvYK9lmjuVvqHIeSkX63XeY7LzxV0SGEsL/BSv24bhp4d3lumGygniAJrMNBcuBsL OarhLEh2ew8QbWV9nT8vW61LbmX5iMjWJtAA8w/s5Djy4lIuW0kOdL26tS4IvHdMXXnI Kfr7l8fXbWKV1pruYWU9m4bWlNPGlcmPB/0vYJ+88H9oR7Wra459GAF8YZU0nNkRRAe7 UENi10AW1D2lu92/5pcC1pD76bDNqwHfGQRbdYwKoUExsGl/4iPB8iFKUgFP6/3em1Rt hJkw== X-Gm-Message-State: ANoB5pml18Nl68EuVFQ5x9evz5W/YfhATT/oEVDWjtXQHsT/RmVQbaCI d+ebkICkllUcjFkGCuVpRi7OgREFRdoudg== X-Google-Smtp-Source: AA0mqf6iAHooNR4xeVmtlTu8wxCYQn6RvZGfmWf4g4O3f1LyTXhw0vhKNwN4D78AoBqTi/t8GN3Y0w== X-Received: by 2002:a63:d513:0:b0:438:c64b:a384 with SMTP id c19-20020a63d513000000b00438c64ba384mr4720773pgg.575.1668737657564; Thu, 17 Nov 2022 18:14:17 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id ip13-20020a17090b314d00b00212cf2fe8c3sm10678445pjb.1.2022.11.17.18.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 18:14:17 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, naoya.horiguchi@nec.com, tytso@mit.edu, "Vishal Moola (Oracle)" Subject: [PATCH v2 1/4] ext4: Convert move_extent_per_page() to use folios Date: Thu, 17 Nov 2022 18:14:07 -0800 Message-Id: <20221118021410.24420-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118021410.24420-1-vishal.moola@gmail.com> References: <20221118021410.24420-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668737659; a=rsa-sha256; cv=none; b=C6QEU8SMhZXR9QIVgLwtM97Mz3wt/qZsbb1L6GM3Gg/uJ29Rg/hSL59GbciI6HDsxmstlA 65JbArlX5U6lo1L5mLW+5FOXxDS9F07QwfdZMj2GD/7/dqWrz16NQfZ6zEbMoSQ/zuRraF L+wIR+jQPjUUALualzwabY3Q7Du7F6I= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=n+Zt6yJQ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668737659; 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=GVrcoUJXUK5/CKXbx6RN1zNp+2tpY9S51Tzzec48Gqs=; b=fwrDl2xD3MKibzUchc4FukX9TEXuzwZWh2pJBQTNauWY0HtCDmo95FFjYa1GrvVJfTX6P0 kth9sEKuiCWSrSxU0Q7EQDCH9rjFKPSBRfpqEIdaXzKuEmKGM6zDClw7SYDHkG3qyBSPCl GXOuPfZQ+6dge//aUMz5JHnwyZ9cLxk= Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=n+Zt6yJQ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspam-User: X-Stat-Signature: gbckjdjdgcb9qkc4ago6fzk7wyxmf1yy X-Rspamd-Queue-Id: EA161A0008 X-Rspamd-Server: rspam11 X-HE-Tag: 1668737658-334957 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: Converts move_extent_per_page() to use folios. This change removes 5 calls to compound_head() and is in preparation for the removal of the try_to_release_page() wrapper. Signed-off-by: Vishal Moola (Oracle) --- fs/ext4/move_extent.c | 52 ++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 044e34cd835c..aa67eb240ca6 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -253,6 +253,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, { struct inode *orig_inode = file_inode(o_filp); struct page *pagep[2] = {NULL, NULL}; + struct folio *folio[2] = {NULL, NULL}; handle_t *handle; ext4_lblk_t orig_blk_offset, donor_blk_offset; unsigned long blocksize = orig_inode->i_sb->s_blocksize; @@ -313,6 +314,13 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, * hold page's lock, if it is still the case data copy is not * necessary, just swap data blocks between orig and donor. */ + folio[0] = page_folio(pagep[0]); + folio[1] = page_folio(pagep[1]); + + VM_BUG_ON_FOLIO(!folio_test_large(folio[0]), folio[0]); + VM_BUG_ON_FOLIO(!folio_test_large(folio[1]), folio[1]); + VM_BUG_ON_FOLIO(folio_nr_pages(folio[0]) != folio_nr_pages(folio[1]), folio[1]); + if (unwritten) { ext4_double_down_write_data_sem(orig_inode, donor_inode); /* If any of extents in range became initialized we have to @@ -331,10 +339,10 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, ext4_double_up_write_data_sem(orig_inode, donor_inode); goto data_copy; } - if ((page_has_private(pagep[0]) && - !try_to_release_page(pagep[0], 0)) || - (page_has_private(pagep[1]) && - !try_to_release_page(pagep[1], 0))) { + if ((folio_has_private(folio[0]) && + !filemap_release_folio(folio[0], 0)) || + (folio_has_private(folio[1]) && + !filemap_release_folio(folio[1], 0))) { *err = -EBUSY; goto drop_data_sem; } @@ -344,19 +352,21 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, block_len_in_page, 1, err); drop_data_sem: ext4_double_up_write_data_sem(orig_inode, donor_inode); - goto unlock_pages; + goto unlock_folios; } data_copy: - *err = mext_page_mkuptodate(pagep[0], from, from + replaced_size); + *err = mext_page_mkuptodate(&folio[0]->page, from, from + replaced_size); if (*err) - goto unlock_pages; + goto unlock_folios; /* At this point all buffers in range are uptodate, old mapping layout * is no longer required, try to drop it now. */ - if ((page_has_private(pagep[0]) && !try_to_release_page(pagep[0], 0)) || - (page_has_private(pagep[1]) && !try_to_release_page(pagep[1], 0))) { + if ((folio_has_private(folio[0]) && + !filemap_release_folio(folio[0], 0)) || + (folio_has_private(folio[1]) && + !filemap_release_folio(folio[1], 0))) { *err = -EBUSY; - goto unlock_pages; + goto unlock_folios; } ext4_double_down_write_data_sem(orig_inode, donor_inode); replaced_count = ext4_swap_extents(handle, orig_inode, donor_inode, @@ -369,13 +379,13 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, replaced_size = block_len_in_page << orig_inode->i_blkbits; } else - goto unlock_pages; + goto unlock_folios; } /* Perform all necessary steps similar write_begin()/write_end() * but keeping in mind that i_size will not change */ - if (!page_has_buffers(pagep[0])) - create_empty_buffers(pagep[0], 1 << orig_inode->i_blkbits, 0); - bh = page_buffers(pagep[0]); + if (!folio_buffers(folio[0])) + create_empty_buffers(&folio[0]->page, 1 << orig_inode->i_blkbits, 0); + bh = folio_buffers(folio[0]); for (i = 0; i < data_offset_in_page; i++) bh = bh->b_this_page; for (i = 0; i < block_len_in_page; i++) { @@ -385,7 +395,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, bh = bh->b_this_page; } if (!*err) - *err = block_commit_write(pagep[0], from, from + replaced_size); + *err = block_commit_write(&folio[0]->page, from, from + replaced_size); if (unlikely(*err < 0)) goto repair_branches; @@ -395,11 +405,11 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, *err = ext4_jbd2_inode_add_write(handle, orig_inode, (loff_t)orig_page_offset << PAGE_SHIFT, replaced_size); -unlock_pages: - unlock_page(pagep[0]); - put_page(pagep[0]); - unlock_page(pagep[1]); - put_page(pagep[1]); +unlock_folios: + folio_unlock(folio[0]); + folio_put(folio[0]); + folio_unlock(folio[1]); + folio_put(folio[1]); stop_journal: ext4_journal_stop(handle); if (*err == -ENOSPC && @@ -430,7 +440,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, *err = -EIO; } replaced_count = 0; - goto unlock_pages; + goto unlock_folios; } /** From patchwork Fri Nov 18 02:14:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047663 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 8294CC4167B for ; Fri, 18 Nov 2022 02:14:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 058276B0073; Thu, 17 Nov 2022 21:14:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F24346B0075; Thu, 17 Nov 2022 21:14:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0F416B0078; Thu, 17 Nov 2022 21:14:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D34A46B0073 for ; Thu, 17 Nov 2022 21:14:20 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9C4ACC0684 for ; Fri, 18 Nov 2022 02:14:20 +0000 (UTC) X-FDA: 80144943480.24.FE947A8 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf25.hostedemail.com (Postfix) with ESMTP id 405A1A000B for ; Fri, 18 Nov 2022 02:14:20 +0000 (UTC) Received: by mail-pl1-f179.google.com with SMTP id w23so3316328ply.12 for ; Thu, 17 Nov 2022 18:14:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3YDT/XAgh5QSXlyod86SZaadrvntYw6ff/cmVDaxdzo=; b=WIhEVv40bO8pPOe0T4T4maV1rYV4pai+d0aHe5h0r42FibWzau6xqjlbhDYj7fVP+/ YVbz1QBIEi5smOOlTRsnqvFnOSv1Un3EXZls7avo8RWt8GuSdf13vWB1vX+nyGT9q/EA T4uFXOL3nEQg/604IZpT78KAD+oBUy2DhDfpQmyGPPQ90V+476q3TDhM8JO5/eefRo39 Kc6oAfVStZxNFPpjkSEaVmtKQ/MwyY+KaTUq/ui8Z+wJ5NVT0RpHdPebMV2bUg0O0Yfb SscM0FktFuryyy6iQ7l4iU39d7doVgLL5n+BXTp0RKjfosJtcvVKIK7EIBdl3j/ynnVZ 8T3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3YDT/XAgh5QSXlyod86SZaadrvntYw6ff/cmVDaxdzo=; b=SaBaO2pSmFYcChzvQlIdHGsEbDVe6dUiLNCa0UUFYBYLZCtQxh86Q6ueUBytW1+FCW wn69MxS3t8ssWnN/A524ggnQ9S/LaDit4WgTIBZojLyD91mWNq2aRuIFIpdk3xOEw1E7 cwIZy19vgBSKe3KPQdJOosrbGsADEmoVmOJoS0w1AvmLS0Onnh3R89AshD4uSAYq83xU rQsZvZZ2O3aUpVH5CnKr84a9iJRUtObu1Ry3rtdi47g3JYd6usoCwc27ib7W+6O42Cxa oXRrAYIKZaefhwjtm4+QVEINRVjserwpbwlO9v9ZV7HE/MlwqAmJc0Uxz3tKm2M3es8a Ra3w== X-Gm-Message-State: ANoB5pks3Ab7V/HAdsKBjMLROcVnseT1FmoZouC8pwXb63SbE2bfoYsy keXlVirjaXIdR3CkrFVC6p4TNpljcvS0HA== X-Google-Smtp-Source: AA0mqf6GjOQDWGuexUgf38gfQKvCyqZA7SD4wDQnxu1HJGFKP1gZXSLR4W2L7BYbOtRyfWYq70EdTQ== X-Received: by 2002:a17:90b:117:b0:212:f2be:bc38 with SMTP id p23-20020a17090b011700b00212f2bebc38mr11372286pjz.175.1668737658849; Thu, 17 Nov 2022 18:14:18 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id ip13-20020a17090b314d00b00212cf2fe8c3sm10678445pjb.1.2022.11.17.18.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 18:14:18 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, naoya.horiguchi@nec.com, tytso@mit.edu, "Vishal Moola (Oracle)" Subject: [PATCH v2 2/4] khugepage: Replace try_to_release_page() with filemap_release_folio() Date: Thu, 17 Nov 2022 18:14:08 -0800 Message-Id: <20221118021410.24420-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118021410.24420-1-vishal.moola@gmail.com> References: <20221118021410.24420-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668737660; a=rsa-sha256; cv=none; b=tBRdYuRHJsFdOhuB/PRGdJtmSXV3rwFuprbtIzwmsn80U8Jf4WOlSGU9IFWHC9nvl3VL/S RYVJMh7kx2DGnz0DSnSZiVKQob5QkERS1d3agsejMPB+HV+2f2qeYUIcijsVJ3fSjYgjpR xO7l6i+gJWPJfa3HvLJvaUB2yBsP3Iw= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WIhEVv40; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668737660; 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=3YDT/XAgh5QSXlyod86SZaadrvntYw6ff/cmVDaxdzo=; b=VLPsliOHTzS+7g9khFBPMn2XQ/ETkatUr9WpOhqrQcPoepEe0oAvzd6ZtsdkEzUjjsaaDc 70kg1kyTzEkBLqKNoc3s1pepQhiHJeOjgwA3LgF4wapRFzKgZHBZjLukq9SvY6b1K0KYz8 JY6FZqyc6l00ICP2nP+51H9AsK+Xx+c= X-Stat-Signature: amtwctqmmukppnb54suamsiaow9i5s6g X-Rspamd-Queue-Id: 405A1A000B Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WIhEVv40; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1668737660-63361 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000060, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Replaces some calls with their folio equivalents. This change removes 4 calls to compound_head() and is in preparation for the removal of the try_to_release_page() wrapper. Signed-off-by: Vishal Moola (Oracle) --- mm/khugepaged.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 4734315f7940..3f21c010d2bd 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1747,6 +1747,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, xas_set(&xas, start); for (index = start; index < end; index++) { struct page *page = xas_next(&xas); + struct folio *folio; VM_BUG_ON(index != xas.xa_index); if (is_shmem) { @@ -1773,8 +1774,6 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, } if (xa_is_value(page) || !PageUptodate(page)) { - struct folio *folio; - xas_unlock_irq(&xas); /* swap in or instantiate fallocated page */ if (shmem_get_folio(mapping->host, index, @@ -1862,13 +1861,15 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, goto out_unlock; } - if (page_mapping(page) != mapping) { + folio = page_folio(page); + + if (folio_mapping(folio) != mapping) { result = SCAN_TRUNCATED; goto out_unlock; } - if (!is_shmem && (PageDirty(page) || - PageWriteback(page))) { + if (!is_shmem && (folio_test_dirty(folio) || + folio_test_writeback(folio))) { /* * khugepaged only works on read-only fd, so this * page is dirty because it hasn't been flushed @@ -1878,20 +1879,20 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, goto out_unlock; } - if (isolate_lru_page(page)) { + if (folio_isolate_lru(folio)) { result = SCAN_DEL_PAGE_LRU; goto out_unlock; } - if (page_has_private(page) && - !try_to_release_page(page, GFP_KERNEL)) { + if (folio_has_private(folio) && + !filemap_release_folio(folio, GFP_KERNEL)) { result = SCAN_PAGE_HAS_PRIVATE; - putback_lru_page(page); + folio_putback_lru(folio); goto out_unlock; } - if (page_mapped(page)) - try_to_unmap(page_folio(page), + if (folio_mapped(folio)) + try_to_unmap(folio, TTU_IGNORE_MLOCK | TTU_BATCH_FLUSH); xas_lock_irq(&xas); From patchwork Fri Nov 18 02:14:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047664 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 30CD6C433FE for ; Fri, 18 Nov 2022 02:14:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EF3B6B0075; Thu, 17 Nov 2022 21:14:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24F936B0078; Thu, 17 Nov 2022 21:14:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 141726B007B; Thu, 17 Nov 2022 21:14:22 -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 00E796B0075 for ; Thu, 17 Nov 2022 21:14:21 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CBA95AB19C for ; Fri, 18 Nov 2022 02:14:21 +0000 (UTC) X-FDA: 80144943522.17.59FAEA6 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf02.hostedemail.com (Postfix) with ESMTP id 749CA80006 for ; Fri, 18 Nov 2022 02:14:21 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id t17so2595892pjo.3 for ; Thu, 17 Nov 2022 18:14:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wss4l8+ki3bcqZpf4pXWKdXS9Ah4/Shxx0wHVdp0ynM=; b=BHAg7M5s8r6Zk3gNga8DlzxghZsFB0+gDqhWzAobQ0NDSCnRl+jsxSvoCauCt5pDlV FDsWr0LWtE3+ZTY7CQ3LTNxeN3cKijwiRiaNvETjKpEgeeIjaGefYqxrpk0elzNuWxJs ZXKMKa/5Iju31VyTJHHA2LNGmdzJjmeLdNHvAI5Fpr2KdzXb90/1Yd/rS/2cqR0oRiiX Qk+aUBMrANKZjsd0FyKxxEMA7BhVE+Ewy6TrW4vdV7QCkzGSUwFyFzgsMEX2rjxIgUFR Q1A/dW1R3WyV8pkB70F3ahkg7sda6EOcxLWMlweeAzvu72bbCTJs57pkgTpCtPxu7pY6 T4Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wss4l8+ki3bcqZpf4pXWKdXS9Ah4/Shxx0wHVdp0ynM=; b=kqH0+lH/B8i8clxDwazPRceR94OGyfqo9Pnnq4tcMQe1tvHAQKeRPtYUrbWqDmOARb UF4t3PXp/IJ1tfrmJbgmklstGRuoCTfvWl4+QOZTtvOTh4Xm5JoplC+Sn0dknJVJjc4G YiW5sms3jp0yIDe8ljRjbB/D9AXOeUVukD2hI0w1vvpM3M3GkH5qnDq5ktrupk4KxFJ7 02Nt0oYyuvFOOuntZ+F8Gm71JGUbN6mu/UPfubiyvD/Mi6DC0Zt7TFA5EL8tlcAXWnY7 eRIV4z4LhQt7FKYhoXlAQnx8dXQJpW2VzzbbCzgKZ4uHLDzgOMNRF5EcAmkYpOMOSuGx l4fQ== X-Gm-Message-State: ANoB5pkveElShTRsMywZ5HrofqXOMQgToQ1/476OuT18zDlCWLEDpJ/R CGo6tJ+ia5Aa9A9JWLnrtvAISIMVk1NZng== X-Google-Smtp-Source: AA0mqf7kbAgQClkwM4QeG3emZxM+wBrivG6gwkUc5TdT1Y7K2yhmUkpU4mlPfxxeDly9Q1KMWA0dXQ== X-Received: by 2002:a17:90b:2542:b0:1fb:e7a:79b with SMTP id nw2-20020a17090b254200b001fb0e7a079bmr11745002pjb.93.1668737660142; Thu, 17 Nov 2022 18:14:20 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id ip13-20020a17090b314d00b00212cf2fe8c3sm10678445pjb.1.2022.11.17.18.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 18:14:19 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, naoya.horiguchi@nec.com, tytso@mit.edu, "Vishal Moola (Oracle)" Subject: [PATCH v2 3/4] memory-failure: Convert truncate_error_page() to use folio Date: Thu, 17 Nov 2022 18:14:09 -0800 Message-Id: <20221118021410.24420-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118021410.24420-1-vishal.moola@gmail.com> References: <20221118021410.24420-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BHAg7M5s; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668737661; a=rsa-sha256; cv=none; b=8dC7Zue8NDPOD+VbzrudiG18uPvarcsDRndm6JSudkD4jV5PZkLQy3EJuFp2jEqc/vb9en kPZhCv/IsLnko27Z+UeabnC6l8B5BRRnit/ma9tE9PVK0ZOHn+6uug/KztuyGrTE80HmJk YNv8O06/hgUuGO0rJSZMNf9gK8KdLD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668737661; 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=Wss4l8+ki3bcqZpf4pXWKdXS9Ah4/Shxx0wHVdp0ynM=; b=kUGRUFyDlXNp/FiqTFsX1YIkRIZW3vg5qabMgLOCMaCPHc1jdJIesjRScUTxtlZygmpqWs 0XiFOSv/psEYInm3QP4BorJzkPw27aKp9N5pCOrdwcs/luaKLeuZhYxESjxJ06g5SUV4+6 fLOBPv3kBPiHiMB6zfKa31F9QFhkEEc= Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BHAg7M5s; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: u79k8x69iwxhmozpk34pxfgorkedk68s X-Rspamd-Queue-Id: 749CA80006 X-HE-Tag: 1668737661-626417 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: Replaces try_to_release_page() with filemap_release_folio(). This change is in preparation for the removal of the try_to_release_page() wrapper. Signed-off-by: Vishal Moola (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 145bb561ddb3..92ec9b0e58a3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -827,12 +827,13 @@ static int truncate_error_page(struct page *p, unsigned long pfn, int ret = MF_FAILED; if (mapping->a_ops->error_remove_page) { + struct folio *folio = page_folio(p); int err = mapping->a_ops->error_remove_page(mapping, p); if (err != 0) { pr_info("%#lx: Failed to punch page: %d\n", pfn, err); - } else if (page_has_private(p) && - !try_to_release_page(p, GFP_NOIO)) { + } else if (folio_has_private(folio) && + !filemap_release_folio(folio, GFP_NOIO)) { pr_info("%#lx: failed to release buffers\n", pfn); } else { ret = MF_RECOVERED; From patchwork Fri Nov 18 02:14:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047665 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 9ADDCC4332F for ; Fri, 18 Nov 2022 02:14:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 894146B0078; Thu, 17 Nov 2022 21:14:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CD586B007B; Thu, 17 Nov 2022 21:14:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BE056B007D; Thu, 17 Nov 2022 21:14:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5C3EC6B0078 for ; Thu, 17 Nov 2022 21:14:23 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3ACAEABB1D for ; Fri, 18 Nov 2022 02:14:23 +0000 (UTC) X-FDA: 80144943606.09.018D68D Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf05.hostedemail.com (Postfix) with ESMTP id DB545100002 for ; Fri, 18 Nov 2022 02:14:22 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id q9so3575963pfg.5 for ; Thu, 17 Nov 2022 18:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CejbmJMt8knLZkp2jnt3nSDaW2/iqvwuj8SHKIZ6DVU=; b=b82Ya60EgEzBmglfPyBteCPU9obmCFXipeevVnQGfYhF7131nPzLpFPp43Ttx1rvn2 aK+X7i1nofdutJEjCXfng2R3bMAfiY8qfs7ydF8u46qloqksHIzzoixx409rSQ45wRef UDiKfwPyx0xH1yEaX3rdOhR/9wlEjtKQAlEI+0dEwWXnjA3UuV60+YQD+MbBUTZk70p8 NJgnsSHd7EoDzmnJH74gRQmfqrFDd0q9Lq0Pn82ss0Y3nD2dH4kG97VKWRdmHzft0eDc 3oapbuXhA7sOvAUDp7vWMjpLtAN5ZvHjjq20fwg/DQ8LUe1NzbQuiv448aHx0g7t5Exo F+wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CejbmJMt8knLZkp2jnt3nSDaW2/iqvwuj8SHKIZ6DVU=; b=DV4X79KOOgU1lxQOYBL1e4siSDcd+ElETRyiWdZhjFSLtzUMcXtZ+Ob4F/w768K2bO JCrVca86yIjOe9A1lUI+FiJIP9aUeCBi0tnTDj+Z9YEEOB19uyUz/iZlSKMX5uSHX9nq jFOySIL+kufXTn1TQMJmEUzYC/KwEELTBoYJX3j4EWWaXLTXA0ncLExNi96pw0mEV+TM khFL7VeISXdSQRrDxnixK+FVUlf9lwIOEa0Nk6+bjDKMahEnkaCqQx53LtiK99wTycJo 1TSvONOmJY3NP5qJSjrEmUyBr7wsxzMSEbSVEvGCxlMg+FvuwKEBR49VwTXmiX18kTlc DCIA== X-Gm-Message-State: ANoB5plu3HfSWzWfFlr6H4T3Xvcx/e7kTY7ZJ0tQ4bAA0FW7iWAuzhEo 6GEw4nzdb3r3VCbYb3gVMFhUdNSj/iyTQw== X-Google-Smtp-Source: AA0mqf7S9erhu0bgdFYN18UsmwY31ELzskD/pg44k2C37qZCuH5QiKU6nJz4HrcQB7qDLTx4MBSezw== X-Received: by 2002:a05:6a00:21c2:b0:56b:bba4:650a with SMTP id t2-20020a056a0021c200b0056bbba4650amr5861219pfj.4.1668737661580; Thu, 17 Nov 2022 18:14:21 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id ip13-20020a17090b314d00b00212cf2fe8c3sm10678445pjb.1.2022.11.17.18.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 18:14:21 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, naoya.horiguchi@nec.com, tytso@mit.edu, "Vishal Moola (Oracle)" Subject: [PATCH v2 4/4] folio-compat: Remove try_to_release_page() Date: Thu, 17 Nov 2022 18:14:10 -0800 Message-Id: <20221118021410.24420-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118021410.24420-1-vishal.moola@gmail.com> References: <20221118021410.24420-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b82Ya60E; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668737662; a=rsa-sha256; cv=none; b=TaQ1d8gElWrRK3+1ef3eOSmCzJCFB1jmGzaGdyaL/N2KqBp2pBolPL0DdX2JLEAKHfFQH0 G3HIZ6p3qv8ysLFjLwEi891dfeFNi3SuSmvSztV93F5A0Ze+C6I/zb0QoBopJzoamip7AV Olqdt020hyu7bHj3qMzN2uzqySq28VA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668737662; 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=CejbmJMt8knLZkp2jnt3nSDaW2/iqvwuj8SHKIZ6DVU=; b=Bwv8S9cKue8uUwPA4Y1BA1PixWVS5mB69HUNFbIro4EFVCR/d3HmuzZSF/BFhxVZw5cXbc owuGzhyJUgc7LkFko7hYBcxMPJEKqDIuT/yEzsZoC9OXTFZwp3wmQw1tch9Vnv9p02NpWz lPxazkYU3U9vlodhyf2JoUyAtCvfa90= Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b82Ya60E; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: c5x54m7z6dkgeixzhoknghp67u64jbb8 X-Rspamd-Queue-Id: DB545100002 X-HE-Tag: 1668737662-636978 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000015, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: There are no more callers of try_to_release_page(), so remove it. This saves 149 bytes of kernel text. Signed-off-by: Vishal Moola (Oracle) --- include/linux/pagemap.h | 1 - mm/folio-compat.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index bbccb4044222..daf5e1a1d313 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1107,7 +1107,6 @@ void __filemap_remove_folio(struct folio *folio, void *shadow); void replace_page_cache_page(struct page *old, struct page *new); void delete_from_page_cache_batch(struct address_space *mapping, struct folio_batch *fbatch); -int try_to_release_page(struct page *page, gfp_t gfp); bool filemap_release_folio(struct folio *folio, gfp_t gfp); loff_t mapping_seek_hole_data(struct address_space *, loff_t start, loff_t end, int whence); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index e1e23b4947d7..9318a0bd9155 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -129,12 +129,6 @@ void delete_from_page_cache(struct page *page) return filemap_remove_folio(page_folio(page)); } -int try_to_release_page(struct page *page, gfp_t gfp) -{ - return filemap_release_folio(page_folio(page), gfp); -} -EXPORT_SYMBOL(try_to_release_page); - int isolate_lru_page(struct page *page) { if (WARN_RATELIMIT(PageTail(page), "trying to isolate tail page"))