From patchwork Tue Sep 10 23:43:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13799481 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 C2B3EEE01F2 for ; Tue, 10 Sep 2024 23:44:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 731628D00D3; Tue, 10 Sep 2024 19:44:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68E188D0002; Tue, 10 Sep 2024 19:44:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 507718D00D3; Tue, 10 Sep 2024 19:44:50 -0400 (EDT) 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 1B4568D0002 for ; Tue, 10 Sep 2024 19:44:50 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C732A1A0C67 for ; Tue, 10 Sep 2024 23:44:49 +0000 (UTC) X-FDA: 82550461098.16.FED322E Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf26.hostedemail.com (Postfix) with ESMTP id 017E114000D for ; Tue, 10 Sep 2024 23:44:47 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vJi6AcuL; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of 37tngZgsKCGMBDLFSMFZUOHHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--ackerleytng.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=37tngZgsKCGMBDLFSMFZUOHHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--ackerleytng.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011860; a=rsa-sha256; cv=none; b=mYngEKhANFco2JftlLb4Jav2iwBN9UudmTid1yziCBP+tbTpRP+6CaNcolXLsBCGexLNFK e19TobgJ6fD3Hlm7CoTphiNQmOAEPyDjHZVXvCCXdHpOU/9U9VIpEP0EkR5wLZbtUcfOR3 wrvSxMIFP72Nh9GcoxUKAEwQNbXQLW4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vJi6AcuL; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of 37tngZgsKCGMBDLFSMFZUOHHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--ackerleytng.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=37tngZgsKCGMBDLFSMFZUOHHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--ackerleytng.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726011860; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wCQtr3LYUTrh92YO/TM3BLSTa63Bn54Ak3CYVuDQSOE=; b=dqn+4ZEk71CeD2GBnZ6lVlGDeQIVpjxZcNGqzGKsu/IyoLQ5MAiP/v/680tYco3hkIAIbp 0SB6PUeyJa9U+qPXMQPgiW++oz70dy+2P6tNuGUGu+4Ytfv5XxubX57RE/PxMeDU7YlDgH iQE8GYGRmZzocQhdgXsr7//lbdWY8Og= Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-72c1d0fafb3so6508647a12.2 for ; Tue, 10 Sep 2024 16:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011886; x=1726616686; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wCQtr3LYUTrh92YO/TM3BLSTa63Bn54Ak3CYVuDQSOE=; b=vJi6AcuLyisBXw4M/DdH6OGsLpzUjIRTfbsXR/FHhbCIbyQ5BCWijXiqYfJHfTCkp1 33ZpEU6uc32aKwQ25ZysVvzJ17+Okp+rLFFm611RdLSsFl4nY323nDv8Az7HzVKcv1Z0 Cbvd+Bq/qBF1EPltOLebNPUpbzqSiAlcdul7IF76bGEDZtXy1szeevjKGZOxXRmIvApg p2q5GDLZlZsYKOqob207ZLFNObKRk7slXac2nlY0K+fc8Z/0FX2W02xuppdFTd9DfpHf pV1mrhEaVg6rPplySvyuo34TlGiS9mvDPfon1jgy1TjAtvPRpOX+/L4gSNT8ZLW4dvcU nXGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011886; x=1726616686; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wCQtr3LYUTrh92YO/TM3BLSTa63Bn54Ak3CYVuDQSOE=; b=JnJg/t2AQYpspCRNsHr9mcyi790B3OLzqnbPKVBEoQsxelnu4q7IkeTiYFPTRutP8n pCYqMGJ2wDCa7lHUWr3d17wkj7BL4ReoKH9ZOzgYHcnGB8q9xhnm4ncnScGTQFQKYgUt crIuruFF+wjpQR//zBwxjkQX9HtuMSQlWVAHb4f456kR/oxRvr+e8j+l4LCRQOjoqvyM y2JBnxm4JvCSeGhUQFQtRPPybs4KMbBIEoXXZxgHxv80ePjLTOFL272XGPIEuMWA9VaL IUXle5+NkG60Qb+F8S6t30Q7XIFegttEKQ1EOm7t3/cknWD3/nxcPa4i7QwhoTDXmZ4Y 8uTw== X-Forwarded-Encrypted: i=1; AJvYcCXe/6YwbNLMWZ8mjh6NQeCb2BxHRb84IRxnFomzX25pK6Y7o/nXJTJg3dP043zC6NKAByMlFIg3iA==@kvack.org X-Gm-Message-State: AOJu0YyRwGdq+b+eRFSqi/OAxOUCUBWBunUleZjeyQ8rwr8Q1+dPkF3l g3vL5AJCGP2wdkG/uDbaAFP58DHgMEc1ULB0mLZRXFkPodx8VHTUIsLZ5bzS3XI7obW4ugqH3YH GcCEg8uAnC3TFVrn5be+GFA== X-Google-Smtp-Source: AGHT+IH5Nj5kPHNo6rBfhQxFH2WNjr8MfjXL+h+toY4sJe8PVOOMsYFK1lr+WyYqGBk0WvcoCe7tmQGhI2Eo6rySgw== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a17:902:b686:b0:205:5db4:44b8 with SMTP id d9443c01a7336-2074c63a9cemr948735ad.5.1726011886284; Tue, 10 Sep 2024 16:44:46 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:39 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <9f287e19cb80258b406800c8758fc58eff449d56.1726009989.git.ackerleytng@google.com> Subject: [RFC PATCH 08/39] mm: truncate: Expose preparation steps for truncate_inode_pages_final From: Ackerley Tng To: tabba@google.com, quic_eberman@quicinc.com, roypat@amazon.co.uk, jgg@nvidia.com, peterx@redhat.com, david@redhat.com, rientjes@google.com, fvdl@google.com, jthoughton@google.com, seanjc@google.com, pbonzini@redhat.com, zhiquan1.li@intel.com, fan.du@intel.com, jun.miao@intel.com, isaku.yamahata@intel.com, muchun.song@linux.dev, mike.kravetz@oracle.com Cc: erdemaktas@google.com, vannapurve@google.com, ackerleytng@google.com, qperret@google.com, jhubbard@nvidia.com, willy@infradead.org, shuah@kernel.org, brauner@kernel.org, bfoster@redhat.com, kent.overstreet@linux.dev, pvorel@suse.cz, rppt@kernel.org, richard.weiyang@gmail.com, anup@brainfault.org, haibo1.xu@intel.com, ajones@ventanamicro.com, vkuznets@redhat.com, maciej.wieczor-retman@intel.com, pgonda@google.com, oliver.upton@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-fsdevel@kvack.org X-Rspam-User: X-Rspamd-Queue-Id: 017E114000D X-Rspamd-Server: rspam01 X-Stat-Signature: 7f713t8x3ux4ogybtu936ytwb53a3uwr X-HE-Tag: 1726011887-212913 X-HE-Meta: U2FsdGVkX19ZkFmtg7015OVNqaOYBLSvxXVyyG+u9IBDYf4e7kGamZMRVb8qKKZkkn/oRL4Ac75dh2wFeDvgYfOhGOolAk8ZUtD08CIaBfC6dlTxrGjUGmlnN+1/n/8/fhDa5jxg8VPTorm+CoJqRpt2aPmZBqJoy0EL5Eb+OJjYTshM0HnPOVjIKVBXCBmFcfaB2j/2VhEmFSHAkwkgKCrhMhT5c1Au9p7az/7tMnkn2RMJDFU/GZbyXpVCrGq+Pr60lfyemEMDbVQodCT64HckCqNLD1yf8H/t+TsZBXLlNTVsaOeaicd2ouF6LidtT3rAf8N85/2jTsSLyseJjanACbw+ONS/Y6TDETZ1YunLZ4ZZycSeIcrmFIXxjuMfpmyvOOPNCFo1//YGnK86eQJGnst94mpgluTtiRX54x1grZXohc9JY4mNRGfG3PwAB4BwzgID/5LWsyFbjk+MLrJimnvsGugunM0DR7q8TXZYd0g46wWv3CbilMDuET5ILvTr/y+dQhH12S571l8ZIXrXtNbNO3sDutn+lE4E8uJkQETNR+AzyUEyV4kOToAesPTM4CFtnRuwk9DeliBNSPomWpKB61B4zyq62Tsvu1zw+Erx6QXARxmRJsAEYa9SmkvMp1vRrA/uTeGo6BGmLjpq2SYHOkIBCSdZyVzQ48xm/mmVw+/uWpFYqP/7La/iAhVu7nLwh+owvf0HFIWO7VTmdnrANVBnR1pXcL6YyBl1EwoGJTrtxto/dITvvmJ3fCE226w/eRzQYi+Q5EJlE2PtGPB49aE5mdGBoaStO+ulCREd7TtgZQschYxWzv64j5cK6yYzy/f/YB+jkMmoCzUpwsRh4ZjxDenKYHuR/PydUwdPZDH7qRoZSFRgyvjl8HPPDSYVsoFPbgDUx1SBIrJmFYtwA83Zp8qUG3E3HW+GixtGCjhgd0ucW6Rek8cOCDcbVCVuStj37M2PVR+ XCY5Fali G1n4QUQqPuNEb0h70Q0zLwGZZkqT+PABtlwLuiqqSlYfsCL0uRsx+qT6WTNcb+7bPwIFXESbPmhvRFrE/4U5zvsnHTVnQ962G5DnTf6AaswOJgP4g5sOuXiyPY5xqc1a59CQmnYrYdQxc14MnS0bTvVSgXYG5x3TdaNiANwwzKA2/XtvSJd+mLBw7lTqO2e2xoqlqi+DFJwnRzsxMpKTKl5yDAsHiv7z0NOAuSmXkcdaMm8pl12Wr4/ASW2H59JUkK3R1G9g5/dPE0tjOfNXCRdWUGZD7R7s1fwkX6Cq4Y6ayyrc/BEd9bKeVYlUWQEli9LCvAp9FNatJgpc2dXf39hOUISxiPZblHma/75okhVxklH+cxnVmtDg2HzhQAdVkkFu1XWiHJq+Jmu+x5ucvT6gdF1bnr0/ppgznfE4/ni9vfw8//HG2X8aQ1yyTmrxCShcoUlF4JWt+AjDoIwg77V4+gYIXYJAoR3uf/J1dP56loXh+3VlEIrw59dR1MjHBc1EuTllJ6vRBoQTiYPDD9WN6KlEbpmJ9H3PgREqeCg5mHM8PZRg5PWZwgHi3jpueVoxFvnb0l9t/bkVCXx1aYk6rF//ato3CLnJtm4uS1JkaQaOwP8zxYp/dYdkOZSDtV7kGf4mq9T7scp2QIEtix0WjkdFwBCtGg6XQ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000184, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This will allow preparation steps to be shared Signed-off-by: Ackerley Tng --- include/linux/mm.h | 1 + mm/truncate.c | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index c4b238a20b76..ffb4788295b4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3442,6 +3442,7 @@ extern unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info); extern void truncate_inode_pages(struct address_space *, loff_t); extern void truncate_inode_pages_range(struct address_space *, loff_t lstart, loff_t lend); +extern void truncate_inode_pages_final_prepare(struct address_space *); extern void truncate_inode_pages_final(struct address_space *); /* generic vm_area_ops exported for stackable file systems */ diff --git a/mm/truncate.c b/mm/truncate.c index 4d61fbdd4b2f..28cca86424f8 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -424,16 +424,7 @@ void truncate_inode_pages(struct address_space *mapping, loff_t lstart) } EXPORT_SYMBOL(truncate_inode_pages); -/** - * truncate_inode_pages_final - truncate *all* pages before inode dies - * @mapping: mapping to truncate - * - * Called under (and serialized by) inode->i_rwsem. - * - * Filesystems have to use this in the .evict_inode path to inform the - * VM that this is the final truncate and the inode is going away. - */ -void truncate_inode_pages_final(struct address_space *mapping) +void truncate_inode_pages_final_prepare(struct address_space *mapping) { /* * Page reclaim can not participate in regular inode lifetime @@ -454,6 +445,21 @@ void truncate_inode_pages_final(struct address_space *mapping) xa_lock_irq(&mapping->i_pages); xa_unlock_irq(&mapping->i_pages); } +} +EXPORT_SYMBOL(truncate_inode_pages_final_prepare); + +/** + * truncate_inode_pages_final - truncate *all* pages before inode dies + * @mapping: mapping to truncate + * + * Called under (and serialized by) inode->i_rwsem. + * + * Filesystems have to use this in the .evict_inode path to inform the + * VM that this is the final truncate and the inode is going away. + */ +void truncate_inode_pages_final(struct address_space *mapping) +{ + truncate_inode_pages_final_prepare(mapping); truncate_inode_pages(mapping, 0); }