From patchwork Thu Nov 21 18:52:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13882253 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 5FCE3E64002 for ; Thu, 21 Nov 2024 18:53:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 002526B0096; Thu, 21 Nov 2024 13:53:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF5CC6B0098; Thu, 21 Nov 2024 13:53:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6E786B0099; Thu, 21 Nov 2024 13:53:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B935A6B0096 for ; Thu, 21 Nov 2024 13:53:24 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 80B9D1C8107 for ; Thu, 21 Nov 2024 18:53:24 +0000 (UTC) X-FDA: 82810999068.15.7615FD7 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061.outbound.protection.outlook.com [40.107.236.61]) by imf12.hostedemail.com (Postfix) with ESMTP id D365440014 for ; Thu, 21 Nov 2024 18:52:56 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=FJ7Nz+xU; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf12.hostedemail.com: domain of ziy@nvidia.com designates 40.107.236.61 as permitted sender) smtp.mailfrom=ziy@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732214954; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bCK0ahHP2aeqKyUHb8ITfSzvvy9IFw+4Pn/KCUxa/mU=; b=sUEWwYApw+PRrjCczV4ibD1EI0tj/nYvq2OMi+aFcQT+ndB7XACzXLBluBaU9AWUat5+uh 7OCswn9yetbFk9AOCoYhnyZh2p2OgkUrziRjKtpcJEHqeGyISSaXn4Yi5/6ETTa1v/ZV8z iu8FokkWA4RKJ0x7/FzGgyGUB0+uWv8= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=FJ7Nz+xU; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf12.hostedemail.com: domain of ziy@nvidia.com designates 40.107.236.61 as permitted sender) smtp.mailfrom=ziy@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1732214954; a=rsa-sha256; cv=pass; b=NmXyI/chSn+uHxaHi27lMpHilzDCQelrC72lt6JyaPZTmwZG5gqAIETR/J7FDjBjWGNllT emmShnNrd+mXiXuiums1xmP7zseQGTjZUlBl+oQNnx6/kqaWGEAUBoEdJHX58B9HAb+lVY hejc1kLMFWaoS7Z6hqxgPLmS6/VaMvU= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GBYEWv1U6iriFRV53KtW7ek0eauOkf+ahrA1fbEHfMuDS2byVjfy/Qb43DD/6RqrTI6im6qyOnIoZJHUAXThZSaP+rkVYm+im6pg9XEKQ4vdTN0vS28ivjkCMBLEc+gMOC6pRt8c6fLxD2oPCOE6bYec3RW4UkGUxYKnNmC+wrGViiX9+kcGQH4AJSCAq15pfZjOxAhehpVa3/ntsI6xJ+6dwRHvWSVzmRTzop/E+WeLuf3MJfWDBGFlcvL4jHeXVnvEUawjfvBnr43uNxuQHJNlQNlljOJr2tIDphRIyj/AmhVt/l9q+C9x5lvfh9WuFomoHCIi9K5EDzHBvEmSAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bCK0ahHP2aeqKyUHb8ITfSzvvy9IFw+4Pn/KCUxa/mU=; b=MI3JA6yGoHixd6fPSmAkQ2zqFHDON+6oiqoQq1gzNh2mk7MWqDDoYKGRY/mEWPofn2P4JCVlLji31aFWGnX8jmt/WKqaan8l1n7uIC8/dPIQR3siFwvuqfiW7+kfIVvhfLy8geomgYp7ggCw7WYFh19cPYZRMevVMaVl9hwFlMlp8we7SKnagqPJLfHuVETpXPO3kX1WnLyH9qWtS3X3R8zT13bO2CMy2CKBoQ4W/gcYusx8c5120OD2HVMACcuFag5Pv5Ejx0ReaL/ufTLEqqH5X6N9Aaqi4TP+1Qx6b9wEAk6syS0KiOC6FDGYfLFL//los+d76GPMwTxAn0OHOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bCK0ahHP2aeqKyUHb8ITfSzvvy9IFw+4Pn/KCUxa/mU=; b=FJ7Nz+xUreBOOJl9EjB6lJR/DUGjcsN99GoAtjuABAK4TJ2sckkxpeNeWbkKlVK53N/gIiDmZ8cXWZ/xzLEg1b+b+ekIPI+8icVsBSIa+RdmCiX9ibZxmqw3hkIqR+ax+Hhk+SC1fx59J37lDaHUcv2YlLAG0QjpdhBVKU/iA/XTDN3Zjhg6YHx+sqbVRGLwljLLSHCYvbIgkwotG7kHvolkkwsloxWgNlHfcEVzQobrZcjIWkCc4VaIamXePujZWDKmhWjR6RCmGH3XpR5zxcl/jo7wqzJNLIwJlylP46ux7U3jwawsrPay+2eeOrOFkXlvMry8LYFsfwgs+TbFVg== Received: from BL4PR12MB9478.namprd12.prod.outlook.com (2603:10b6:208:58e::9) by MW6PR12MB8834.namprd12.prod.outlook.com (2603:10b6:303:23c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.17; Thu, 21 Nov 2024 18:52:39 +0000 Received: from BL4PR12MB9478.namprd12.prod.outlook.com ([fe80::b90:212f:996:6eb9]) by BL4PR12MB9478.namprd12.prod.outlook.com ([fe80::b90:212f:996:6eb9%5]) with mapi id 15.20.8158.024; Thu, 21 Nov 2024 18:52:38 +0000 From: Zi Yan To: linux-mm@kvack.org, "Kirill A . Shutemov" , "Matthew Wilcox (Oracle)" Cc: Ryan Roberts , Hugh Dickins , David Hildenbrand , Yang Shi , Miaohe Lin , Kefeng Wang , Yu Zhao , John Hubbard , linux-kernel@vger.kernel.org, Zi Yan Subject: [PATCH v3 6/9] mm/truncate: use folio_split() for truncate operation. Date: Thu, 21 Nov 2024 13:52:17 -0500 Message-ID: <20241121185220.2271520-7-ziy@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241121185220.2271520-1-ziy@nvidia.com> References: <20241121185220.2271520-1-ziy@nvidia.com> X-ClientProxiedBy: BL1PR13CA0218.namprd13.prod.outlook.com (2603:10b6:208:2bf::13) To BL4PR12MB9478.namprd12.prod.outlook.com (2603:10b6:208:58e::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL4PR12MB9478:EE_|MW6PR12MB8834:EE_ X-MS-Office365-Filtering-Correlation-Id: e4a62e1d-4ab9-493a-619a-08dd0a5dab7f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: Edd1Sjel1NqMjTX5gjFo0dMqOeTyVVmQ8/u8jK2GpY+lSvxnI3g45RoGwi6Aq0DUh4IUpbOFymEB0zF/3HfXpWmiN7IjUdQnePkDddkHkVXo5ngTRfJCwImrtHUMsB11wIWZ09/jQDKXKvr2LEByu8hiK8WhnU0d2SmmFt1BCSz4K9W79tsDdigrcaK4V6luA1jy97PmTxWEZVndrc6qqSnKC9PohNgeoeikhRKgDf4/+nTPBuSRd+n6c75H5DGMgjaz/oVx4prK5WaSpixyFO5QAwR2Be6B8xIDZX8xPO29NYbZcTrk9vYPPA4b9HwzpTHyhSOWgDDroZjSAPJ/4BX+ECSacud3fWkrQbTVUNaI3P02hi7vE0eak6hF3f/OUFd6mOwiRHAuc//YidDe/LufjJQyDV4T1oMuxx9oJcisIAfdoz9phlNTEd5PauaNXZ8+mBBWnKZr4/qlRW4uRyv0haRFKbAY1w/oUsE0cVakHKqNRAATszDnztik4sEHMmbpC3Nj+ypox8KEl+J07x1lB2f1sRTVy9HW23E0fcCFPtlI2xSHSbZPHyz2k0938TT1W2EL+QiQxv3JLkLdU4gdSqchuW5YpmsTGBfCBnGFOIjJXZ+71zkcJV+QLfMSxO2AsJ8lqndZAoTf0h4wfywdbGbzfltF4mTqeRlFvj84XxaMHK/vLmUuRzj9HrEwEhGF/5Sn8mVlp6bayYTFl3bJFpsTgA+e/3nfHHapycqBGZSTbYKDNyqT0XRP1k4DVP0NzeqrirDCrqemY3jDWV5WjM263jMAbb8ctKKcFdmE/I4kNxFQOzpYdYB2wyItsl4WDsjNWxBoZxXv1sNPBDq4WGMx/pi/N6atCJwrGoe/CMZ34auTKRJWZXJjLow6byxM4YQRBrWlltTyoy6S8hM3cOU/mUVKFWvmXXvI8GCJZkwvXFn8EB2KDZyYeggygyDAMHHYUzLnJ1edwjBUPBIp9VRajv1PjAgY9u/YoU51RZA4SytkGd4UD4Ybp5lDe7dvUJxl+Xob8tszV1cZ4abvhlM4s7weMRLl/vDu/o0f+8qStEHwQlF+pPj9BlS82kwya5ihgTUb5PdhGRCL5p7IhLWANCiRX0uLcaoCY/NoXfAiGPXdt2YSR8JdYQdGNDC+R4nfYX3QQZOZQch8RjsYOqBKFR/HygBJbrZImjjDb1uirG6pgRpS5oC3cqcVU6vea0FkJfzzfRBL0yDGS4VRyq8IFULZYbamM8tvz5KDjBTphBstzrC/ERLyI5xyk1EUHcPiALZ9NZZtdHLTYMgPuPB9fZ6pArYI3+RgFQpW4QP+bHDW57HrEINT8a1z X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL4PR12MB9478.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0NoFIYX1dAlIuQMaEyOPzhf0ILAHlQZLzDtPx6ISrDqshcWvWsO2w43J317KPhKjVtcjL8BkYzl+7bi5PAjw3CuSMOeUuCGKcULBkTStHF1Q6Y1snp0QRgzMivnK1RMbWuFlXZRGaz3wEyN2Hw+8uzSxkryQzaPc5qalrOowuse+mmiF3lv046rd9NKkgCSRCeWJulDX+sWrJVgFs7V6P4vAqNyyCFvGlC+0Gwkclx53FOYKOaX4f/VVZGZ9Y0H5icUhR/Zyp8NFSwywPIJwTx9qrhYdyHHVYit+DwTnKR0vECeIV8YVDm8wbHNgFbPPYbLOhBr8vK1x4ALCqPTIGj+yDRdF1O6JEFlqx9t0sAFzreka2mCBjGRfd3ZprTx1HQM0XY7nYzvWXP0QlDE9LHf+cKq23PJLUJdY8uV6I0IxcJW5JNfPY7hjQ8VyvdGTosErwL8ykjTHX+bjqeCfuloFd+CiFkWWFeBKIAtxmheQ2Gx076H/LUB+RQBjUq62OIE+6pfDzB3YP0Wudgo8v40ycuCnS3HJd5Jt/H9vKGyREVPVUbVJfUE+WaT349Aa17S2UGQ5aN/sKdsT36ZfhveWKiaAxj1bD+aZf0CjfbNs2A5tfF3/iCSNeIsMJXNpa+tCfwJs2w9y6s6SCUN0ZPg3ThyE0fNVcUJOdNfFaG/NC94AAeGT2L6qMtweu4eZl7EqlAb0iQKSsk//e0ZHaUcwvWDcA5AlPczXB7g5Zzvx3U9fVK33TRArRx/b9JXL3L/XbNRE4b+MiAYF9HKcaL4K/UKvq/KiVN4VzKZ0372CEpOLu1OBfhwOvn6FAURaupFIE755Z9kn6gACDXGScDA/u+zwt/kTdszsrRq9TJBgOejab1tNNYH9J6LYUiurYI9wN5+Eu5K6dkYnNbywxujD6ceBA1nXOfhvt/raKOCHRAg1G9XHr3una/sa+iIpPnJjhDeOOy1qXwZp8nUlN5j1m5ZC/ynw61PS5oYOIRfiGgozeUvE7ivoZyhqHB5D2k4imjyP+JwMuqCnl+Ol1sbY+lRMbCPYU3s8NEsPPg+SxJLZizbMoK9C/K7/ZW/1y7i13I5t3Usm80wUnz1DOL8fAWh9xGOrR0B5UeQrTtF+Yxofj7UChPZj31apH/pDBToE95vnNqlXAkA92dNWQtMrGKs8cRGVNqvgEqpswMHUCgjEkTdtY+bsNYbZiAAcXTnsDmVORRKUNLE778yIa0FTJ5ZWrQ+IpRQ4GSkiClXqh/1YLb4MGNZ1HWRl9Gc+0VDs7Z89ZQh5r7eI9eMuZHpmxuNWQnm8l9X+BT2Y88l0Czo5E6S03+kUB3s/vssTqfWlXaNdKObSurB/tp5YQvR74kg7tLNJV7t5Am007UP4Hn2gGR8EoAMNhQAsB0EUr6wjWCpqHMwE+JpWPbv2HUOwWVUHjiB0kx3WABcvaIS7NFVZQZmgkcvIcETus0qNBL1oTFu2YFhnULoD1+OEjVj5sjQiOtjCVkq+HqLokiqn51s6CiO4XyssTdwQ4BR0Kvym2l+yuMC1wxrpAkd+Vwb8UFQYbA1sHz8g5/UvvH4= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4a62e1d-4ab9-493a-619a-08dd0a5dab7f X-MS-Exchange-CrossTenant-AuthSource: BL4PR12MB9478.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 18:52:38.3127 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0Oxh8ANGuq3V2Z2UnNkciWxbMkuGLQRjbAGLlavFBY1yBWro59Awwo0yOl0qBNv4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8834 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D365440014 X-Stat-Signature: etryfk7jfmtkssox44k8ur518wuiystr X-Rspam-User: X-HE-Tag: 1732215176-891084 X-HE-Meta: U2FsdGVkX1+lOeZl73yRuXHNc4oBDmv5msTLT9BpUk0lNXNFzSSgCUTQMqgc4eYH/siLl4DipGGjG2pcCSGCyoWmbS6Y4N0QaabY/ME5wRMHQLEFeJKFcFHr4z1u2YIJfvL0iTzdCMvTjERnv/cTgg8MxmOs8WXIc5j8JnYHWZg3p5nWEl2xCy2QfcZPp7jekwkwlVLYFFBHn0kUJtokI2BTlXtQ4Q2mqhJhry4WLToYe7cfeS4Rh+sAbkf8tEgKqrJScGlU3mrUje/cDwk2y6ncXxVPKOD/4oKRqVpLI0m8MLxxStRw1qE6E9vGqlVDihvY3l4MLZo8Ov0qpAhUv0H8TAuSy/lJLXEgXaO2eKuAsUk6AHq5+wt4SyoJITANsn9huLsctd6MF4XmH0zLTpiOn2tQpK05gABW2XeTrWiI31naR0HjmExUc2rwblYRtbB/7Pcox5OKQ+ODhqe9Fh7wSvuolYZmkGCBcaZjrgstWdY3QHV+MVvlckMCxWHMB9ogzvry3Dt2G0cRHKgq3sUqGRqv+2sVtjnCiGjf4nE4eP9DiMnB2JfLa+KJBa0M+gO/dgz9y8WDuzrRZNfE+04+7WXCcTjXV4FjRwOjGKkziITTsvasdMetAB57Ft4epHa74sryJNvkAfJGxRCRlbgTur0sf8gR8QkRkb67hL2tuZo6r3Zk21CXyG+tXiwQ+XM7h8Hb8kNWWJfmvsW5k9kjkAik3K7UeIm9uvitCPkh8Xdy1W00QsKrYcRgi8O9TOqi3Bfh9URV/U+1jQ+eNcm2ZhfjQDvVanVzxgLMkOxkmiGJlZyEPiKJqM0wC8JGY6+NuNBGc3pHOlnKlrB38Vham/8aHB+NoKPEqpfM/5lIU/soIu2mBqpsZg7/CnPgvl73Od33b+6qXZQJnW5x2UA54wgWY3/O29OtVceTZyGgATuWnggEllEN+60G5t/wNlL8BbPeivj5u4U/IGq AQVAXRlt IJqGX016Qdcd+0lYlGQrOre5JiO6hTvOSID3TNok43IpPkucyZkz+mODFXqQtxYywUYINnIeNhi9fb6+F88Z8ngVUdsvgJLs+EevbS5tZlmSCOrjgzzC27Uyz9bQTer2SgUt+dIPnw3PYVqqDutS02Zo0JRoYa1gcdzzy0eq/Sg0KzKnecr0j3cOwpFGmYNZ4FN2XIGeHnZXbNz0Sb1BnC+3tco6Pbbc6H7yhaV2WKmnDQDGQ/ZWGuzG3zjj/LhdPMhnvG27cWzFC4t1+d9vmNj7jGz1losWhfnSr9/sfm6O0NSPxzzvownfnTLjSWalSDMXwmR/IlVwWXal0vMtgikNvMLw18uYomafoANG1m12y8cX/D8JYVzb0PMaHh2HuG6uOPtI0UueSv+I= 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: Instead of splitting the large folio uniformly during truncation, use buddy allocator like split at the start of truncation range to minimize the number of resulting folios. For example, to truncate a order-4 folio [0, 1, 2, 3, 4, 5, ..., 15] between [3, 10] (inclusive), folio_split() splits the folio to [0,1], [2], [3], [4..7], [8..15] and [3], [4..7] can be dropped and [8..15] is kept with zeros in [8..10]. It is possible to further do a folio_split() at 10, so more resulting folios can be dropped. But it is left as future possible optimization if needed. Another possible optimization is to make folio_split() to split a folio based on a given range, like [3..10] above. But that complicates folio_split(), so it will investigated when necessary. Signed-off-by: Zi Yan --- include/linux/huge_mm.h | 18 ++++++++++++++++++ mm/truncate.c | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index b94c2e8ee918..29accb5d93b8 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -339,6 +339,18 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list, unsigned int new_order); int min_order_for_split(struct folio *folio); int split_folio_to_list(struct folio *folio, struct list_head *list); +int folio_split(struct folio *folio, unsigned int new_order, struct page *page, + struct list_head *list); +static inline int split_folio_at(struct folio *folio, struct page *page, + struct list_head *list) +{ + int ret = min_order_for_split(folio); + + if (ret < 0) + return ret; + + return folio_split(folio, ret, page, list); +} static inline int split_huge_page(struct page *page) { struct folio *folio = page_folio(page); @@ -531,6 +543,12 @@ static inline int split_folio_to_list(struct folio *folio, struct list_head *lis return 0; } +static inline int split_folio_at(struct folio *folio, struct page *page, + struct list_head *list) +{ + return 0; +} + static inline void deferred_split_folio(struct folio *folio, bool partially_mapped) {} #define split_huge_pmd(__vma, __pmd, __address) \ do { } while (0) diff --git a/mm/truncate.c b/mm/truncate.c index e5151703ba04..dbd81c21b460 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -179,6 +179,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end) { loff_t pos = folio_pos(folio); unsigned int offset, length; + long in_folio_offset; if (pos < start) offset = start - pos; @@ -208,7 +209,9 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end) folio_invalidate(folio, offset, length); if (!folio_test_large(folio)) return true; - if (split_folio(folio) == 0) + + in_folio_offset = PAGE_ALIGN_DOWN(offset) / PAGE_SIZE; + if (split_folio_at(folio, folio_page(folio, in_folio_offset), NULL) == 0) return true; if (folio_test_dirty(folio)) return false;