From patchwork Fri Mar 19 13:25:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42681 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 63937386F442; Fri, 19 Mar 2021 13:26:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63937386F442 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616160385; bh=CRcmJgVcQb7kDJTPoZ+izeYButk/n7KGvtegjciwvIo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uBufnEuL1Jp34ns/N4jTfKRhy74oSQNpt9JclPW+V+AfGVwheISLCDwWnEl6zWCkX Kn0JXcvrtLsVrSg5d0TK9uLoSaXRUD+nBqNljvpdkoN/nb9f0rTqloqcS5aXkNjTVK n1+fZf/9C0Z2Y0UGzFU46S9V/VQtq4xVn/752npQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2050.outbound.protection.outlook.com [40.107.20.50]) by sourceware.org (Postfix) with ESMTPS id 966543857025 for ; Fri, 19 Mar 2021 13:26:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 966543857025 Received: from AS8PR04CA0170.eurprd04.prod.outlook.com (2603:10a6:20b:331::25) by AM0PR08MB4148.eurprd08.prod.outlook.com (2603:10a6:208:131::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Fri, 19 Mar 2021 13:26:19 +0000 Received: from AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:331:cafe::87) by AS8PR04CA0170.outlook.office365.com (2603:10a6:20b:331::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Fri, 19 Mar 2021 13:26:19 +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 AM5EUR03FT021.mail.protection.outlook.com (10.152.16.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Fri, 19 Mar 2021 13:26:19 +0000 Received: ("Tessian outbound 10f3eddefbbf:v87"); Fri, 19 Mar 2021 13:26:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c518ac922aa0e3da X-CR-MTA-TID: 64aa7808 Received: from c38759783d13.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 40754298-AAB8-4CE7-AAA6-2731FB148A62.1; Fri, 19 Mar 2021 13:25:58 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c38759783d13.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 Mar 2021 13:25:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e+OX00w7znuxYcvV/jsOhaF6bi9B3UUVme9kdvDGe9ZgFMEqFtllDf3W32CzsGILUqxx1DiASjAZzhU4ynTBC623sTwkx1afcKT19ZOmkSJocXw3/a/SfUVXyiTNtqMZQr55cTqkxOpuTKkE5i0C+96OvXbrnJtDoNWVXpKy0zgA4XTcqgv8arLz4MA7A2E3mRbS4K28rJJ/2sdW09vqFuLmZamcXfaB1V7H0cHf6jYeWpJ0h6fAT7lwCsEdlBUL6mZpzzZg5+nYiSxfkBwN1DZ99KsXDJqHX4pwR0Vh7attYHwQ8rpaYmaV/h4tBdcX0p1UaySdwwQMnc94L5rbew== 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=CRcmJgVcQb7kDJTPoZ+izeYButk/n7KGvtegjciwvIo=; b=k1PA1xb2rFuQFyWmenF6D8H2d25w8+7WzK4hrEsayDkpsMydbo6tVTie3XICUnzaWrMKlQS1jkUWOa0j/KV274nzFOVeq3x0b3Jn69bNPsmlzan9BJBl0WNaeh4AXgBlzPoqrwDsb3gj95wT1J5azF7Tv/dzLXQFIRzgTlRh4Fcp8iSKKrAFjo37YoWMs2DOT+3xk12D3t1hU5IexpCI55Bk6oL5AZZKF5rwzZOxFvk/Wnxug9BPtGXJDXmTUWGb3obbXUytaWQ+qdFXSOtuhPV0LwrhHSaHyj34XNKYqHkEFFbcl0cvuRFZjDnOT8F0gsmo6us7ev/Vx651xspPWQ== 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 PA4PR08MB5966.eurprd08.prod.outlook.com (2603:10a6:102:ee::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Fri, 19 Mar 2021 13:25:57 +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.3955.018; Fri, 19 Mar 2021 13:25:57 +0000 To: libc-alpha@sourceware.org, DJ Delorie Subject: [PATCH 0/6] malloc: more memory tagging optimizations Date: Fri, 19 Mar 2021 13:25:45 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: SN6PR05CA0005.namprd05.prod.outlook.com (2603:10b6:805:de::18) 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.49) by SN6PR05CA0005.namprd05.prod.outlook.com (2603:10b6:805:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Fri, 19 Mar 2021 13:25:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bf833543-b742-47d5-81ec-08d8eada94ae X-MS-TrafficTypeDiagnostic: PA4PR08MB5966:|AM0PR08MB4148: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: jg/EsAuLf30j7Nx/5mQKLgITnwelfwmaCrQqcnqdaWYMYhgOt/U0SxkBRGWCTo0T7uJp2BMd08NaEjKIENYlNMfubw63giITK8Iki7LUoajRzD1TX4xalVV/COEiGTs53K5XczYHXaK9Q9pDcwUXgV9nvSfDKgvBuAd3aIbtq9UxbLRRqWH4E3pA7ymG6pERHFxPE4n6V2neSwIHPEaJ8DlUyVif++DZZbj53hyydq0sxsgLtXHucqjA3W7HafyxbeF23/9K74RVXY04pi8YCGMLUpQHLv6PZruws5x+DQzUfhXXzF0oZ27ouIaTvxBHyfQQp7WSGE3yd7F2slQTvEZwUe8K66aFej5C91TSquoFe6r6ARr3C40l/EwDBzoK+QBE5OYlQkmUysSXxBVCRYYpU1o8jAMTGXHR/OLPAbXRjnjIOKB6EpE1mP7ByPQ/0BRzzG5NUifMDi9casqXIjL40WlcsFGGFQPWJoUYAQEP6L2XOwEzWxNtwWUcrEag+xPYWxhgjhBkdLk+w/Hw49fQHL5bc7Rz+USuFzBsQXvnCmXajnWEtgLIDyRVKkRMp/cRlPrHdcPRsTjjCKNvnOGW9Gj80qLImBNjzOD0UKdy2J/XGfWyJujFQF5eQcUIq4Mz/05opPpBamkxNpp3OmkHuEotK3XpLIWsKFtCWJ+qJvLYI4SHDim3t7GSy+7Y 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)(396003)(39860400002)(136003)(376002)(366004)(346002)(2616005)(6916009)(26005)(316002)(36756003)(8936002)(6512007)(44832011)(5660300002)(8676002)(66556008)(66476007)(186003)(2906002)(6666004)(6506007)(66946007)(69590400012)(16526019)(86362001)(6486002)(83380400001)(52116002)(478600001)(38100700001)(956004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UmW6ikPhixjFpN02zFWJuUugcFEerThmtazBKIxzSv+WXm4+u4U/4/rP22QNVQpsJzuYvZuOpv64VrS+sV0l3A48sl20hxX3+gw5HdS0WBSw02nnumsuFgrDIX10R5LSDeEGPFnCKu/V4GXRp7uujscVtzZaVWgHZj/OG7ersMXHWyVe9YSVUNuXVB0FC11QIi2AUEhQLSfwkAH/RqB9Oafg00kfZfpU5u9JRzAQgdOlAWCEV5Bhpp4yPx+hptye68Y49ScqZV5tFQRgF9eNS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change-Transport-CrossTenantHeadersStamped: PA4PR08MB5966 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: AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7181d08a-94b1-43bf-923e-08d8eada87be X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s5XxNy1JNdnHTE8N3O/N55EZjKQi8cXMFWaTbLCD5OYTuokPMvw3cH/ItoyTUdHqV51TA5vJFW8o+Wnu+MLpRrlNxzda2CEJ4ne97cIeKdf2If9MTPRmCqHin/1Bwn1GlovarhnFSWBxFlXunuzsdJixNFyf7p1PieNLO0ntwLO6hg6+otzoNdxrJsyao5SJaXU1s3NZOh4/opM6IxG7x1cMgScMrjLswYoosp3AdumPQ3sUMVEMxokuXsPsPU/7KmkDD5UDMk+bqwvf5J6U0a64j5yAdmR/C6ezCsKmJGOWaaQeJm+ctKwW74R25WBxbKFUrGS3RCFIJs0E3CS9YwIX+KB6kpSDtfHZ4Oq2IYtqRPQ0MX/KkTBG1tHWiMA0RnmImu1xNdVG/30+uml8hQF3L3fXzl1GDDYsIFVk/2Nir9GdAr3y9Q84ngiAeFasiIJfMyCg/g/KyNb7DLz+3awLTB/1vsawjG0ehEtkUIeiUvBJj7uGIGIxuflt1VP5O/I5x2OBa1cx+HWZJxmTxqncakU8WkXixNdcng/qUXodKGdtH1LXuo8T1pwHHkhkw2SiRmHp+p31fE8zYvTk26/pA5IcnTxeOrZxy/RmxxLQQPqwGRY0OKU/9NBERpYU02yFi7A3qoVaw1v9q5LUm/2wiowgdOL0QgDXUicwigKNUFXVNOPx3P45l9/wMn8q 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)(136003)(376002)(346002)(39860400002)(396003)(36840700001)(46966006)(6512007)(44832011)(2616005)(8676002)(82310400003)(316002)(356005)(956004)(478600001)(83380400001)(336012)(8936002)(82740400003)(26005)(6862004)(36756003)(186003)(6666004)(16526019)(5660300002)(70586007)(2906002)(36860700001)(81166007)(70206006)(6486002)(69590400012)(6506007)(86362001)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2021 13:26:19.0570 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf833543-b742-47d5-81ec-08d8eada94ae 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: AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4148 X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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" Second set of refactoring patches on top of the previously posted patches. The two sets together are in the nsz/mtag-2 branch. The main changes are renaming CHUNK_AVAILABLE_SIZE and changing chunk2mem to not get the tag at mem (so the returned pointer is not suitable for dereference if mem is already tagged, but that turns out to be rare). Further changes considered but rejected: - remove tag_at from mem2chunk too (mem is often known to be untagged, or we can assume the internal tag is 0 and turn tag_at into an unmask operations). this does not seem to have much performance effect on small allocations. - don't try to use a new tag different from the old one in tag_new_usable since at most call sites the old one is just the internal one which is excluded already from tag generation, only realloc benefits from the current behaviour. this change would be a bit aarch64 specific (tag generation can exclude the internally used tag) and does not have much perf effect either. Szabolcs Nagy (6): malloc: Use memsize instead of CHUNK_AVAILABLE_SIZE malloc: Use different tag after mremap malloc: Use chunk2rawmem throughout malloc: Rename chunk2rawmem malloc: Remove unnecessary tagging around _mid_memalign malloc: Ensure mtag code path in checked_request2size is cold malloc/hooks.c | 13 +++-- malloc/malloc.c | 126 +++++++++++++++++++++++++----------------------- 2 files changed, 72 insertions(+), 67 deletions(-)