From patchwork Fri Dec 6 14:09:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 102564 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 8C29D3858D3C for ; Fri, 6 Dec 2024 14:12:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C29D3858D3C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2023-11-20 header.b=DFSELN22; dkim=pass (1024-bit key, unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=MdWqocLP X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id C10A13858C42 for ; Fri, 6 Dec 2024 14:10:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C10A13858C42 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C10A13858C42 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1733494240; cv=pass; b=sKrCsOHqy3PmhOmmdVfqQgY5UM6K3MCPEet2XQRBMlfAs1httOuzE7n2zZxVQvEAcC4Xyc5IfIjsB1dko8leSsFsPZ+IeTDqM8GOMjG4T1eEVKiwCp5ECR8LPgEBWHSv3WH5ynirkSEQLkDjOefMLnccdd/UNfzw4h2KrcSyjLI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1733494240; c=relaxed/simple; bh=dgQI5nkFHr6GDcrU6BPLWSZ7muPek1mnn1OU5xzLH0s=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=rwCfslGsHlGcN49G5ovh+i3NXQiuSCLJmpb3T9Yo4G0qAEzAgaM7amXx5NKDOo86KnugyH2yjHGvA3FY2r7ec8noyoQgBCy2sN55OwE3485FfrL/0LR/i9LsvE6SsPnRJFZ+ME+4w0ArurjNx1IDUJVQNADL3tj2fpw3J9y7gqU= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C10A13858C42 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B66s6g1023424; Fri, 6 Dec 2024 14:10:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=AmSOvLjz+ps73VDi25LvfFu0OvwAJvUYOSJPLKJCInk=; b= DFSELN22Fl1pJkPlRJyjJGvzzA5UdJinvYMeoyfuQ2bWby2V5HURH0iE/7FrRUQj kr/ePvUPaY4jsHGZTHzLrb0UvzOGzslf4xGucd+JiCZN5tHXTv42Uuw6fD79vuOn 8NZ57lVcJptQoHQaVvfSHK+GDwQoxFWTxnn48V6RtT2CUN5DwTqhVOICB0cSpik4 TKU7gwjabfbeOvKs2GIcM3cSnHbcjIsDMDynglZ6VBzmISsCezavPqWZVgs82tCk unQU2pniYopyhU5LTZ0q2zzn62RfRylZ7E5VHyLmErSYjJ43adS4AAXUbiOuoMrC 5YpbuV02OLO4htAwQBsBng== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 437sg2dfhg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Dec 2024 14:10:39 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4B6DPdO3020349; Fri, 6 Dec 2024 14:10:38 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 437s5cb4aq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Dec 2024 14:10:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OeRgygyw+6Ufuisbja3mTALLI9HeePc7vthFxatj2FJxZiR1xCq5vud4hQK64aOqmTieQqiBogVV3ZjDfD/XLaJkDL4bAPAPlhOCU5BsJhpkE9g00SDZ0BpDLxNVL+DZxYA5pdRrRZ7aoV79xbesAxmNLTwzvP2zw4OOwmHpi6qo6MGPi0p3rT+BlaEGyJT4VjWDZaRAbeME0EAK//E6+jN+QvFwKNapCwAhwXR7Kgdbx4joMp59JNzMZCV7PExG5mWiX4nxr9S7JLjra2F8+nF8ZxXOyu0uw9X4gZuH2UyDiSrhM/ZYcVq22f9W45RIq3BKW6LnmyZWHoW8VlYeig== 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=AmSOvLjz+ps73VDi25LvfFu0OvwAJvUYOSJPLKJCInk=; b=EXFL+azXYkGkDeMH4JwBA1EFmsb21WaAa54B1yaOM8A72AkIltAXJLAWY17v45YQBuzU4wEKOEr03i7m3RGMCCnUwuTNNLbMOZ/AwKIv7pmhL9neq3s7LRzTrLfrfYQYRjGzbCz7eHy8oU1H5+rdEFhP3Md3Z8bvw3aYSyRUvdZeLHQ+am/Z7i9PAXXfoIpYfiVJeYGOUbiqNiD0Sj+GTc5sXirhmr3lshSyaTAidDwEs7mlPlX1tiiiny3hRk95A6BNLqG4EwLzsvkxOE+1rixrzE2K55pI6x9bMYj/agldaLE7rg9I/ryhNWBb92hnqqAaszpaFJd0R9jqXI7qpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AmSOvLjz+ps73VDi25LvfFu0OvwAJvUYOSJPLKJCInk=; b=MdWqocLP0DOyDzj3qr+psaJDb9JNKeDsAei9n10O/pyV7eT5sQRTYMd9S9vgsSOz9aCy1XF3y4Z+sB0D6kFjP5c2ju/V7qdgPr6zcLN7aZmdZsqSHQXE2xtH0kWGNpJnHtn7YeXn6ZvZZXjDIheguuh3aImNyiIXHvYza9r/8M0= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by SJ0PR10MB4768.namprd10.prod.outlook.com (2603:10b6:a03:2d3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 14:10:35 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::5033:84a3:f348:fefb]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::5033:84a3:f348:fefb%7]) with mapi id 15.20.8230.010; Fri, 6 Dec 2024 14:10:35 +0000 From: Cupertino Miranda To: libc-alpha@sourceware.org Cc: jose.marchesi@oracle.com, elena.zannoni@oracle.com, adhemerval.zanella@linaro.org, Cupertino Miranda Subject: [PATCH v2 1/3] malloc: add tcache support for large chunk caching Date: Fri, 6 Dec 2024 14:09:19 +0000 Message-Id: <20241206140921.139205-2-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241206140921.139205-1-cupertino.miranda@oracle.com> References: <20241206140921.139205-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LO6P123CA0051.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:310::7) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|SJ0PR10MB4768:EE_ X-MS-Office365-Filtering-Correlation-Id: daae3275-6cbc-4fac-4caa-08dd15ffc095 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|1800799024|10070799003; X-Microsoft-Antispam-Message-Info: 5xR8qRCosGa/OcBFr/htgylg4s49VjPQPK0zbnoNJlqFA990ABR4Yy2tuIa+5ak8vGF6NM9wKyOOjiE8Fd2j7smUHEM1qbR2bPXISjuXUneZyQnBSH0q3um6FAMS8T+d3RkX1O7OtQ4ba5S1wKyDqSXcZt6De0NIzY+F6A3P+Li6uH/gEgJYl4YD0T+mqqrza8WZZaWiBPbk7bSwfBT5jA0q97/Mwno2UGvWpdzx+/Jy8YOcm6Ivgr6BJC6oGMqNp+oqMuu6WxwquN6QPOnih7lDQ9tILTchI3RPVazdb9A+mCjIdmNhHkQ1gjmP2KgOtoFI6QZAcfWxglJZ/gxUovKEkczMX6jw9RBjXPlkuavQih/35Ahwl+zQbWVjMREoc9dfuivNr26Rfzzs9UGe58Mas/MAGyPiPJiUBD9vwLBPFQYjXbC+NNKmIq29xWNopmf0WU1oJSy0ZygGVCe/LZ8Jqf+nyJvSYO2iDiuoMD4hPcCawuGEeyQYEU30jY+KgHZtmCFTU8Q0LOiOjcoAkYpSm5tNrCC75x7xvuEpkQ/GgzG3DPsbaesdZiua011l5ajMJgvStpTrMXhfglUWoyuHulMDonxxxIZI2wb/enzw1UnbDyJH8jR0sK4S92T4vT/d/BGDYgp2sx+9CldKLZfWs0k1LISBgqtdWxSI56XdLDAfn+HyNs4SIlFduT1ol64at4gKG9HvlkpBYiudxAaOaCl2JbQZ9GQovZrtkfKOYSVB7HlIuzddsYayJRVvgnxK6pTxtHV9gSnN9oYtV67+06MDlV8dUNkwCtEgWY0jt2RBJuhnrAkKFxGchWlhIDKVUiqr5i8y4EQBlNOihKoLaCYWXIOrnHU7Epsa2AmJXJjJu3o27t9hgjthAK3kkLcjUuPylX01hErbcRxgQPGNcXvmXHyw+aglmPns2OPovFwumBLNQrcJayATYWWKPglbF8RRDfWaCSHDXDbrlEc895cTMLlOCld9FYYUt3o1BwhmOmV9+ybSKexV2Dc219/gtoRoBGYGwUAjR2GhNfs8fRrHHk5SCqUNm0cyGY3iAKHBmiXWG0noRxmWSB06E2K6IiFVHCOldWnjDYsKfGfdU6JQKidkqagEFzP99DSX1iKCvmJ9d6T14ZlxkE4EvWI3swSs9ilyoa17vb3Cb6XMWiatOOH0zSaWrRuPUcRhZ2X9056XZSuXjkd/G165k421esOwUM+YNeGAKuPXIIhpmDpvoKVVqlswf3Zukh0AfRJi4LffLM7Sw3Q3x+giUvA53jK94QZxfnitGDDoB9yNgNPIS8ahRUC2YY0yBpUW4PA9mh6SumUL/v/JCqmqwGrj6h/KWWDP9vI/rgTyEw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR10MB4382.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024)(10070799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: keAI89Abx5kCHsxHnqfI4MNItWNqY4DIDuIVYfNrAs5pNpcvnHqV91lTxbzpds9QdRJ2nmnR7PvYHHpp/jX+72AitSlVPtZZaQaWVYoXCsvFMq5A0Ta9mhP3hJxqTPPrxu59RrbyLSAM5Dih6E6DvdvpuNtkolHPjEWTOPUfReyy0xCYYFZmKibSg7HL/zG5VXc09Gv/590Qmczin2oEGRPT+a4+Dhh3LcXxp44+muuGkijlI+lAt++o86XsXqdEE0C//cDA9MtR7FdCedXuRt+t/CpRRxiUBcHEFlNoZ3BKBOgSAB0/RkMga8tt1WysCVbths21YvW5nmXfJ1CR/HeoEIfdv038TZV2xHR2Ezw3paetP5X/57qGTTuQTGZ89AtHs0yavtrPCAffgcEjlcxG3NvRXLa2wc5oGoiqaRMeSwrRkENc3T93jIl6ATRe03/BGNNv8a9lR1pdJOxgoyMkbxWaEwFYNJfpShWE/jKFvRSMhAHrcru40rQL2LXSH9F1fXj018HMuGwWBEzKNXlyCs0U0ZrdH7FEfMofzX67ew7waRum71rvCiH1kiITCYXzJNxaNOBsDbAAz+SQNoEWpv99CUw3xVwohbdyvaPDEErZT8EpQ281fyFhNVOvSuPE4LGCZYzSTl37ah8xryt5HjT7RHqc8uLhe5+oFRFgQuozuD+j40ttjUc+Q0UNCQpIz7I/bsGat/awvyRGBt62odUTtFlYLU1SLi1tCED1mw3qaHVPHol2JgFZPt6SSQjyP8/O5EoWlwD6VEX1khBD1mXQpr6LCnMKjOSi0h5/lbTjF8wf4pN9ZVGprAN2DCN0EmVRVNedQefwaaarz6jKshT/SBL3QTAr0A0dvrPAhfnXfbhi+M7hLztt/XkPy4CbV2+zamiVSA4esxTypg+PteDPZ79jLXF6Yng/OK8G1MFXENEu9RtUsHD31d06w5LnL+vb3gYlnwW9bz4yrVfeOYPd9kfQb9xdX1YVu1xbSx8Ol3dr5JRo4L+IcJHA/ObnLj8O+4SiKbtBO3lrFDj8sPyPBE6syiNDKnLRSaGXjvDTuBVw6OuUx9ZnlOV/q8TzsbFRNtrgJpCNaxENQ3cToBpEiNSTB97f3kOxX+kXtHuDnvX7FSbpRDLdAAvFyi1VEwAsT093QJXIFs9hmOXUY4i0+VFM+zQvOm8V5B+Kz3XHKhtok8TPtGfoI5xtgheHQUqtukweOz+akqpAFoAjWUJOUZ3RmeKFmS1Uu2baKCNfb8xBMu3So0JNMXkz9hVyRE5jTAb1pCMcYCAZtak31fZQvySVQ6EJM388yqv9tlITNm/lz7h9FrZ9Sh1fu/bfx+KIGOH5okgba30HLlW6tVMKShRaSQcgMzzNv3VqrI60VPDyPcnFkY2lODPoEuRH0P92z8vcSJxcT3V6SMrd4UVDtuKV6lXGRsyijA2Gl+uQbt+uwfMDJbRnRepwrpVgAC5mNhEf2ZFarVRiw0Z2+9j11JHnTFZij1+BdILI4obvvYN6n09IuJaK2F4Z3bOAlXan0vVStDFCfciIn2kZkN71YSJopt9xke41LgALCNWMPMx89rNvpRMmH4wDjRokNeNQf57Q/vvWoDZPy8/Sgx4sLIxvYCsOAEZZ+gM= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: MIiiCus/wV1ALHKVLIn33EwtVT9gmxPGQVnTlZtivK/6jDDrU2yYM5uioRJJk5x56pK+eqci4eLTDs6TF5htllhsrs4gEVHn+rDEhfl2zOC8412kE2139ljGk3XGMY83n/UHeyg4m+vCrKtZzhK8mlffgk8R25WBzLZT//fnemT7CXdpCmm9iT+b7QpRp1hqpo6uWy1yAIJSXivXmtJYlpUFpqW8bwC/XK2nTLrNdRW7ue4vrXZGZbv3fqJpCawC1cGTD9pJWC67EWcfIG1w83nOCIp5JOM7ivaH9/DmmOz+1pgQAwF6yro/URdAKaRoPG6Kj4TA7LUW3mlNHOkGgwr/aMMVEbXOkeBzL+DqhMKAvizuYVdNFguht8C2LXLqNYg7vuXBCNfXd8+/0X4LpPa7WqGG2IRElLdF2WwRBj3YtUBIlIklMjjV0x8O3dn+96NDicpS/hv+EDSApWeuWRfBR9elb2btKErLESAkGnsugT5JYsWv2TE2WzjHWV7hF8FbPA9DtkHhS+bTgT4WlkixP3CERRRQDPkkKQWxqjiNf2/+PA8a7HLWyIuS5Kj7UlADzm30qd6JIYsC4s8vcZbw7LDv3vYBlKii8BdSMrM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: daae3275-6cbc-4fac-4caa-08dd15ffc095 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 14:10:35.0421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dAvwAFgzaop04e4B5Dg53IWFKuh06Ua9yICLw6Mztrn5TVO7xkZqBcgKlUZFVv65UFxfMPIsz4AH+McZ04/kARqsUhZLzG0Kkt6YJ+xmpWQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4768 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-06_09,2024-12-06_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412060106 X-Proofpoint-ORIG-GUID: GF8qBggvg3NB9pYl85VelIPHD1DxXSBG X-Proofpoint-GUID: GF8qBggvg3NB9pYl85VelIPHD1DxXSBG X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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 Existing tcache implementation in glibc seems to focus in caching smaller data size allocations, limiting the size of the allocation to 1KB. This patch changes tcache implementation to allow to cache any chunk size allocations. The implementation adds extra bins (linked-lists) which store chunks with different ranges of allocation sizes. Bin selection is done in multiples in powers of 2 and chunks are reversely ordered within the bin. The last bin contains all other sizes of allocations. The patch also includes trimming functionality that gives back to the arena any older non used chunk, once the threshold limit for the tcache size is reached. This patch although by default preserves the same implementation, limitting caches to 1KB chunks, it now allows to increase the max size for the cached chunks with the tunable glibc.malloc.tcache_max. Also in order to define the capacity of the tcache, the tunable glibc.mallc.tcache_max_large_capacity was defined, specifying the refered threshold for removing older non-used cached chunks. --- elf/dl-tunables.list | 3 + malloc/arena.c | 2 + malloc/malloc.c | 383 ++++++++++++++++++++++++++++++++++++------- 3 files changed, 330 insertions(+), 58 deletions(-) diff --git a/elf/dl-tunables.list b/elf/dl-tunables.list index 40ac5b3776..e28d4877fd 100644 --- a/elf/dl-tunables.list +++ b/elf/dl-tunables.list @@ -74,6 +74,9 @@ glibc { tcache_unsorted_limit { type: SIZE_T } + tcache_max_large_capacity { + type: SIZE_T + } mxfast { type: SIZE_T minval: 0 diff --git a/malloc/arena.c b/malloc/arena.c index 91a43ee394..cd88071a08 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -250,6 +250,7 @@ TUNABLE_CALLBACK_FNDECL (set_arena_test, size_t) TUNABLE_CALLBACK_FNDECL (set_tcache_max, size_t) TUNABLE_CALLBACK_FNDECL (set_tcache_count, size_t) TUNABLE_CALLBACK_FNDECL (set_tcache_unsorted_limit, size_t) +TUNABLE_CALLBACK_FNDECL (set_tcache_max_large_capacity, size_t) #endif TUNABLE_CALLBACK_FNDECL (set_mxfast, size_t) TUNABLE_CALLBACK_FNDECL (set_hugetlb, size_t) @@ -309,6 +310,7 @@ ptmalloc_init (void) TUNABLE_GET (tcache_count, size_t, TUNABLE_CALLBACK (set_tcache_count)); TUNABLE_GET (tcache_unsorted_limit, size_t, TUNABLE_CALLBACK (set_tcache_unsorted_limit)); + TUNABLE_GET (tcache_max_large_capacity, size_t, TUNABLE_CALLBACK (set_tcache_max_large_capacity)); # endif TUNABLE_GET (mxfast, size_t, TUNABLE_CALLBACK (set_mxfast)); TUNABLE_GET (hugetlb, size_t, TUNABLE_CALLBACK (set_hugetlb)); diff --git a/malloc/malloc.c b/malloc/malloc.c index ac3901bdd5..642cdffd23 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -291,14 +291,18 @@ #if USE_TCACHE /* We want 64 entries. This is an arbitrary limit, which tunables can reduce. */ + +/* Last large bin is for alocations beyond 1kB. */ +# define TCACHE_LARGE_BINS 10 # define TCACHE_MAX_BINS 64 -# define MAX_TCACHE_SIZE tidx2usize (TCACHE_MAX_BINS-1) +# define MAX_TCACHE_SIZE (tidx2usize (TCACHE_MAX_BINS-1)) /* Only used to pre-fill the tunables. */ # define tidx2usize(idx) (((size_t) idx) * MALLOC_ALIGNMENT + MINSIZE - SIZE_SZ) /* When "x" is from chunksize(). */ # define csize2tidx(x) (((x) - MINSIZE + MALLOC_ALIGNMENT - 1) / MALLOC_ALIGNMENT) + /* When "x" is a user-provided size. */ # define usize2tidx(x) csize2tidx (request2size (x)) @@ -1891,6 +1895,8 @@ struct malloc_par /* Maximum number of buckets to use. */ size_t tcache_bins; size_t tcache_max_bytes; + /* Maximum tcache capacity for unbound size bins. */ + size_t tcache_max_large_capacity; /* Maximum number of chunks in each bucket. */ size_t tcache_count; /* Maximum number of chunks to remove from the unsorted list, which @@ -1926,8 +1932,9 @@ static struct malloc_par mp_ = , .tcache_count = TCACHE_FILL_COUNT, .tcache_bins = TCACHE_MAX_BINS, - .tcache_max_bytes = tidx2usize (TCACHE_MAX_BINS-1), - .tcache_unsorted_limit = 0 /* No limit. */ + .tcache_max_bytes = MAX_TCACHE_SIZE, + .tcache_unsorted_limit = 0, /* No limit. */ + .tcache_max_large_capacity = TCACHE_FILL_COUNT * MAX_TCACHE_SIZE /* Not enabled by default. */ #endif }; @@ -3110,6 +3117,11 @@ typedef struct tcache_entry struct tcache_entry *next; /* This field exists to detect double frees. */ uintptr_t key; + + /* Entries to allow large data to remove chunks as they exceed max data size. + */ + struct tcache_entry *rm_prev; + struct tcache_entry *rm_next; } tcache_entry; /* There is one of these for each thread, which contains the @@ -3121,6 +3133,12 @@ typedef struct tcache_perthread_struct { uint16_t counts[TCACHE_MAX_BINS]; tcache_entry *entries[TCACHE_MAX_BINS]; + tcache_entry *large_entries[TCACHE_LARGE_BINS]; + size_t large_data_size; + /* Used to remove older entries from tcache when size limit is reached. */ + tcache_entry *large_remove_list; + tcache_entry *last_in_large_remove_list; + bool in_remove_cycle; } tcache_perthread_struct; static __thread bool tcache_shutting_down = false; @@ -3208,6 +3226,153 @@ tcache_next (tcache_entry *e) return (tcache_entry *) REVEAL_PTR (e->next); } +/* Compute large bin index for chunk size. */ +static __always_inline char +large_csize2tidx (size_t x) +{ + char idx = __builtin_clz (tidx2usize (mp_.tcache_bins-1)) - __builtin_clz (x); + return idx < TCACHE_LARGE_BINS ? idx : TCACHE_LARGE_BINS-1; +} + +/* TODO: Do the mangling of all linked-list pointers. + * All linked list pointers were left non-mangled for review/debugging. */ + +static __always_inline void +tcache_trim_add_entry (tcache_entry *e) +{ + /* Add entry to tail of remove list. */ + if(__glibc_unlikely (tcache->large_remove_list == NULL)) + { + tcache->large_remove_list = e; + tcache->last_in_large_remove_list = e; + } + else + { + e->rm_prev = tcache->last_in_large_remove_list; + tcache->last_in_large_remove_list->rm_next = e; + tcache->last_in_large_remove_list = e; + } + + tcache->large_data_size += chunksize(mem2chunk(e)); +} + +static __always_inline void +tcache_trim_remove_entry (tcache_perthread_struct *tc, + tcache_entry *e, bool remove_from_sized_lists) +{ + /* Remove from regular uni-directional sized lists. */ + if (remove_from_sized_lists == true) + { + size_t tc_idx = large_csize2tidx (chunksize (mem2chunk (e))); + tcache_entry **entry = &tc->large_entries[tc_idx]; + while(*entry != NULL && *entry != e) + entry = &(*entry)->next; + + *entry = (*entry)->next; + } + + /* Change the last entry in remove list if entry to be removed is the + * last. */ + if (e == tc->last_in_large_remove_list) + tc->last_in_large_remove_list = e->rm_prev; + + /* Change remotion list entry if the node to remove is the head of the list. + */ + if (e == tc->large_remove_list) + tc->large_remove_list = e->rm_next; + + /* Remove chunk from remotion list */ + if (e->rm_prev != NULL) + e->rm_prev->rm_next = e->rm_next; + if (e->rm_next != NULL) + e->rm_next->rm_prev = e->rm_prev; + + tc->large_data_size -= chunksize(mem2chunk(e)); +} + +static __always_inline void * +tcache_large_get (size_t nb, size_t alignment) +{ + size_t tc_idx = large_csize2tidx (nb); + tcache_entry **entry = &tcache->large_entries[tc_idx]; + + /* Skip all chunks that are too large. */ + while(*entry != NULL + && chunksize (mem2chunk (*entry)) > nb) + entry = &(*entry)->next; + + /* Find an entry that respects alignment. */ + if (alignment != 0) + { + while (*entry != NULL + && chunksize (mem2chunk (*entry)) == nb + && !PTR_IS_ALIGNED (*entry, alignment)) + entry = &(*entry)->next; + } + + + /* Make sure we have an compatible chunk. */ + if (*entry == NULL + || chunksize (mem2chunk (*entry)) != nb) + return NULL; + + tcache_entry *e = *entry; + + e->key = 0; + tcache_trim_remove_entry (tcache, e, false); + + /* Remove chunk from list */ + *entry = (*entry)->next; + return (void *) e; +} + +static __always_inline void +tcache_trim (size_t extra_space) +{ + tcache->in_remove_cycle = true; + if (tcache != NULL + && tcache->large_remove_list != NULL) + while (tcache->large_remove_list != NULL + && tcache->large_data_size + extra_space > mp_.tcache_max_large_capacity) + { + tcache_entry *e = tcache->large_remove_list; + tcache_trim_remove_entry (tcache, e, true); + if (e == NULL) + malloc_printerr ("tcache_trim: Failed to removed entry from cache"); + else + __libc_free (e); + } + tcache->in_remove_cycle = false; +} + +static __always_inline bool +tcache_large_put (mchunkptr chunk, size_t tc_idx) +{ + if (tcache == NULL) + return false; + + tcache_trim(chunksize (chunk)); + + tcache_entry *e = (tcache_entry *) chunk2mem (chunk); + + /* Mark this chunk as "in the tcache" so the test in _int_free will + detect a double free. */ + memset (e, 0, sizeof(tcache_entry)); + e->key = tcache_key; + + /* If it is a large data chunk then add it in the list ordered from + * bigger to smaller chunk size */ + tcache_entry **entry = &tcache->large_entries[tc_idx]; + while(*entry != NULL && chunksize(mem2chunk(*entry)) > chunksize(chunk)) + entry = &(*entry)->next; + + e->next = *entry; + *entry = e; + + tcache_trim_add_entry (e); + return true; +} + /* Verify if the suspicious tcache_entry is double free. It's not expected to execute very often, mark it as noinline. */ static __attribute__ ((noinline)) void @@ -3216,18 +3381,46 @@ tcache_double_free_verify (tcache_entry *e, size_t tc_idx) tcache_entry *tmp; size_t cnt = 0; LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx); - for (tmp = tcache->entries[tc_idx]; - tmp; - tmp = REVEAL_PTR (tmp->next), ++cnt) + if(tc_idx < mp_.tcache_bins) + { + for (tmp = tcache->entries[tc_idx]; + tmp; + tmp = REVEAL_PTR (tmp->next), ++cnt) + { + if (cnt >= mp_.tcache_count) + malloc_printerr ("free(): too many chunks detected in tcache"); + if (__glibc_unlikely (!aligned_OK (tmp))) + malloc_printerr ("free(): unaligned chunk detected in tcache 2"); + if (tmp == e) + malloc_printerr ("free(): double free detected in tcache 2"); + /* If we get here, it was a coincidence. We've wasted a + few cycles, but don't abort. */ + } + } + else { - if (cnt >= mp_.tcache_count) - malloc_printerr ("free(): too many chunks detected in tcache"); - if (__glibc_unlikely (!aligned_OK (tmp))) - malloc_printerr ("free(): unaligned chunk detected in tcache 2"); - if (tmp == e) - malloc_printerr ("free(): double free detected in tcache 2"); - /* If we get here, it was a coincidence. We've wasted a - few cycles, but don't abort. */ + size_t large_tcache_size = 0; + for (int idx = 0; idx < TCACHE_LARGE_BINS; idx++) + { + tcache_entry **entry = &tcache->large_entries[idx]; + while (*entry != NULL) + { + size_t entry_size = chunksize (mem2chunk (*entry)); + size_t entry_tc_idx = large_csize2tidx (entry_size); + large_tcache_size += entry_size; + + if (__glibc_unlikely (entry_tc_idx != idx)) + malloc_printerr ("free(): large cache entry in incorrect bin"); + if (__glibc_unlikely (!aligned_OK (*entry))) + malloc_printerr ("free(): unaligned chunk detected in tcache 2"); + if (*entry == e) + malloc_printerr ("free(): double free detected in tcache 3"); + + entry = &((*entry)->next); + } + } + if (tcache->large_data_size != large_tcache_size) + malloc_printerr ("free(): large tcache size is not correct"); } } @@ -3238,22 +3431,35 @@ tcache_free (mchunkptr p, INTERNAL_SIZE_T size) { bool done = false; size_t tc_idx = csize2tidx (size); - if (tcache != NULL && tc_idx < mp_.tcache_bins) + + if (__glibc_unlikely (tcache_shutting_down == false) + && __glibc_unlikely (tcache->in_remove_cycle == false) + && tcache != NULL + && size <= mp_.tcache_max_bytes) { /* Check to see if it's already in the tcache. */ tcache_entry *e = (tcache_entry *) chunk2mem (p); /* This test succeeds on double free. However, we don't 100% - trust it (it also matches random payload data at a 1 in - 2^ chance), so verify it's not an unlikely - coincidence before aborting. */ + trust it (it also matches random payload data at a 1 in + 2^ chance), so verify it's not an unlikely + coincidence before aborting. */ if (__glibc_unlikely (e->key == tcache_key)) - tcache_double_free_verify (e, tc_idx); + tcache_double_free_verify (e, tc_idx); - if (tcache->counts[tc_idx] < mp_.tcache_count) + if (tcache != NULL && tc_idx < mp_.tcache_bins) + { + if (tcache->counts[tc_idx] < mp_.tcache_count) + { + tcache_put (p, tc_idx); + done = true; + } + } + else { - tcache_put (p, tc_idx); - done = true; + size_t ltc_idx = large_csize2tidx (size); + if (tcache_large_put (p, ltc_idx) == true) + done = true; } } return done; @@ -3264,6 +3470,7 @@ tcache_thread_shutdown (void) { int i; tcache_perthread_struct *tcache_tmp = tcache; + size_t large_tcache_size = 0; tcache_shutting_down = true; @@ -3275,7 +3482,7 @@ tcache_thread_shutdown (void) /* Free all of the entries and the tcache itself back to the arena heap for coalescing. */ - for (i = 0; i < TCACHE_MAX_BINS; ++i) + for (i = 0; i < mp_.tcache_bins; ++i) { while (tcache_tmp->entries[i]) { @@ -3288,6 +3495,32 @@ tcache_thread_shutdown (void) } } + size_t initial_tcache_large_size = tcache_tmp->large_data_size; + /* Free all of the large entries back to arena heap. */ + for (int idx = 0; idx < TCACHE_LARGE_BINS; idx++) + { + while (tcache_tmp->large_entries[idx]) + { + tcache_entry *e = tcache_tmp->large_entries[idx]; + size_t entry_size = chunksize (mem2chunk (e)); + size_t entry_tc_idx = large_csize2tidx (entry_size); + large_tcache_size += entry_size; + + if (__glibc_unlikely (entry_tc_idx != idx)) + malloc_printerr ("tcache_thread_shutdown(): large cache entry in incorrect bin"); + if (__glibc_unlikely (!aligned_OK (e))) + malloc_printerr ("tcache_thread_shutdown(): unaligned chunk detected in tcache"); + + e->key = 0; + tcache_trim_remove_entry (tcache_tmp, e, true); + + __libc_free (e); + } + } + if (tcache_tmp->large_data_size != 0 + || initial_tcache_large_size != large_tcache_size) + malloc_printerr ("tcache_thread_shutdown(): large tcache was incorrect"); + __libc_free (tcache_tmp); } @@ -3356,22 +3589,34 @@ __libc_malloc (size_t bytes) #if USE_TCACHE /* int_free also calls request2size, be careful to not pad twice. */ size_t tbytes = checked_request2size (bytes); - if (tbytes == 0) + + if (tbytes <= mp_.tcache_max_bytes) { - __set_errno (ENOMEM); - return NULL; - } - size_t tc_idx = csize2tidx (tbytes); + if (tbytes == 0) + { + __set_errno (ENOMEM); + return NULL; + } + size_t tc_idx = csize2tidx (tbytes); - MAYBE_INIT_TCACHE (); + MAYBE_INIT_TCACHE (); - DIAG_PUSH_NEEDS_COMMENT; - if (tc_idx < mp_.tcache_bins - && tcache != NULL - && tcache->counts[tc_idx] > 0) - { - victim = tcache_get (tc_idx); - return tag_new_usable (victim); + DIAG_PUSH_NEEDS_COMMENT; + + if (tc_idx < mp_.tcache_bins) + { + if (tcache != NULL && tcache->counts[tc_idx] > 0) + { + victim = tcache_get (tc_idx); + return tag_new_usable (victim); + } + } + else + { + victim = tcache_large_get (tbytes, 0); + if (victim != NULL) + return tag_new_usable (victim); + } } DIAG_POP_NEEDS_COMMENT; #endif @@ -3657,32 +3902,45 @@ _mid_memalign (size_t alignment, size_t bytes, void *address) } #if USE_TCACHE + MAYBE_INIT_TCACHE (); + { size_t tbytes; tbytes = checked_request2size (bytes); if (tbytes == 0) { - __set_errno (ENOMEM); - return NULL; + __set_errno (ENOMEM); + return NULL; } size_t tc_idx = csize2tidx (tbytes); - if (tc_idx < mp_.tcache_bins - && tcache != NULL - && tcache->counts[tc_idx] > 0) + if (tbytes <= mp_.tcache_max_bytes) { - /* The tcache itself isn't encoded, but the chain is. */ - tcache_entry **tep = & tcache->entries[tc_idx]; - tcache_entry *te = *tep; - while (te != NULL && !PTR_IS_ALIGNED (te, alignment)) + if (tc_idx < mp_.tcache_bins) { - tep = & (te->next); - te = tcache_next (te); + if (tcache != NULL + && tcache->counts[tc_idx] > 0) + { + /* The tcache itself isn't encoded, but the chain is. */ + tcache_entry **tep = & tcache->entries[tc_idx]; + tcache_entry *te = *tep; + while (te != NULL && !PTR_IS_ALIGNED (te, alignment)) + { + tep = & (te->next); + te = tcache_next (te); + } + if (te != NULL) + { + void *victim = tcache_get_n (tc_idx, tep); + return tag_new_usable (victim); + } + } } - if (te != NULL) + else { - void *victim = tcache_get_n (tc_idx, tep); - return tag_new_usable (victim); + void *victim = tcache_large_get (tbytes, alignment); + if (victim != NULL) + return tag_new_usable (victim); } } } @@ -5510,14 +5768,23 @@ do_set_arena_max (size_t value) static __always_inline int do_set_tcache_max (size_t value) { - if (value <= MAX_TCACHE_SIZE) - { - LIBC_PROBE (memory_tunable_tcache_max_bytes, 2, value, mp_.tcache_max_bytes); - mp_.tcache_max_bytes = value; - mp_.tcache_bins = csize2tidx (request2size(value)) + 1; - return 1; - } - return 0; + LIBC_PROBE (memory_tunable_tcache_max_bytes, 2, value, mp_.tcache_max_bytes); + mp_.tcache_max_bytes = value; + if (csize2tidx (request2size(value)) + 1 < MAX_TCACHE_SIZE) + mp_.tcache_bins = csize2tidx (request2size(value)) + 1; + else + mp_.tcache_bins = TCACHE_MAX_BINS; + + return 1; +} + +static __always_inline int +do_set_tcache_max_large_capacity (size_t value) +{ + LIBC_PROBE (memory_tunable_tcache_max_large_capacity, 2, value, mp_.tcache_max_large_capacity); + mp_.tcache_max_large_capacity = value; + + return 1; } static __always_inline int From patchwork Fri Dec 6 14:09:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 102565 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 C1E983858CD1 for ; Fri, 6 Dec 2024 14:14:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1E983858CD1 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2023-11-20 header.b=cxwa/wC5; dkim=pass (1024-bit key, unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=x+KAvTcq X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 5F4FE3858CDB for ; Fri, 6 Dec 2024 14:10:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F4FE3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5F4FE3858CDB Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1733494245; cv=pass; b=RHuDPYMTGIcPq17cK37FoUFHiZggQFEuWlQIzaI7xYhIwj5YLWBVs3s53umXtL1NQ+jKebQ9QImgzZXwN0BtXrOfHo4z/c+cdpRPhPrsXFyjU7b777qbRkBXZuJVMTO5L6Vegho0iHTXLhfbM9sVEiAWjG+elZcuRlpe+MxW7Ag= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1733494245; c=relaxed/simple; bh=dSc04ed640ODVyZaiKPq11zjQc22UqE7CrMfju0oIcY=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=smLbLGQAANtxaWEgFT9+CLa9XEy25fa/hb+XagTJhVyEvvu4OUJA9dSrSlkfknBLW3rxXuq0aQXNCy/xTr6jz4Te9A/XOBoprsQJNH/HrvmRYI7Gmc6hBBXD1YNaibVn7V76w5TfC7H+Ecnqk//qnbnAdCh9BGG13GgCfW834m8= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F4FE3858CDB Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B66s2Xf023110; Fri, 6 Dec 2024 14:10:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=U8FjJe5l8jgyaOVSLumB/gBTzKrDNJJ4db6xllU7EkA=; b= cxwa/wC5R9EUoB1JpFINx8tLx2bYt0wpIraGCrFrNlLl1duPRURzX/4hsQtMk0Xg Xj0LC8HDdbtjbHChVjnPxSPVZiD6TbXwV4MfPwDSkubwhSjzDFUk/HnTKaa8Zv7W Y6Clhmch3YklvLzKxSxvcq2m7fM70DK0cj05vGNq0tr+/VYZGds3q17+b6kGVhbQ hWWVQt3LU/R4Ttn/prCc4yS3kAUQfgRxLbF5R06gRNfQvRU1plShZLZsWSvZS1Q0 3wmb/20IclGazY9wqE6FDUPeiCbJ5ns8RRCdYC8fYjCjEyWtaGrtB0GB4pKHFEbM 49vW7MgtAGtCyVaAAEPzFw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 437sg2dfhs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Dec 2024 14:10:44 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4B6CMYKg039998; Fri, 6 Dec 2024 14:10:43 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43836y8cwu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Dec 2024 14:10:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l6wSPTDb6gWoaO6gkNeq7egU4qGLSC8glDEL1rT1sfcDhTzy6nu1Kh1bxHOp8t6tesKrjZvWoCjTNlkBwzYTkRPDnz6G30FPybidq2HmHRtJCKASqCfyxfkbLly0y1wKAjRxGFGbCFJr0HthX6gzSHcWLJyPJF5zNGcd94HkdaWNq/QxYC9MkOTZmVc59KoSv0k4o4bWEco2R2ClzRy+1tGRZttjrtVd3+DHPBdro/98fOOhqIHFHL1Y+u9XBpO+Panf8tsDV8vNn9uzJtjU8aXdxMjGpvwp4E/BCifYyH2CHQgfc1rE5qmYpBXVL82DbCaEfhwQawFjXd0nIPmgPg== 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=U8FjJe5l8jgyaOVSLumB/gBTzKrDNJJ4db6xllU7EkA=; b=OpkNudrVqNbhGi1EqFhSDsXE6fYH3xEOzYCmtOkZFg9rSoidHNQPDxi7vy/FyLU4Ye2V96IylwgKUv8B97HPYrshBzZx6SXHyn93JJjIZ3cz0uS+TsXL96Kg9c3+a1OmjErK8h6pDQlaBje62+YduR6h3XfM133MNmTRvhRqVe032876P6mckt/ldgt6IRD90S3N769Sy+PWrFMpXtLiUN5Zwh8tAOP0nK33eM5AI5sTAKEvIy+2Ndv3Miw3pfpxkfMP89468mikXpioLKnq/etS4UJvVZ/rekbjBsMv/dxAf+a/6Gdu02H9h1OnfvfmtopI3u/qg/zSzwImb3jUfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U8FjJe5l8jgyaOVSLumB/gBTzKrDNJJ4db6xllU7EkA=; b=x+KAvTcq6c5AXafL3y5Ajbndp450yWksihdfC/XC1iyIlnZEUgE7blqBz0O+VXTi2Qp/oRRO4N6wzY5dgiIReZB/4pOIWEULuloEPbGq9m5hx9lSQv7icnp2FsJoWagkVQ6djQFfZjoz2bmh7pkzCNm3/sfKJk65OM7nTIFi5zo= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by MN2PR10MB4352.namprd10.prod.outlook.com (2603:10b6:208:1de::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 14:10:39 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::5033:84a3:f348:fefb]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::5033:84a3:f348:fefb%7]) with mapi id 15.20.8230.010; Fri, 6 Dec 2024 14:10:39 +0000 From: Cupertino Miranda To: libc-alpha@sourceware.org Cc: jose.marchesi@oracle.com, elena.zannoni@oracle.com, adhemerval.zanella@linaro.org, Cupertino Miranda Subject: [PATCH v2 2/3] malloc: add testing for large tcache support. Date: Fri, 6 Dec 2024 14:09:20 +0000 Message-Id: <20241206140921.139205-3-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241206140921.139205-1-cupertino.miranda@oracle.com> References: <20241206140921.139205-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LO4P265CA0144.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c4::17) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|MN2PR10MB4352:EE_ X-MS-Office365-Filtering-Correlation-Id: 173094f4-6f3b-4996-ebe7-08dd15ffc373 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|10070799003|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: xQSI0Za63yMxX3IVvoTjd6vQVK+ttnpi6TSJ9hqUxCWBForOuyD7yct8PAzS7A6qE0uR9W2OhVjzlya0/KJFfx1ty0EA+peys3CTpdPBhk5Ae/SFzlzFbj60M4jFvLExIngJFkWcT3zBxu9ultZACG/WllVMQyEXSe4e/8BQ7uOpDsRqHKlqVE1qpwMaKFavXjObpjf9wNpH8ePv4p78N0VruUSAWZ8krp13bOGhp5T6b70IOBymhT9JyYPQC29KtIGC5tUyn7Gf48iveV5GUIqn4CrsIBC2YjLkDqxMYPm5cu7pbBGuRIWjzRdVT5VPZJC2jTBcBzlKkKsFGwe7ML9FBLud9aVS/yCe4t003WRTegzlC8+TlFg4XeXR87nN233ytDu21IYSLOMy47cE4TUlDtCyc4CQkyLg/qpfwGT8jxksNk8/qZe2nizZDBtvtoMzwOIVRVu3wGahem6rPdfStSAwCcHquu0TqGYTN+iKfhbaRuQrXTpeR8stEvsEa+qszktyxZ8jtI+oKU/b9P/6WyXWAUE2zqeGlMgPpAVLUYJbbw0rTy9uY6uYLnkCK6eioEZxKJ/nrpnxdYF/ZALH3K9FiAoHOVsuTfbRQExxyOzBWRS6Z2nTZSV2+dyECGSxrTChoYr55USlUl2IUbDYhjzifx3WFn08BO+Y0mQJkYfrXvSU1GgQpPHlWDKEzPZGks8DR1FCvKuMehDV8tYpk3JN8lhu7ya943TLGaRfUSKFmWcrFv/R/o6aVFz/YHrpuRj9R6EaB9JetmVNOGKvVELGaIjSOei5tt6iJNinUoEFzx9BMErW4x///uJb/zKAeN3u96oWncaCgxzh2RZ0RhUay370ocS/oEWnLpLI6ut/50gJ+uhx7leWT6evndRh6y57KO1d4j4SfsYIJBNrd0F6LFLzTJFcImeNECeUkrGS3CCPcrp47GApLWXysBeBcaTaYC5yqKllfvbt+yDQpNkj5Nr5iAHbm4CN/xR5BscBe0fBohhIRIbKJzn6KMqTNf2+yEAraOzjX8QtdG6qLgdhb2lYSJINHInOxSJKPKbXiZQZuJoXa/5XIntwIENSs9lpO1fmfz/aEFhlVjuyNBgcqMUlAjlMt6ux079WkuZJ3ABvu5WWKRjasrNv6iqh7Q8y5fpD7pTLSwuLmp5isUwOYZh9Tp4aQmSz1wkj7BSpwadaXslJcqauEACdRZk1c1Gwy1Y7ywcPm/4oyfezvb8AeeOX40bRc/5Bk2bqzuME9iZhOYko9vpgTtVUdVsUHHclqutxL+JFkKOx4+vI472CaN0mtdx8GD4EDJoDXyw3+imexxXTZz4/8Gqj1QqglaxBZnJw34peE17GGw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR10MB4382.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(10070799003)(366016)(1800799024)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9KET87PBEgGOhiz0krYHnOqoVqlrC8DNUTaDNOcQQDH8sKoh3fbJr/DhvsiK79X6E6nA7zFPlr0MA9+nVNq5WTANn/p+emci7lt+vGtFdYyozEJPJqaxfiOGkupfHn+zYVni0e/g44cs1dwXDxpIU8RDt6Xb5dqwikhUcPewJROaR2e/YrlYwbvvIFJpJv6aTLCpk+z/BxbYKWduggZwuuZa2vzDf1EfCL66wKCjIvi7/IWwtyoxROA4TE1LId7yKaGhVxIFDQhFLPBSyEp8Q5soKlOa7QoZq7sthHJnC08ObEUPUXF41TxTmVqnmf/evNALhJkCdXsEMxu3oHlY1qVWnncsYgZ6p5D1t4TvNV9pSeeWoAzjNJI+l3hNs0MkDQPUJ7WZNxTWC590+Idp4WNNB9KsWjgPHRYUWqzJ79J++DU+gC2ek5GY6sKasDf90qZLeh7oZISSxTtxq/IbET52XC35xa3z0zD4aCchlCFaEnR4WeyJpvSMeYiplBYd3B3HbRJWxK3xRSukxv0WhHPAalteaVqqsvwp42d6O55vX1NnCL/XohRKpeByZvfzw/goLrDN4hswwSr2JKWZhK8nGPUzvRB251MoxD+TrY3FavK5WSGj9UyAnF1awDfEXF8pSCL+b0W0DN1ZDGi3r3wCsBh7sEM5Zhze5+yk5vxNy6UGvb3VV7lPvKV3xqMd4ZjcYsf6Vtw2IsggudQbg/NE7gZaQb4rqHcK25MkGgG0uNWyoMiIawFX1dDsfMlRth359IlXxpMgfwoOUBunsPh7LCbugXdygd4/qwpcbof3wQM1GSX94DvThL/1ZCC4bj6GnYoNArc1MwOuj/hlVky34kSTUdufTwNU9pC7h35Bzjzw10OufqwdSe2MpLZHrNvnNjWF8axf3mliJZj1IpADdabL0AlayVAj6/9DrZSMqAknKUJmAdJT1h+fk/iopA/Ggv4o8Mt4Sqk1xHv++nbH5rxuopnCj98mM06KTsdoJTZMeVQykr3a/it3eEoQ4lRy2mKRQDl/+DUZckxIVkcuCv8KWkKXgWB4rWfSh3u4Srd7F9zx7ISDtRvVrTE9mHLIF4VTOQltDd67o3qFFA9ZfsvdE+NnddtgGg7z7SewvSVY9yJZZ/TnUR2chfdHfYBwFZGwfYuR1RqUeGTc9P1yTBTBjeomRt3glD3FaOZrn1ykHnTc1xaPLN2qG1pjM1f2dNYodvapui9UelCfp+BawA7Ip8GnBVPG/AGUObwM0lXMyQN+/Gg6Xls3IVy6SX7YIcVxEskuVTQWiBnS1mGLzUuz9Ekfth961ZThmRRvo8QNTV+poQ0RDKqtu+SzcTSPmF6tQj3X7GAK7+v5CMUduySDQ86SKDXV7jziaK1O2JnqfCwCQgFcmxBfBMs9U07Y5797MAYhXPJZgF1/etgION+6LHWRx7SJPVmb2miGcHfUbrq7iTv5KaIGB3Jfcny1D3J36lE1490TpspYRWkFL6tzUkkl8Xn6MmJgXyVftPZw64bs2IMob5DPAiss9idnWV9YW11lzmmNUWpp6OT3MhKUrRtFCYdm0XyBjybdw1i4u2F3xi0R4r0Nhmgfx6l25U2cdhppAPVrBfm3ND/eslbCxXBgVivDtozFH+k= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: SVJ94tjEG3HsdfJ44RVaAYEsR00k+OPZOQ77C3Fwib+Obrat2CX3NWmCDfkXUhYi0kSUcdC6wfF/XT9DVF5Kq/mPL0mXCC7VW1D5ziZJf84RZSEzS6uRi89HL4APB1zIoH2qXuEcmQYVbzfmNzgswkDDCfSmKaqIMB4USG6g47JWKyATt3tPONQdCo0w9m1ocQmBR+IH0I4YWVeivEf24RWg1R24sOE/RVU2ZEFgBl2QVwKoQ9/E0yhh0IiQIN6USJEte/SbkMoe74jiZWD4Y+rBckKbtbKn6t7w4q7/+3i70YPMj7Ru8yKf8JtkBsCAtUY40Ha1f2rNN50DKyBlhRW3i+a8vX0iCdZoqYKQ1pJvKZmJDIxGzRSIpsJEkyerqETmgnyHXLmOVTL4tDnX0v7rvuvZ9dbMYrE3tE4C96FiboOd7Uf6Gi6fpDMN1oN7VzXQARBJTW24B/VPQ18qJ5VmVhhcpH+gPVQJ4R6nk9Mivx1wf5bYjWOcYZ+1UNlBNTOacTaYAH2V+ZJrIYZXNBmSNEfHId12hvXPaGJiiYkKwqmUOyQ8lMS6bbtrsZu32HGzec0RCRUmKmuDICFdiU94Lj0hRB6rXieJYW5JSnw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 173094f4-6f3b-4996-ebe7-08dd15ffc373 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 14:10:39.8390 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8nx8UR0jDAxWcS7MyN80BLMwsoA2UfolZN8SP2KNB6Ov83kqCy4isS5MyScguLvlz4WVDP69C8Zgi0VvizAfJjLu680RNT+TUuskiwFgpwA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4352 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-06_09,2024-12-06_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412060106 X-Proofpoint-ORIG-GUID: qDq_9zX61X3OlcUhJmoetHheXV486jXT X-Proofpoint-GUID: qDq_9zX61X3OlcUhJmoetHheXV486jXT X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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 This patch adds large tcache support tests by re-executing all of the malloc tests, using the tunables: glibc.malloc.tcache_max=1048576 glibc.mallc.tcache_max_large_capacity=4194304 Test names are prefixed with "largetcache". --- Rules | 19 +++++++++++++++++++ malloc/Makefile | 15 +++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/Rules b/Rules index 713c225d2e..9cccdd2160 100644 --- a/Rules +++ b/Rules @@ -151,6 +151,7 @@ tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \ $(tests-malloc-check:%=%-malloc-check) \ $(tests-malloc-hugetlb1:%=%-malloc-hugetlb1) \ $(tests-malloc-hugetlb2:%=%-malloc-hugetlb2)) \ + $(tests-malloc-largetcache:%=%-malloc-largetcache)) \ $(test-srcs)) $(tests-special) \ $(tests-printers-programs) xtests: tests $(xtests-special) @@ -163,6 +164,7 @@ tests: $(tests:%=$(objpfx)%.out) $(tests-internal:%=$(objpfx)%.out) \ $(tests-malloc-check:%=$(objpfx)%-malloc-check.out) \ $(tests-malloc-hugetlb1:%=$(objpfx)%-malloc-hugetlb1.out) \ $(tests-malloc-hugetlb2:%=$(objpfx)%-malloc-hugetlb2.out) \ + $(tests-malloc-largetcache:%=$(objpfx)%-malloc-largetcache.out) \ $(tests-special) $(tests-printers-out) xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-special) endif # $(run-built-tests) != no @@ -177,6 +179,7 @@ tests-expected = $(tests) $(tests-internal) $(tests-printers) \ $(tests-container) $(tests-malloc-check:%=%-malloc-check) \ $(tests-malloc-hugetlb1:%=%-malloc-hugetlb1) \ $(tests-malloc-hugetlb2:%=%-malloc-hugetlb2) \ + $(tests-malloc-largetcache:%=%-malloc-largetcache) \ $(tests-mcheck:%=%-mcheck) xtests-expected = $(xtests) endif # $(run-built-tests) != no @@ -209,6 +212,7 @@ binaries-mcheck-tests = $(tests-mcheck:%=%-mcheck) binaries-malloc-check-tests = $(tests-malloc-check:%=%-malloc-check) binaries-malloc-hugetlb1-tests = $(tests-malloc-hugetlb1:%=%-malloc-hugetlb1) binaries-malloc-hugetlb2-tests = $(tests-malloc-hugetlb2:%=%-malloc-hugetlb2) +binaries-malloc-largetcache-tests = $(tests-malloc-largetcache:%=%-malloc-largetcache) else binaries-all-notests = binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs) @@ -222,6 +226,7 @@ binaries-mcheck-tests = binaries-malloc-check-tests = binaries-malloc-hugetlb1-tests = binaries-malloc-hugetlb2-tests = +binaries-malloc-largetcache-tests = endif binaries-pie = $(binaries-pie-tests) $(binaries-pie-notests) @@ -288,6 +293,14 @@ $(addprefix $(objpfx),$(binaries-malloc-hugetlb2-tests)): %-malloc-hugetlb2: %.o $(+link-tests) endif +ifneq "$(strip $(binaries-malloc-largetcache-tests))" "" +$(addprefix $(objpfx),$(binaries-malloc-largetcache-tests)): %-malloc-largetcache: %.o \ + $(link-extra-libs-tests) \ + $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \ + $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit) + $(+link-tests) +endif + ifneq "$(strip $(binaries-pie-tests))" "" $(addprefix $(objpfx),$(binaries-pie-tests)): %: %.o \ $(link-extra-libs-tests) \ @@ -337,6 +350,12 @@ $(1)-malloc-hugetlb2-ENV += GLIBC_TUNABLES=glibc.malloc.hugetlb=2 endef $(foreach t,$(tests-malloc-hugetlb2),$(eval $(call malloc-hugetlb2-ENVS,$(t)))) +# All malloc-largetcache tests will be run with GLIBC_TUNABLE=glibc.malloc.tcache_max=1048576:glibc.mallc.tcache_max_large_capacity=4194304 +define malloc-largetcache-ENVS +$(1)-malloc-largetcache-ENV += GLIBC_TUNABLES=glibc.malloc.tcache_max=1048576:glibc.mallc.tcache_max_large_capacity=4194304 +endef +$(foreach t,$(tests-malloc-largetcache),$(eval $(call malloc-largetcache-ENVS,$(t)))) + # mcheck tests need the debug DSO to support -lmcheck. define mcheck-ENVS $(1)-mcheck-ENV = LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so diff --git a/malloc/Makefile b/malloc/Makefile index 1630aaf6ac..6b6c58136d 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -147,6 +147,21 @@ tests-malloc-hugetlb1 = \ tests-malloc-hugetlb2 = \ $(filter-out $(tests-exclude-hugetlb2), $(tests)) +tests-exclude-largetcache = \ + tst-compathooks-off \ + tst-compathooks-on \ + tst-interpose-thread \ + tst-interpose-nothread \ + tst-interpose-static-nothread \ + tst-interpose-static-thread \ + tst-mallocstate \ + tst-malloc-backtrace \ + tst-malloc-usable \ + tst-malloc-usable-tunables + +tests-malloc-largetcache = \ + $(filter-out $(tests-exclude-largetcache), $(tests)) + # -lmcheck needs __malloc_initialize_hook, which was deprecated in 2.24. ifeq ($(have-GLIBC_2.23)$(build-shared),yesyes) # Tests that don't play well with mcheck. They are either bugs in mcheck or From patchwork Fri Dec 6 14:09:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 102563 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 1FE803858D28 for ; Fri, 6 Dec 2024 14:12:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FE803858D28 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2023-11-20 header.b=W2KSrm0I; dkim=pass (1024-bit key, unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=V7VSec8I X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 69FD13858C53 for ; Fri, 6 Dec 2024 14:10:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69FD13858C53 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 69FD13858C53 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1733494252; cv=pass; b=X+3BiMgW+pvvgMXjl3RTIrc7IzVCTtpQPkAyHhYQfu54pcJjEHUTXQxTjLI81mNx6WXsTBH6gBiJervEbQ6+VGhF99/1W0hHJ4Kz6QgFRnxT3ronH/RyfqWDWuCUcJkobMMSbBFZ6qtbY4dNWAjhi+0gS0SvyrZZqDnwazcscDw= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1733494252; c=relaxed/simple; bh=h8K8ya2kLkACcENOtazLV619aLAVljxHbndb9FEBZVY=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=uGaro8fofXsqfV27Hr4VBNDcwVURXEnsqWMPyo3hKEABdTe9dPe/5nBvjfCamABEeyqJbx9fsagZoCW4LIxTyMf4oP07kFwOqZzIN5EFTqUWNrgQqF4WuZ62o/TUqzkZaI4ro2NVaFNFauR8TePe1H1BhJj4byzHa0Dz5CpIVwM= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69FD13858C53 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B66s0ZC021497; Fri, 6 Dec 2024 14:10:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=NEdxkVnDFPqL0iycpECxSRIFNYyTiFvrngr1pAbynko=; b= W2KSrm0IbNLDrbiHNZLrnjB8bXN3O+KGsV4VKh+DY7Ia243vY5pu42rDBTXqhrdX x5KqS1UZL/JSeamHHAMFbBwaI2fD2H14Zn3OG+j/voiLYz8lOoWbAsJViruYbkZt ADs4xnaAAO59QHjZ3thitbJAmLZJUL1tLY8BftHKjMKsIQpIHRDG9aKSJf/Q627g XxWctrO68qxV6TgelQvzVR9jyQAT+RsNGBYYJm1MduHF+0m4Tw8JBradbu57ZCLG 6HKIP85NmR0tVTeMcIO3EoV36LT0JYImSpfjTzlwLw5FA1x3z1QSeZILUxfEny6Q KS03FaxU3q+r0CAZy/7AaQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 437sa05mwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Dec 2024 14:10:50 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4B6CWeIZ020354; Fri, 6 Dec 2024 14:10:48 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 437wjgy30c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Dec 2024 14:10:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eUgA53p7c0L2YoxAydsYyEd7SmFybohJTM+obE+Wp2uTnb3ZfFbaro2Jx7a6+5TCLyBEtkhu/dWKLYCF0BpyyyrVyI3NIy62AKmJrWb9xHTHmSew2tS0cRQO0WEGYqWbjcIq4LIyN4sIFDSW9ITFusr1Jbt8gSX2kVE0NmEzMCf9NNDaT4C0C8gJwsVj7cIh5XVwAmKervMxPh2tCxzMxB62klqqap877wiQ7negINbuFbnapy4mO0C7jzPJwXGheRorg7gsmBkH/hxAYv8+40Ar8OZ5BopBmxl7ykegpN90UheH9nLvsjfueR3bqFfQZW7QIsV7QRvZ/RTh7u9tPQ== 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=NEdxkVnDFPqL0iycpECxSRIFNYyTiFvrngr1pAbynko=; b=P+p+0XbV91IuV4p/2uhRJ22US82aec4ANAKprg97zs9lowMa5ZeKbIeF96pplXdUvqezYc+D80DdaDpYoZWt60GdtLjBQsgoNIgdlJHlrlUdJ9iquOcklpj1rKo1sZUIxbJiJdS7TXCIm9IDmeRjFb3aII2IAl1ryn8rV82y92HTq0d6vF3CRD0tS4At5ZlBznIetjfQ8IBkYZML96dWELdQ6mPiVhZB29hWz0bgW+8AzdwNY3PYK/Gx9pUWlJclqlbwyXOCQtgLuUDhkFbBydM1kkVfeaH3GFwCpLIGJ46eAevzUL1MgAbhPhECTfhEbWpUHBcA1Lhh/xhV0Td0og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NEdxkVnDFPqL0iycpECxSRIFNYyTiFvrngr1pAbynko=; b=V7VSec8IhR8Mmbvah8aCOq7HzMmP+o2bXK+SolxiMlqjDmuBR3BTiBn3Ta1XmhzG9ytx48Fq1lkmGhVZWhM8PRBfUf24k6+P8AIXMky5Fb+D5FnOd/3X99K1QjEWg7pN4cA3cwNs0K9ZnHl4gL2sjTbfMnwC6joNUlZJoOUumV8= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by MN2PR10MB4352.namprd10.prod.outlook.com (2603:10b6:208:1de::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 14:10:45 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::5033:84a3:f348:fefb]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::5033:84a3:f348:fefb%7]) with mapi id 15.20.8230.010; Fri, 6 Dec 2024 14:10:45 +0000 From: Cupertino Miranda To: libc-alpha@sourceware.org Cc: jose.marchesi@oracle.com, elena.zannoni@oracle.com, adhemerval.zanella@linaro.org, Cupertino Miranda Subject: [PATCH v2 3/3] malloc: limit when to allow to free chunks to tcache Date: Fri, 6 Dec 2024 14:09:21 +0000 Message-Id: <20241206140921.139205-4-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241206140921.139205-1-cupertino.miranda@oracle.com> References: <20241206140921.139205-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: AM0PR02CA0174.eurprd02.prod.outlook.com (2603:10a6:20b:28e::11) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|MN2PR10MB4352:EE_ X-MS-Office365-Filtering-Correlation-Id: 77b1efce-b066-464a-ffd9-08dd15ffc6ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|10070799003|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: drnNR4Jq4HliCZGOCTi255DVVVq2FT0owp/MQZ5NkeQCBzf/ZVvB8lqyMwGFI5QIfqg0nqmF0q09onsF2VvFVMfH+gPkUtyjKI+iYVVB7uehw/VSI3BC2jFphX0GCAUiKS9v9wf5STfg48VIFWNi0oa1dk2xAIvYRbo4Lqm/hQTntCdsanvWrDZ9ltmRed+HpFbedrK01DC3408kf0dyJqaTWJtEqL1CS416tx/Doyhek5NvabFG6bidi4FsGiRtOUophMP4iNrGwArW/Ubbn1Tw40vBbf7Xwp86Kj0cqn6c2AJWglL8hd+SMR3HSCvqPV5v9AT1E9WN9h+C76eHDvkjxbcXxi9x9acU9ygsxrKTBtU8gRh2/3UNq5jwbZMWecmrAZv3M/3OUETN1ETKmnMJ/sL9ZY4ArJKmh0Oow0woX+eLXV5UmMP20WCDeAlzLjTy5Tly6eQUV4LVdjPSD2kcOuc1py+JpoLQMgLVDRQDTUifhW+za9k9hRdKLP/VdsbdaWIUe5dkmN7TbYhB773XjhKyQSsZS9NFiqRHquTUcrH/6sVMbHkoowQKBCfqz/MgGGXZK/JJJMmUhUn0BhvJMAn+zxZykXenMNSJwJckMNMSc58F/bAH38Cbtzm6uvLt30UjbcIOaTD6U8gLGWh/gbRPYdRHQrTHSx7ZxIbj1AVq7N0dwjVBlxhkDhB5yxVrFL8Vjn/XeIbLN3+SBw1KXK+BqpTctn1WUYQiiiOLd+rszRh9IjYa7NrA7ZyS/Fq2I1tFcoA6UKYnq3m0Q8tEif/u+hlE/r0zeFjNwQl3XtmDaDjisJQ8dRkfRByVlwf6edp/crOWRGWNdcR5WK6IjnN9lEsrGOPm3IPzYO2BnTg0DoLYhbQxo+UbFUHk+Mz33vjYjVTN6hzdoUSKE49KJUY1ZOjLvA1kOFmIIR+lVaCIRfFl9DmhYtQkhk8oPTtQIeDVfZGXMUn3UW3IiroCOobfme2HcP0q92bKpT6R2WIvVxEPKlTTftJh8CyS5cLn3E0QyPAu9jTI6kWfP5BjwhxlZxhXuaX8igBkutEQbo/U4j5kXcDEpWoeYT+vhUVIx7SXRougL3+MxU9u0cg1Chmj5iDFIHG8BiuB3YzWS6tBFQkNGZ4GLf77cg8qhC+oKLAs1yfFI8T/MrYDztFrNqmEDNcnSgDV6jCATpjXiWsSfym7Q1J/9y34ViTL4BLhzhaDh9d6UgBfvyQ6SLIwAiEf1U3z9jghBd+lgdx7W5bkZ59vk9E9ofdVi1onVfKtOzkYuetufdG7wDlhFmeeNLoYFZWhOa2wqhMeYFeoqwTxYBkNz65EMg9KyXMQk2ceb/HJgpO21no7hEYmYg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR10MB4382.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(10070799003)(366016)(1800799024)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jh/lkaoYFVj6qYLUnh96Va55l36yK+lNIbb+HO21nLqiVPiaDJVaAwDJdaLFlXn1poS7zid/d5CAqRjTTkk2TYijRaj/dd/ixRlkgfBOBH9yfRhi88rWyFhTgJPE5m0ZbozdwQjFF9pn3dEY0oqWlh7vSAGtBalONmJ/oENigYN8kaaRlxa0tM9Fyo4xiVGdFSjzEWoF7j1ZfJ5VS4T/Z6bAlqDJlTj3NqwPdVWz6kmFogh0hAMVp4jLdEDveapgmopPEBpIyk14/bFeuK9DQ+j3eqkrU8MHrBrOIdP4yA68NfuBwdWgQFXmc4EZIFt6EMLh/MNAPz0i6xjjtLBaOwUn2oPqYPAztnjhV8LhLxdEkM6iQMh/ixqsgWxSPACwM7k5fmib5O3irYi2IQ5SVMIbnDiPpIiM1QXBEFGB8I9E/0hvcCnG7Sg13awynN6xL/p5Rjfj6zolyGLu3aVX5r9e86ImqjCAbl8PednaTigrnJct4c8ZOimlSVMElZgbJditOogIZTOXg3hIqKfy329zLVyGfwcc0SAjbRceBs1srz23WKX4OnsTjDgris0VUjHNVqlXuj8LkF3aoIyNBMkRCOJGzetdBYP8sbROVITAvpuDDdFtK0MxW4jaRNKqwKJbxh1q9O1Mhgv9R2pX3QRPYfzW3vaw6Euxy3zmn221CHDU8pb3yifs/XuPISrka8GCMD/KzvlkV43y54Ui6WcrM9iPdiYywHcIgi3rPJOhif8ouNoQ9DZlMw6m2FWid3inDld4m5owNpfx0YIUkQcHX5TjCFmYNwqSkFE6LkN1KpYMeAm+Cwkd/0C1gAJJrLVXkj0TNVBIzSIBZjkNKngHbMpfFY50mt1szWP8S+3sKSkveS0h3uWS7a9GeQPyEniGadJyaSEOFkbBzlv736qKipgE6D/tX5OypwkEjZiGBLTNN7VFzO6yYcqETCX4UcjwNYY32cJ+slSXSsbLYXmHcGOnkO2WuO8rrv4txtN4w8onQjwfmsozBHc+sF64Z+MOqzL53jjYuyCWeGCD+kvhuyBULDnazjt7CUvcntuUBYSQlVaNyl0E2+eX9Z8sP5QrCqAc0J+hEymmQ7uKqVLNk+YZwPYnUhIWJw6ylzI7FO9np6jHqLktKq4lfcVx86VfTHzV2njMuyO79Ok7ed9pQ0jaIA7/KprCCorBhQvtW7UYuBkFF1f7rHz+loywWXpU8L1CHv4mVUypHE5vasMvnYdlqXZ2gNDIq1LcKrFNmYFi+V/pTAlruh+9BDz1bgXzqAgz1uVAODGVjmelSMQpQfHKvnSXrAC1t+Dhk4BjXBlDmvsqmPG+Hpb/TxmeNI5ntn6YO8jwU5tz97yKZgkYeHvqVD6rC+4KsUZPC7GjrjGrIdfTFpcKEA9vaimBs9jzKx3KN6bNenJpHN0i0VwGo5Y0tHFcRrNZ5QaXjHPCcPARsExJV7cH1ySZqzvLQjN5dymfYgIlbVd9K+rRre9KPolCiqjT6LOkXTRlrhynezbee6b9WL+Ltl7bYqQbb7zDQoxZOJ5A7kG92tKxQ7RvFLeOWE2ByJb1+LlvUbuqoBpMqChWjqdcqzHfKjhmvGUZJGZkl1ij3b+xN/Ya/Wdwd0A++o2p+VCtxbDTZmo= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: zb+Er4kOIlx3syP5gHD0keTOmvVO4E+BEeRibVzluWZjLMhTXjxhJXJlSzqTA9Ww3F+i810wWs5yky4/ta4aQYjh7TF2//4DGe/LmNl3pBGKYoUFem4OFwI+3LiZnri6m7wjJTpjO8Y18IEZhWIfTdlgMzFkzD4P4HPjKLQB7RX5gOgo5ZncqE6MX+kAX2I/WITL1c4HHtz5fMqydVINNikN3dSra5AqZYrNdovJk6Vh05WZqUqBVMViQQAscBzi7OKYxtG1FTUvNJ90DegsV8PjjWs2TFcBsJ3TX1qUY8VlVZ+FBIPdPxteF7qbcBGmHLGs41FVPT82bfQf0G7yKnh5RsK9/NkbWM+hkMHm/wJx6kNW7NQ7yirnoEOt0Uhi8UmN4byxhovP5VtP8FHd7oRgP43TqqTZ531A3BzUSu3HfgyUDi2sudHuz6oZelUAnJ3Wzmf4KsJ+8ukv5YGkVdHLqlPh662hJA4qacdMPAmJgPS42h3FfvtXfdA9T95/FJ6nAMrZm74Mgb9nQIV0rSQ9pRPsqhtp8tNJIuEZBe7pNSAy+t3U48h5nQaAyXsdFVjgMdrp9mrqUQr9v412VX2sYu8eFJUHREC8++4RvyA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77b1efce-b066-464a-ffd9-08dd15ffc6ac X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 14:10:45.2722 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8xTZxRg9zdZlf5/THVsKIzerG+hURikPsqnb4z2+p1Ea6Opw11ttaVYlGxY/FTyzuJ5NZQKu5yJRr57xgBWiTymJBo4oG+g/cWNgM3cQuvY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4352 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-06_09,2024-12-06_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412060106 X-Proofpoint-GUID: iof7C-G5YjgaHDP_YeXOIGmwhhhDslDE X-Proofpoint-ORIG-GUID: iof7C-G5YjgaHDP_YeXOIGmwhhhDslDE X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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 There are internal calls to _int_free that should not allow the chunks to be taken by tcache. This code introduces an argument to _int_free function to allow to disambiguate when the call is being done in a context which should not allow tcache to take the chunk, for example, when top chunk is adjusted. --- malloc/malloc-check.c | 2 +- malloc/malloc.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/malloc/malloc-check.c b/malloc/malloc-check.c index 6ac71df5d5..db0f6e33b1 100644 --- a/malloc/malloc-check.c +++ b/malloc/malloc-check.c @@ -235,7 +235,7 @@ free_check (void *mem) { /* Mark the chunk as belonging to the library again. */ (void)tag_region (chunk2mem (p), memsize (p)); - _int_free (&main_arena, p, 1); + _int_free (&main_arena, p, 1, 1); __libc_lock_unlock (main_arena.mutex); } __set_errno (err); diff --git a/malloc/malloc.c b/malloc/malloc.c index 642cdffd23..05e5b3f230 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1090,7 +1090,7 @@ typedef struct malloc_chunk* mchunkptr; /* Internal routines. */ static void* _int_malloc(mstate, size_t); -static void _int_free (mstate, mchunkptr, int); +static void _int_free (mstate, mchunkptr, int, int); static void _int_free_check (mstate, mchunkptr, INTERNAL_SIZE_T); static void _int_free_chunk (mstate, mchunkptr, INTERNAL_SIZE_T, int); static void _int_free_merge_chunk (mstate, mchunkptr, INTERNAL_SIZE_T); @@ -2653,7 +2653,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) CHUNK_HDR_SZ | PREV_INUSE); set_foot (chunk_at_offset (old_top, old_size), CHUNK_HDR_SZ); set_head (old_top, old_size | PREV_INUSE | NON_MAIN_ARENA); - _int_free (av, old_top, 1); + _int_free (av, old_top, 1, 0); } else { @@ -2919,7 +2919,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) /* If possible, release the rest. */ if (old_size >= MINSIZE) { - _int_free (av, old_top, 1); + _int_free (av, old_top, 1, 0); } } } @@ -3693,7 +3693,7 @@ __libc_free (void *mem) (void)tag_region (chunk2mem (p), memsize (p)); ar_ptr = arena_for_chunk (p); - _int_free (ar_ptr, p, 0); + _int_free (ar_ptr, p, 0, 1); } __set_errno (err); @@ -3828,7 +3828,7 @@ __libc_realloc (void *oldmem, size_t bytes) size_t sz = memsize (oldp); memcpy (newp, oldmem, sz); (void) tag_region (chunk2mem (oldp), sz); - _int_free (ar_ptr, oldp, 0); + _int_free (ar_ptr, oldp, 0, 1); } } @@ -4902,7 +4902,7 @@ _int_free_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size, int have_lock) fast path to free into tcache. If the attempt not success, free the chunk to arena. */ static inline void -_int_free (mstate av, mchunkptr p, int have_lock) +_int_free (mstate av, mchunkptr p, int have_lock, int allow_tcache) { INTERNAL_SIZE_T size; /* its size */ @@ -4911,7 +4911,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) _int_free_check (av, p, size); #if USE_TCACHE - if (tcache_free (p, size)) + if (allow_tcache && tcache_free (p, size)) return; #endif @@ -5270,7 +5270,7 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize, (void) tag_region (oldmem, sz); newmem = tag_new_usable (newmem); memcpy (newmem, oldmem, sz); - _int_free (av, oldp, 1); + _int_free (av, oldp, 1, 1); check_inuse_chunk (av, newp); return newmem; } @@ -5298,7 +5298,7 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize, (av != &main_arena ? NON_MAIN_ARENA : 0)); /* Mark remainder as inuse so free() won't complain */ set_inuse_bit_at_offset (remainder, remainder_size); - _int_free (av, remainder, 1); + _int_free (av, remainder, 1, 0); } check_inuse_chunk (av, newp);