From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013024.outbound.protection.outlook.com [40.107.201.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C34D347DD62 for ; Wed, 10 Jun 2026 20:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.24 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781123787; cv=fail; b=aAoPG58BznlbzBCxnLMI3EwYUR14CWvQ/i9LQjt240DSxZ3tKuPrbzFHPaXdJJuVmCeDaIwbmk3gb5niv1MVB2ifttxB8Dnt7SEC2ulTmF2A6IeH5ZTN5rHPGQzoZN1FW+kgnpohC/GvMTOzhcg32clzW8647pi5KIw01QtiAVw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781123787; c=relaxed/simple; bh=qql1FzntdF0i44HGY04BVXWneBYZFQ28Ykw85iVsQFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=J3kA++SZnqsnWLs8g8O6NO4mYPQvq9XEi9KPQh15E1ZKyXJn0hzgM+lkzBOrYFoL8FurzOC4bum4cXHA9umCg8dBOdO1H1JYj3Xu8ILWR+SmWf5H4jd2cMBfBglJuXGgBmB1y7EhgNPTqpRXub0Mf6wtak32P5Ep0Aoz8n+4/oE= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=VRmQtOdC; arc=fail smtp.client-ip=40.107.201.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="VRmQtOdC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Gk+6TCUiUiFL7xtV6/XOmqvx8Sdnb7s5mT6KzFikBwKFbXJpF9LojYD9yaXPLTmDc6WRvTH51hnmUGKZcC/uUqDAlaTJUBWHiXpx83NshaDZIEFFUJLOpz/BNRA+reRQqYBY7mnVcG903oiWOH0PcKKDbwXiZtAJkPBtMIX/ttsIWd35FdNlXTqkSQTAVebzeqqObKxKBxBe37yY9Qlm/82fJ3fMAqNbgkJiHF5EX3hgv4OCwTZ1qQLo6Z43nPc7+tE4H9U9AkqOEdpxhOTKqiyspQ1CWDL+1oYxR0ge2HU5uj5LVTiiJXHHFG4A2/YNmKG52eJx9Dx8nBeq5o/j0w== 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=t5rbbrakfJ733LcIqCs08hLoqz6RdsMYH898Am/2d9A=; b=Ex+GOjlO4xVF9X5AzsUAwsK7zSI5GBe3xhv1D5X7eok3IApvfsWWjSVSEJMW6RLkDHnzz0iqK9d4/tuRX+bCT8AR6M7DWQbaEZVhpg07A0Lf+N6rhSHye1lJusAbZfRXKZLI9vmM1c2qZiJyj5OlSakN2JUgxhXHmT7AlHtyZBWp99qvEtHp7l/nNnEvNwlp1w33vTjpc31zOC04fyQRtDdxH0whzW9MIfylDEcawEiu+UoKwF/0GeiHDfGOemP3wm9QJ9HM+hWHAQro2w1vFh+kak/HDd9mUdKDpCJBA8mhUHapaQqiSrLFTF8nGOoZQSr6M418eJ9IDJxW9IE0Iw== 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=t5rbbrakfJ733LcIqCs08hLoqz6RdsMYH898Am/2d9A=; b=VRmQtOdCtlBBNbcEiPgqE4LGQhT6ksqxx1kl3GEAV+xRAWrX656hbjevzbgeDgjPHqnQjHa8B5BAgeHhnqoOOJx+psOKUi7OGs9EvgUe3rM5FvsGyhK+7KQ42d11FlSuj4e6kbEHe6ElwmWVQlaHtBhq+zI+QCLO9gUwU3uR1hDX0NzTt7GP0IM+KCyq1rB2Gsi1ZxLE+I0HYU2YpeobgckX7a+B+nkMf2fONar/0OIBJr0J2KccREQx7qq9f+bKwtoxD7rD/IMbOO81/y6qO49nAw/EJdNjTAMnqaDdaaWBECfpIEH/Qz0HaSeoyYrw4Ok0N8Ow1Uk5z3Soi2iZVA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) by CYYPR12MB9015.namprd12.prod.outlook.com (2603:10b6:930:c8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.12; Wed, 10 Jun 2026 20:36:15 +0000 Received: from DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::f01d:73d2:2dda:c7b2]) by DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::f01d:73d2:2dda:c7b2%5]) with mapi id 15.21.0092.011; Wed, 10 Jun 2026 20:36:14 +0000 From: Zi Yan To: Andrew Morton Cc: "zhaoyang.huang" , David Hildenbrand , Lorenzo Stoakes , Barry Song , Baolin Wang , Lance Yang , "Liam R . Howlett" , Nico Pache , Ryan Roberts , Dev Jain , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhaoyang Huang , steve.kang@unisoc.com Subject: Re: [RFC PATCH] mm/huge_memory: do not add dropped split tail folios to LRU Date: Wed, 10 Jun 2026 16:36:10 -0400 X-Mailer: MailMate (2.0r6290) Message-ID: <4E038FF7-876C-41F2-B65B-40D6FEABF0E4@nvidia.com> In-Reply-To: <20260610133002.4ded8d8cdc8e23e434fedf1a@linux-foundation.org> References: <20260610120535.2370844-1-zhaoyang.huang@unisoc.com> <20260610133002.4ded8d8cdc8e23e434fedf1a@linux-foundation.org> Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0926.namprd03.prod.outlook.com (2603:10b6:408:107::31) To DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB9473:EE_|CYYPR12MB9015:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ea46039-6633-49fd-d9b4-08dec72fea9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|1800799024|366016|7416014|22082099003|18002099003|4143699003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: B57Lq7Fb2zVpwXJM9JeHnW5ZvKxkh5ZOwhYweK1eNNHBNwvSmi7L/Mwdli/OQrECVuxaVw/+eZoWIpOriFlb1vG/dtk1r+bC8okk4E/yvv0yxxBs8Gkac6fRYxdRX+mwMP++O+AP9N6oRD88EKADjZH+Sl5HsTkJZTxI8UBiOh5B9UZgXyxPX+MttkbgT62lhu3e0kc5mLWdSj7VI7uedmJUckuoSzGwHCR0YBebTPmthkwADkmrIJcMoJ+YMSF9mivy8dD4H++Gfr+8QC21egnCGOUrP1caoRLImlHBH8hOxLhbvSXrqxY0cK7JoJ73nmwI+nn6yo3OdcrRcnm8hr1bEtdSwj3T5Kp2sXEJFBmqsDPCUmqzJhP7gl5HhqCYLlRs02/9E2fToRAV0NLrdIO7BVOk2rd905ZK91pxODKjcm+tkk9SuW5bG8uHieEbPPl21VpLv/thxvWusCowkICiq+nDvGsuow/jGDHk8YxNZQe6B6R9n351gzHfRBCg46LDlGdqvdl986fI2c30/VIp+yR96/leh3CQxJG8jAQsaLaYOScNi7u38Hy3aDGKINzcCdSws6nyDnoIbwSxg+wRjaLMrgkT4awc2L1osNP/lJSHfBOD+JqJozODQlh8ZS5MZeQfGNvunpXhBb5M64Uuc3xSNsSMvdIKikRZGpwG+ab9jYiObiLx/91SGhxF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB9473.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(23010399003)(1800799024)(366016)(7416014)(22082099003)(18002099003)(4143699003)(56012099006)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?77RnT3vgCXaVMj6RbY2v/H9mBElt5WArQt1M92dY2izfCC6QgkQxfrk+7T3E?= =?us-ascii?Q?x8GIuKGKMcOCBBcZCaeOJThtyY2zd+LSFHX+xqUulCEGqWZqCBWWTzQBY+2D?= =?us-ascii?Q?iG3gmCFpVXkw6vpucZf6jp5X1zMTfFTaFZGkujHVj6oPmK41OlArgC/jYZpR?= =?us-ascii?Q?OiXrOznIK/jHRBn06As+c5EaTQGtJ86fTZlaSfj4vpx9JTetiDDCN0VriCP5?= =?us-ascii?Q?LB+HSQZKppBwetlLRkJG8403ttGsyq5HKRQqzVFpTcaKS/DcMfuIXLBgLO+e?= =?us-ascii?Q?FC8FZFE3fB5OXUGgfDjdSfZbIQGvtAkeh4PlIymXgXBGbSFGBU/0mlSXzh6l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2ipgRDbAVp8Wkb1axtBF8Sfg1Qqwc2oB?= =?us-ascii?Q?6VQAFXWUwAsWQVnjp43RvbBqBsh1I6n0++NqIa40akXQUJRZTVMBKvqB41jx?= =?us-ascii?Q?3PNAZ1TT5jcV1g/XxEGvs2JqVZtBnj37n7TkTjtzjdjl7sxIQY3FivKiJf65?= =?us-ascii?Q?W93NKvLrwnXfYieMNWuehgQhBBhhQkSWgJ6oHUxsHErElOs4jWR8ig1zyp3f?= =?us-ascii?Q?s2GWrx5DP3uyNil6uJWdMcnvZ1OikYQl7XluFC/CCoIZsnZNH59HrJDjsrfp?= =?us-ascii?Q?S0esVpCTbuemtiEfsKFrqhLxFeNOPZghzWVm8Yk/RQCDQQJbxZ4PBTPZGiO5?= =?us-ascii?Q?/gZc8QgGrOw7A9mu6equTFuwHGYZfvrToOlKKT3MgxQGweqkTp+BEhgL2qdD?= =?us-ascii?Q?ooa5+xuHta4A+1mjcD8SyxaG/tD1P/iCVeu5SEEwVSLtZg2ebtGNV9ztvCSZ?= =?us-ascii?Q?0fxnsboBEE0mBGwceByMExvrmFlGzE3qAaB2VzcWAAh+VgJr?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ea46039-6633-49fd-d9b4-08dec72fea9d X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB9473.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2026 20:36:14.8392 (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: 5y9Lh9JH7oYen0nm4e1aRHH7BzJ3DmZSEn++VtdrVtUeWdQ61GZP/ToDVi9DVc7Y X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB9015 On 10 Jun 2026, at 16:30, Andrew Morton wrote: > On Wed, 10 Jun 2026 20:05:35 +0800 "zhaoyang.huang" wrote: > >> From: Zhaoyang Huang >> >> The kernel panics are keeping to be reported especially when the f2fs >> partition get almost full. By investigation, we find that the reason i= s >> one f2fs page got freed to buddy without being deleted from LRU and th= e >> root cause is the race happened in [2] which is enrolled by this commi= t. >> We solve this issue by reverting a f2fs commit 9609dd704725 ("f2fs: re= move >> non-uptodate folio from the page cache in move_data_block"). >> >> There are 3 race processes in this scenario, please find below for the= ir >> main activities. However, by further investigation over the code, I >> think there is a common race window for the truncated folios between >> split_folio_to_order and folio_isolate_lru, where the folios lost the >> refcount on page cache and remains the transient one of the split >> caller, under which the folio could enter free path and compete with t= he >> isolation process. This commit would like to suggest to have the folio= s >> beyond EOF stay out of LRU. >> >> Truncate: >> The changed code in move_data_block() lets the GC path evict the tail-= end >> folio from the page cache through folio_end_dropbehind(). Once >> folio_unmap_invalidate() removes the folio from mapping->i_pages, the >> page-cache references for all pages in the folio are dropped. The fol= io >> is then kept alive only by temporary external references, which allows= a >> later split to operate on a folio whose subpages are no longer protect= ed >> by page-cache references. >> >> Split: >> After the page-cache references are gone, split_folio_to_order() can >> split the big folio into individual pages and put the resulting subpag= es >> back on the LRU. For tail pages beyond EOF, split removes them from t= he >> page cache and drops their page-cache references. A tail page can the= n >> remain on the LRU with PG_lru set while holding only the split caller'= s >> temporary reference. When free_folio_and_swap_cache() drops that fina= l >> reference, the page enters the final folio_put() release path. >> >> Isolate: >> In parallel, folio_isolate_lru() can observe the same tail page with a= >> non-zero refcount and PG_lru set. It clears PG_lru before taking its = own >> reference. If this races with the final folio_put() from the split pa= th, >> __folio_put() sees PG_lru already cleared and skips lruvec_del_folio()= =2E >> The page is then freed back to the allocator while its lru links are >> still present in the LRU list. A later LRU operation on a neighboring= >> page detects the stale link and reports list corruption. > > Thanks. Sashiko AI review might have found some problems with folio > flags: > > https://sashiko.dev/#/patchset/20260610120535.2370844-1-zhaoyang.huang= @unisoc.com Claude also raised the same concern when I was reasoning about this issue= =2E At least for now, my conclusion is that the race between folio_split() and folio_isolate_lru() should not cause the issue and something else is wrong. Best Regards, Yan, Zi