From patchwork Thu Mar 4 16:31:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 1447437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=SQCGKBsv; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DrxGQ2nc5z9sWY for ; Fri, 5 Mar 2021 03:31:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 75D9F3892447; Thu, 4 Mar 2021 16:31:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75D9F3892447 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875516; bh=BoAYnFdLSsOq96ZqNyJwkrnbveQdMIGdKny3wIZH99o=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=SQCGKBsvHQgNT7a/W85fViWUU5U3Re9ZhazL16HzbSo6ENWtWFiqxNmflj/T620pm zQeUU3bhdReg4Tp5st3kkkbZRbIpzK4ksiUdVAKB8uz9jiWW1yMaXtd6eNLNmiOqw9 ehKlNmaiEe+m8NaYeyKJMQiN4Q5jLiXvEViDCzsE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2083.outbound.protection.outlook.com [40.107.20.83]) by sourceware.org (Postfix) with ESMTPS id 61A883887018 for ; Thu, 4 Mar 2021 16:31:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 61A883887018 Received: from AM5PR0202CA0020.eurprd02.prod.outlook.com (2603:10a6:203:69::30) by PR3PR08MB5802.eurprd08.prod.outlook.com (2603:10a6:102:8a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Thu, 4 Mar 2021 16:31:49 +0000 Received: from AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::2a) by AM5PR0202CA0020.outlook.office365.com (2603:10a6:203:69::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Thu, 4 Mar 2021 16:31:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT015.mail.protection.outlook.com (10.152.16.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Thu, 4 Mar 2021 16:31:49 +0000 Received: ("Tessian outbound dd71fb35fd76:v71"); Thu, 04 Mar 2021 16:31:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f0ebd91ff4f5cb70 X-CR-MTA-TID: 64aa7808 Received: from 1a548f8db80e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D8C6D10F-537D-4E2D-A658-B77AED27D553.1; Thu, 04 Mar 2021 16:31:43 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1a548f8db80e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:31:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZTE0z8cO+G233wva4hT9QsJvptdtp9ww1hCwVxdsIB4PHSdvRHWHdyo7mTRR2ebRdrnZdNizqjdpE5PjbPLwEu5fdNX6O2QUIlsFMbN0PqX3FMsU+aZlwPWsMipqDUumpN0f09BYXrJfyVarri8j803N7RBGsS4/L+wpidPOoGVY92Fg1Hdsboa/ENlsEraxI6tNuqkbzpNL2BH5dzPDsdSdJphpodHYLdxEQiTpeGr8KfQJUb+O0XkrDUaYFLUHFi6HdOF3hOVd+MDN+6LWC1IFaTxDvaUo/NG1vLNm0DFLZjsCu2wAaWJiztSfZaPcD/qFb4NuWYvFskDlRYxiqw== 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-SenderADCheck; bh=BoAYnFdLSsOq96ZqNyJwkrnbveQdMIGdKny3wIZH99o=; b=VIUKj45Pcckt5GdgEfytByGsP3dZmEIH5/OJ98fBV5hSLeO0aXSPmtEc/h3wgnVv/6PYfS4jWwtFAviK5hgpjloHGFVp8jtoSzzSd9gX0qjm7uuWdjeS/ZsTMaLBeeioVGq7iOmZNvH2/nKjZR9dWtxt3EZyQLvU6GQklXF6JAPJe8sGu1Agk2n7uCxf0CnExlvHRzrajnPcosewX5QwIseFe4+kDpm9dqHQvxG4DIRqEFk4m+lejuq8sXn4Pvb/FzKDR9wk+LR9Ck5RljHJ4ov48R0sMwPcVgvzsopvBc/Q5t0vZiFUx7SQC2QDVMi0/Lnjfw/hpmpdmclpnWG58A== 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 Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PA4PR08MB6205.eurprd08.prod.outlook.com (2603:10a6:102:e6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Thu, 4 Mar 2021 16:31:42 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3912.021; Thu, 4 Mar 2021 16:31:42 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 05/16] malloc: Avoid taggig mmaped memory on free Date: Thu, 4 Mar 2021 16:31:36 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO2P265CA0348.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::24) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.55) by LO2P265CA0348.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:31:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6d317948-4868-496d-b4b7-08d8df2b029a X-MS-TrafficTypeDiagnostic: PA4PR08MB6205:|PR3PR08MB5802: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: eBDW+LYsl8bvHxZodqmjy6HiSbxsH+fq95YevKiFIyU393LqmIHG1tzfGlHv/4adkisvTvdbFtzPTFp8FvWk0WyKYw9ADvdYdPN0ZlCrx89oNdYaWrE188ih0Nj4KBEhuC2cw4dWSsaJv+eAyJZOn8UbEoLtO4mJKdxXWsQouYDxwDKsbCEa0djCbj5bEjs8OE1d1uI6M5E+O7XcsrMrNgLeU2XJ96Wg0a9mGiWJUF/fL1tduHXw0cGL/ycNo5fhV3c7kTXmqwCofsFumyXt2lhrtWEEPGpGW14pYJZSTPtHtjsMnTdw3uGg2Y+ig+nIs5jVbZeGaFDKBKjRiAUMndSsizoo6mg8UAn0Mh4IV2BhbYXNpxXdc7hAyOb/OQ3MO9RChYe10rWzk0kzvMG/sSv5o84Y2O70/Jj7ZhyYr8fq1OO06HFfa9hxJH0Si1xX/3cwB/ddXE7+uIOFcjn095h4zr4lf0EJF3NDcA+89UBL/o9h+IAGf8+YE599vHiEAUwejMo1U/BKwpLs+v5xgYkojYt/XFPdIOQ7tgapu4ayaffJNHsy4YkDtJ8bbCzQMJ/OGKjZJKM7/zdLXMNQKQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR08MB6320.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(346002)(396003)(366004)(39850400004)(6916009)(86362001)(956004)(52116002)(2616005)(44832011)(6512007)(316002)(69590400012)(26005)(66556008)(66476007)(186003)(66946007)(6506007)(16526019)(478600001)(6486002)(2906002)(6666004)(8936002)(36756003)(83380400001)(5660300002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aNNp2mkeUNEMrIJRgmhSkKqOCGdjZV0XohmBMzwrdK3pEQILEE4B46CWGTF4BaxtVpuQm7IuxCqmbImKmR/H0/7P8MfK0tENv/FbXE/l5+0f68lURw3SSrq9K75r87GRrEVIfUyojWieJFhlIs2LqAXlhaY6CFtv+If0tR+ewYgrF2B+phnedIA2hhAGuSYdHO36SHIyJf+p36k/edwsh1mbiOsT/lJPat+TMAtGMNaxwofz4hQbAkjDYli5rrg+pqrSDJaUUiq8Kj4pFta/tRSnbc8aRtcFIu7TtK5WGdTFUJmP0e8DqBefmajiDRfYaTIqOtxR+pcSpVJSl6H+HSaDJH3A13gRqGVg7KoISx1E43Y+jY67zkCbLi9DwTyMqXEAwDXd1Y4U5nvW/A/a3BccMm58/AEKsZZKJvxqobHqv38mnJ8KVzduW5v00PD9M3qZRjiBH5PCMmEJkcCAy3cc1ARS0JfTvvO81zCHOcdkIbvqhWk3XW0Y7n9MkpnY+Rjt9heP2BaMbr/uNOb8I5DMA1PGRlv5vZDKXoBnG5qvFskN+6S76CTYRc5MV+u9XwSGfBj8I84goSGEVPdHDeds4qd5WgkWsevUPvfkSVbpK+203OpxVmXOQhUxlgCeJYpTIGrQWx+2o7gEaNZQtTF24K1ZR5ZHXii8CEF6SZjzA2uUvgicGbOSFC2fUdqdvLD49MxaEBUqFkOrsE0E8u12lnmGwnM7lap3Z2aQwIHjzFm0jJqEUD9FPHPtLPF4VsdvD3J89yNrsXeJl/m01vkpaG4/9cI8cKx53SwV5wUV6WNUXVDtUMv8Uyqm8u+IWG5ufoQaPBOVwoLJN+SAdiigNWJjCgiiywr/VjXtoo5a6MEiI4SFQEHJLKBeyyUkqfUYLS7RMwcc7tvBvTxU9URKOkI+lhOSg0AuRIGgj9XAdG1daXwGt1Y3TIRhekUtYUb8N2u/p638X/HhiXT+aTC6njMdYCfIChR2ECJLQxGhlR3/8rBmgGcIE1GoqpPC9d/s0QPAm/Kk3k3XzeoWjcRKE5/FvYxZF6pWxUlFFgyDDoDKz4lC2JNtOLPk4k7RTTY48FGvwX9cr44wpt/e0i0ZaU5yonSUSQ3eTwbrKCHa0jrRgOQT4BSQ5JXD2YIeLuadCHPiu5i87bRScOUex1o20Q2/+MctlKjc16X2yXagX3YCZ3GP9e+alq1sY5fuWq00mT+9enLEKBz6LV0nnCPmwaFjuhEEd2N4uhsnMN4gPtfUzn40uhikF/QIHHIeU8NPZDGADB2l2yaXthPq8JiP+x7Ppi7ITzXDURLm5KV/EE5TUNf6vQKIxMgQhm86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6205 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5dd9c944-2d6b-4c81-450e-08d8df2afe5e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hmilt5rcZ3zp0Br0yT1XRiELzMrvhChSCp6V7AXle9ASiL1v64DJyjKHYQgmQwqlzOh8gGe/CCXljrr3hFIdPK9vQB7E0Q8ZSY9Zii5FHlB2Ig9OvQ7jCRBFx0aDD/vp1f50Z+esJ2BC2YyizwDUk14P+Kwb1vETszvtlQ8eZWzoh8Pb+r2zfiTlPP/UnLg6q7DTH1+OIqSonN1/OeyhmU0yJzTFoQ3BSh6B1AyNF7/9ImzsRs1QGSILUnUq5PNIUfatEjQ/7Hx8m5goTX//APbM9mAGcsWgjOmOl7L/VCbsvXTsUpnrMqDz2Ho3rtqZQoodBRBBLXG6Z2/hGq62ML5E6h03xbUQs/brs6OelABFHxHwc9xbwF3/MJytWRAWHcQtX8AVmXLKZNcA/zf8sCO4bKXrkEJj1LlaLW5hoDV5DCj5elVpalGLkrU2cLibqL9Fwx/5I1/FzI7UbaSQ62o7JQhVIYuHCtVjHlJAPzvBCBOYBNTMxxdhuhrNYVvhN8KHdvWGMgp3xWPf6GQbODs81E3Out7ntaeP6POLWqramhlyzzofAuVE1wcvJukFaXDa/SOFEsJ4A2PIWo0VOAwPm6LZNTA3v3kLcOG0L5NoEaoVeMcjOnvs5StpwSRxXPCl6WjPXSbh0wNKZEJ/ISaYA7pgDpmmBkVe/dPSOlvwoBZaX/Y6RskWuy0gDB2o 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:(4636009)(396003)(39850400004)(376002)(346002)(136003)(36840700001)(46966006)(336012)(6506007)(356005)(5660300002)(16526019)(36860700001)(70206006)(70586007)(26005)(6512007)(47076005)(69590400012)(478600001)(36756003)(186003)(82310400003)(81166007)(82740400003)(6862004)(8676002)(2906002)(6666004)(8936002)(316002)(956004)(86362001)(2616005)(83380400001)(6486002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:31:49.2666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d317948-4868-496d-b4b7-08d8df2b029a 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: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5802 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Either the memory belongs to the dumped area, in which case we don't want to tag (the dumped area has the same tag as malloc internal data so tagging is unnecessary, but chunks there may not have the right alignment for the tag granule), or the memory will be unmapped immediately (and thus tagging is not useful). --- malloc/malloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 4538a01614..b4c800bd7f 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3284,9 +3284,6 @@ __libc_free (void *mem) p = mem2chunk (mem); - /* Mark the chunk as belonging to the library again. */ - (void)TAG_REGION (chunk2rawmem (p), CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); - if (chunk_is_mmapped (p)) /* release mmapped memory. */ { /* See if the dynamic brk/mmap threshold needs adjusting. @@ -3307,6 +3304,10 @@ __libc_free (void *mem) { MAYBE_INIT_TCACHE (); + /* Mark the chunk as belonging to the library again. */ + (void)TAG_REGION (chunk2rawmem (p), + CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); + ar_ptr = arena_for_chunk (p); _int_free (ar_ptr, p, 0); }