From patchwork Mon Mar 24 19:29:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 109120 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3ABC3858D29 for ; Mon, 24 Mar 2025 19:30:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3ABC3858D29 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=FJEGIai0; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=FJEGIai0 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20613.outbound.protection.outlook.com [IPv6:2a01:111:f403:2612::613]) by sourceware.org (Postfix) with ESMTPS id CD6C13858280 for ; Mon, 24 Mar 2025 19:29:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD6C13858280 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CD6C13858280 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2612::613 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1742844579; cv=pass; b=c/MsBs/QpljkBcTbPRIdof6XHG0zceJ68nt24Tl9DePGSuA1FuhyoAs4ROEMMRy8EvFOCG4GK0Pufz2KTXjSqrGxpC2QRkKkHGOmohA6fE8Y2lovl7knsvlQPo/LBG9MWx4DwWHRKJk9YNu6uXI2rmQapvRWiFv1J6OOn1RWmbU= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1742844579; c=relaxed/simple; bh=RVDPlQ/YdJXdqu1P/ohHJaelq1aMRZnXAnn6myzZn9M=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=MZ6yDwJsssj8HNv7WSbRDk/7h9qK+yPFlyF8bOlzd8u3JqbS/0GKN9Pa2HhUbfMvs/vxTTP6xjT5TMVd4IpRNMEBKykUzvr/gbSerRIAmYybHsUZHR0OfsOu2nSKI+KRqvFecRxSeEvKCwPXG447TW1hPWr7sCLLQjw22M6FiD8= ARC-Authentication-Results: i=3; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD6C13858280 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=badxbuR2qnfHNzNWsLWHk8T8KL9dHfDCzqbxLROJa76fxNTt/wrxORVykanQ4Y/RpMc6YG3iRbw3kKQfF7EAsh9ZTNNys+xVW2xsC53oP+/1ZYmNwDEA99J4ZudDdyU2oYXi0mc8AMKsWLyFYSj2tO7oiNYJ+pVu8LUQc673EiHCc1OcxoBxqoFtfALipBtXQGrGfMA6ncSn40yPJ+bIrlGEnrORrFWIKvguotXiJtfYS8i2CQOKenHTtjRWAuMQ5HSDyO5gHjHEur9I1krTTRM75fc8U4xMY2eCEkkdEbRWdjAdwOxB+bpQyEPQWgRZuGrkgfbly5mqbQdSlY4b7A== ARC-Message-Signature: i=2; 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=rBiMqQwuWZODm64xv5YJZWvlukqCt8+O67YXiPxJGP0=; b=AfeMpnOMUqqVmrKCp/guGS9ZFLDXwwjUQmUzpvju1dqLkjxAUZEgA0M+Rw1BiuuzOiK7/VMWG98BBplMqyILTTD2976iffjDaCf+H2Ct3WqX8FVMLB9ta8y0u1U/Q41eKb4u2fLHwIgpvTKyucUI2KjN1voMqLVeIuYOv5P9O35+dRk6UWOaBMj7XIuskHLNRUHVABej0zZEePNNR+RxygZVaazRoPpvTS04wRZboetcrJ0+GMm2CnLH5riHM6feZqt9grRcULNRK/6zp5xPkO065P1Vk64Rx7TYw7EaZtTwHpqRKbFd5UvsrnDmhgSgvVZxeTZnfFEzANP1kUqreQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rBiMqQwuWZODm64xv5YJZWvlukqCt8+O67YXiPxJGP0=; b=FJEGIai0mA2Azu7GAUDg+epNGRcr0XjDi0xEOsDyu/0kqeziZmz9wtzCKtXdVjrd3pF/NqL7O7ICPo2UTHYzo0eWXKZS6Sn4jVS4Uxe46tSQ3FPKPZVjZc9ZZla0F6V9ifqHL7/YYSH8DUj1PYH8LERA4qMA5e3ES4kPw3mZTfM= Received: from DU7P251CA0029.EURP251.PROD.OUTLOOK.COM (2603:10a6:10:551::35) by AS2PR08MB8574.eurprd08.prod.outlook.com (2603:10a6:20b:55d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.42; Mon, 24 Mar 2025 19:29:34 +0000 Received: from DU2PEPF0001E9C1.eurprd03.prod.outlook.com (2603:10a6:10:551:cafe::3b) by DU7P251CA0029.outlook.office365.com (2603:10a6:10:551::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.42 via Frontend Transport; Mon, 24 Mar 2025 19:29:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DU2PEPF0001E9C1.mail.protection.outlook.com (10.167.8.70) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.20 via Frontend Transport; Mon, 24 Mar 2025 19:29:33 +0000 Received: ("Tessian outbound 9d54e9aaa332:v601"); Mon, 24 Mar 2025 19:29:32 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 26b0f832dd1ee902 X-TessianGatewayMetadata: 7dMs+NNl9t22V9qISfQynazPXicepdYBCfebkBfdL+fNY0NfICUL5yvwjAhNzY5PMS5Els6Dua3B6qMiVKUFI4AUq0VuIDWhGdXUOYhmR4ZzhtK0XMT17BVnBWDR/AFk3i/jhKfXc/SmeHmGpX5Cl67MMCKnCWJ/0LbEUQKeS/J61by19CORK/nsIksxRteihsjNzFKIGpz8OHS4bRRXDA== X-CR-MTA-TID: 64aa7808 Received: from L4578bedbe6e3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0E85CA14-7FBA-4C0C-A430-A66CFE78CDA1.1; Mon, 24 Mar 2025 19:29:26 +0000 Received: from OSPPR02CU001.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L4578bedbe6e3.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 24 Mar 2025 19:29:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SR3KlogC/EXJkWtUrNIYX8NJqLI594fcwckKr2rnT55sq3gYirZ/+2x4H1NSW4pqduJCjlLB6OLvk+0GsiKHVQfdMopUuA5qXAoE5s44auHq3WKDvAHRI0LUaL7TTZdcWc5rUwti4rPShrnuXpL6weHFQby7otYTi2Aey4KR60A6rO6O2E/rkkw27PAX2ejTHRp0WHimfPwkpFHd00ZdQvSijho/zW2j6Uy+00B1hd/ETLnUlXvpcIMjcsllqWDCqGjOMFhZTDF+6BI/dJd76lPuzdYnjnWx2jihoCBhBlGUGR4aU7ML5Pv2xSkUylcywq0fHgp8Q0M3ePAmZLYQBQ== 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=rBiMqQwuWZODm64xv5YJZWvlukqCt8+O67YXiPxJGP0=; b=mnwZdTdotoErvYjozzRU7bziO7B4QSW+C9F/cR+b09sK8UxHsv6dd3aGYQfPOg49ibbcGsKG6Nsr0gsCIiZK48UOPBWfQeUoh6qqqhXbILNZdsQqpozRxTO22tWdbq3NdT+/b9VLtrLa3xRhWcYzt4rReuFe0j2azBBjoaXtNsuYH9f3HbT0jnvsNUOJM0UrNjja2MCpJrI9raqB+qs/Mq/iB/lmoS0oPnOnWQlSBUiizn4yBpjwlWAtArHnQj9ZPhEAzIqbEnGcyErqBg5tODcsPRjLw7g8w557An383shIMZ4NITq3rvyrWm27wyDoQjIMznTJWTNeSky9XL6OZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rBiMqQwuWZODm64xv5YJZWvlukqCt8+O67YXiPxJGP0=; b=FJEGIai0mA2Azu7GAUDg+epNGRcr0XjDi0xEOsDyu/0kqeziZmz9wtzCKtXdVjrd3pF/NqL7O7ICPo2UTHYzo0eWXKZS6Sn4jVS4Uxe46tSQ3FPKPZVjZc9ZZla0F6V9ifqHL7/YYSH8DUj1PYH8LERA4qMA5e3ES4kPw3mZTfM= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by DU2PR08MB10261.eurprd08.prod.outlook.com (2603:10a6:10:499::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.42; Mon, 24 Mar 2025 19:29:24 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::b366:6358:236e:352d]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::b366:6358:236e:352d%4]) with mapi id 15.20.8534.040; Mon, 24 Mar 2025 19:29:24 +0000 From: Wilco Dijkstra To: 'GNU C Library' Subject: [PATCH] malloc: Move mmap code out of __libc_free hotpath Thread-Topic: [PATCH] malloc: Move mmap code out of __libc_free hotpath Thread-Index: AQHbnPLSwGr3LFtZaUO1b5u8rZXHQQ== Date: Mon, 24 Mar 2025 19:29:24 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAWPR08MB8982:EE_|DU2PR08MB10261:EE_|DU2PEPF0001E9C1:EE_|AS2PR08MB8574:EE_ X-MS-Office365-Filtering-Correlation-Id: eccf21e5-9264-489d-dee9-08dd6b0a3479 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|366016|376014|1800799024|38070700018; X-Microsoft-Antispam-Message-Info-Original: =?iso-8859-1?q?5xdOBzACRnYxxtKC1?= =?iso-8859-1?q?lplLInMhSLzNOzfr+vafslhhMfOq8gO+h+kIHSBBlJfWBJHn4lZddakDiPJT?= =?iso-8859-1?q?+nBGANXdPEOIkEcRF4nDH50joQuDd+wOKm+nKAGZwKbPnsczfmWZVEbAGOzW?= =?iso-8859-1?q?amQ9xsaM5DMbZzI9WJqNhs0nK87kZGDv/YT9eSGo4NnW7atNy7/cpJ7u0zA3?= =?iso-8859-1?q?wC9Fe3BEqwaEETBMaJI0k6XzNeXYIvziD41jnCKqWhUSw35voOxXjSXFLlWH?= =?iso-8859-1?q?sSdo/WtA3U2FHVNdo3Ah1dqdy3o7JsmlJoSO9ByNlChnVvSZU7TVENvK8LAM?= =?iso-8859-1?q?i61HeH0pTV+w0zJjAuTAIRE6wbmHV0o9R9YiUw1LNNijBTpyllAeCJL/ZkE0?= =?iso-8859-1?q?LAKS9mK5XwV7izk3eL/MjvoUjFwoBsadbJvJZney468VWhSMRs55GWBmGboh?= =?iso-8859-1?q?rewMcTtH2aSgOLz+lLsI7K5C+3bN47zknMRW8/ClaoUD3p72O4Vh1VWvR9VH?= =?iso-8859-1?q?Qn8yJzh0hg0pwUmIZQ6ZtcAfX4GjyatFvROl0UtwPtXAKBJhLQa336NG3ZkO?= =?iso-8859-1?q?qmVmMP9AFj1f/adYjYooD8JDqJMXhDbo8jX+Kuq/JDsag1ZfQkN6AKBBg+bU?= =?iso-8859-1?q?4wrZiM9w76S5npBiXghQShuUynPng/t0hqKDKhR0MMCnkuKtsl0OygCpjzod?= =?iso-8859-1?q?N3Xxdp/D0BWZnEb/vuOlSEI83EsCBhgEBcsjEBljAdACnbniDoUDbMFEkiAY?= =?iso-8859-1?q?823lMFV+aKWfVJAMQ3WgK02TQdqCeHvlO9hQaQUVrPmh6FBJwv3ULdUdeTNw?= =?iso-8859-1?q?6+Q8NZZA8r5bvLK+ivXSuIGdMhk7K67Jfaf9S40TLfYbrHxHuOspIIvmw9Kb?= =?iso-8859-1?q?9Id1jZLoTs1lMop+ui6xoyXSCYqIejm/CcplZ2jdW+Yfwy6A9Pkg7dLu6Gwm?= =?iso-8859-1?q?qhdBeHwxcK3VXImCTIPFSPk5MXarnunErkrftSFNw7jIXFmGptVScNwpEVZn?= =?iso-8859-1?q?A2EVNI/Stfl4egrlqVF3TPCCp28Ji3Kx9WCQw7jgfxcAY6Sw7aN//udIFXz7?= =?iso-8859-1?q?0WzrE312zKCqGpA6fFHo9FhE+u7MSMXpWa/bH0uCROVCx56vMLtOmsMRsOOn?= =?iso-8859-1?q?DMK34ZZ6+QgeuuinvdGw0mwwN/2bSzV1h+8VTf3AJrCCS3kYmbsIpchnzspW?= =?iso-8859-1?q?EKUxwsftc3yk71pjxJ3cjQ2yJ5vYPbtee3CVZQKYYzUpP2OP6aDDjzthmUWs?= =?iso-8859-1?q?9VZddvzPUkdmR5jeHkqEj4I3crthbmu9EjDm7BORYPiW8TRNjPtNuH27iaZd?= =?iso-8859-1?q?BBWYPe3ADC5sEhAFgIPEtcnjlgdWoY63TaBGfl4cuv4tndAYWfGm5jLFYnSZ?= =?iso-8859-1?q?EvWg9O7uuciMQESNCmlLkrCkI6aGs5Ng+DB7vG5mVVgxzwA9Z93txxG4FeCF?= =?iso-8859-1?q?HfiNkvK2t+2g9c0amQk1pnmDT6XQoYG423exfI4+6jiSPNQjk35iQB912rKG?= =?iso-8859-1?q?DPBOY2+AF+D5tjTVhVtuTmbxRy3iVZcErb/sA=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8982.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024)(38070700018); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB10261 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:102:33f::20]; domain=PAWPR08MB8982.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF0001E9C1.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 52fc3cab-570a-4e97-3bc8-08dd6b0a2f5f X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026|35042699022|14060799003; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?q?yE1IM8zi8Nq/aUuOMibcUUZZ4q?= =?iso-8859-1?q?Q4std7qAzx2mlfrXkH5NvJql6l7FAA6qaIbw7lX7RnKYwZvj5USu/XweaxSP?= =?iso-8859-1?q?zhJb8XQjLYF0viDaunFPNBrLwJQwQyTY5jX5rNKnxJG7USyZMAbbU5UF66kK?= =?iso-8859-1?q?WgZ+8SGTBfo3M24gCrOokrbnNdAc8vH3qUEhDEEb/E3n2cWFx4T7NTlcy5gb?= =?iso-8859-1?q?auqQQ3Qg9AWLnDu7OpZZk3nHnARgxIWjdG/QNWsumGcCJZqXq70Z2D4mvYh5?= =?iso-8859-1?q?hArEvp2bLSATK0MklE6jaMDEkPmgMXoAMTXfqNB+XnJZD15QOHhSAuN5kpfg?= =?iso-8859-1?q?5j/sbLPW1QYvst2JXVdN9lFUg8tXZtXt5KF8HxFXHOUVAgSCGYjIyUZ3XgSm?= =?iso-8859-1?q?qCN1A6bWIy9yn7NpIOv2shLIzPpOJMD6qmfE497Uf5mDe+hOxDECaekpRPOU?= =?iso-8859-1?q?x4bbDKcYwsctnQenVCilIuBMZMAQs9dBdlrzxtRotIZjjSOui+KH1bheXKt6?= =?iso-8859-1?q?JVtXDVnD2lSlwT+3kjwo7C9YurZDl1yPCXTjejl+5zmXrwAbXaQMHOm/3NYs?= =?iso-8859-1?q?Z259hOw9UYOmlYUWQdV2XPKq1ZM6sayo5HjTiDIz5gAi5FlN40j5IFm/wfJ5?= =?iso-8859-1?q?ikM3htiox/C1l9yKLcBclvw7da7TadyiCKmEht8SI9jtzqOc52C75ggVtYNS?= =?iso-8859-1?q?cAoK40mBy4UK86QTgIv8JCzGGJ5Xbuum4m8XDQRjmyeqLgumKq2NXIhaUx6r?= =?iso-8859-1?q?qrsGvzil6Qgqs2hb8/ucxHPL6avJJDZRjtkY1yb0M7Z7riN2trtOLYkkruEr?= =?iso-8859-1?q?Bqf/R7z2SgD72fP5zgiiRg36X9aPQgJhurZM2tpatIqZkD5BtinoT95K+5by?= =?iso-8859-1?q?HhZlnGVYTCahWTDwaZlqqF0R8o2LMU2qLxbMMxNmryB0sVrwS/XlYmD+Egjw?= =?iso-8859-1?q?uFnGmXEb/RaYJeCQwHqtn38cidObW6kjHfvzgprCS1wCGGF0G6UA7sQ/LMIB?= =?iso-8859-1?q?L2mwdovpVVZtdpKn8bDm2hFbfONpz1ff/IB+7YRLRg9yRZhAmHXM3t8pEOPZ?= =?iso-8859-1?q?qJsCquqSoVnSNH17DmEx12UJHcR1W9jd0karrWaO7XgbigLGaTJeH41FqsfZ?= =?iso-8859-1?q?quSyKbeXVuRiH/UBVO2SmPPa/iOzcjUqE/YS7qGh2HZk9lNhMYMWLZmYjClK?= =?iso-8859-1?q?JdpQZzUyiCiIu4Tz7jGzJ0H3MwOXagGGXWjCKZR/6f4kKmsxuyOZiN3+x0iB?= =?iso-8859-1?q?3NRUfHI8CDqQAKn9lnDW/L80puNgH2/Wkxx1RIwy/vOaMgVbScSkyy/wfHtl?= =?iso-8859-1?q?G963Gyt8BNfxfQYzBk4TdUBXy85UXdj9aAyhKQiq8MNyUSLR1qKl+g7VH1/7?= =?iso-8859-1?q?uwAeFX1Hw3kQOUzsnW6fTUU5Co4cxEbCp+bA3Mp/UE+YJdVmVU8We/pJQH0j?= =?iso-8859-1?q?hEaIj4m5hbB5efRE/ZhU/KNQyJONITAbFOmD2syPnNl0+7QfZAZTZnxuASUY?= =?iso-8859-1?q?xW/GW4euKMznchHlEQs4qMVbhtCjusWJISSn13XOGBSUw9cEXSsLGYKMMlbp?= =?iso-8859-1?q?LruYylEdAJ?= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:64aa7808-outbound-1.mta.getcheckrecipient.com; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026)(35042699022)(14060799003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2025 19:29:33.0569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eccf21e5-9264-489d-dee9-08dd6b0a3479 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C1.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8574 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Currently __libc_free checks for a freed mmap chunk in the fast path. Also errno is always saved and restored to preserve it. Since mmap chunks are larger than the largest tcache chunk, it is safe to delay this and handle tcache, smallbin and medium bin blocks first. Move saving of errno to cases that actually need it. Performance of bench-malloc-thread improves by 6.4% for 1 thread and 4.9% for 32 threads on Neoverse V2. Passes regress, OK for commit? Reviewed-by: DJ Delorie diff --git a/malloc/malloc.c b/malloc/malloc.c index b73ddbf554461da34d99258fae87c6ece6d175ba..f362227e68b78e25583aa971cb6ee131f44a92e5 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3313,6 +3313,9 @@ tcache_init(void) if (tcache_shutting_down) return; + /* Preserve errno when called from free() - _int_malloc may corrupt it. */ + int err = errno; + arena_get (ar_ptr, bytes); victim = _int_malloc (ar_ptr, bytes); if (!victim && ar_ptr != NULL) @@ -3321,10 +3324,11 @@ tcache_init(void) victim = _int_malloc (ar_ptr, bytes); } - if (ar_ptr != NULL) __libc_lock_unlock (ar_ptr->mutex); + __set_errno (err); + /* In a low memory situation, we may not be able to allocate memory - in which case, we just keep trying later. However, we typically do this very early, so either there is sufficient @@ -3446,37 +3450,15 @@ __libc_free (void *mem) if (__glibc_unlikely (mtag_enabled)) *(volatile char *)mem; - int err = errno; - p = mem2chunk (mem); - if (chunk_is_mmapped (p)) /* release mmapped memory. */ - { - /* See if the dynamic brk/mmap threshold needs adjusting. - Dumped fake mmapped chunks do not affect the threshold. */ - if (!mp_.no_dyn_threshold - && chunksize_nomask (p) > mp_.mmap_threshold - && chunksize_nomask (p) <= DEFAULT_MMAP_THRESHOLD_MAX) - { - mp_.mmap_threshold = chunksize (p); - mp_.trim_threshold = 2 * mp_.mmap_threshold; - LIBC_PROBE (memory_mallopt_free_dyn_thresholds, 2, - mp_.mmap_threshold, mp_.trim_threshold); - } - munmap_chunk (p); - } - else - { - MAYBE_INIT_TCACHE (); - - /* Mark the chunk as belonging to the library again. */ - (void)tag_region (chunk2mem (p), memsize (p)); + MAYBE_INIT_TCACHE (); - ar_ptr = arena_for_chunk (p); - _int_free (ar_ptr, p, 0); - } + /* Mark the chunk as belonging to the library again. */ + (void)tag_region (chunk2mem (p), memsize (p)); - __set_errno (err); + ar_ptr = arena_for_chunk (p); + _int_free (ar_ptr, p, 0); } libc_hidden_def (__libc_free) @@ -4665,6 +4647,9 @@ _int_free_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size, int have_lock) else if (!chunk_is_mmapped(p)) { + /* Preserve errno in case block merging results in munmap. */ + int err = errno; + /* If we're single-threaded, don't lock the arena. */ if (SINGLE_THREAD_P) have_lock = true; @@ -4676,13 +4661,33 @@ _int_free_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size, int have_lock) if (!have_lock) __libc_lock_unlock (av->mutex); + + __set_errno (err); } /* If the chunk was allocated via mmap, release via munmap(). */ else { + + /* Preserve errno in case munmap sets it. */ + int err = errno; + + /* See if the dynamic brk/mmap threshold needs adjusting. + Dumped fake mmapped chunks do not affect the threshold. */ + if (!mp_.no_dyn_threshold + && chunksize_nomask (p) > mp_.mmap_threshold + && chunksize_nomask (p) <= DEFAULT_MMAP_THRESHOLD_MAX) + { + mp_.mmap_threshold = chunksize (p); + mp_.trim_threshold = 2 * mp_.mmap_threshold; + LIBC_PROBE (memory_mallopt_free_dyn_thresholds, 2, + mp_.mmap_threshold, mp_.trim_threshold); + } + munmap_chunk (p); + + __set_errno (err); } }