From patchwork Thu Dec 5 00:18:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13894604 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 E62B3E7716D for ; Thu, 5 Dec 2024 00:19:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C0336B0093; Wed, 4 Dec 2024 19:19:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76F4C6B0095; Wed, 4 Dec 2024 19:19:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C21A6B0096; Wed, 4 Dec 2024 19:19:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3C7ED6B0093 for ; Wed, 4 Dec 2024 19:19:12 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AFB578124C for ; Thu, 5 Dec 2024 00:19:11 +0000 (UTC) X-FDA: 82858995240.30.AEDC5BA Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) by imf18.hostedemail.com (Postfix) with ESMTP id 2BB9D1C0007 for ; Thu, 5 Dec 2024 00:19:01 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=B3r0mMGn; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf18.hostedemail.com: domain of ziy@nvidia.com designates 40.107.94.40 as permitted sender) smtp.mailfrom=ziy@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1733357935; a=rsa-sha256; cv=pass; b=KnBve1ig1gS8Z4SODkoQ0CtPvMuuxkLDx5zVKMxs1BZw2m06PuN3gNHLlv3xJMVbksi1JZ +gM3aWoxE633RnGoXn4TxD4dVPwPhYd5x1QIsbgy81fZG5SsEbQo9bG7HHAZ4rYOOdklnl I7qFEnR/ZlLFgoWPRTnWE1voUEr+cBg= ARC-Authentication-Results: i=2; imf18.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=B3r0mMGn; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf18.hostedemail.com: domain of ziy@nvidia.com designates 40.107.94.40 as permitted sender) smtp.mailfrom=ziy@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733357935; 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=ScO3EO7bE1reYb9jG/eBQkGrULymO/6W7BTzXOMGCLQ=; b=HiQyxjbQmyzy7u/38WqyO755FEd1nHz5VE32ekhzgsJ5oEANL/lvX1CoNyhddbU+L7Gx/K baIqI364KKKoPUmd34XZbVfI8IZvzZXr/tVj7XOz+QXI/iLfoOHYqrulgK63tMqCDKHolM Usfc3eyMNxQ2/+LuHFZeAkjYF0s4CFY= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xs3g6oOZ6htcTISdZVUZUJo+mxpVfdqpBWxZe0yQ4HcbuwqXTM+pZzLvMCIymSXHlb2jkkaAnfw2yKh697n8j/3R0VW/CM1W6t6GtR7KU1SERIfHUZgBX7ItrY5HcKp1dzX3X2TotDtyElT4XZGjuLhm3uTTwMfGWoPBjPlftZRueoaZWsbubAaBZ0I1fVnDV9RzJ9PliGYOKPkHZbq53SIMcmoJvIpCWXZLrz6VpubUXfKYI+LP4PMs2qEB+bDkoTw8CoWnkY/e5mYnVmBhJSdrY7lJ46sbFXG04iCAmz/WJnyJjDSiVb4rdCEe2eRYqjJUn4FtzwEC3eJDXiB1Ag== 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=ScO3EO7bE1reYb9jG/eBQkGrULymO/6W7BTzXOMGCLQ=; b=JAc3tM9CopY0rL5VrIbHpBEoTzjUKpuF5NCeHH9kFXjPzCe4HEiB9WtNSM7tkLQEhaTNBAtgBK2rDqurlUeilPpyYao8Y/bfmW7ci2UWtprzYHLcwgDJaB1wTy/TbkooUU3jWSYnYUQY9bX6GRFDIIbMexlvrHKZ1I7/+e5bmn10TLiBivNwyfbtLQqovxy9qKNwGlopkegQrP36EbboauS+a2ZYEOKEvD0K7opikE8Rf6nPk2ImNAJDMAGB7VtzySJOCK34uGlSzbsr8PLjc06urImmj7VyVBsZfIflYOMH1t+5ZNT0glSWSm3ahXLEnLfuryeiMCMusZSNKZmT6A== 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=ScO3EO7bE1reYb9jG/eBQkGrULymO/6W7BTzXOMGCLQ=; b=B3r0mMGnAD8KNmtFPQOwr7PN48Z3LQs60uh+lnzixeSHimBzpTLwZpMhwKhnGB+Ip08IsuY5ZT6Kb0f3Nye77jJMIGBFM4M+mHPJ2i7z1dlroOpheGL5KjlZysBfjAJLCvatNkhleCQflxFRunzfbnhtYbBhtZgK1/JcJrx1v76nEmAjErgVW4QE4Zyi+aKVFVSx9aea24j1pLPTbuYxkVSzE8omo1Ze37IurWo6lxMv9cjaWOoXoccnK84a52U+Z598TFtPTs+denIc/t5TN3euHwrMaQ4ptRzkVSI6zILqnh7CCpu9sZgdT262j6WmqI5zYf2Skb/3Mkyjvruc2w== Received: from BL4PR12MB9478.namprd12.prod.outlook.com (2603:10b6:208:58e::9) by IA1PR12MB7589.namprd12.prod.outlook.com (2603:10b6:208:42b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Thu, 5 Dec 2024 00:18:50 +0000 Received: from BL4PR12MB9478.namprd12.prod.outlook.com ([fe80::b90:212f:996:6eb9]) by BL4PR12MB9478.namprd12.prod.outlook.com ([fe80::b90:212f:996:6eb9%6]) with mapi id 15.20.8230.010; Thu, 5 Dec 2024 00:18:50 +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 RESEND v3 6/9] mm/truncate: use folio_split() for truncate operation. Date: Wed, 4 Dec 2024 19:18:36 -0500 Message-ID: <20241205001839.2582020-7-ziy@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241205001839.2582020-1-ziy@nvidia.com> References: <20241205001839.2582020-1-ziy@nvidia.com> X-ClientProxiedBy: BN0PR04CA0073.namprd04.prod.outlook.com (2603:10b6:408:ea::18) To BL4PR12MB9478.namprd12.prod.outlook.com (2603:10b6:208:58e::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL4PR12MB9478:EE_|IA1PR12MB7589:EE_ X-MS-Office365-Filtering-Correlation-Id: f2e236ec-df4a-42dc-898d-08dd14c264a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: EpHA/NyAKWq7xPgwK/z96oBkzI9C16OQUotJFcKbg2XVkkHyL5VKHczgiI37WjXk8bEkEtY4vwRVAJVHZH04oNHt00wVisAkDSR1qDsJcOt1Y2B7Bo0q0l70UcRw3PMnbJq2fdYfRkCdvazumcA8nUpzSCQ9KBKkFEvLAx+JtyhPgy8fLWBC3K9IexGAl+8nCVvNSG8ZiiGsujGkaD/Xc63BK+CeQO9tbCKgx08Iwi+RkbUBF0WrPCfV2HA/r6pXhWizJmZf8+s796babPMnGHyZ5vSq6PzsOMc+gHYn59BG8mQm2DysV4iK1Xcd+O3aOh9AEOUOfkBqOsQ6Q0u4gzmDAH1kzdGitCfhum80iku1HiR078Yazvi0sFHRt6r9YJfN7koIfFftmhPwbBTlc5XvZRPHB1IB6apyNdpI2n/okSqRcF2EkCjY7kVxzwiEagW6oOOyw8bVdv2/475Nv3C/p6SV7cPJvCJ2rrU27OTGF/k5h6XRuaxWn48xv3tofFrn6A6suddADQctVVcNwySeTh3YPR5+pq5ahV+PThumnyichHWfF3m4Rm4mP9P8hGZNwIAnmdOEXLjkN0V5cKzjbEUDRW+TNk9Obx+aO1R+DPGoTyRiiPefEqrOPT/DiHl/S1qWcchPzG8MHdqX5jNR7bow/7XwriGzGLCKEZ6z1AC1Ahg/98XH3FcVjpffuvLFNHSDXDV/GhkNW4XKoOpuMZgwCF5lQkLeXa8Bi9YjViYEqylf/JRGPEvXYqZPNVD3htf10H+Nz1RZkKNJ83okt6U0pLU9AUo8JCKdoS1OCepvrmqA+LRoA2KDDj6QEuCZNz8ZWlgk/GyigLfGQDyfFtJ6hM987xiRh+hRpMHxXKXrYsXQSJyRubTZV1VGrr0y+LDTClzUvJsuQ+aTwRnv4FzWB1WRAlC+Cvwy7OYNl6/X/QsVGBBsmcd/ZhF860RIOlWOaFUvemgDX6nh14lyPaOoOd5T/xXnIwF5qLIZrctynYF7qv0HGy+2B/YLyuP0xVj1iwNneHMhvL4xtW7NBrBteE7I+AOj+oH0YLzrU89qstRw8EkuaLOMSpov07rzdjxeV5lzBqCnT4vt21RNTq7FfVZtLLBMYF6H6AxZpAdviTsUIw+B3Sdy4Tp2RlkT9tcm12Z9V6l26t67f06WCTmi6awzcSzOlFIkanfjJsl9OPcn3090AcSJXIYHT3TEINStcA7C0femzzCRjUfg9pWMqHxWlpdpVDsAC2SRQUySjnoXymUfBYOdlR2EUOevdwnqLtNTpRIbJbpwvhXM7wUJjvK/W0ufkuFdOnIU85VQlng2jxIHh/wIZpi+iBoUgKj07GUu1LlsxlFqPQ== 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)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cgzM+UQcnads1cEpigAqjrabxL2OQn8OwZu3TpzIPeo+RNwdbZcMkoUD9sn4jZgsGu1KjBArRor3K4PmyuWnNDirx5uSMSq41k3UjfQa5RPGQEgrTHJjjBGXN6dkJ1/+De8F7Ia9g/Vtv1ottbJT/xmant4lj8YtK77BJrrQrG4JPO/TS9kpaRmo0c2Rv2YmlcrirqIzw1fu8KDQQe6vxfQdVv6tsdmeBlhwGqpA/qK3smb/k9u+w7ClZZnfDZjP7k42OTy+fvvPNdRGkb3g4PyS81l8caRBL1Yp3d1jwkvEpTTdGN2U0IbXKl1scsSVENlNku3Per9BGqfwSufC4mPdpJXIdFv1L5pvjStezzZPtxV/qOj7KuTy4nuUhvl4RtoOvBcXSxDxhuTrJVBjq7LVBhUUj5Vl9HG1lbM/shF/HCeYKVQ9vYv7zsacnwtb6+kuxmD/Dqmk3iqY/OftZsNeIUj1X2xtYjEayV44EuSG1euSYhp69Glpikc+f8bUQRWxW/47jXFK+wSCQtSl/nQooUQ+9/odf5S9aN7dqF9xUi52QXmVc3D6n66cRE/2vihvCQ1JHCt/j0TirywiBUchgRP9TpNGNMttfj8SXPdlNfXM8n5XGcThKbO/ja4X9Wqmwz/UXvfn8KeB2KETaHAIpSQjsDpqy0tTvrfc1R0DPmt3J+Mbc6ZrkcMro1s3zLpvuxfSLoy6TxoQnLZGMK1ObCHK9AFWfkO0qam90tEghWkV7qOGdiuy2JlLuhXB0KNOXVY1vFicyDfMc3QDHaOwYU+cIaHAW2Z+CSFxvNPW08UgWahzlOnN+MiQz1j967nScrmFmQaMGWdWt/JvMDdpJOlPPacdmGQKp6ehk11H5Ji5dzgSY6aYj389ahk74oW3mmRr1fMhr8oflJpKPbHliHqam1spnCrKkudd1adi4VwBiBRunLqyK0tnVzpOPOn1Otq8ZlcpUZlxYM2ysYfNIyUWXf51cKRQePWNlXswOGR4ofSqoxDV6x6pyw8wY4NoSZ+EuRIPI+otVgcL6Olm2i1GqnXSOrZUbcIoYG1Z62tcj09IY3CBmshTjh00dYipBBx5e+pOCdaWoUdyJIKNz5q4DFlZACTpdkwdUpDTdHqrFe0lGbfExD/FD2w1Bjq0bOZ8FPRmFaA5OxE6E4NnrRehBM8MofWiJ2LVprgVBHCyOHl//JxWRCDBwL+d844nJGkQlqEPCj3PAXmg75K+jFYTYoi4F/fgovcCWE/usbox3zoqwaO1PfzWhs/SEVYp13vp0RqaRnXHRNxnTAR/xNYzPPZlEZ9NzEOA1Ug2Kx+tSvB3PWQJEfGfX1moI0fjpWT/aOPEh1a5BlJ8PZZO0e/lFCrRUKVFVvgWHPHzPPf5ysT68kZ/jw42vlk6BrcAJzJTokEZhQFt3MfDmz8S4C+wtKsCyM1r/8tjyNUXn/tBvTEnuqjrfWreo33E2C07dG1n8flf5ucUhh+dkT8/uVehPdRRuaIkRH4pVKJc/ZZDbl4xJV/vqkhi0PaE25qGVCWFX7vdhohfVf8bFK0gWZD01aVhbN6eBRPQFRrziUemRd0fupFv+0CMrOT+ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2e236ec-df4a-42dc-898d-08dd14c264a5 X-MS-Exchange-CrossTenant-AuthSource: BL4PR12MB9478.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 00:18:50.2388 (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: 45UrZFgpBllT22CXE3zA7dyNgQ12FJui3eGkM7WtjM/Ie2MxbLL8Ua9DrRFpwH4z X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7589 X-Stat-Signature: ekosrsw13upreb59i1fknco9qxxhijje X-Rspam-User: X-Rspamd-Queue-Id: 2BB9D1C0007 X-Rspamd-Server: rspam08 X-HE-Tag: 1733357941-659651 X-HE-Meta: U2FsdGVkX1/PGneZe0ajKKWftHFF+Kr8uGLhdHkEbH0Dv/N7FhPwSwE9qlQ39uX18tkAjoyvotVw36MAA6viGfeepsALcnYbbbcN+DDyiR1PCrxb9FHyfOH/GR5CPJqTsvYnD1IMFXMyOqFtFX2rJPXTaYnurfhLpS2+cpsdqa/UKP02OGVA1wIRkY4jPxK4KruXQXgUzOIksJkDr8YoQlVNPYQDEaAoVynhK/miQRqwCEShhkC5r4VdUGceizly4uFnUap8588gBrnMFyoP15cPtmfdK24OkLtZ91K/VMnrY/lzmOE9ArTcu2b3rOfylmO0fjBhMpFVEd1kqZeTgczLKvoyPcuk+CjMhUB2fZfqracchofQ0LlKeZsT9UO6irYp0/O6LXVWyzulsgwH7YL9danudzbinn1ogQ/iWRdm2bxkXAr2xnYsUic+Aj868/lIdPbQsHHL4FCTxIYwNHtJUqlUPjHGkEMAdpMb0he3A6JaQyGC0E8zeeB61Ud3+N+gEPvoJmCCh/kCl9ejYtbhmuIr/5s2AYTrWoQ55xO6izR559nr++V3DH9EmV2J9/7zLlMvyED4Ufo9zRRX5lM3oKehs9okHFzZ9AW22a/b4NMKvmOSN6WoLox9XBcGGZ+EKcvTOAY9T8QEu5SOP2Ic/433X7RcwBFOJznEBiUnkoBaMnhXyXA+USNnlBx/jmyxkEBuQsZ1LOWjrD177xZWnmS38Immq+fRE1ZzA6lnDPRZEbJKznsLuYLNc+19aKoaNzrhs41Jbim7VCZLVSXo1redCTPMHAOWM6KnqcDWM0C5VF96snUHXknq8Sh4/4UKal1v3G1rMoiAh2HMHd/QA1Gwfk/SmREGw76Qm2g1RHfouNFmTXuaoLqyZGkw8XThtR8tM6uD+TwRHoCoUAu1O0P8AtgyCb+QU26Ewf0nDwocCIuMN1u6cVGrBQ2f/kSwiPoLboe57TMXsOV sFUSiiry O2NbiH9KxKW8CZKKpeZLziLzHgBYix0RvQO3UTEKzBfYlxdJ24X1YL5e1S5WD+jb8yV0QAxl/GoxewGNyqQrcIBU8RSbeNMR1emORI71KBc37t+hMSuUx0LIfo84sVqvt4AhHnPGfw1gfUacpgeAMtca1PGdT6GNyASNRa2Qnqx/DcZPoPyXaRzqNFBayx1MLneaJXKxaedu/5wIMjbt/4goirP0U+gtRJ7p7/AtTt6+aBmTsMZ980XezkkHq4Z1JzBr68486qItVP/D4l28SLX4TdeHrVIaPpsOHEL+Ua2ChNWlRSwpuwtrO+1cS+m018cWtDE9acCn2f6fkIIZvek1U0xqwa5Pqe3C8oAaHl19LkDfyTwojlC9WKBdWWIFJJjhKrtyfo3LZN4c= 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 7c304d2f0052..9f33d6821748 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -178,6 +178,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; @@ -207,7 +208,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;