From patchwork Fri Nov 18 07:30:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047790 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 BA316C43217 for ; Fri, 18 Nov 2022 07:31:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AC7F6B0072; Fri, 18 Nov 2022 02:31:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 35CCF8E0001; Fri, 18 Nov 2022 02:31:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 208626B0075; Fri, 18 Nov 2022 02:31:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0A9346B0072 for ; Fri, 18 Nov 2022 02:31:02 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C485F120D3C for ; Fri, 18 Nov 2022 07:31:01 +0000 (UTC) X-FDA: 80145741522.23.D4872FB Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf07.hostedemail.com (Postfix) with ESMTP id 6B77640008 for ; Fri, 18 Nov 2022 07:31:01 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id k22so4129935pfd.3 for ; Thu, 17 Nov 2022 23:31:01 -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=Re0/IOxZf5Hx6BeFa9inJCF0a6cGKdlu1k/P2sxW8QU=; b=JbqHqUy5gwXZXXmeVcz1VjkFSML8VbgCJWNNoIeSydHy4Efkp/nj8IFLHy4/PRyQHV ZD3+lwCTNEDhNf9veaDSLhz7j3rTE4dSA4jeOiZEUCQyws3Y+MXRKm5Dx6naoty++WGj mgSMypdnxVTv66L8q6FElC2UoiRdmhg+l5LTbN2Cc3AqtbTaJnJbry0nqqNvt41WohIs ztjkEsGC3JY6Tb7yMLuQkZ4ruAJGVqCUBWYkGv/ejG/TxtUngfWOAkENVYlHfIHeipzE 4EaQZm6twldEsxve4TG9hLLt2BHQD5Wol13hE8LCOU9klaLw9axg+PJfCy1uLkMcLHnC TDyg== 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=Re0/IOxZf5Hx6BeFa9inJCF0a6cGKdlu1k/P2sxW8QU=; b=WZzwA5M2j7PV3u2pXIy90G9MMhOGzjzKkxrqnkU1QkT6G1uqgH2wZHANDWCLQ/ppXs gPyksEeubY+Gi1V9i9zZB4NyuTLtqy5yn8R17qqb6JKfPu2AlcmUxvwV7MtfjnoBwyiy 8UvR8Ad3YdZOCGgm9owLhPpHSb1lHQj+p6C32LzH8/gkMuJEpjl9yz8CUfPiL7exie3P /Zt78Tf4/+8/b3+2YtRJYDhkXwWSEoGe2+Ya+sHPideiwt7cY9IxHIGOgcRsWNwwC8zB y/25pnq/6YstEBzOmYI2tiBqDsnKghocggIxcpzbPXCRSTfXQAS6/hta0J3brfnBcZGz BYqg== X-Gm-Message-State: ANoB5plEoF6NbszkZ8aE62Yx9NFwui2R5jU2ECf/gsz5SbjaPg3FaJVp cBiNleFub84Qs1JCdMF2d+Oj5Nosh5fvWQ== X-Google-Smtp-Source: AA0mqf74xy5zzCPkhfKsu8yk5H8M6NX2NwxmI1wq416bDYujVpUPBbKbSm4WAOvoHdM/PeGp3gUU1g== X-Received: by 2002:a63:2117:0:b0:474:f7bd:9462 with SMTP id h23-20020a632117000000b00474f7bd9462mr5417655pgh.189.1668756660244; Thu, 17 Nov 2022 23:31:00 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f7-20020a625107000000b0056b818142a2sm2424325pfb.109.2022.11.17.23.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 23:30:59 -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 v3 1/4] ext4: Convert move_extent_per_page() to use folios Date: Thu, 17 Nov 2022 23:30:52 -0800 Message-Id: <20221118073055.55694-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118073055.55694-1-vishal.moola@gmail.com> References: <20221118073055.55694-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668756661; a=rsa-sha256; cv=none; b=Mm9WF0eS1cAKHRj/pJey3F7d/KjEf0tTyYhww46S9c5GNfSp+RaTHSFJsbCK0GLhDUr1WR NCwOu1P3KkwijBGgO5v9m9yZyBg78bt8mDXGiL2HP3L1B+zaj1MQqeJpfEVSnQ+afrmulE EdgWYTUt7hFW11ONnFpiEpMa865PgcE= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JbqHqUy5; spf=pass (imf07.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.178 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=1668756661; 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=Re0/IOxZf5Hx6BeFa9inJCF0a6cGKdlu1k/P2sxW8QU=; b=XLPi2CKQGlBRVuNWxpNstH+j1Dx3QAmtMIPayt0GXrtx8vXhrqEIubHeGmuxUAu8b3Rkc0 WCw9kzepjMUdPgnP1EnoQFP2+JPhix9DBmslqke7Xs1CSb5ul1m4+qBVmMPW3AOV6mVDYn D3lqzm7vivTAQajicMCIbXmLQs9vX9c= X-Stat-Signature: kaztf91mzpbwqxqbqwq5pixi6nrbd8q6 X-Rspamd-Queue-Id: 6B77640008 X-Rspamd-Server: rspam01 X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JbqHqUy5; spf=pass (imf07.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1668756661-632636 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..8dbb87edf24c 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 07:30:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047791 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 EC9E8C433FE for ; Fri, 18 Nov 2022 07:31:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8682A8E0002; Fri, 18 Nov 2022 02:31:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CA238E0001; Fri, 18 Nov 2022 02:31:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66BB28E0002; Fri, 18 Nov 2022 02:31:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4A1328E0001 for ; Fri, 18 Nov 2022 02:31:03 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2CDDC1A0F1E for ; Fri, 18 Nov 2022 07:31:03 +0000 (UTC) X-FDA: 80145741606.02.DE33E82 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf22.hostedemail.com (Postfix) with ESMTP id C5BBCC000C for ; Fri, 18 Nov 2022 07:31:02 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id b29so4093735pfp.13 for ; Thu, 17 Nov 2022 23:31:02 -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=hj4sZ/oWS0i8ScGh0vbYAIusnjEYl4+v/V1w1lie+penPK+3QNfEw3e9lA2YvJY2vR 6U/s2favaWtrdVTN7ZxQYN3TNv3Gzmpp604WxQwf07cMv2V49N2eaV7INf9Mr/Fka3YI xDOXnWXwgetOrVE/PlHzDoVG1SMMD4hoFkHh/oQNMdcDaEpRuTgXjAO9bddr37OTQA9S ktOJf5nHzqLSna/GQtVnkHo4D6L/QgA1XlGFW6vtKLEvNOd3QZJfPnrf0ZJ6H9hrmP42 2o4Oyky8msMLDuOQ8ogXe9MjRO0eSJ3lurHDvLvpnWxaXJlo2L20CeupZWrVkRx6b2tf oYKQ== 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=xtw2Yw8ds54wAY2z9N6lZx/qrgx6BAqoQ9aOdBjdlJN1JKfd5omDMt1r4M+6xuWaMG JxXXI07MY6Z1XIvyKHgZnLlLRRllqXOIFT4GpDVtIkTwIJ7q7d1GIfzRvsM9R2Kv1j9L 7oO0LlKyqJRZcGwC2xz9UJjzoC8sqb1uD963OEh/nyGTkk8H3VDm4XxiqUNoMmxkNfyQ Qc4IHbasQIoAVczdxQ2U9mwPrfJAG624BFHQyrsSEgGzARHg8Qv2dEbv5PyCwUM/IIhv sSirXHZi+ZpRp6fNCvCBY/AZt1nTNL71fDqgA72Izbbnor32FcJd0p2JyScjgXA5PhUG e7ag== X-Gm-Message-State: ANoB5pmOxXJsOVxvKu5wViUiKTx3Tj8162wmMDK578EB01pdUAc38LDN a9RiS+A2DwOsjZEiYDXwHLQmvbfYC9DaLw== X-Google-Smtp-Source: AA0mqf6Qwaa+ZZgNht+Axt+loxkyuK9nKvCzY0zbAE/3kovjQkyD7Ab088QV4MqOyd52TwsU9j43RQ== X-Received: by 2002:a63:1c66:0:b0:476:c782:e5d1 with SMTP id c38-20020a631c66000000b00476c782e5d1mr5496113pgm.261.1668756661587; Thu, 17 Nov 2022 23:31:01 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f7-20020a625107000000b0056b818142a2sm2424325pfb.109.2022.11.17.23.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 23:31:01 -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 v3 2/4] khugepage: Replace try_to_release_page() with filemap_release_folio() Date: Thu, 17 Nov 2022 23:30:53 -0800 Message-Id: <20221118073055.55694-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118073055.55694-1-vishal.moola@gmail.com> References: <20221118073055.55694-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668756662; a=rsa-sha256; cv=none; b=3hRB4yeirO1Q83VsyBoZCXTKKqe9XEyIVYLdIWtLMqYVYDNM3lkjZS7f8pjOa3Tf70Qltj WU+QEemKY/E+RbUnA1lQ+15e77u4AlDoEt+/C9PnkOJl0syvT1prqcfNQW35r7+3sWTaUI JGe5hWEliHFJs/xO2srl5nVqVcMFKB8= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="hj4sZ/oW"; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.178 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=1668756662; 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=fV4ua/OICXWLqVbIfkMn/fpxbgJl/u8cC4zKsS08foKlqDcHHj0zMnHFJik3madsinUS8U u2o2VQCRDmidPqiNR0BdBvzeyTrGAlvuheajCEYQsmpPiXefIfUPhTjtJhBsQgtD0FvR3E QpiCh8CwOc1Y7icyPJ4aeBs9DOdDJZc= X-Stat-Signature: fddtte9ozw55xzsa748jej1s8po8cyy3 X-Rspamd-Queue-Id: C5BBCC000C Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="hj4sZ/oW"; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.178 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: 1668756662-196952 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 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 07:30:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047792 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 1C072C43217 for ; Fri, 18 Nov 2022 07:31:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB2608E0003; Fri, 18 Nov 2022 02:31:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C5718E0001; Fri, 18 Nov 2022 02:31:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 866778E0003; Fri, 18 Nov 2022 02:31:05 -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 774748E0001 for ; Fri, 18 Nov 2022 02:31:05 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 52C734126D for ; Fri, 18 Nov 2022 07:31:05 +0000 (UTC) X-FDA: 80145741690.12.18D2FF9 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf02.hostedemail.com (Postfix) with ESMTP id 048D680012 for ; Fri, 18 Nov 2022 07:31:03 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id k5so3773667pjo.5 for ; Thu, 17 Nov 2022 23:31:03 -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=ckE22BdRtTbcTpcAczDBDx142TEzFlzwaz45MGFZZgwWkx2w7J9ONyEK1YVTBtjfR6 RqbV2slZHKwdlqMT3lnVqoWGcRGASMPNbRG0a2ZrIDEaqZNX3aw9GppTxZWNyx6UaYyq /ZXWxeUL/0Ezt57Yz21sJQrooj599j6KBMdv/q/RYuFFdCIM4Yqt2Xr0oLGb5vXXsPOg r6eaZJ/pKRNO2dyZ4Bd5ISXKU7nzL84AoEDMUBU7Gw51pMl98qYM2mFUepjU9gkvOFX3 XxF7OVdMMEoAcAvgYU0CPiRt9xKcZFhO4Bnpn6/jj0RbAutl40YuQiuwkUsz0eBDueq8 YxHg== 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=azsLo9NCtJ1DvHYaavU41TylZSY0asqDIM70vHlCifAYGwA+h4InRtIMXBf5tq/45P xa55n1m44qybXlojJkRGhGxioqS+PxGZP5PUwRbWDfgPwgdjJxJINL0d8Xxd/Ln/1eFn ZtVaxAysr3bvqFz1XFYvS0WvOdDitlR4zUj5KCJfemuas9RS/xwf5X64ZzsEKe4xtVIZ my7qOFwXsCgtsBiJsnFSTEn0/bgjKXaChAEoxyU/AneMAmCy2HiDJUYFOCRhveYBtlc2 wuzHzv8SJeoTwISlgEnCj9TMhDr4sZx3/HzRjhKpgV0m/Tw3v+2M/pj2cbfCXwEKTPFy E3Zg== X-Gm-Message-State: ANoB5pnlZyo/WIrLAyu+MXBn1eEHl3ZmNbbAoYoFzYPvSn7AwgMUiLsa XglzBZHAERzB0LrGzXsCIpm0+aQFhGk5zA== X-Google-Smtp-Source: AA0mqf5rq6PJFQI1QyEafiKw6xrOHDycZs2gbfK12hDo+brU69QumLv0AmatzvvNoW9m3BJjhDEi/Q== X-Received: by 2002:a17:902:c141:b0:186:c958:64f with SMTP id 1-20020a170902c14100b00186c958064fmr6370295plj.33.1668756662876; Thu, 17 Nov 2022 23:31:02 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f7-20020a625107000000b0056b818142a2sm2424325pfb.109.2022.11.17.23.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 23:31:02 -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 v3 3/4] memory-failure: Convert truncate_error_page() to use folio Date: Thu, 17 Nov 2022 23:30:54 -0800 Message-Id: <20221118073055.55694-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118073055.55694-1-vishal.moola@gmail.com> References: <20221118073055.55694-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668756664; a=rsa-sha256; cv=none; b=wfQob2fgQb7XIdhYU82DtwZ4lxtE1TgDHWksOF1eZGBlMGOaNkYbkB5PNVTOu+S4NdLVPN 2DgBVtyFiLQQH0/wbjz6zau2PZ2VEcbsbaWh/oJGeuOvq6JhrnWAVAj8Pb4WvgQD5PcpRM /EVC7HAcZLYzYBkc73bwyYV870izJP0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ckE22BdR; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 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=1668756664; 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=UhN5L7WZVfUai4qAWtCT1JJnVxo//ExI9uJe0wAczPD9Dg9zCChMi4s/JHYenUapx1+yEf vNUT4t4io5cS0KOVupi36Olx7Ie6YlKkVCivQV/wiN+iObVc21BCPC3jJGkaBVv/9RYWdq VRnC3jEA9WGCsEmg0JWN/BYNE/EFhXE= X-Stat-Signature: ynxhx1i5jh75wnonkcmi51mhgtm3i5h9 X-Rspamd-Queue-Id: 048D680012 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ckE22BdR; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1668756663-394150 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 07:30:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047793 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 67C9FC4332F for ; Fri, 18 Nov 2022 07:31:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 078AE8E0001; Fri, 18 Nov 2022 02:31:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 002668E0005; Fri, 18 Nov 2022 02:31:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBECA8E0001; Fri, 18 Nov 2022 02:31:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id ADC958E0005 for ; Fri, 18 Nov 2022 02:31:05 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8A9314126D for ; Fri, 18 Nov 2022 07:31:05 +0000 (UTC) X-FDA: 80145741690.11.20D3DA9 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf28.hostedemail.com (Postfix) with ESMTP id 4072DC0010 for ; Fri, 18 Nov 2022 07:31:05 +0000 (UTC) Received: by mail-pj1-f46.google.com with SMTP id q1-20020a17090a750100b002139ec1e999so4305976pjk.1 for ; Thu, 17 Nov 2022 23:31:05 -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=e28sylLlQZUiBvoVF9tPYbPyjfnV4i6SeO/H+EXMvftssRjI+reFA4qMGgM5yDcDPw iuHW6cApXuI55771oVrwJmic63Uelq3yaeLZ7tQHhypfuc99pqDHg5C1hqlTZ14qKTQd 2D9MC/BqCBLie09z4RZ/9ewSv68efJQc0B8gSz0Nnz4BvLtr4LIXj8aeoZO7fOc5jSQC G/3ZLlmqFGfU2VlFaXy+wKBwsMDO+r3CwnrqryV45PVQ26JdwVg3r+I9Ta6QVvi6F7oi pkPax989JPanp1uEe3vWC5ZAANTFOsyggZLQKbgOVlz7G0KJzrCiNnodIUbMl2Oy5DZ8 Qvhg== 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=x7rZvnOr2+dnU5dnaC6gJ6qcYr+yYXzMAzUE2Rfo8pHN80G22NoNT7Ig1BuA3eUlk2 F0Xxg8+adfeRa1Uj/ctrlwRYe8itq8GplhPIDJKl/jfs2YCbkFm8zDXWBl68WBYqeR1G Lau2lbLvYMUN1Z03GeeNh13SRZ5m7v2eIMMIzqVqYIVziQM5wcbtC+yK7nb63jHOYOOi 1W7WZiqZzv+9CslAOUBg8hKjImKmr0se3pIQskVPQ7Ll7zCoaUqgk5EotzVVNqhJCSX+ o6MKitQsDb1o1lf0zP7mv8L9x5ZDRlICchtzF/93sKIbjx1j8rRftJsC7lgNSyH4qEmd qAGQ== X-Gm-Message-State: ANoB5pk0rKGc25fORvF16F8+lg6M/VXBH4YnxBHtZlCS3WBwDCbpDc24 zGm0NmAnjfACZh2+Y/vrfXKDZI2aKcTitQ== X-Google-Smtp-Source: AA0mqf7ZECbq0Am2Wul1fzK1qGNPncRAHISQHFCEqviSEGgaCjJZBMDKZ9VwhWGiv4XU+wtL9oWIUQ== X-Received: by 2002:a17:90a:d3d5:b0:218:845f:36a1 with SMTP id d21-20020a17090ad3d500b00218845f36a1mr2283406pjw.117.1668756664181; Thu, 17 Nov 2022 23:31:04 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f7-20020a625107000000b0056b818142a2sm2424325pfb.109.2022.11.17.23.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 23:31:03 -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 v3 4/4] folio-compat: Remove try_to_release_page() Date: Thu, 17 Nov 2022 23:30:55 -0800 Message-Id: <20221118073055.55694-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118073055.55694-1-vishal.moola@gmail.com> References: <20221118073055.55694-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668756665; 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=ZQXjULfNmUw/urD/QSC4n1aAICx46M/tA43yEx3wq8HxfyeJ35cPD7Ve4+/wB+XpyeMLxT GgQHVoykAb9+MiZmKbgP0VPy9x1hyjcuB3piPiCQTcr5zVKyrOdvG1mmo9efe74Hj783YA TKeL2gKbHVAMBW5QpMQ1HvLsqqUeZDs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=e28sylLl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668756665; a=rsa-sha256; cv=none; b=B7f8ozAT3E7JU0+4URCw5hnj0MAn09wrtPLeVpqghrrs/6psknajxoZategD9Nx0EDNmbg r0/tHOjgS7A7aKSknZ42r0P+SrATQrNcXrAUBmB2bOXztW/9O3OkicNXcQSdpUaRemLG8g 0Lktp7PnlUSWpFY86gq9aetFiPKpLzg= X-Rspam-User: X-Stat-Signature: zpxfq3w5f7g5357s3ry75zy6ke97p35q X-Rspamd-Queue-Id: 4072DC0010 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=e28sylLl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Rspamd-Server: rspam07 X-HE-Tag: 1668756665-111077 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000058, 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"))