From patchwork Tue Jan 9 18:30:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Mezentsev X-Patchwork-Id: 186506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp304351dyi; Tue, 9 Jan 2024 10:31:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+GyI9zTqwZkm6aeF+RecYFLZe1Z8y3FfBks9Ky/Diusz2E2sPaN2GP4aqj9lAL7UN+rGS X-Received: by 2002:a05:6214:518d:b0:680:cd3f:8b55 with SMTP id kl13-20020a056214518d00b00680cd3f8b55mr1815950qvb.18.1704825075850; Tue, 09 Jan 2024 10:31:15 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1704825075; cv=pass; d=google.com; s=arc-20160816; b=M+OPH+K24GuvmrEMWEIuuOctUZWMSsUttQ/pZX2gWzFCgq0uM3nufYdxlT/hrW+MyM BDeov4yUYKWOYZvPu2TBooKPSVkEaDTp3S5EgulvSE0V3PijQJReZOsttvS7oERfJyQA 2N9BzWrcc2OCYfLE8PLRfONXuhwMfzYu/1ZvvRct/JztYvHW88LMHTDdnI3TMD+EEjOl AGLCISQPO2xHUWWNsDAZRlJe573KFzs9dUM8WMVltMOxvOTvST3MMvhWMBz5IEWpq5t5 fatqDbW/hMXDhRQopsSJHDIbkrLlTm26EyBQuLHKev79hiQe5qReAg9Bh4hz7ZbGcFwk WNhw== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=fNfrurvkPzZQvYtBAYN+KM+d2S+Z6ACSPGrmFYpV144=; fh=rGgRskdXqkw/EDUeDqnE3q/qQuWE7ZzID6eKNBELT+8=; b=lQTUNJKTz/ufMZHcmSbECTnxJLfz5+rluI7ZN5Az3mdBaYQWxp3jCLpL+hUX/72PjT nlFPE+3AU47mWYjqV2md9lBavhRzfXO2OgrIWhmL3rD+IzSkUi8ojn9XjLiSk4pnGozb z7NplPqYbd7LSM3ZSJouTVx54pf8pR+VUXAPqmc+kzD6Q+tw3uM7bR4MwYSpqZMDk370 kGTQ4lRh8lCcqfWbsmbyd3p3p1cyYHDr0ZFv8LxWcH2v7FOXEn3c/QNPeGFCBxtWaprb 1p8RH0TikhEsF2lU8lnno9bhYwwOO6nQo41gO+2qiWbdpKyKZ+eoRln7SI9zioO0iz6J ZaOQ== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=T9IsmlaY; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C8VIfPU3; arc=pass (i=2); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d27-20020a0caa1b000000b0067f95cebfa8si2737619qvb.343.2024.01.09.10.31.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:31:15 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=T9IsmlaY; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C8VIfPU3; arc=pass (i=2); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AC933858296 for ; Tue, 9 Jan 2024 18:31:15 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id D304C385843E for ; Tue, 9 Jan 2024 18:30:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D304C385843E Authentication-Results: sourceware.org; dmarc=pass (p=none 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 D304C385843E 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=1704825064; cv=pass; b=GSh4BublcMGmFbrBzrTKeoPdgFVPfuwxQZ1917Ipgu74BMDca0HSPKkJJ/G5QKY5/p+PGzEOhD2721yvVAPUb5EZTbj+OPGcVaj8++DesWU9FerPlm4Ik4Umu8RQhZpKXvnkDwDwctjdhQZs9Bs3BE1OXsYbcYQazb2Naou1hUI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1704825064; c=relaxed/simple; bh=+fxjdCxDXEw0x8lRPDr44FLAsvIvI+GfEEcpWY8dTPA=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=I3QrFWMSnMnRUAdcyfE2PsILh8isqQFubZ5Z0CgYxvdR4umMtJuZv7mQijqHhMiLto364247dOO8NwvnOGkZbNdXm4ztvcvZ1ii+Paffqo/cy2vlWv1+S3cYUGVggIsg4U8yMSUokWp4w91mKe48NxC0yKtYKqcdvj5mdMxVe6Y= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 409HuNHD027409 for ; Tue, 9 Jan 2024 18:30:59 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=fNfrurvkPzZQvYtBAYN+KM+d2S+Z6ACSPGrmFYpV144=; b=T9IsmlaYyh8DPHX3Z6SYKWbsNvAYxsGTa85gVm+XQRlWW4AOlxty9dNWRp/sgkpNXYGS flA4V1aO/qTYJHmciBFJ0OWNdND8yR6Nn90BMrp2a1TAhXlv0zVG6LaOPAj1vSujHm9n g+3skjnj7O+HvtNjiI7DOI4LTVDHHLq7hbQBoE7uWLUBr08cgxIjcIdP2MRDJpQ2GDgr xmQgCwXaeWMZ9eT8pA5nY6UNTHfSYXjqvIvgmojRBBgnV4mzQOTIPmL8PUMq3NvPIWc6 NUuWwQHqyVHrenctka17A1ZpZ71HiKNCi3J7nLxTFzJOiBJVD//SxCmz7A214U6PJPge Mw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vhayug291-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 09 Jan 2024 18:30:59 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 409HFmki012095 for ; Tue, 9 Jan 2024 18:30:58 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2168.outbound.protection.outlook.com [104.47.73.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vfuwh6r0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 09 Jan 2024 18:30:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m27rA7fkLeSxyEmqtjg3LtYZMcKy6ecAMJ1XQV/tuTCxYaC5kokk3npkQ3c4rc2glM6lFWg20V9ZRIsLUPHh8fAFvuQ5fYAJkiqPXMg7qfnLSQC0o7Qaq5I+4vIgZjPbPSuT1sOC8aZc/gsdfLvN6PtAy2VkCwOJ7glT3I8sO5hwVxyec/XEtTLOg/O4fAnp/HdQAnnqRWQWoRxI1N0sJwxlxe60slpp0TKxv028cxdElDzqXrlX/sndnHnGy8gYLgACQ22OkXREzNVgKdjTpFSNZjYq1hRcRcW2VCuVycCPb7TsTMCwKLlqYbeZrqfZmxxCcfO1S6BvXoKDoKZyfw== 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=fNfrurvkPzZQvYtBAYN+KM+d2S+Z6ACSPGrmFYpV144=; b=dlBay8PzczouSoAmthZcQ3R73LMAcPVtaG9D+P6xeJ++8vWBFTjdk3nFvd3sb/vecfWeAoXivh0jMPgzYO7utjy6tJQ0eBm64XuMezY0tDqxqRS9IOHC+ue+U6A8ohw0c0p9P2wW9xYMGbxEImTWYUMA8D12XfAdET766fypANtyvM74Csov2dR3hlJ1p/oiTbgiFZanrkj3ee0uoU70iiW8qsnu0ESbSl6+5yFFMSvSY7x115apDxhC+Hs0QRhAmlKjqqDIviFS/7zcPH8JoZUo20O5I3mkCk93PcS8hMICscLZ3MGFeXZwNUPA2VxfaqY98zueFWJb9CgHWlnu/A== 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=fNfrurvkPzZQvYtBAYN+KM+d2S+Z6ACSPGrmFYpV144=; b=C8VIfPU3zawk1ozvRjtWsR05mQxLuA4j93JMm5dhc/HekeGEvgALnOG7pDo7Yp+0RY/QszSlEuKMxXLVzz1SqXWwPXJ4E4miEBQiEiysLNZ+LnQN3JIv0xG7S0st2X1wlnGgqkREpnynYzD6FHXDYpiqjNRD2zARGNawgOxzrtk= Received: from SA2PR10MB4636.namprd10.prod.outlook.com (2603:10b6:806:11e::10) by PH7PR10MB5878.namprd10.prod.outlook.com (2603:10b6:510:127::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Tue, 9 Jan 2024 18:30:54 +0000 Received: from SA2PR10MB4636.namprd10.prod.outlook.com ([fe80::5b9b:a8a:21f6:a505]) by SA2PR10MB4636.namprd10.prod.outlook.com ([fe80::5b9b:a8a:21f6:a505%3]) with mapi id 15.20.7159.020; Tue, 9 Jan 2024 18:30:54 +0000 From: vladimir.mezentsev@oracle.com To: binutils@sourceware.org Cc: Vladimir Mezentsev Subject: [PATCH] gprofng: 31123 improvements to hardware event implementation Date: Tue, 9 Jan 2024 10:30:46 -0800 Message-Id: <20240109183046.1044824-1-vladimir.mezentsev@oracle.com> X-Mailer: git-send-email 2.31.1 X-ClientProxiedBy: PH7PR10CA0013.namprd10.prod.outlook.com (2603:10b6:510:23d::9) To SA2PR10MB4636.namprd10.prod.outlook.com (2603:10b6:806:11e::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PR10MB4636:EE_|PH7PR10MB5878:EE_ X-MS-Office365-Filtering-Correlation-Id: 80d1fb9f-ad3d-418b-f794-08dc11411d3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E0XP+LFc5IYeh7Iq63FZjrvsFyPHrUZbau7hR2iCmW7dhg5ONvlsRh0RLlEFi9JIHJNotd12yiyQ2iSNKKRtA4LrWo2REr5eZ2QZ9b+lsCoc4c6G352m1kgtqmI3Oh63g+I7jatYpxZfR4bAxtenpDuELnNsgnkicZytmKK1iuKISLGX6vcwIGqQDfRGxn1wXV6HqdQOcRRHqs7/5uJvRPbX8bWr02p0Ij4fajxC2/hVEMOJTWKtDvi0dx47XtxykIYfao/lw5acEdEINhvqwdJLjkcPCh55NVZHMjzVIiJsmWL26u9VKp7D2wphI0ORXMOjpYH8DxyT3BGrag3sj1y7tn0u0UZvTKnZoYsNvM1Im4lh7Drw0BN/gD5PoiGVmvyEky5oCZXgYhssb9fcnVIKklK3rOnlbmeImJsaYtrYVyiih71Je6XOTR3ONsr6pqWUx73a5r/u5udeAWf44t4qKFH4WNYCakYmD+Owf4afVQ8oFUCGUA2uiBu2hUzDB+aDzC96xX3CrZsKOM3jUJYARZH9b1tPQdrnzf/gOVtNEmXm+mccUVIG1DjJmla5AXcik11C85dIjH6nkr5H07TZN4kbSDNIPL36kPalJo4XnGBH12jQ3O6RlKaFNMpT X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4636.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(376002)(396003)(346002)(39860400002)(366004)(230922051799003)(230173577357003)(230273577357003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(66946007)(41300700001)(86362001)(36756003)(107886003)(38100700002)(2616005)(9686003)(1076003)(6512007)(6506007)(6486002)(2906002)(66476007)(6916009)(478600001)(316002)(6666004)(66556008)(5660300002)(8676002)(8936002)(4326008)(30864003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FUVBbAutzZparzHlj317I23TkCD7QsvlRl9Z8fu8soGzvMHVN4ALfFZNiFdq1eNdjtoHNhSU3FTVQoysg8hGU/OzgH3L1qsGe7LUSCEo9cKup8OfWnermyRkTxtbZ3ICD+as318FsTAZIV4ejV8gqGqSMnEd4Ds9lEALqDTzyaG7nq+ITF8muHXfHms+UHXYttntqgfgHNYNhfMT+odGoi+jT8dK4O+dM//fUOM7A5R+k/ZUY5/adQ15ov6xlUUo+kxmF6uU4uRG3Kdv9ntWlaKzy+YevecD0k4TDbX3RvEHh2RTxPVs5goL+bdedRZydyyQQAgU77sU2r2/nZG6xkTKsOfbWpReo02sWSqwAkUCGYLQk1eY6vQWcV4E9H4rZBZxHmFwtWWxNhdkJacoVdlit9E6E7PVJR4qbCaJz95MvfVF3JW6WA7hKPXcQ+FQLS0zES6dZiYLVpnU4fK/c/tMmO68x108FQtLUcNpMslC9kr8KgNMuFqgu8wPd56ynZIfpH05uLCo+xm99gZ2F3Ds2i3EIJHYeMhfET6kq9mcydhlV7btHYhVR2P4WRa4W7ihbr4R1QlchjeIW8iPCJNyvB62q/LFpPRT4WhlzRM4+swzH6moDNptin1Ol9GqjZf9dzyK3fIVi2HBWd28X/5ke1CuQBx1FWORZwPkQ/26mJM5bU5XbXi+vkTBPEAgyE27J59e3bQTGoACpNdllYGJsvi0X+8KNqNs2tROc6zXHF1Ny3YwpI4lBa3FpbArwPLtk/eEBC0gSTvKYHxiswCXxaxLeIOGNXwMNQeALXcIJ4VV5S8JaMfXevKqSS2RXfUEg8rIQcCrbmSY0JDwchMcb293XpqjZZafDVro3aSG7jztBqbQHqLKqKvG5iMfsI5StKcanzosjjUuQUlc29rf2TK/lWLoQ0dyPlEP5i+GIY5+N35Bb3KZ+bwMcqMvkD/Nnn4QOgRVqtdAhDXCOoAL2MZv1Yt7hXvdS+G0QGTgtjZaGEe8NnQ32Bs2bZfuYsk8WwdnPqPhJGPmIrv44NOAElNTfUU3u7gAxUeKFhxUAlXx48rFqleA87/uLiaxyLNZJSvAitEYEPnJJvyiPdCLLL0XmnhOFWd+aF5VivfvBFw5SeqH7+Tr//f6/svjQqzJKRaVRyxCjugGsFNsExRl7QsDoNY26N99A2m/itP1dZvDNBcv8HdmyL971EybPwgaseub+LIg1g1sZlvzy8dJF/5hegh/eHqlIvMVPRK+5O9g2QrcVXkgcQuaa50863yVHQoGnafIJQ6fZVIHFUIwj3fED133V5xa2JInwqLfDfjyBY8QAH+rUUk+yyG8E4CnA0hBnnTzeeZOep6vS60n682sTKqMaFK/hHXOc3oK+VEzfKNs/7VyGUeSe9MxobV5WGQDVjPlLaiqwhFIuSBr83Jj3xgbYXxCimteWEutrZKqzDEaB3heVwzSvkfJAuR/lAUZ9eJ83dQsVaSgouzOTghQovI8HcIfGRFSde3kDncd6RewQh/hOQE/S4WxST+dNxod4zsG19Tn1tyZ5pnyFM4GnsjzlZt245Phhx4aXDMGKkE5Ze70L/x7XpN1kS4BYPS+Uz4MjfIDhfC3qzw46drY+vmr2sZz2aACyo5eczkwUokACk3BAUAyHkr3 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: unInGP9TyN28fo0yXvX3dYejPD6/3N2rmTdGe4Cs3ckaTSZPSDoJT0uZtQW2PjLBXJb4tXg/YHaLuZ28sYJb4YEgAkSm8vcS/QPUP2OXhWa4bobZCOuQbdzAZGgQneoXYqGDGH528ZxCutybSpXia4DEX3MFRzjaGCisdSIrj2ppd2I6MfEf3/Rdzi1+111pCQddT91T2ij9fR7UPHwi3oeWvzw7cBAUbwwfnIFkFiIDdkX2U2vLQmtoNhU+0z+rL+wmyS5QHSIvp+K/cYujwseXIkA4ZDTVubRFiHIcA5KwcOQH3BzAFDtybxmQoeK/SutF8DrzumyaqKz1i1TQhU+G2GrEjpWsz8qyxfigV5Pmt0O5VeOL/x9xCM1kan1m+GBY01B4EUuY7JYy+zrxqRB7ShhDis3S4lfBtMgfN0IRxwQsYRcn/dWLT/MXHf225PseDbiQEcQ8YC5ktvX6XHW0cs3etmUuFOfb2s/T7DK9tZM5DZ0eT9QxyK/R/FkbLWTdW5XvGPmKJBY9dTOpdTIrUaYPQr+dIGDUzuPd7AuRb0toK7a432tHkbUCE34gNIHh5sNm/mXTuePgrSiTGUR6ppYKl29fBc+Wcpl49G8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80d1fb9f-ad3d-418b-f794-08dc11411d3f X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4636.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2024 18:30:54.2658 (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: lddS+g32L5gV56fwbqVzu83XcRXrxdX7QX9wQHVj0ergM3TxT9yxAt5ixRggqfqqRT6W2h+WTJk70kW7UVC6tAeQBDJujYvBHUnsAFBq/SI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5878 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-09_09,2024-01-09_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401090149 X-Proofpoint-GUID: i6L5FyFSBCUQdpyocRfR2jysk8jkYTjE X-Proofpoint-ORIG-GUID: i6L5FyFSBCUQdpyocRfR2jysk8jkYTjE X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787638659122271836 X-GMAIL-MSGID: 1787638659122271836 From: Vladimir Mezentsev Our hardware counter profiling is based on perf_event_open(). Our HWC tables are absent for new machines. I have added HWC tables for the following events: PERF_TYPE_HARDWARE, PERF_TYPE_SOFTWARE, PERF_TYPE_HW_CACHE. Other events require additional fixes. Did a little cleaning: marked the symbols as static, used Stringbuilder, created a function to read /proc/cpuinfo. gprofng/ChangeLog 2024-01-08 Vladimir Mezentsev PR gprofng/31123 * common/core_pcbe.c: Mark the symbols as static. Add events_generic[]. * common/hwc_cpus.h: Declare a new function read_cpuinfo. * common/hwcdrv.c: Add a new parameter in init_perf_event(). * common/hwcentry.h: Add use_perf_event_type in Hwcentry. * common/hwcfuncs.c (process_data_descriptor): Read use_perf_event_type, type, config. * common/hwctable.c: Add a new HWC table generic_list[]. * common/opteron_pcbe.c (opt_pcbe_init): Accept AMD machines. * src/collctrl.cc: Use StringBuilder in Coll_Ctrl::build_data_desc(). Add a new function read_cpuinfo. --- gprofng/common/core_pcbe.c | 46 ++++---- gprofng/common/hwc_cpus.h | 16 +++ gprofng/common/hwcdrv.c | 35 +++--- gprofng/common/hwcentry.h | 5 +- gprofng/common/hwcfuncs.c | 82 ++++++------- gprofng/common/hwctable.c | 124 +++++++++++++------- gprofng/common/opteron_pcbe.c | 21 ++-- gprofng/src/collctrl.cc | 211 ++++++++++++++++++---------------- 8 files changed, 293 insertions(+), 247 deletions(-) diff --git a/gprofng/common/core_pcbe.c b/gprofng/common/core_pcbe.c index b71d46f4e31..8dfde6036f3 100644 --- a/gprofng/common/core_pcbe.c +++ b/gprofng/common/core_pcbe.c @@ -2597,102 +2597,95 @@ struct events_table_t static const struct events_table_t *events_table = NULL; -const struct events_table_t events_fam6_mod23[] = { +static const struct events_table_t events_fam6_mod23[] = { ARCH_EVENTS EVENTS_FAM6_MOD23 NT_END }; -const struct events_table_t events_fam6_mod28[] = { +static const struct events_table_t events_fam6_mod28[] = { ARCH_EVENTS EVENTS_FAM6_MOD28 NT_END }; -const struct events_table_t events_fam6_mod26[] = { +static const struct events_table_t events_fam6_mod26[] = { ARCH_EVENTS EVENTS_FAM6_MOD26 NT_END }; -const struct events_table_t events_fam6_mod46[] = { +static const struct events_table_t events_fam6_mod46[] = { ARCH_EVENTS EVENTS_FAM6_MOD26 EVENTS_FAM6_MOD46_ONLY NT_END }; -const struct events_table_t events_fam6_mod37[] = { +static const struct events_table_t events_fam6_mod37[] = { ARCH_EVENTS EVENTS_FAM6_MOD37 EVENTS_FAM6_MOD37_ALSO NT_END }; -const struct events_table_t events_fam6_mod47[] = { +static const struct events_table_t events_fam6_mod47[] = { ARCH_EVENTS EVENTS_FAM6_MOD37 NT_END }; -const struct events_table_t events_fam6_mod42[] = { +static const struct events_table_t events_fam6_mod42[] = { ARCH_EVENTS EVENTS_FAM6_MOD42 EVENTS_FAM6_MOD42_ONLY NT_END }; -const struct events_table_t events_fam6_mod45[] = { +static const struct events_table_t events_fam6_mod45[] = { ARCH_EVENTS EVENTS_FAM6_MOD42 EVENTS_FAM6_MOD45_ONLY NT_END }; -const struct events_table_t events_fam6_mod58[] = { +static const struct events_table_t events_fam6_mod58[] = { ARCH_EVENTS EVENTS_FAM6_MOD58 NT_END }; -const struct events_table_t events_fam6_mod62[] = { +static const struct events_table_t events_fam6_mod62[] = { ARCH_EVENTS EVENTS_FAM6_MOD58 EVENTS_FAM6_MOD62_ONLY NT_END }; -const struct events_table_t events_fam6_mod60[] = { +static const struct events_table_t events_fam6_mod60[] = { ARCH_EVENTS EVENTS_FAM6_MOD60 NT_END }; -const struct events_table_t events_fam6_mod61[] = { +static const struct events_table_t events_fam6_mod61[] = { ARCH_EVENTS EVENTS_FAM6_MOD61 NT_END }; -const struct events_table_t events_fam6_mod78[] = { +static const struct events_table_t events_fam6_mod78[] = { ARCH_EVENTS EVENTS_FAM6_MOD78 NT_END }; -const struct events_table_t events_fam6_unknown[] = { +static const struct events_table_t events_fam6_unknown[] = { ARCH_EVENTS NT_END }; -const struct events_table_t events_fam_arm[] = { -// ARCH_EVENTS -// *eventnum = pevent->eventselect; -// *eventnum |= (pevent->unitmask << PERFCTR_UMASK_SHIFT); -// *eventnum |= (pevent->attrs << 16); -// *eventnum |= (pevent->cmask << 24); -// eventselect, unitmask, supported_counters, name, cmask, attrs, msr_offset - +const struct events_table_t events_generic[] = { // Hardware event #define HWE(nm, id) { id, 0, C_ALL, nm, PERF_TYPE_HARDWARE, 0, 0 }, HWE("branch-instructions", PERF_COUNT_HW_BRANCH_INSTRUCTIONS) @@ -2741,13 +2734,20 @@ core_pcbe_init (void) { switch (cpuid_getvendor ()) { + case X86_VENDOR_AMD: + snprintf (core_impl_name, sizeof (core_impl_name), "%s", X86_VENDORSTR_AMD); + events_table = events_generic; + num_gpc = 4; + num_ffc = 0; + total_pmc = num_gpc + num_ffc; + return 0; case ARM_CPU_IMP_ARM: case ARM_CPU_IMP_BRCM: case ARM_CPU_IMP_CAVIUM: case ARM_CPU_IMP_APM: case ARM_CPU_IMP_QCOM: snprintf (core_impl_name, sizeof (core_impl_name), "%s", AARCH64_VENDORSTR_ARM); - events_table = events_fam_arm; + events_table = events_generic; num_gpc = 4; // MEZ: a real implementation is needed num_ffc = 0; total_pmc = num_gpc + num_ffc; diff --git a/gprofng/common/hwc_cpus.h b/gprofng/common/hwc_cpus.h index be820819dd3..959e67d2f9d 100644 --- a/gprofng/common/hwc_cpus.h +++ b/gprofng/common/hwc_cpus.h @@ -23,6 +23,19 @@ #ifndef __HWC_CPUS_H #define __HWC_CPUS_H +typedef struct +{ + int cpu_cnt; + int cpu_clk_freq; + int cpu_model; + int cpu_family; + int cpu_vendor; + char *cpu_vendorstr; + char *cpu_modelstr; +} cpu_info_t; + +extern cpu_info_t *read_cpuinfo(); + #define MAX_PICS 20 /* Max # of HW ctrs that can be enabled simultaneously */ /* type for specifying CPU register number */ @@ -91,6 +104,8 @@ #define CPC_AMD_FAM_10H 2501 /* Barcelona, Shanghai... */ #define CPC_AMD_FAM_11H 2502 /* Griffin... */ #define CPC_AMD_FAM_15H 2503 +#define CPC_AMD_Authentic 2504 + #define CPC_KPROF 3003 // OBSOLETE (To support 12.3 and earlier) #define CPC_FOX 3004 /* pseudo-chip */ @@ -191,6 +206,7 @@ enum { {CPC_ULTRA2 , "UltraSPARC I&II"}, \ {CPC_ULTRA1 , "UltraSPARC I&II"}, \ {ARM_CPU_IMP_APM , AARCH64_VENDORSTR_ARM}, \ + {CPC_AMD_Authentic , "AuthenticAMD"}, \ {0, NULL} /* init like this: static libcpc2_cpu_lookup_t cpu_table[]={LIBCPC2_CPU_LOOKUP_LIST}; diff --git a/gprofng/common/hwcdrv.c b/gprofng/common/hwcdrv.c index bd8da49b419..340b473f6cc 100644 --- a/gprofng/common/hwcdrv.c +++ b/gprofng/common/hwcdrv.c @@ -675,26 +675,21 @@ dump_perf_event_attr (struct perf_event_attr *at) } static void -init_perf_event (struct perf_event_attr *hw, uint64_t event, uint64_t period) +init_perf_event (struct perf_event_attr *hw, uint64_t event, uint64_t period, + Hwcentry *hwce) { memset (hw, 0, sizeof (struct perf_event_attr)); - hw->size = sizeof (struct perf_event_attr); // fwd/bwd compat - -#if defined(__i386__) || defined(__x86_64) - //note: Nehalem/Westmere OFFCORE_RESPONSE in upper 32 bits - hw->config = event; - hw->type = PERF_TYPE_RAW; // hw/sw/trace/raw... -#elif defined(__aarch64__) - hw->type = (event >> 24) & 7; - hw->config = event & 0xff; -#elif defined(sparc) - //SPARC needs to be shifted up 16 bits - hw->config = (event & 0xFFFF) << 16; // uint64_t event - uint64_t regs = (event >> 20) & 0xf; // see sparc_pcbe.c - hw->config |= regs << 4; // for M8, supported PICs need to be placed at bits [7:4] - hw->type = PERF_TYPE_RAW; // hw/sw/trace/raw... -#endif - + hw->size = sizeof (struct perf_event_attr); + if (hwce && hwce->use_perf_event_type) + { + hw->config = hwce->config; + hw->type = hwce->type; + } + else + { // backward compatibility. The old interface had no 'hwce' argument. + hw->config = event; + hw->type = PERF_TYPE_RAW; // hw/sw/trace/raw... + } hw->sample_period = period; hw->sample_type = PERF_SAMPLE_IP | // PERF_SAMPLE_TID | @@ -858,7 +853,7 @@ hdrv_pcl_internal_open () perf_event_def_t tmp_event_def; memset (&tmp_event_def, 0, sizeof (tmp_event_def)); struct perf_event_attr *pe_attr = &tmp_event_def.hw; - init_perf_event (pe_attr, 0, 0); + init_perf_event (pe_attr, 0, 0, NULL); pe_attr->type = PERF_TYPE_HARDWARE; // specify abstracted HW event pe_attr->config = PERF_COUNT_HW_INSTRUCTIONS; // specify abstracted insts int hwc_fd = perf_event_open (pe_attr, @@ -1283,7 +1278,7 @@ hwcdrv_create_counters (unsigned hwcdef_cnt, Hwcentry *hwcdef) glb_event_def->min_time = hwcdef[idx].min_time; glb_event_def->name = strdup (hwcdef[idx].name); // memory leak??? very minor init_perf_event (&glb_event_def->hw, glb_event_def->eventsel, - glb_event_def->counter_preload); + glb_event_def->counter_preload, hwcdef + idx); TprintfT (DBG_LT1, "hwcdrv: create_counters: pic=%u name='%s' interval=%lld" "(min_time=%lld): reg_num=0x%x eventsel=0x%llx ireset=%lld usr=%lld sys=%lld\n", idx, hwcdef[idx].int_name, (long long) glb_event_def->counter_preload, diff --git a/gprofng/common/hwcentry.h b/gprofng/common/hwcentry.h index 78b62ab6a0d..c812ca5710a 100644 --- a/gprofng/common/hwcentry.h +++ b/gprofng/common/hwcentry.h @@ -112,11 +112,12 @@ extern "C" int timecvt; /* multiplier to convert metric to time, 0 if N/A */ ABST_type memop; /* type of backtracking allowed */ char *short_desc; /* optional one-liner description, or NULL */ - int type; /* Type of perf_event_attr */ - long long config; /* perf_event_type -specific configuration */ /* the fields above this line are expected, in order, by the tables in hwctable.c */ /* ================================================== */ /* the fields below this line are more flexible */ + unsigned int use_perf_event_type : 16; /* Set 1 to use two fields below */ + unsigned int type : 16; /* Type of perf_event_attr */ + long long config; /* perf_event_type -specific configuration */ int sort_order; /* "tag" to associate experiment record with HWC def */ regno_t *reg_list; /* if not NULL, legal values for field above */ /* Note: reg_list will be terminated by REGNO_ANY */ diff --git a/gprofng/common/hwcfuncs.c b/gprofng/common/hwcfuncs.c index ef3d0d080e2..1b0a429f502 100644 --- a/gprofng/common/hwcfuncs.c +++ b/gprofng/common/hwcfuncs.c @@ -259,18 +259,11 @@ process_data_descriptor (const char *defstring) clear_hwcdefs (); if (!defstring || !strlen (defstring)) - { - err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; - } + return HWCFUNCS_ERROR_HWCARGS; ds = strdup (defstring); if (!ds) - { - err = HWCFUNCS_ERROR_HWCINIT; - goto ext_hw_install_end; - } + return HWCFUNCS_ERROR_HWCINIT; dsp = ds; - for (idx = 0; idx < MAX_PICS && *dsp; idx++) { char *name = NULL; @@ -281,13 +274,33 @@ process_data_descriptor (const char *defstring) int timecvt = 0; unsigned sort_order = (unsigned) - 1; + // Read use_perf_event_type, type, config + hwcdef[idx].use_perf_event_type = (int) strtol (dsp, &dsp, 0); + if (*dsp++ != ':') + { + err = HWCFUNCS_ERROR_HWCARGS; + break; + } + hwcdef[idx].type = (int) strtol (dsp, &dsp, 0); + if (*dsp++ != ':') + { + err = HWCFUNCS_ERROR_HWCARGS; + break; + } + hwcdef[idx].config = strtol (dsp, &dsp, 0); + if (*dsp++ != ':') + { + err = HWCFUNCS_ERROR_HWCARGS; + break; + } + /* name */ name = dsp; dsp = strchr (dsp, ':'); if (dsp == NULL) { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } *dsp++ = (char) 0; @@ -297,7 +310,7 @@ process_data_descriptor (const char *defstring) if (dsp == NULL) { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } *dsp++ = (char) 0; @@ -306,12 +319,12 @@ process_data_descriptor (const char *defstring) if (*dsp++ != ':') { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } if (reg < 0 && reg != -1) { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } if (reg >= 0) hwcdef[idx].reg_num = reg; @@ -321,21 +334,16 @@ process_data_descriptor (const char *defstring) if (*dsp++ != ':') { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } if (interval < 0) { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } hwcdef[idx].val = interval; /* min_time */ - /* - * This is a new field. - * An old launcher (dbx, etc.) would not include it. - * Detect the presence of the field by the char 'm'. - */ if (*dsp == 'm') { long long tmp_ll = 0; @@ -344,12 +352,12 @@ process_data_descriptor (const char *defstring) if (*dsp++ != ':') { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } if (tmp_ll < 0) { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } hwcdef[idx].min_time = tmp_ll; } @@ -361,7 +369,7 @@ process_data_descriptor (const char *defstring) if (*dsp++ != ':') { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } hwcdef[idx].sort_order = sort_order; @@ -370,7 +378,7 @@ process_data_descriptor (const char *defstring) if (*dsp++ != ':') { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } hwcdef[idx].timecvt = timecvt; @@ -379,7 +387,7 @@ process_data_descriptor (const char *defstring) if (*dsp != 0 && *dsp++ != ',') { err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; + break; } hwcdef[idx].memop = memop; if (*name) @@ -394,27 +402,11 @@ process_data_descriptor (const char *defstring) } if (*dsp) - { - TprintfT (DBG_LT0, "hwcfuncs: ERROR: process_data_descriptor(): " - "ctr string had some trailing garbage:" - " '%s'\n", dsp); - err = HWCFUNCS_ERROR_HWCARGS; - goto ext_hw_install_end; - } - free (ds); - hwcdef_cnt = idx; - return 0; - -ext_hw_install_end: - if (dsp && *dsp) - { - TprintfT (DBG_LT0, "hwcfuncs: ERROR: process_data_descriptor(): " - " syntax error just before:" - " '%s;\n", dsp); - logerr (GTXT ("Data descriptor syntax error near `%s'\n"), dsp); - } + err = HWCFUNCS_ERROR_HWCARGS; + if (err != 0) + logerr (GTXT ("Data descriptor syntax error near `%s'\n"), dsp); else - logerr (GTXT ("Data descriptor syntax error\n")); + hwcdef_cnt = idx; free (ds); return err; } diff --git a/gprofng/common/hwctable.c b/gprofng/common/hwctable.c index a2a553d74d5..4af5248571f 100644 --- a/gprofng/common/hwctable.c +++ b/gprofng/common/hwctable.c @@ -23,9 +23,9 @@ #include #include #include +#include #include "hwcdrv.h" -#include "hwcfuncs.h" /* TprintfT(,...) definitions. Adjust per module as needed */ #define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings @@ -2367,52 +2367,87 @@ static Hwcentry amd_15h[] = { {NULL, NULL, 0, NULL, 0, 0, 0, 0, ABST_NONE} }; -#define USE_ARM_REF_CYCLES \ - {"usr_time","cycles", REGNO_ANY, STXT("User CPU"), PRELOADS_85, 1, ABST_NONE}, \ - {"sys_time","cycles~system=1~user=0", REGNO_ANY, STXT("System CPU"), PRELOADS_85, 1, ABST_NONE}, \ +#define INIT_HWC(nm, mtr, cfg, ty) .name = (nm), .metric = (mtr), \ + .config = (cfg), .type = ty, .use_perf_event_type = 1, \ + .val = PRELOAD_DEF, .reg_num = REGNO_ANY +#define HWE(nm, mtr, cfg) INIT_HWC(nm, mtr, cfg, PERF_TYPE_HARDWARE) +#define SWE(nm, mtr, cfg) INIT_HWC(nm, mtr, cfg, PERF_TYPE_SOFTWARE) +#define HWCE(nm, mtr, id, op, res) \ + INIT_HWC(nm, mtr, (id) | ((op) << 8) | ((res) << 16), PERF_TYPE_HW_CACHE) -static Hwcentry armlist[] = { - USE_ARM_REF_CYCLES +static Hwcentry generic_list[] = { // Hardware event: - {"branch-instructions", NULL, REGNO_ANY, STXT("Branch-instructions"), PRELOADS_35, 0, ABST_NONE}, - {"branch-misses", NULL, REGNO_ANY, STXT("Branch-misses"), PRELOADS_35, 0, ABST_NONE}, - {"bus-cycles", NULL, REGNO_ANY, STXT("Bus Cycles"), PRELOADS_35, 1, ABST_NONE}, - {"cache-misses", NULL, REGNO_ANY, STXT("Cache-misses"), PRELOADS_35, 0, ABST_NONE}, - {"cache-references", NULL, REGNO_ANY, STXT("Cache-references"), PRELOADS_35, 0, ABST_NONE}, - {"cycles", NULL, REGNO_ANY, STXT("CPU Cycles"), PRELOADS_85, 1, ABST_NONE}, - {"insts", "instructions", REGNO_ANY, STXT("Instructions Executed"), PRELOADS_75, 0, ABST_NONE}, - {"ref-cycles", NULL, REGNO_ANY, STXT("Total Cycles"), PRELOADS_85, 1, ABST_NONE}, - {"stalled-cycles-backend", NULL, REGNO_ANY, STXT("Stalled Cycles during issue."), PRELOADS_85, 1, ABST_NONE}, - {"stalled-cycles-frontend", NULL, REGNO_ANY, STXT("Stalled Cycles during retirement."), PRELOADS_85, 1, ABST_NONE}, - + { HWE("usr_time", STXT("User CPU"), PERF_COUNT_HW_CPU_CYCLES), .timecvt = 1, + .int_name = "cycles" }, + { HWE("sys_time", STXT("System CPU"), PERF_COUNT_HW_CPU_CYCLES), .timecvt = 1, + .int_name = "cycles~system=1~user=0" }, + { HWE("branch-instructions", STXT("Branch-instructions"), + PERF_COUNT_HW_BRANCH_INSTRUCTIONS) }, + { HWE("branch-misses", STXT("Branch-misses"), PERF_COUNT_HW_BRANCH_MISSES) }, + { HWE("bus-cycles", STXT("Bus Cycles"), PERF_COUNT_HW_BUS_CYCLES), + .timecvt = 1 }, + { HWE("cache-misses", STXT("Cache-misses"), PERF_COUNT_HW_CACHE_MISSES) }, + { HWE("cache-references", STXT("Cache-references"), + PERF_COUNT_HW_CACHE_REFERENCES) }, + { HWE("cycles", STXT("CPU Cycles"), PERF_COUNT_HW_CPU_CYCLES), .timecvt = 1 }, + { HWE("insts", STXT("Instructions Executed"), PERF_COUNT_HW_INSTRUCTIONS), + .int_name = "instructions" }, + { HWE("ref-cycles", STXT("Total Cycles"), PERF_COUNT_HW_REF_CPU_CYCLES), + .timecvt = 1 }, + { HWE("stalled-cycles-backend", STXT("Stalled Cycles during issue."), + PERF_COUNT_HW_STALLED_CYCLES_BACKEND), .timecvt = 1 }, + { HWE("stalled-cycles-frontend", STXT("Stalled Cycles during retirement."), + PERF_COUNT_HW_STALLED_CYCLES_FRONTEND), .timecvt = 1 }, // Software event: - {"alignment-faults", NULL, REGNO_ANY, STXT("Alignment Faults"), PRELOADS_85, 0, ABST_NONE}, - {"context-switches", NULL, REGNO_ANY, STXT("Context Switches"), PRELOADS_85, 0, ABST_NONE}, - {"cpu-clock", NULL, REGNO_ANY, STXT("CPU Clock"), PRELOADS_85, 1, ABST_NONE}, - {"cpu-migrations", NULL, REGNO_ANY, STXT("CPU Migrations"), PRELOADS_85, 0, ABST_NONE}, - {"emulation-faults", NULL, REGNO_ANY, STXT("Emulation Faults"), PRELOADS_85, 0, ABST_NONE}, - {"major-faults", NULL, REGNO_ANY, STXT("Major Page Faults"), PRELOADS_85, 0, ABST_NONE}, - {"minor-faults", NULL, REGNO_ANY, STXT("Minor Page Faults"), PRELOADS_85, 0, ABST_NONE}, - {"page-faults", NULL, REGNO_ANY, STXT("Page Faults"), PRELOADS_85, 0, ABST_NONE}, - {"task-clock", NULL, REGNO_ANY, STXT("Clock Count Specific"), PRELOADS_85, 1, ABST_NONE}, - + { SWE("alignment-faults", STXT("Alignment Faults"), + PERF_COUNT_SW_ALIGNMENT_FAULTS) }, + { SWE("context-switches", STXT("Context Switches"), + PERF_COUNT_SW_CONTEXT_SWITCHES) }, + { SWE("cpu-clock", STXT("CPU Clock"), PERF_COUNT_SW_CPU_CLOCK), + .timecvt = 1 }, + { SWE("cpu-migrations", STXT("CPU Migrations"), + PERF_COUNT_SW_CPU_MIGRATIONS) }, + { SWE("emulation-faults", STXT("Emulation Faults"), + PERF_COUNT_SW_EMULATION_FAULTS) }, + { SWE("major-faults", STXT("Major Page Faults"), + PERF_COUNT_SW_PAGE_FAULTS_MAJ) }, + { SWE("minor-faults", STXT("Minor Page Faults"), + PERF_COUNT_SW_PAGE_FAULTS_MIN) }, + { SWE("page-faults", STXT("Page Faults"), PERF_COUNT_SW_PAGE_FAULTS) }, + { SWE("task-clock", STXT("Clock Count Specific"), PERF_COUNT_SW_TASK_CLOCK), + .timecvt = 1 }, // Hardware cache event - {"L1-dcache-load-misses", NULL, REGNO_ANY, STXT("L1 D-cache Load Misses"), PRELOADS_35, 0, ABST_NONE}, - {"L1-dcache-loads", NULL, REGNO_ANY, STXT("L1 D-cache Loads"), PRELOADS_35, 0, ABST_NONE}, - {"L1-dcache-store-misses", NULL, REGNO_ANY, STXT("L1 D-cache Store Misses"), PRELOADS_35, 0, ABST_NONE}, - {"L1-dcache-stores", NULL, REGNO_ANY, STXT("L1 D-cache Store Stores"), PRELOADS_35, 0, ABST_NONE}, - {"L1-icache-load-misses", NULL, REGNO_ANY, STXT("L1 Instructions Load Misses"), PRELOADS_35, 0, ABST_NONE}, - {"L1-icache-load-misses", NULL, REGNO_ANY, STXT("L1 Instructions Loads"), PRELOADS_35, 0, ABST_NONE}, - {"dTLB-load-misses", NULL, REGNO_ANY, STXT("D-TLB Load Misses"), PRELOADS_35, 0, ABST_NONE}, - {"dTLB-loads", NULL, REGNO_ANY, STXT("D-TLB Loads"), PRELOADS_35, 0, ABST_NONE}, - {"iTLB-load-misses", NULL, REGNO_ANY, STXT("The Instruction TLB Load Misses"), PRELOADS_35, 0, ABST_NONE}, - {"iTLB-loads", NULL, REGNO_ANY, STXT("The Instruction TLB Loads"), PRELOADS_35, 0, ABST_NONE}, - - {NULL, NULL, 0, NULL, 0, 0, 0, 0, ABST_NONE} -}; + { HWCE("L1-dcache-load-misses", STXT("L1 D-cache Load Misses"), + PERF_COUNT_HW_CACHE_L1D, + PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_RESULT_MISS) }, + { HWCE("L1-dcache-loads", STXT("L1 D-cache Loads"), + PERF_COUNT_HW_CACHE_L1D, + PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_RESULT_ACCESS) }, + { HWCE("L1-dcache-store-misses", STXT("L1 D-cache Store Misses"), + PERF_COUNT_HW_CACHE_L1D, + PERF_COUNT_HW_CACHE_RESULT_MISS, PERF_COUNT_HW_CACHE_RESULT_ACCESS) }, + { HWCE("L1-dcache-stores", STXT("L1 D-cache Store Stores"), + PERF_COUNT_HW_CACHE_L1D, + PERF_COUNT_HW_CACHE_OP_WRITE, PERF_COUNT_HW_CACHE_RESULT_ACCESS) }, + { HWCE("L1-icache-load-misses", STXT("L1 Instructions Load Misses"), + PERF_COUNT_HW_CACHE_L1I, + PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_RESULT_MISS) }, + { HWCE("L1-icache-load-misses", STXT("L1 Instructions Loads"), + PERF_COUNT_HW_CACHE_L1I, + PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_RESULT_ACCESS) }, + { HWCE("dTLB-load-misses", STXT("D-TLB Load Misses"), + PERF_COUNT_HW_CACHE_DTLB, + PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_RESULT_MISS) }, + { HWCE("dTLB-loads", STXT("D-TLB Loads"), + PERF_COUNT_HW_CACHE_DTLB, + PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_RESULT_ACCESS) }, + { HWCE("iTLB-load-misses", STXT("The Instruction TLB Load Misses"), + PERF_COUNT_HW_CACHE_ITLB, + PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_RESULT_MISS) }, + { HWCE("iTLB-loads", STXT("The Instruction TLB Loads"), + PERF_COUNT_HW_CACHE_ITLB, + PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_RESULT_ACCESS) }, -static Hwcentry unknownlist[] = - /* used for unrecognized CPU type */{ {NULL, NULL, 0, NULL, 0, 0, 0, 0, ABST_NONE} }; @@ -2485,8 +2520,9 @@ static cpu_list_t cputabs[] = { {CPC_SPARC64_X, usfuji_X_list, {"insts,,cycles,,dcstall", 0}}, {CPC_SPARC64_XII, usfuji_XII_list, {"insts,,cycles,,dcstall", 0}}, {CPC_KPROF, kproflist, {NULL}}, // OBSOLETE (To support 12.3 and earlier, TBR) - {ARM_CPU_IMP_APM, armlist, {"insts,,cycles", 0}}, - {0, unknownlist, {NULL}} /* processor is unknown, but experiment is allowed */ + {ARM_CPU_IMP_APM, generic_list, {"insts,,cycles", 0}}, + {CPC_AMD_Authentic, generic_list, {"insts,,cycles", 0}}, + {0, generic_list, {"insts,,cycles", 0}}, }; /*---------------------------------------------------------------------------*/ diff --git a/gprofng/common/opteron_pcbe.c b/gprofng/common/opteron_pcbe.c index 6cab4d102cc..c0d505597bd 100644 --- a/gprofng/common/opteron_pcbe.c +++ b/gprofng/common/opteron_pcbe.c @@ -315,30 +315,25 @@ static int opt_pcbe_init (void) { amd_family = cpuid_getfamily (); - /* - * Make sure this really _is_ an Opteron or Athlon 64 system. The kernel - * loads this module based on its name in the module directory, but it - * could have been renamed. - */ - if (cpuid_getvendor () != X86_VENDOR_AMD - || (amd_family != OPTERON_FAMILY && amd_family != AMD_FAMILY_10H)) - return (-1); + if (cpuid_getvendor () != X86_VENDOR_AMD) + return -1; /* * Figure out processor revision here and assign appropriate * event configuration. */ - if (amd_family == OPTERON_FAMILY) + switch (amd_family) { + case OPTERON_FAMILY: amd_events = opt_events_rev_E; amd_generic_events = opt_generic_events; - } - else - { + break; + case AMD_FAMILY_10H: amd_events = family_10h_events; amd_generic_events = family_10h_generic_events; + break; } - return (0); + return 0; } static uint_t diff --git a/gprofng/src/collctrl.cc b/gprofng/src/collctrl.cc index aeff5a0336c..d3d853a43f9 100644 --- a/gprofng/src/collctrl.cc +++ b/gprofng/src/collctrl.cc @@ -39,7 +39,7 @@ #include "libiberty.h" #include "collctrl.h" #include "hwcdrv.h" -//#include "hwcfuncs.h" +#include "StringBuilder.h" #define SP_GROUP_HEADER "#analyzer experiment group" #define DD_MAXPATHLEN (MAXPATHLEN * 4) /* large, to build up data descriptor */ @@ -55,7 +55,84 @@ extern const char *strsignal (int); #define _SC_CPUID_MAX 517 #endif -const char *get_fstype (char *); +static const char *get_fstype (char *); +static cpu_info_t cpu_info; + +static void +read_str (char *from, char **to) +{ + if (*to != NULL) + return; + for (char *s = from; *s; s++) + if (*s != ':' && *s != '\t' && *s != ' ') + { + for (int i = ((int) strlen (s)) - 1; i >= 0; i--) + { + if (s[i] != '\n' && s[i] != ' ' && s[i] != '\t') + { + *to = strndup(s, i + 1); + return; + } + } + return; // string is empty + } +} + +static int +read_int (char *from) +{ + char *val = strchr (from, ':'); + if (val) + return atoi (val + 1); + return 0; +} + +cpu_info_t * +read_cpuinfo() +{ + static int inited = 0; + if (inited) + return &cpu_info; + inited = 1; + +#if defined(__aarch64__) + asm volatile("mrs %0, cntfrq_el0" : "=r" (cpu_info.cpu_clk_freq)); +#endif + + // Read /proc/cpuinfo to get CPU info and clock rate + FILE *procf = fopen ("/proc/cpuinfo", "r"); + if (procf != NULL) + { + char temp[1024]; + while (fgets (temp, (int) sizeof (temp), procf) != NULL) + { + if (strncmp (temp, "processor", 9) == 0) + cpu_info.cpu_cnt++; + else if (strncmp (temp, "cpu MHz", 7) == 0) + cpu_info.cpu_clk_freq = read_int (temp + 9); + else if (strncmp (temp, "cpu family", 10) == 0) + cpu_info.cpu_family = read_int (temp + 10); + else if (strncmp (temp, "vendor_id", 9) == 0) + { + if (cpu_info.cpu_vendorstr == NULL) + read_str (temp + 9, &cpu_info.cpu_vendorstr); + } + else if (strncmp (temp, "model name", 10) == 0) + { + if (cpu_info.cpu_modelstr == NULL) + read_str (temp + 10, &cpu_info.cpu_modelstr); + } + else if (strncmp (temp, "model", 5) == 0) + cpu_info.cpu_model = read_int (temp + 5); + else if (strncmp (temp, "CPU implementer", 15) == 0) + cpu_info.cpu_family = read_int (temp + 15); + else if (strncmp (temp, "CPU architecture", 16) == 0) + cpu_info.cpu_model = read_int (temp + 16); + } + fclose (procf); + } + return &cpu_info; +} Coll_Ctrl::Coll_Ctrl (int _interactive, bool _defHWC, bool _kernelHWC) { @@ -81,59 +158,9 @@ Coll_Ctrl::Coll_Ctrl (int _interactive, bool _defHWC, bool _kernelHWC) /* add 2048 to count, since on some systems CPUID does not start at zero */ ncpumax = ncpus + 2048; } - ncpus = 0; - cpu_clk_freq = 0; - - // On Linux, read /proc/cpuinfo to get CPU count and clock rate - // Note that parsing is different on SPARC and x86 -#if defined(sparc) - FILE *procf = fopen ("/proc/cpuinfo", "r"); - if (procf != NULL) - { - char temp[1024]; - while (fgets (temp, (int) sizeof (temp), procf) != NULL) - { - if (strncmp (temp, "Cpu", 3) == 0 && temp[3] != '\0' - && strncmp ((strchr (temp + 1, 'C')) ? strchr (temp + 1, 'C') - : (temp + 4), "ClkTck", 6) == 0) - { - ncpus++; - char *val = strchr (temp, ':'); - if (val) - { - unsigned long long freq; - sscanf (val + 2, "%llx", &freq); - cpu_clk_freq = (unsigned int) (((double) freq) / 1000000.0 + 0.5); - } - else - cpu_clk_freq = 0; - } - } - fclose (procf); - } - -#elif defined(__aarch64__) - asm volatile("mrs %0, cntfrq_el0" : "=r" (cpu_clk_freq)); - -#else - FILE *procf = fopen ("/proc/cpuinfo", "r"); - if (procf != NULL) - { - char temp[1024]; - while (fgets (temp, (int) sizeof (temp), procf) != NULL) - { - // x86 Linux - if (strncmp (temp, "processor", 9) == 0) - ncpus++; - else if (strncmp (temp, "cpu MHz", 7) == 0) - { - char *val = strchr (temp, ':'); - cpu_clk_freq = val ? atoi (val + 1) : 0; - } - } - fclose (procf); - } -#endif + cpu_info_t *cpu_p = read_cpuinfo(); + ncpus = cpu_p->cpu_cnt; + cpu_clk_freq = cpu_p->cpu_clk_freq; /* check resolution of system clock */ sys_resolution = sysconf (_SC_CLK_TCK); @@ -1720,78 +1747,62 @@ Coll_Ctrl::set_size_limit (const char *string) void Coll_Ctrl::build_data_desc () { - char spec[DD_MAXPATHLEN]; - spec[0] = 0; + StringBuilder sb; // Put sample sig before clock profiling. Dbx uses PROF // for that purpose and we want it to be processed first. if (project_home) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "P:%s;", project_home); + sb.appendf ("P:%s;", project_home); if (sample_sig != 0) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "g:%d;", sample_sig); + sb.appendf ("g:%d;", sample_sig); if (pauseresume_sig != 0) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "d:%d%s;", pauseresume_sig, - (pauseresume_pause == 1 ? "p" : "")); + sb.appendf ("d:%d%s;", pauseresume_sig, pauseresume_pause == 1 ? "p" : ""); if (clkprof_enabled == 1) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "p:%d;", clkprof_timer); + sb.appendf ("p:%d;", clkprof_timer); if (synctrace_enabled == 1) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "s:%d,%d;", synctrace_thresh, synctrace_scope); + sb.appendf ("s:%d,%d;", synctrace_thresh, synctrace_scope); if (heaptrace_enabled == 1) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "H:%d;", heaptrace_checkenabled); + sb.appendf ("H:%d;", heaptrace_checkenabled); if (iotrace_enabled == 1) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "i:;"); + sb.append ("i:;"); if (hwcprof_enabled_cnt > 0) { - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "h:%s", - (hwcprof_default == true) ? "*" : ""); + sb.appendf ("h:%s", (hwcprof_default == true) ? "*" : ""); for (int ii = 0; ii < hwcprof_enabled_cnt; ii++) { - /* min_time is a "new" field. - * - * To help process_data_descriptor() in hwcfuncs.c parse - * the HWC portion of this string -- specifically, to - * recognize min_time when it's present and skip over - * when it's not -- we prepend 'm' to the min_time value. - * - * When we no longer worry about, say, an old dbx - * writing this string and a new libcollector looking for - * the min_time field, the 'm' character can be - * removed and process_data_descriptor() simplified. - */ - hrtime_t min_time = hwctr[ii].min_time; + Hwcentry *h = hwctr + ii; + hrtime_t min_time = h->min_time; if (min_time == HWCTIME_TBD) // user did not specify any value for overflow rate - min_time = hwctr[ii].min_time_default; - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), - "%s%s:%s:%d:%d:m%lld:%d:%d:0x%x", ii ? "," : "", - strcmp (hwctr[ii].name, hwctr[ii].int_name) ? hwctr[ii].name : "", - hwctr[ii].int_name, hwctr[ii].reg_num, hwctr[ii].val, - min_time, ii, /*tag*/ hwctr[ii].timecvt, hwctr[ii].memop); + min_time = h->min_time_default; + if (ii > 0) + sb.append (','); + sb.appendf ("%d:%d:%lld:%s:%s:%lld:%d:m%lld:%d:%d:0x%x", + h->use_perf_event_type, h->type, (long long) h->config, + strcmp (h->name, h->int_name) ? h->name : "", + h->int_name, (long long) h->reg_num, h->val, + (long long) min_time, ii, /*tag*/ h->timecvt, h->memop); } - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), ";"); + sb.append (";"); } - if ((time_run != 0) || (start_delay != 0)) + if (time_run != 0 || start_delay != 0) { if (start_delay != 0) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "t:%d:%d;", start_delay, time_run); + sb.appendf ("t:%d:%d;", start_delay, time_run); else - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "t:%d;", time_run); + sb.appendf ("t:%d;", time_run); } if (sample_period != 0) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "S:%d;", - sample_period); + sb.appendf ("S:%d;", sample_period); if (size_limit != 0) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "L:%d;", - size_limit); + sb.appendf ("L:%d;", size_limit); if (java_mode != 0) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "j:%d;", (int) java_mode); + sb.appendf ("j:%d;", (int) java_mode); if (follow_mode != FOLLOW_NONE) - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "F:%d;", (int) follow_mode); - snprintf (spec + strlen (spec), sizeof (spec) - strlen (spec), "a:%s;", archive_mode); - if (strlen (spec) + 1 >= sizeof (spec)) - abort (); + sb.appendf ("F:%d;", (int) follow_mode); + sb.appendf ("a:%s;", archive_mode); free (data_desc); - data_desc = strdup (spec); + data_desc = sb.toString (); } char *