From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id DCE5F3858408 for ; Wed, 17 Apr 2024 18:44:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DCE5F3858408 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 DCE5F3858408 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=1713379493; cv=pass; b=OPzhpGFt16gaxkQWsMAWkM/iI15ueBhTRp0Cno8+wgJ2vdhsjHmU5cdJ6WJHXrOZEOLOfBpvLoZ38MKSEG/ezv3PY9VWzmtBnfwwROp+iL1lvzULr+RCaRexqTe74k+CpsyZ89YDF7Ir5186xtEo7T7wN2WEsy4t2lXUYcHKkAA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713379493; c=relaxed/simple; bh=51ucd4e+7ZUhYh8H/ZS8zuZNqrxP/hNpRV0kh8gZMDo=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=ubheVjpoIwSaYSHW4EFMtYI710dFq4m/EzGnoQX1mQ4Scak+SIbZRtmnd3CKN6mnE3vAOKEedQiylEKH5k81Nx1c0Fq4DgSY4isOjf1RzHZud7qyIY/iE4vtSZ5qDv1Yvr7Xjgi664/pLTXK0q/7jopDAiwF5PToxPuNB1uaDtI= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43HHiVQl006061 for ; Wed, 17 Apr 2024 18:44:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=+RMfRtm58IrhG5jea0gDW+zPcXZPCu6WxrZliMABr84=; b=CtEVvZfavDmZ4LTy+OdxuF/UBnTnO3UtbNwsqx5i0q6luORZ0FsdjlBd8W0w7/j7kh0D 47vU1qxSravaHRJNC2yGDANp6tNrhIAWPAeMyq1EdqRs+9JUXkTVZbSIb6WVM2mAGurh i7UlZ1x65dvikgtfsVcfGPkXJnzj8/lYoPArdgb8YjNJk0QeCZvqcsrhsrARXWagdAKH SSJg/NsE/bj/d90AAidUtLJGBYmcelGL6/4zcr0mXoBj+1Eg0K5bsjtC5wZNCM4yTIcI b1A9QI7h97LlImbNBI43AoIqfVLNqUC5jGGjetqd/QPe99YqmSw02yegMUNY8MZ5v9X9 bw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfhxbrhpf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 18:44:50 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43HIdJJV014525 for ; Wed, 17 Apr 2024 18:44:49 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xfggfhey9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 18:44:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kl/wQBNHrpFIieI8sIHqGG3a46EmGjPCfeWHbH+0H+iRyMe3XhdaqQWFZftP286brdVKqxJJX1i7mP0vtiQySuFJf7WdYrehHINDGG//lg9hDzNPgAnMmf6+0mQih5f0yFSNbf9qBHEASq+gWnOO4IQ8udI2PHkt+AU1h5iaf56shx7j7ZYGqi0c8Q01NSEj50q+ZznJYX8xmCB6fv+7RUsf7DTEy/+eMlFROvWC56zmjyZXUw2141aaoh38885uPQENfuuimnRwRXN7FthqjZj4+cvkrtv34UyqxQHNl8c5HAfloNyiGhGBexowSesiwJLd2N44pW2u1V1X1xKAdg== 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=+RMfRtm58IrhG5jea0gDW+zPcXZPCu6WxrZliMABr84=; b=gsh/ZVpD8AcLASdbiBCuirfNED8WioeiBcSEs20AunUHYvpa6UHkfrOxi9LtBZbCjvWUbeGjYYcbtW8SeWsySvJdiInYArWz2YwZB6L8uQVk56HaOvkQXYXKKi6EIoYM2mCvZGObV5olXuOQ2S3Dp4pmeiBUNSRpcDDmFB7HMe1+USTYbV0TbaH0uL+cuhCO+WQApReQvKvouTfdgseMKWNT6HsaaVvBtrnUspEsZDbeyzN/Fl6GRyDLR1R9pIsiri0ixMzR+fbgbZ+muEUzYipr6TaggLDFH2kutUegwq+0jd3oDjz4/sm2j9eq8bqqDZ/0MBCTNgDiFp9HjWeKRg== 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=+RMfRtm58IrhG5jea0gDW+zPcXZPCu6WxrZliMABr84=; b=j3EiXUfI0ozyG8aJNbcur6eG7rudomcvzoqe81rH/w+AdvNbm2mh+hVzd9MA/+tsLO2BbVXOYRqVtL7Ptz3o9AEa9Hr/7AVRn6BNv1Z8vgZhE/IM0Ap3RBptFcJVC/qLU9qrktS1p4rpVxGlmlJAf9DwfJKVGR5IReoT6e3m63Q= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by BN0PR10MB4856.namprd10.prod.outlook.com (2603:10b6:408:12b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Wed, 17 Apr 2024 18:44:47 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c%4]) with mapi id 15.20.7472.037; Wed, 17 Apr 2024 18:44:47 +0000 From: Cupertino Miranda To: gcc-patches@gcc.gnu.org Cc: jose.marchesi@oracle.com, david.faust@oracle.com, elena.zannoni@oracle.com, Cupertino Miranda Subject: [PATCH v2] bpf: remove huge memory waste with string allocation. Date: Wed, 17 Apr 2024 19:44:41 +0100 Message-Id: <20240417184441.339037-1-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: LO4P265CA0263.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:37c::12) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|BN0PR10MB4856:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a90e05a-96a3-46d8-2024-08dc5f0e74b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ifGZiuD/eYVs9YRIz5SILqEAu3QlnaGHuWo6QveFKUXzC1tIIPSFx88WM0JM5c1uhRzi6fhMioNAry/BynHlUjWPqqsplqwouvGH4JQfU6GmscJ92gBLRHlQhMiWGa5szaZNWV5+QY+Ll9/PYxnjXo1iOudJIx3SJivm+h1S2pf+BIKDZp19QtZ6xS41WIxerNqoKFtb2+UOQT+sp8EJWPVwNUYj+yt9jSlhEytC2S6nupHk+5/m2JGOa8Z4n0BELMRWq/kKMGr6h/2fnVj62SMjK64NWQqX5x08BiJwemKplDTG+VG7JAdBk9RQBS8EojKIjSUOjfTox0/6okfPP0dzI/ZtKoE+2l8euJt3rXHYSbqEK3VxSzztUmc1u369N35Z261+mCkyVrZM8eqU3Vy22UQ8vxsV6fKVfRnwK9b5hD+1oE/thuC0ktpz3t1pM5k5bk7BCcP/UyI1YaMVGFyhX+yDay4a/EeFW1cb9wjLZQi5Y24A1QYtgD497SQRAh4qw/9IoXVjuh+mQCM2+Nkv0n2Zjxr8i1ankfHEb645F/Q3k8fZEOWvt4jXhOXHAk5fa8c5/gMkKrXTmos+fU1Ly31+0bxM0TW9BelTjt/4MXAqDUSUoWUaIiE/7UCsblVOwjRaaw8wybZqm4VMjsIRAJCGapYtfgmGq1ShyHU= 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:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Ktm8O68NsCy/FG2n4kPJxjh+SwIUBUK/h1m5Hni/PXPt+UKswOAIGhtuXz9f?= =?us-ascii?Q?jIDGzm6xgin8jvYldwq0K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11+EB2S9fvIAgPZkM8Y5encAiyUet8ptjuzaPOm5gPyuugpRHLAilYzKnO?= =?us-ascii?Q?ZeG9c43OS5opZSVE8TzK14vXGAniaNmB2x8/4uX7Aq587LDM7nmeIaeWdt5x?= =?us-ascii?Q?bNKA055KHomemhRmHLGem5cAK5lLJZQ/GnymSpv6oz9WlYbTriijmcNAzwSW?= =?us-ascii?Q?HFJ9mbaXeM3pKHLxnohd8d7xZx4mWuIQZjTIaKoau3aEHCUNKRhU6fji5L7h?= =?us-ascii?Q?3Ty1jncri7hTPgXyZRbFTOnw4jJqDP71d2EBYhNH84Lbhp0tg6s7WKNSc0NA?= =?us-ascii?Q?f1ed2PzipRghRWlDPGhrQO/twomw5nyd4Xn1oV4N2pF47pfzGEXVrquHDMJn?= =?us-ascii?Q?o/XslhzkDzefeFosALwQmtSTKG17Rh6R1GnSV8CwneDmPORTxDQfuUKUaUsv?= =?us-ascii?Q?hT9v5N9TfhFRa0cm1tkCrpSxsgMb4oL8CqT8KQGSxjvsjFqB2UmwvgLiwZFq?= =?us-ascii?Q?2ENvRPOdvS6N7x+zCNeYrYokNupKzTd00gKrIGTyncQRMiogJ0YohxwR8wrS?= =?us-ascii?Q?wlxvDP4BtmGMmDYtCSTcuNI/oMD3+YhueYl2dkvfA6qBB0PSrE/gEiM0Fd2m?= =?us-ascii?Q?GleMxTCOXoaux645vAjrjeL1Qbngo6nNkRlMmhU8p0bvAX6FFZ4P9e6W6Jrs?= =?us-ascii?Q?YtuiF3r8Fl/xC4ABLx2lhY0=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VlzoTGdkgJK1prJ2BhockjY9VjNGlYCB6aTBNiMuiUgQDDqWAMbgqHQfTyIWHA9TDgBxYQ2s1W2MYrag+y9lpujgiXIEdYLq1TLxefQlEDQodbjQ3cqZ0xWTZpbfBU9dISVgrMDXjNarXS5ZZNjlLFzDmp5wST/i0V12/PzlT87RKhHut88r81cOM1uBKUoDTUy3TGVoyWVB3/oWRaiT3SsgyfZ35yPNej/yx9qGiQPdTSc0r0E/ak18rg0ocvpDq3DDdXY7fsuqLKyyaOX8wfSZ1qLTjzPRL6Wh57po3q2H3RNI+1tIcoqix4tYUEneGWTBXsohNzsaa/9lBunzrbj6HLP2ThQ/7hess33FGJfEVOD/jd5qlarIabZGGUhC5ID/Yy1zKBcFIkHrIkwrBmDy7eCNtkvDp27fmW9mnq6rSviO7plNXsl6x3cecEtkL3GYsNpLio5N6CVMEXS0xTNzMnHufuP6VkIMmtsHqp3A8RQd/kYvNc30w9vVUvrfmP/ZjXfNk9dEBEGxtlO52/w3L/cphcym6vvxBLOFNpOJI8Zb8JGO1gHpdQcyJFDAaUnf8bASga4CryzL53o2GgowmwpRAWKx0VodY7ZneQM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a90e05a-96a3-46d8-2024-08dc5f0e74b7 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 18:44:47.4068 (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: DcbmUOANtQjgKsR72mvRNczkwPj2x8dR/gJP4uqlezyHVbz6aadvnHbEJ9aemF+1ae23rUHKZQxdx3vt+YqQjlw0kpLuIra9WIsZtwzTbpk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB4856 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-17_16,2024-04-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404170133 X-Proofpoint-ORIG-GUID: 9brS_eQyAZLsjmYhb0ShqFQshCG_KO1D X-Proofpoint-GUID: 9brS_eQyAZLsjmYhb0ShqFQshCG_KO1D X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H4,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 List-Id: The BPF backend was allocating an unnecessarily large string when constructing CO-RE relocations for enum types. gcc/ChangeLog: * config/bpf/core-builtins.cc (process_enum_value): Correct string allocation. --- gcc/config/bpf/core-builtins.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gcc/config/bpf/core-builtins.cc b/gcc/config/bpf/core-builtins.cc index e03e986e2c1..beb039ea6e0 100644 --- a/gcc/config/bpf/core-builtins.cc +++ b/gcc/config/bpf/core-builtins.cc @@ -870,12 +870,14 @@ process_enum_value (struct cr_builtins *data) unsigned int index = 0; for (tree l = TYPE_VALUES (type); l; l = TREE_CHAIN (l)) { + gcc_assert (index < (1 << 16)); if (TREE_VALUE (l) == expr) { - char *tmp = (char *) ggc_alloc_atomic ((index / 10) + 1); - sprintf (tmp, "%d", index); - ret.str = (const char *) tmp; - + /* Index can only be a value up to 2^16. Should always fit + in 6 chars. */ + char tmp[6]; + sprintf (tmp, "%u", index); + ret.str = CONST_CAST (char *, ggc_strdup(tmp)); break; } index++; -- 2.30.2