From nobody Mon Nov 25 22:43:36 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2058.outbound.protection.outlook.com [40.107.93.58]) (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 674AF1CBE8C; Wed, 23 Oct 2024 17:13:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729703581; cv=fail; b=PXdevjLFWbZGctwAUzoEt4mharKSe372XuDTCtvxZOKNj6HRhhwkzhPkWQUck1de3H83G8lsfgJ+s3ScWizSXEjWzD6jA0ZL+/bZngnFyxqmQ1yNJEL1so1QeFHXuD0FjY6whXyLbAgt5GnAiQ4kQE1DbOkH1PZ9zp13zvUQk00= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729703581; c=relaxed/simple; bh=b5wLiDMB8DV+BqYy8+lVONVMDJi/TmDqNZlxfryY4WM=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=XVBU4VsaP0GHwYQjxvwZ0wQr3OUu21uMkRYRe34WWMDnp+rEz/ksH2NvYNrwLAF40xcvHhr4qkZ0UiBh24dYp7mPeTah8QyJu6G/oQvHpNAjNIZWbX+RqMeKzLrL6rH8l9PAEotmsBZlwUj6alOmiM6weNEx6vyiQLxPPvGVEOo= 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=RQeu1mOv; arc=fail smtp.client-ip=40.107.93.58 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="RQeu1mOv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DUyUjT3QRuqkbcRpkqia+pIEUmaCZVICMPMamqF1+8672lB0iUiI3FBJ2BoWAWC8Hh8hoSUrRxl9F+47AvTdawwdh9OLh/WVMUUe+B9JAqgtqmC932oX0v6+7GiN8LuswSPwVkMIK15Oph4QCMS4BQ7RQ2o5XQe1DCSpYQMlGZPqXkdokR9rARHQTCeT7iBDm49r/SQkK1DPToN/axg6oJV3B3Hx+os+XdwLc54pScMcQSsF6gE87bsQwcdwWsW1VCYFZGZW6SgwwTTlKZm6xNIojQYxqX/8FIfA+Ow81mBIK62wGajSx1dkQMCZ201QAIJcdDyn+hw7M9TKx0RAHw== 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=zzcAyqu/MVxyI5pW9uS4cxtAvGQBBEfvUnoTPh/5le8=; b=kskR23HULm1JtGAchubjFjIi266GZ9evIw8kICox6ScNon6wD3nPQ9OZdyIviVrBmykX5AIW2psOd0KMXDDgXEC3gVtTvrPK9VHuAQjUgUrw6urBXduseo/cnc2DKnYbTnM29QzD7au8A3o1AHihQGg3veSSrQFVeUtyxrh31Q4bNg9inbsmelBNgEk6RgaeySAldNHSQ/uANgcm2taDst2BR2W2ZUX/SXgGhGo/PhSr537xS9Ksey3QYlxUwKaQ2jTEk5NsJkB1E7G8syQ2Xbpg0tDEM2vGWK5vWi58I1EhW4Ziu9zRuIEgvwYGZSBYcwc4wnF+fFx+PG6p9DG2Ig== 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=zzcAyqu/MVxyI5pW9uS4cxtAvGQBBEfvUnoTPh/5le8=; b=RQeu1mOvx94NdlWU/lPD3Xs/9lFypOQE9pgrDoZmmHYBG+10CKHq8KoqQO/V+IkGk/CoVWTPNpcipj855tx6PEDvBOFWjc8ya01YHag9mLyR6sv311nmXVAB9phdx9qGrZA7kmy1FSDvuJDr5mZTAyB6AoJLRjF2tAxghmoDylE0hYiFlH1QloR8HHwuWsoAIEqIlxczYMxPsJUCp279fNVamuBL+aat5Sx3pwIRQGIU6R7xGZOYJfokkMoeV/57lYlYRu/CaYkumeyPXFgNPUJH6yu23s18ZCeaiFmo5U6d9SjRS66VzcUeNingRYs5zMoi4pRrvVzzCAGPLAGjRw== 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 CY8PR12MB7171.namprd12.prod.outlook.com (2603:10b6:930:5c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Wed, 23 Oct 2024 17:12:56 +0000 Received: from DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::5189:ecec:d84a:133a]) by DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::5189:ecec:d84a:133a%7]) with mapi id 15.20.8093.018; Wed, 23 Oct 2024 17:12:56 +0000 From: Zi Yan To: linux-mm@kvack.org, Andrew Morton Cc: usamaarif642@gmail.com, baohua@kernel.org, cerasuolodomenico@gmail.com, corbet@lwn.net, david@redhat.com, hannes@cmpxchg.org, kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, npache@redhat.com, riel@surriel.com, roman.gushchin@linux.dev, rppt@kernel.org, ryan.roberts@arm.com, ryncsn@gmail.com, shakeel.butt@linux.dev, willy@infradead.org, yuzhao@google.com, Zi Yan Subject: [PATCH] mm: avoid VM_BUG_ON when try to map an anon large folio to zero page. Date: Wed, 23 Oct 2024 13:12:36 -0400 Message-ID: <20241023171236.1122535-1-ziy@nvidia.com> X-Mailer: git-send-email 2.45.2 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MN2PR15CA0025.namprd15.prod.outlook.com (2603:10b6:208:1b4::38) 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_|CY8PR12MB7171:EE_ X-MS-Office365-Filtering-Correlation-Id: 09557070-1230-40db-0c31-08dcf385f04a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wG9m4RyiH4FS+YoApwSCuUPk4G3D5fvn2u6ow1gULrqYYf4roy7XYLNgS7hA?= =?us-ascii?Q?vLBULVbzN31KYnjOQU0QaIu0OHPf6PXXYDkkvjvuNx7cgEKrn8SjaQ2inVu3?= =?us-ascii?Q?y3uJ7hH9AURaLYJRf5kzYPCBetS8gOmiM1M6BBDpF3QqD1MFsK2JJjcE19BA?= =?us-ascii?Q?YLp5kZ3wxJj+1j7jQf3WDooxb10OKynpyWJFFLXNm0kwbb8YnBSMK+ZYWFR0?= =?us-ascii?Q?VxwwWuDu/KMx4dde3Q4dEoIzM6nkUCzVuhtoStsHlcUoJQMVwaoF24QPqyYi?= =?us-ascii?Q?J81q/Epe5F2YyuCTFjeicqTwtvE0rB2PpRn1GLerBO1VtK9jOcGGkX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XqKOyFP4rmieDspr8v6kevY1tmcPlfHiaGP?= =?us-ascii?Q?UT4hgWmZyzKL9akdMfnlkQSIWExd8RaElFtMgPrRMbH8zYETF9s5YVL8ZNPn?= =?us-ascii?Q?gnfyH+xYkjJf6rbHfJfQ54e/?= 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)(366016)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Yxuk/8TjGbelmvLPrYG2F2N5eFduVx9a5CMwkmZftB1QbipxE+OTPYST0Rks?= =?us-ascii?Q?BXNG1Qz1Vrg+iAE9sHw8i+4XyzEoHCYT62YH81j72lw8r/UmXKJK74V1kOVn?= =?us-ascii?Q?DXiAId5egKcj74oYSl52DPq4cpE/0sImjMiK+c+QU2pqqDcXuQ5+Gf+OPaxw?= =?us-ascii?Q?eFa3cImGFYbPiSjK73Gakjda2cgpdERDzP51kWV412KzjWDgyH7el9DZuw47?= =?us-ascii?Q?1+wperPE/LFK8CzXzNh1oFqs4v3bsZFF7gD0TH50S8VwiEtfRsimTLajQaoH?= =?us-ascii?Q?oUyj8yBC0KAPRnysv2iDE2BXiSQIKfiSi5xWc0eT8FfMuGdgGzqVoTg3gxMs?= =?us-ascii?Q?fHoYyKUVcw6RaxetlqaLOCxYwUPAtO0BHe2Qun30U+8NdFDjElpPT6DXRBS5?= =?us-ascii?Q?/pBhHvPs2XtTGe8KqwmSqgohOyWjY7oB58uQQOkEdm209q8sNUTPMfq+MeC6?= =?us-ascii?Q?fTirJ7pxbFOZ3RV2WY6OvzqZlMrf3tvG33KDJY6Z6yhBQaVwOii/LhLXaG33?= =?us-ascii?Q?bS1vPzCsh4RGjuOEUnfPfVT5NU6l7qp9dsat8u/Id2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2uMiHYwi4gMTcmsTMzNMMau2/ScU24h9lhm4tUjG?= =?us-ascii?Q?0ToSJ0uZ8v16p/+q1pCtdAd1+9qnE+tJc85G0sogHTBiWs/EXvPTE9Nkaqpr?= =?us-ascii?Q?LOb9OtuV7a+viyR+AoJvOnd/wrAFenXkbw3MJ86k?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09557070-1230-40db-0c31-08dcf385f04a X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB9473.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:12:56.8566 (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: VKVrlc/pZ+eqKH48fxfTAZO2zINNEAp7SjIhXDK2b5ft0maJ/GSjyZLmarR0IfLt X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7171 Content-Type: text/plain; charset="utf-8" An anonymous large folio can be split into non order-0 folios, try_to_map_unused_to_zeropage() should not VM_BUG_ON compound pages but just return false. This fixes the crash when splitting anonymous large folios to non order-0 folios. Fixes: b1f202060afe ("mm: remap unused subpages to shared zeropage when spl= itting isolated thp") Signed-off-by: Zi Yan Acked-by: David Hildenbrand Acked-by: Usama Arif --- mm/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index e950fd62607f..7ffdbe078aa7 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -206,7 +206,8 @@ static bool try_to_map_unused_to_zeropage(struct page_v= ma_mapped_walk *pvmw, pte_t newpte; void *addr; =20 - VM_BUG_ON_PAGE(PageCompound(page), page); + if (PageCompound(page)) + return false; VM_BUG_ON_PAGE(!PageAnon(page), page); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(pte_present(*pvmw->pte), page); --=20 2.45.2