From patchwork Fri Oct 11 15:03:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13832631 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 249AFD0D7B4 for ; Fri, 11 Oct 2024 15:03:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94F8F6B00AA; Fri, 11 Oct 2024 11:03:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D7D36B00AD; Fri, 11 Oct 2024 11:03:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 703C36B00AE; Fri, 11 Oct 2024 11:03:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 52BCD6B00AA for ; Fri, 11 Oct 2024 11:03:22 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E0062121333 for ; Fri, 11 Oct 2024 15:03:17 +0000 (UTC) X-FDA: 82661639760.04.FAA0B56 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2087.outbound.protection.outlook.com [40.107.102.87]) by imf30.hostedemail.com (Postfix) with ESMTP id A3D6E80008 for ; Fri, 11 Oct 2024 15:03:14 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=gyicmjCB; spf=pass (imf30.hostedemail.com: domain of ziy@nvidia.com designates 40.107.102.87 as permitted sender) smtp.mailfrom=ziy@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728658929; 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: references:dkim-signature; bh=wI3bTfA8oCD7MS7gEe8h7SX+aYPspElrPFvEqxHqj3Q=; b=hzZwUJecHrphMaLvoVpS1WfPfAUsBlWjdmP4qI94ef1rHS9lxKDEIin201vmLS5JuQ2Ixx oR7uK8VhSQn/e0fqFJfTnUTRozMw/AErMHauqW0WMboppat73/GoIwRRUN2caXKFOqzIhl DNKQ5RdeTzTobtOVTkX7P1lqepGxAWQ= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=gyicmjCB; spf=pass (imf30.hostedemail.com: domain of ziy@nvidia.com designates 40.107.102.87 as permitted sender) smtp.mailfrom=ziy@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1728658929; a=rsa-sha256; cv=pass; b=nBEDZ9wlNRV4VzRiBQBqB6+Xf3EfjD4adsvE20iBfQZ88H/zMD8MMjd5X9/h6WbF4mx0wW 6wMcRi6PpdSGfZlZyewrHETD7C44eS0KE2xb6CXXzuolqg/I33mA7C308sR7REYUjxDq5z m/6N4Er22gjyTN89SRhbAX1UFLTdDY4= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NkEe2XI4ETyo0Lhr6pJfa6BIRMv4pq1kelGAJPaZadbf89bEYcaYJAEGAuiJVZicsN6psKesfoBNlygq6E4TwVPxPzQsUk678NvSQY32mF2veLByipklKi90SnvoDgd4qLbFMGzsGL9Shnw8/fBuSTyXZoiQa7RDcYM/RiipfzWxHvvpTSNC+iVzV3z0vHT1KzA+5abrbmwY222Fprr+FLqLlg952J8Izh5n3jNyamGcb+O6fc8krAQMKiHkuV/DmJX+iVGfwahARFyl/BrTFbitSnOzJWkbLq9UlfUdvFOO5iLa8PN9LFHxNOsqFY6kmBDGcmBXiKt8X+kJbQEwHA== 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=wI3bTfA8oCD7MS7gEe8h7SX+aYPspElrPFvEqxHqj3Q=; b=Wz7ueWboDK9a8OK5csU3yywRhtFy1lGssgtYjBGWSP9apM5YCohCkm/MSXNUXhK4i26WaELkNk8ukWkxzWaeMkS681QMpadPnGSwta4K3p7DUG5DNV+oXr3KH67D+WYdIDpwYC3NisD9gxPAXqyqLWQDENiSDqEwluihRTTjxEaSU63V63jniEoxiJeH9w4zoC/w4zlMXCL92Pmc9dMRhlrNdG6eJN1umN4ZK5rdHJlyTRyl8rx9S8bTtlkr2ssYZrgoeQLOgIKHjohAVQj8AR6kA2L3HQcQ6Wy4nVIEQARiXzbf1NY5kXaGtCE0LN9A9pr1gfeyyGsjThFkNB90Og== 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=wI3bTfA8oCD7MS7gEe8h7SX+aYPspElrPFvEqxHqj3Q=; b=gyicmjCBKR/Pr4t6kRVVAprZPXDvS7wPDYJoKiP38bya2y7Wq+9eL29Ud3/teeO6PItAuwqRM9awDtZYGT47xr1OuQ67t/H8NqvSvj9864zlpKDI9IvO3gnSbZ1S8AHmKfxJaIp2KKE9SpdCs1l2Y7LV8+uSrwi9J4LUgtT8+oBXWFVYERnxbgxa5imBKo19KQIwin+mJm5KJlkYFqwOg4R44l/V/WITq4sU++Zdhx5SJ2DXw9owrDujgh0RJgzDmKBhAwYADawx+u+/kmUayYwyKLJ3wRJ9mQZjOZla4hM2NQE7FiEpLyv9urhRvyd3j1ID3fqrSn+l0mn3csUEMw== Received: from DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) by IA0PR12MB7776.namprd12.prod.outlook.com (2603:10b6:208:430::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Fri, 11 Oct 2024 15:03:14 +0000 Received: from DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::5189:ecec:d84a:133a]) by DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::5189:ecec:d84a:133a%6]) with mapi id 15.20.8048.017; Fri, 11 Oct 2024 15:03:14 +0000 From: Zi Yan To: linux-mm@kvack.org, Andrew Morton Cc: David Hildenbrand , "Matthew Wilcox (Oracle)" , Miaohe Lin , Kefeng Wang , John Hubbard , "Huang, Ying" , Ryan Roberts , Alexander Potapenko , Kees Cook , linux-kernel@vger.kernel.org, Zi Yan Subject: [PATCH] mm: avoid zeroing user movable page twice with init_on_alloc=1 Date: Fri, 11 Oct 2024 11:03:04 -0400 Message-ID: <20241011150304.709590-1-ziy@nvidia.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: BL1PR13CA0072.namprd13.prod.outlook.com (2603:10b6:208:2b8::17) To DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB9473:EE_|IA0PR12MB7776:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f946485-5e2f-4368-c491-08dcea05d493 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: fG0cYSP/+3/DWXF98pXe/xtgrpn0nvEZaP8+Mg4DMJDJSnf+KyqoPZXJGQlxN68vyJBwOcYHJNdUPqazfwhFoWBYYZ6m/Ry5opO7In+TbK0QSTFXCGhBuKZBxKqbixvnT2jYGZZmjdIHeGCseliy5VerUft54fEvbqwh4KFz3r4EGSk5pbFp4pAEWAtiM9IbRGwXHE3x+g5VZPMIHwstotmnF58cltnOeVx3aBMd1HzRFt8GBI3AGtuZbTQVFOQz1TAH8WbDql5LiXxyINntJmnmVQI/9uni/Zfa7WGEqIadMwRniMqNZ+tkukTe4tljdM9qLwGvleW2uWWrI195PnaPvnFXxCQ0xV7wGpkjzSSDwCtEysmuS/Z55tcpXnRfo07OB5KIhDmkH8j/WIEEUrpGIJ1B+s+BpHVKOthsdSPFLBxxtFRXLrCaFfnu7Wh/GkCbE9B5XmiMkWYaFKGCKvs4Fjssgi4S6FcZ5wxEDKnJ46cWNZsM596ghzkLm9MUGFLQgP6+zSfRMfxGxIdGFegelcPGFgDCFeDjUOOHk0Kf797RHGhopYv7ES6yLP723LDftV/05WJe4ZqV0T627jzh0bKhqIdbxoM0Gf6KFSnotnx0wnB6Gzg0/6GhX72/lbd9mrgneFz93rmnqQ0cP30o4lvD+CQUlL0oUJ49PzM+HVhmq2LF6gUNCb72djIC37yAr9ooATfeSWHLq+ySiuKBuP/r1uPmfgwO7xj09ei8PnseQlZjwHkXi/lbSfXyXTVnyWqaNv5unGBseRre0mYUYE3UE91GwMuWpWRcBTs1KJsqAasW0wOYMDN7EczCzC4qhatM6trGcZCHGlLSn9xRVbs7Pwjrv+H5TezanwcCWUZddjcHSsR0pwyuayMWakYr4F9rFsF9O25Ic+uZZIEVc7qY11QNffJPtaY4WF6lk/wXafR7ti01FCzC4WQhGtfM+VK+yaJydvQN6R0zKTsHOuZvnDyhYVzkgZqPvWrSejsf+4zCn6oPFrOT/IAu1esFTv+d9wpH5xWHuE78WA7tkCH6lcKNq9TwNjwqyjx8/JbUOPmIdbSq2DRT3pY/nwEwAiTxFXz1eNrl80O8jfhZ1ofwFdHIV7z42+ejrsYlLZUs4aDVRWB2lBDR8AovSpPNYs6ixKfnvtRhh9TBCeXmE9Xl89ovuFXoKwqy1zWAHf7STI7B9NCYWLTKdH/mp1EuW5s/oYkLrv43HDv+N+sHUf8MiiqCk+2Dtb/xaDN1/HpPYOFNEMhDw2NrHnM6DCrLYeaVpz7UV4HThq79tQ== 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)(7416014)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BR8YS6hx18AU+xwmCrsejWeKc76vcYoui3az8jFE4iKYjKzTCHqCT7W/8nRkwz+QVygM9Qifd+RZRXCB5rtE+Ua22HgWqbnv74XQ6WER7DKg2v8gx4Y98ttUAyDAKOfGOxFp0Sq4h1H79eumDm7QAiv6RW8RFZ08t4vdAABiMEG/yC5pGKEiyaYM9RLpTw3w5sL9gS5DRBiUvHtmKHZZrhVZ0L2bBttTUYJ9B+nQKWokKPONqRgTvdmPBSNZUNAs226rvs0JupFVXUzpWbhY8UxTh5LCJu9T1uKTxUi7/vkKRQvPfpTXMjKvnRnWoA/E51c7JK7oRkfMoe/jI8//2oI+HjBQKUZcs5Fh1gBMrPGiHR7kbG83bQ/wzb9KiA500syx49nXr/aFvohXXW6jriaFa+511upk6gngHiuRk82CQpsQyYDaq++keUqLTU2SPacnAG0esIs8tGW3+WFd6WjX7f6LZHAeO6cbOLeZmEXyfRyV3POgg4YEIAj7sK/LRAaQ407XPWpbUrN3aDBnKbfgjkDs3Wm3eWE5zNZCcFSxDeUl+mQhGE91nQbNycl4W97by1yOIE+QGLuwPL3goEMkqSpBLlBH+JfIGnQOpAfNnS/NDbepHD1mkwUjx7GB8ipacF4LOrXm2S0SWXX9VCXARhkrhOe7G79hWyq53o3qld2uKljAgDR1+63XPNiY7AFODihdItEOctgWmTT5XZi0iFk11XdKZe940EPfwcHTxsGhnHNRrWHiyCMfk35uST4wDAQxB1QFDR5WdPHAznZp2DBai2Tu/FfOwzXuHKGDyaeqsYc70dakLknWkh+cnyhc1mFfc+Au8Ydse21RKyciMnXY2JCtp6vDMni2Nvv4jBfG996+lF9fF+/AAFvEDfgouXt0k93wiLrkam3MO/dekbXJjk31je/bGJtPtytawkeOeXH6rhKLph+F5uin2Ep/N/6mQ9EJTGrEZmKEQ0SON31tgW46ZTMUl50g9/8CkVYqzgCmnJX5UNUHm7UpXNf2GL38J3HOC4/z/qnzD7NCGiesez3lVCs88YhEYTerXqrDbq8Dw0EVNi9Me2VBugK5ksx6A+/owp8y+QQAib+A9aPBNNo/sbVOvM6lJyYnfLAvDRRiWhlv4vxuDM4jbN7UCl1Q8KbiaNWCG1e8qjsLBqb8TV8dbncZtVMwbxjjVg41MCAq0PXnhZy6sk5BxUOVzgrjtvOYl/mk4jioFNXpSFITeG8m5dNBejEXEIrsicvWUrKl8hqcl7pthk25lJ1FADibCoe0cYULlI/Pws0YX3Flu3vhGbW0SrdnFcYECeiGdPn5La0haWBJf77z8sUEDeaIVTpe0VMPvXfLLzM9ymo/QJomiNcoOOrERq9p/6KBvWIXYH9PzpkPcWkCv5hqwTQm2cOIKdQIWaPIf15xAhONtpcFORHcnCiATS4KXFwdclvDvCSdH4XQ0fJzwKTI7VFBKwymtD79R0x4lGqH8J+ELG4QQOvECWk4nOZPYWhFSk5OBgmemjrYLImjlDRrhz6d3G5D10WJTfKO4WQZfzVL8hTcz8yzchsLGw8= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f946485-5e2f-4368-c491-08dcea05d493 X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB9473.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2024 15:03:14.3122 (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: 148YgHeoR0jtCr4wHvsjmFFTfubXlI2yEQ3meywJizIOI2Ydh7IjtDcNGiPKurR9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7776 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: A3D6E80008 X-Stat-Signature: tmm7c4nx7kqs8dr5n1echz3opumcubzw X-HE-Tag: 1728658994-744481 X-HE-Meta: U2FsdGVkX18o/6ECKr2+LezaIXQjTeTyaaEb4ZQqV4FEbglOOlqPNjgVQE9lotNxEtGuOf2C98ZvaLwLisFPmH52CvAKGTCuAIHdSQukqz1znp+Pf5vztB+xR2812akWd9rDVujJhoevX+i9QswCjcc4CMsA5l/n7nVxai6x6A1CRb2pCQFomRv2ANc/VooL2+FWKKN4s7oodygleaU8spcTjgAK9UFNYrMOE2YYj9TTO8qTsEtTHv4wJQZZfQXYkGl/O4rd9sL/FrEIU1KRgnc3maUGToc2Z+/twbquLmncpO/7ZHSV158RQFYnczMbHogqn8LfdpWzyscPri0EYMjw/2IDeqFr5amwm+Ec0iF/rZ0De2OFYGh5EIbW2R9wD4UW5gNwq4rajsGZsLUsXfZEU4k2G+bsZAo+lL5RjRiN+KvxCISYZDNXHCFZ0n+zWjSnXik0a5j9UZ16mN+fOXUfNyxogqrdvedqPEtTn8th+1e/II1oOTpW7whTrmxY1zGXayT+7s7yiQkOswsMYzUyj1pKxyhqHlbG3KH2gqm5/UtZB1vYbfgw8l3o69D6IoMq91QRHRuNkR+gPs88YMcFDBgzGxmZWlKDorjv89l3k9B19NQe3KO8N0M/0bJ4g23lwAM2shdLRpHT4EB3bRRk1eNH55sspm+2K6IPvyGQDV6IYQ8ZKACqNN/RLzawmwtdJcXuVIS1zNZogkWDCngnklQlHIPM5blCn+wYMKZApCplEJLoeb+99hHwrW0RGpPOLbhAeC3NR0xhlfOeUKfKbwZK/v2hZguw1CRI0VFd2NgNO3hpwxxeaO97EqLXWxA2jZHIuhcz/3z9XDy5UvieOdpehwb+qquD9/YGVfRq1d8fvEdnAQtDWgdn1z1qS6m95lSbSQvNv6IAVtyiqY0cMaxvm+cOloyZDto5KuMW50V5CDtqjsRIFf8xdHwOgW/LbnYD2O8M96VnH9m 1+YgSt/2 tNvPkTGOO/8onTBQbVRvAYEvqd/T985RdiA+aPmDCUd7WM4IwBYvY6G2v1c0fAl0nGuxYMza4C9up9gVOWbWUmer9C6jYQM+q65FsrcNcwnxeNrjTYMjfPZjRI8+sD3fjZzInLBS3cO47uf6d++InKN/jsYSG6lTrPkc+fBYPVZtMWzBhWeCgC1jWkIYrseXjC1VI3W4Qf4cK9mH7pLMAncnv2AGtLuwO4wjkLBh6l+GuLBV7ebBoKfJOLIpEO2wZt05JBSKB23uwzvn+FSh0QbdFCYcZDGskOMXr1vdqAT4f3UuQ50RLiiTqcCcOp0kXtY42N2ug3mIPejwH+o3emFOYEA== 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: Commit 6471384af2a6 ("mm: security: introduce init_on_alloc=1 and init_on_free=1 boot options") forces allocated page to be zeroed in post_alloc_hook() when init_on_alloc=1. For order-0 folios, if arch does not define vma_alloc_zeroed_movable_folio(), the default implementation again zeros the page return from the buddy allocator. So the page is zeroed twice. Fix it by passing __GFP_ZERO instead to avoid double page zeroing. At the moment, s390,arm64,x86,alpha,m68k are not impacted since they define their own vma_alloc_zeroed_movable_folio(). For >0 order folios (mTHP and PMD THP), folio_zero_user() is called to zero the folio again. Fix it by calling folio_zero_user() only if init_on_alloc is set. All arch are impacted. Added alloc_zeroed() helper to encapsulate the init_on_alloc check. Signed-off-by: Zi Yan Acked-by: Vlastimil Babka Acked-by: David Hildenbrand --- include/linux/highmem.h | 8 +------- mm/huge_memory.c | 3 ++- mm/internal.h | 6 ++++++ mm/memory.c | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index bec9bd715acf..6e452bd8e7e3 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -224,13 +224,7 @@ static inline struct folio *vma_alloc_zeroed_movable_folio(struct vm_area_struct *vma, unsigned long vaddr) { - struct folio *folio; - - folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr); - if (folio) - clear_user_highpage(&folio->page, vaddr); - - return folio; + return vma_alloc_folio(GFP_HIGHUSER_MOVABLE | __GFP_ZERO, 0, vma, vaddr); } #endif diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 82f464865570..5dcbea96edb7 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1176,7 +1176,8 @@ static struct folio *vma_alloc_anon_folio_pmd(struct vm_area_struct *vma, } folio_throttle_swaprate(folio, gfp); - folio_zero_user(folio, addr); + if (!alloc_zeroed()) + folio_zero_user(folio, addr); /* * The memory barrier inside __folio_mark_uptodate makes sure that * folio_zero_user writes become visible before the set_pmd_at() diff --git a/mm/internal.h b/mm/internal.h index 906da6280c2d..508f7802dd2b 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1233,6 +1233,12 @@ void touch_pud(struct vm_area_struct *vma, unsigned long addr, void touch_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd, bool write); +static inline bool alloc_zeroed(void) +{ + return static_branch_maybe(CONFIG_INIT_ON_ALLOC_DEFAULT_ON, + &init_on_alloc); +} + enum { /* mark page accessed */ FOLL_TOUCH = 1 << 16, diff --git a/mm/memory.c b/mm/memory.c index c67359ddb61a..88252f0e06d0 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4719,7 +4719,8 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) goto next; } folio_throttle_swaprate(folio, gfp); - folio_zero_user(folio, vmf->address); + if (!alloc_zeroed()) + folio_zero_user(folio, vmf->address); return folio; } next: