From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2040.outbound.protection.outlook.com [40.107.21.40]) by sourceware.org (Postfix) with ESMTPS id BADD7384EF7B; Tue, 6 Dec 2022 12:45:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BADD7384EF7B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DT83tH5BT31cL5WmJj5CfBWa1wZ27gQnoG7iVP1M5e8=; b=VppXEvx4fRpjcyhELq5ZiRmzydHUK7csPFsBtBPTxyy1m7QgIEoXfacd3ZTe6SPkJbB7DHVLaqw30hSJyAgdufQte9C8tHlMKoBnKKnJrPD1GfXi3KPOWT3WEJEAl+wOlsjs0RgMEm0GSI6CWzkpA54vl910wKKK2JaUIvdz6Zg= Received: from AS9PR06CA0310.eurprd06.prod.outlook.com (2603:10a6:20b:45b::20) by DB9PR08MB7795.eurprd08.prod.outlook.com (2603:10a6:10:39a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 12:45:44 +0000 Received: from VI1EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45b:cafe::ad) by AS9PR06CA0310.outlook.office365.com (2603:10a6:20b:45b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Tue, 6 Dec 2022 12:45:44 +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=armh.onmicrosoft.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 VI1EUR03FT026.mail.protection.outlook.com (100.127.144.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.14 via Frontend Transport; Tue, 6 Dec 2022 12:45:43 +0000 Received: ("Tessian outbound 58faf9791229:v130"); Tue, 06 Dec 2022 12:45:43 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 707f5d8217101667 X-CR-MTA-TID: 64aa7808 Received: from 896af1fb5dcc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4148A7A9-E2FD-4743-8503-E87B2281D37B.1; Tue, 06 Dec 2022 12:45:35 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 896af1fb5dcc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 06 Dec 2022 12:45:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eMbIRTolLQBVuiaRqwnif3Gb/m+QbojcNAY1wbkpdKiJpUiOiN22jsXxfmw3yo3c3ItggRn/nDmSHHS3XuwPqEn7kULuSl6SlbBk3TE8bl1Wj83diLnzPN5U3D1jesADc/z8Me3yoBA5lzomxPDHpox03U0YSBk8Whc5tnbwBbjvLMBzTjhcty11dZdUbfhUKF742EIeUqCy4s/CcGLmtBRV7hvLA3PR36PAmH+aasQlQpuo3X9KxUEHX6bP+Xzl1e8EAjT0dFFKJ6W3ZubgMwj9+4GvuUlBKTe0jgGn7VXtp3epueCf8bHKFc9M2U4m261aBzlMHngTqIVy1JhUwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=DT83tH5BT31cL5WmJj5CfBWa1wZ27gQnoG7iVP1M5e8=; b=Toz+SZ1mETITJhD0wAP3aWIhJsGpDEz/TnNkeQZG5quU4eSgljNCG/Cn/lyFCrLqcADfi39eN7xZrQ+0i3pzGXuddLLKO2mR0Sxl/sV31M/8irfLs7DcZfNobiInYxhRz0y/bUmcVTuCxWhB5OPj9Pe85otSytGnn1w9iHylEoI0hzjut5Fa48f8xi8fYCtJ17auwcgXjvx0pg7hXOn3eKJU18T220gvam80qEe6esojYCiZRybknoA53VHHi3XaRooh7rAjszLlOZB8BIswTPB/a0xkaMvBRmeLcxvLpJN2pRlv65DZUNaxNaZACdatSVQoLuEhRwk6sWTC1rFVZQ== 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=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DT83tH5BT31cL5WmJj5CfBWa1wZ27gQnoG7iVP1M5e8=; b=VppXEvx4fRpjcyhELq5ZiRmzydHUK7csPFsBtBPTxyy1m7QgIEoXfacd3ZTe6SPkJbB7DHVLaqw30hSJyAgdufQte9C8tHlMKoBnKKnJrPD1GfXi3KPOWT3WEJEAl+wOlsjs0RgMEm0GSI6CWzkpA54vl910wKKK2JaUIvdz6Zg= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by DU0PR08MB8113.eurprd08.prod.outlook.com (2603:10a6:10:3e9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 12:45:34 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::66e4:4940:d096:4f7]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::66e4:4940:d096:4f7%8]) with mapi id 15.20.5880.008; Tue, 6 Dec 2022 12:45:34 +0000 From: Wilco Dijkstra To: Siddhesh Poyarekar , 'GNU C Library' Subject: Re: [PATCH] realloc: Return unchanged if request is within usable size Thread-Topic: [PATCH] realloc: Return unchanged if request is within usable size Thread-Index: AQHZAwVIxOOptCgjXkWJDnX1Zslj+q5UYQGAgAx2P+U= Date: Tue, 6 Dec 2022 12:45:34 +0000 Message-ID: References: <3cc4e7f1-fa60-edf7-c31b-a3ba34ae4eab@sourceware.org> In-Reply-To: <3cc4e7f1-fa60-edf7-c31b-a3ba34ae4eab@sourceware.org> 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_|DU0PR08MB8113:EE_|VI1EUR03FT026:EE_|DB9PR08MB7795:EE_ X-MS-Office365-Filtering-Correlation-Id: de7a2654-1399-4f33-6fbf-08dad787ca26 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 1EKkAUT1fNFl8WAhHVERUqHda/JFpptGjMNCwWBFsf7ri3BD3rpiD1Vt+5+2lMh/9iMeEEWJJa7+xDjvyr2oS461UZo2k2xqPpbVErm+2WLuAdlHjkOe0l+F5atbZqYlMwx3PVMf/ZxuUQ6ErCod3uGOJqF+9Tm7oYkBTZw9rgVFfhg1FWfiazGOwuBMIutHW/Na4SXfwcta0VyqxVa1NQ41LU78TU8naY6s7N6kXpiwROwOUXpXZ6VJ9CE+OFfwG5myHJlD/tziDUUFEL5j8mhRO/7A6BL4OJf1v9V168duinJBmiqaBg5NZw61CKqrLPhJQA5d2f8+Rnn2+MxRMlk1BAjyQfnLv0022rwy01vyJ6WX1XyTf+UY69x4T8/RJ0Pu7O6mgtesBs/mfJKpSf4INwnpeFihjV+M4anEaAixRC1VSadp/MtH3N0nYF8l85WPvH0Ys2342Tjx+GZQDjfgTBIsf6pMjIliqVsmiFGOoq9Tf2+UmKWd9ecEhkyhAaBaik8OMF2V43UeNjCmxCRe4BEmxJ8+Bwmx0RHb88p2qY7+JMTiyt/Iio//+5CtayWnOY5p1QB0cEj5/VueYgngXRMHd8GR59tHQ64W3cLS/ATa6gDxj+KueNwPqtVAuDZT1bhfPwBEl2ZNklVwM+0J8zPCaHmlmKptOtDFExNU77OvkpMW0n4rbPRJhSt30w11l4Z/g73tre/TJKc98Q== 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:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(366004)(451199015)(33656002)(2906002)(38100700002)(122000001)(8936002)(52536014)(5660300002)(41300700001)(186003)(86362001)(83380400001)(38070700005)(66556008)(64756008)(316002)(110136005)(66446008)(55016003)(71200400001)(66946007)(66476007)(91956017)(450100002)(76116006)(8676002)(7696005)(478600001)(9686003)(26005)(6506007);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8113 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-Transport-CrossTenantHeadersStripped: VI1EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 85b236c9-d57e-42cd-c2cc-08dad787c44f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E5SRSx3LcvxdNl6JqUJDFxV8saPdZfzRBYQSgENhnndu9FRUOL8nA83zFlw7y8HDudb+H5xGUvBacil6a1hLnlIaCGqrtN2fe+sJhnSdQ/z3k1Z9ny24aFvrtC7bLpN2HeQYG7i47Z4Opq+H9tPhjFBHmz90pzAYmA0mK5zow+az9EBp7ZNI1v6miR2vMsbuY9TSoBbhL01rZVzlETeb3voRYZ1ndiL9kCTHnsEcvWOdAoRt9aBDsNXfbfH+cPqiaCXSpUS3nLyP/fYTxelYX7Hlg/tOUfODI5nkKJc9sKKJfaWt+Nj7amXKrYuDKG01Eghp/iN2JGCAIbqjNJ+ms4rAfEMkUDjzizs68Il44QNt5BnF9qR/TftpPtmIfhCRzj8uKurkhZLOyo6WUUn7e637GwQor4vlmyhLmcDsgym1qe9wwJA/uGto86cCwn+BHu4i2yPM5fNvtMo4u389UmM9T6iWhUzdEka9PHLqYCrkwPKUPbK96DxKPvlWiGL6yRa5OvDXwoopX51wp18n0vmNnugslewi6vXUFjlBx7c5hOQjf7vucGSxQSqRtbY2KlmmNYHBIKoYnrV7R2AiDwZHMWvns2Lo+Q72eK62BpwnZQWO+sef3IIdDa17ZIz6oLkAwWK5Q7vk1prOAVIZiZ2whhJfIUWNmHa72rEzNg3a9uRd6r9e/ZCyP07fuVgMdzhYfRejWttgmHA6IGsZcA== 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(39860400002)(376002)(396003)(136003)(451199015)(46966006)(40470700004)(36840700001)(5660300002)(52536014)(8936002)(83380400001)(41300700001)(36860700001)(2906002)(6506007)(33656002)(478600001)(40460700003)(26005)(7696005)(86362001)(9686003)(47076005)(55016003)(336012)(186003)(40480700001)(82740400003)(82310400005)(316002)(356005)(81166007)(450100002)(70586007)(110136005)(70206006)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 12:45:43.7013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de7a2654-1399-4f33-6fbf-08dad787ca26 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: VI1EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7795 X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Siddhesh,=0A= =0A= >> We do need to handle the case where the size is smaller than the usable = size since=0A= >> we'd still want to free the unused portion if it is a significant fracti= on of the total size.=0A= >=0A= > I'll make this a function of trim_threshold so that the reuse happens =0A= > only if the difference between the request and usable size is less than = =0A= > the trim_threshold.=0A= =0A= That's better, but that really only helps the mmap case, and all other real= locs will=0A= never release memory due to the 128KB default value of trim_threshold.=0A= That's something we should explicitly decide/document and remove any redund= ant=0A= code from realloc as a result.=0A= =0A= >> Note the mmap code always tries to remap before checking the new size is= smaller=0A= >> than usable size - so will end up remapping even if you downsize by one = page.=0A= >=0A= > I don't see that; I've put the musable check before the =0A= > chunk_is_mmapped() check.=A0 What am I missing?=0A= =0A= I'm talking about the committed version, basically if there is any change i= n number of=0A= pages it will do a system call. With your change there must be at least 128= KB worth of=0A= pages to be freed. We should do something similar for growing mmaps - large= blocks=0A= should never grow/shrink a single page at a time.=0A= =0A= Cheers,=0A= Wilco=