From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011066.outbound.protection.outlook.com [40.93.194.66]) (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 570EB379EF2 for ; Thu, 23 Apr 2026 05:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.66 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776920956; cv=fail; b=C1CK0s3tBMQTUEd6UZgv1e8WIL2OBkIEhuncU6CiQYCEQiNLMpaQWBp+GY4wX5C1mx6J/tMb5q1HBzysGBvQVEoSbx57o7GiOCR8WdXZU6R1qm+rZIuAkgT0VKc2wA5ckDB7x7N8d9/knJLNcWmJd5L4A6p6aCj3rCqzc2VEeKs= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776920956; c=relaxed/simple; bh=U3LJ5kyiEBojF80VD8pn67JC7+ooJtywyumlmLC7mao=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=MqUdA2nMHas93xgROBk6OmpDET/9QG77eDqnJBPTyYKh6MQrc59Ogb/W0kT9iLhEQB8Fiiv9fg9ZVRcQd3KNYYHZWxtgbMAHsxQJUna22bhq+5ZkojTeS+vpKPn+mz46C0bMO5C9i0CRvuJTb999vMa9XB6CrQ+ySPm3UUHDcyo= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=F+75qAft; arc=fail smtp.client-ip=40.93.194.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="F+75qAft" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C2LcJlWTKXDUj46CyiNxuJ/05HVCAw5jnpV95g67Sxmmi3d9U03yXDJ40TtKu3VoGq2fLdCsXFsuY0WnhEIQXt3G9StMtv0eDh2EBsx6hHUCbu+vOQakkQJ/JIzadTlAR57yNWdHWweDJdPRMx608Zp79og/vbpU9UfqalfEAYat1rtH+pi2mzosz4VwgWoXeN7QeXm8jlb2pbQjh9uKJptG/9xpyYKcRuKmtfaNVUzdPGxwTIaom1Ue4x5Jjdp//dt/PQa5QEx6fZ6ZeXkPvN3rBOkRq5+3AVpTe0NabD9xzeCTJYqYVtgwuWhRnpUVF36Tt0Mm81UNyHcyjhpVYA== 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=ZW71aZUB75cXXss4TYHkq/jv9kF0X1M2pMtVLer0VLg=; b=ys2juKmWBm0T9h0mRy6isZ0OlXefER7W/sv1XKCZ0JLmeUCIqPl4YV2XVQsR0WPOC7d0dHXD6I7hiaNkSYXCZ0MHk9KJLLGZ4L4k4ldEInwRivTYdCZLY6VF8ZPhHlg89Zq6qcMIP6eVCHi2FP6g0HE6aRX7md1PTmQRoBXtNekhM93jK/oTbfRTaXrfRE062rUUCy7vRixJYjamzZ49lVk5ifEyCORKCoE94wRkpkre+fqD5rujpuYJKL00Cuto7y70oNJFncEqnQYFBEjeTLZoA6iP4afoREPqcqMLtluPoG1TsVQB+tcBELao6c62lV9UJRyIqMgLjhncTH6dGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.55.251) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZW71aZUB75cXXss4TYHkq/jv9kF0X1M2pMtVLer0VLg=; b=F+75qAftDe9AqpAtI4/niAuYB/lDFAKXqyfxTo6WoF/6OiCdOYWvXCwRzUXFE2kf9Aq65NJRN8EjeDnOkFNgWBpZ/7U0z3TazRfNYUSpY2oTHLnMsaJaNEM642khZRnmair1gzx5PKOrPBRce0qhSYtKLREyrLeRnMyLF85Soo4= Received: from BY5PR03CA0014.namprd03.prod.outlook.com (2603:10b6:a03:1e0::24) by BY5PR12MB4145.namprd12.prod.outlook.com (2603:10b6:a03:212::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.21; Thu, 23 Apr 2026 05:09:11 +0000 Received: from SJ5PEPF000001EA.namprd05.prod.outlook.com (2603:10b6:a03:1e0:cafe::9c) by BY5PR03CA0014.outlook.office365.com (2603:10b6:a03:1e0::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Thu, 23 Apr 2026 05:09:11 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.55.251) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.55.251 as permitted sender) Received: from satlexmb08.amd.com (165.204.55.251) by SJ5PEPF000001EA.mail.protection.outlook.com (10.167.242.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.18 via Frontend Transport; Thu, 23 Apr 2026 05:09:11 +0000 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 23 Apr 2026 00:09:11 -0500 Received: from [10.136.43.140] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Thu, 23 Apr 2026 00:09:07 -0500 Message-ID: <5eb58895-b9c2-4124-aec7-e55074c372d5@amd.com> Date: Thu, 23 Apr 2026 10:39:06 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mm/page_alloc: replace kernel_init_pages() with batch page clearing To: "David Hildenbrand (Arm)" , , , , , , , , , , CC: , , , , , References: <20260422102729.166599-1-hsalunke@amd.com> Content-Language: en-US From: "Salunke, Hrushikesh" In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EA:EE_|BY5PR12MB4145:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d36551c-6eff-4346-0a1c-08dea0f674e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|376014|7416014|82310400026|18002099003|22082099003|56012099003|921020; X-Microsoft-Antispam-Message-Info: zPYxSSup616s9dwwHr5N00EaY/NaLmJFpROgXM0PpN32mUhFH7C7PgDgLMuR9ztW4j/iB5Tiy8yX/ycLDANVgaHi7OFVfB0j9gHoJ8d5KC7tT8ZpBd4OKwy82+eVDayH+nLxl4sZjl/CYKgEWzxyV9p49DShdzvjFynqP/OKT4BTW0GN5cothMhjgX4E0fa7HugVAV6Vdrc8FdMcSjhuFIOqoeU0DAvhMiAfyhi8rpCwdpykGqw7itleX2PAQJEEOHk2Vbb//XsPQIhqlCDfsgwOU8xPGZvqArcefJjy5huePhmTOm7D6W20TXOqoXcMxIa8WQ+TWhDWtGf8jvv2yAJoyC/Lw5kEB6bBBgoD12U46dU/f1xarJFqLUHwDQpvVbv4kTkKNjK8Ed8Tdek2itPR6R+OLaWBbIau3AJ4cXmu9fDKFPfZ3+faY9YILhSymRz2v3dc3cJGGccDUqBzIibuLGp53FGUaWd5TuvJlVOJ+HmAbty5agP5ut5AfrFcoNcteuJi3l5/7kHs+3OOTulbkJcQgiT2nu8wEer6n5jL33+boUGfouF3btowS2eaTGBQJ0xVQn8SdiS933ziZDjo1sx5ovQDQFaIoqjsA4HaEQ5B5AjI1+cfG7gFXLjSbAXM/h/MU3/iEjdV1hBlrytM+z61WaQRAhvQBZQ2xbBNR7j6t4q5CqGLgJOgyReKhM2uxBWfRw1tfM8P0v+iS/qjnKEZGTFIVECOEHq2t5nzGkLhcUPKF689h8Hjg8TbYKR6RtZkmLdE2Di+gqZbT7b+7hecNCotTh/Mp1qilsHK2SWqbrgA9EoNO1IZ0TrH X-Forefront-Antispam-Report: CIP:165.204.55.251;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(376014)(7416014)(82310400026)(18002099003)(22082099003)(56012099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bw/35Xfhi32T9QBBll/XIzN/otwMQ4hhq0QdTW5GhRvOoroomTgROI6dKzYYuNHkcF4cxaTiVhr6gSpnJvuwWWDZiVu/Ma/QSdgRLvQnFvluMLnM2phx+BvokClrdC43ZD6ejEK8qkieZVVqa4n4raepvTcDgfJln7o3ErDiyPfz5XS8bruF17YO5kJ/+8EUpX9alq4LosbBpxP+TMURKsSJHbLDzmhRfznyt5g0SexaxqEPMAHVoXS/YNLbpQBQLaAb5THno4XWhVNgm6Be5zUkKcWXxMBi6MZQdyXQX+wVxDLFbtRVOc7kKMRdS6et+1uSyBNr8qjtyTvqvffv7Q7R+qCrHeIffrjVfytEdxU4aiMAZylnk8Wyh5ZhpkmPl4vIHW1jddF5FtQgUqGJt8M/ZWugRT9A7GhgMkfm90/YBPLwkOcccQ8Ox5EBLi3M X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2026 05:09:11.3723 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d36551c-6eff-4346-0a1c-08dea0f674e2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.55.251];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4145 On 22-04-2026 23:55, David Hildenbrand (Arm) wrote: > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. > > > On 4/22/26 12:26, Hrushikesh Salunke wrote: >> When init_on_alloc is enabled, kernel_init_pages() clears every page >> one at a time via clear_highpage_kasan_tagged(), which incurs per-page >> kmap_local_page()/kunmap_local() overhead and prevents the architecture >> clearing primitive from operating on contiguous ranges. >> >> Introduce clear_highpages_kasan_tagged() in highmem.h, a batch >> clearing helper that calls clear_pages() for the full contiguous range >> on !HIGHMEM systems, bypassing the per-page kmap overhead and allowing >> a single invocation of the arch clearing primitive across the entire >> allocation. The HIGHMEM path falls back to per-page clearing since >> those pages require kmap. >> >> Replace kernel_init_pages() with direct calls to the new helper, as it >> becomes a trivial wrapper. >> >> Allocating 8192 x 2MB HugeTLB pages (16GB) with init_on_alloc=1: >> >> Before: 0.445s >> After: 0.166s (-62.7%, 2.68x faster) >> >> Kernel time (sys) reduction per workload with init_on_alloc=1: >> >> Workload Before After Change >> Graph500 64C128T 30m 41.8s 15m 14.8s -50.3% >> Graph500 16C32T 15m 56.7s 9m 43.7s -39.0% >> Pagerank 32T 1m 58.5s 1m 12.8s -38.5% >> Pagerank 128T 2m 36.3s 1m 40.4s -35.7% > We do have some elaborate handling in clear_contig_highpages() to chunk it up > (and to call cond_resched()). But that function can get called with much bigger > ranges. > > I'm not concerned about the cond_resched() -- we wouldn't do one here before -- > but I'm wondering whether we could end up triggering a HW instruction that is > uninterruptible and takes a rather long time. > > But clear_contig_highpages() breaks it into 32MiB chunks, and only x86 supports > it so far. So we won't exceed that with the maximum buddy order of 4MiB on x86. > > Acked-by: David Hildenbrand (Arm) > > -- > Cheers, > > David Right, on x86 the max buddy order keeps it well within safe limits. Also, rep stosb/stosq on x86, currently used for clearing, is interruptible, the CPU can take interrupts between iterations and resume where it left off. So even for larger ranges it wouldn't be a single uninterruptible operation. Other architectures use a per-page loop for clearing, so the same applies there. Thanks for the Ack! Regards, Hrushikesh