Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752873AbdDDHh0 (ORCPT ); Tue, 4 Apr 2017 03:37:26 -0400 Received: from mail-dm3nam03on0089.outbound.protection.outlook.com ([104.47.41.89]:54000 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752785AbdDDHhW (ORCPT ); Tue, 4 Apr 2017 03:37:22 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=cavium.com; From: Ganapatrao Kulkarni To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Will.Deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, acme@kernel.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, mingo@redhat.com, jnair@caviumnetworks.com, gpkulkarni@gmail.com Subject: [PATCH 2/3] perf tools arm64: implement function get_cpuid_str Date: Tue, 4 Apr 2017 13:06:42 +0530 Message-Id: <1491291403-29893-3-git-send-email-ganapatrao.kulkarni@cavium.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1491291403-29893-1-git-send-email-ganapatrao.kulkarni@cavium.com> References: <1491291403-29893-1-git-send-email-ganapatrao.kulkarni@cavium.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BMXPR01CA0020.INDPRD01.PROD.OUTLOOK.COM (10.174.214.158) To BY1PR0701MB1690.namprd07.prod.outlook.com (10.162.110.28) X-MS-Office365-Filtering-Correlation-Id: 6ffd1e40-c45d-4afe-a5e5-08d47b2d6c9a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1690; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1690;3:oCI98gztYGbcVb73rg1hxXv5u3t648VwqTIonRzZDqaLlFFOBJCcuzVyRvxFhpdIC4X1053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99qHZGhfVeLZ/Sa/ytzsAmgZzzTK6gal4xg88gQ9FO7Qe3Cc9r/f+SHvIOY3xEEydIxSXZmyRmgzdNw1FeVkQZVzcHuC5K0Qwr6cVlhJRlqwXv0qi/XYRY7sjf04oK04IBt0FmA1jdH7WxBtFbqqv2ZGZd0B8tJlc3VzCaYMkhfDUr0ISX/UHK+oLmo5xJI9CA4g6v+Q2qQKiRdvf28dDgu7751LlE1wdaJ8YP+aVl8XZPVES54iUJ+nzNjp2FM898DULw+E+OzmQZoPEP/MtdOmLdyzQpmsC/wPS7NmAh7119tz+PtFYnVJJng2eg4mOQtdXQjmbZyAtkJN1C2DYMlVs0kcJ6kxy0CLNJEv51q7M7VY+T2OAJ/xrLeOJXz5TQDmMV8lXq7wVpWGgllg3eZl1cLoC7R/eS7pgVuR/HuiP+gwzgvoTEQyDB8GvUsh X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(6072148);SRVR:BY1PR0701MB1690;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1690; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1690;4:YfoRRax18LZSRodmyJHOh0onUmDrDFJdNvgvP+46EwhpyFJwDWVC1nl5Un/qaxgOQgTjljQo4smNUK9WE9J7CfmWa1DQdwJFnlwaw1dTigVuMK+w30Ewi1QNTwWNIJyT/lC5B0BNzHXPAltbkNodfK+Yd3EhUbctURbilZc/rJm+fA787bOZqXr3HwUTE6v3Qjo8jSvuYCVSeB7Sq3cQEtR+/w4WVlnmorJmRL5n/7iydhFMoYOXTKtlRG4TxQVFJuxu0JDcEnHOJc2JVGeMFo5+9SXjR+DMNjbiSUAn3kMumQPQt1mWY+xBdsUnUrP3eZW3Chjd+BZ+5MC+cYC2o4gOKr2mUkW2nytF78FH0ipkn9Hl2jV2YULDCN7gv8hChMPKDERRYVpCaOd18L7ejHccti9JbD79q7dWHS0Sbrl+sNmjccShY9PEawDjCu/a1Lri2sFXA83hVqEqu5dULWfqcn7uN/V8zCPbEKhLXZMD41OASQjH3hYh7wfXEXtSRrN29M1t4dU3xHQBpTCD1JuXlZrriWY4xTLZrB/wCzvUYuV6C9I4DskADed2tbke/yEF0yZ7D9imtLE9CDmAKIfE4/J/z/4zSfaXrjLT07w/asHk5Z0agsnW7IEXovqTMdNyWC7ORJ+8dxYnok48mK5RjmdEiccUQ7uLZ6qDn3j4w3TzQ9K0bf7IuWdnczMBXSPJZvmTzu2Un3DlmMLJC1XRwv3Vzv1sjvHYyZiV0bkGsLB6+pEaVXOlcJdyy5BD2lMEp3IiBU6BmiTCStBJpQ== X-Forefront-PRVS: 0267E514F9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39450400003)(39410400002)(39400400002)(39850400002)(39840400002)(50226002)(2906002)(3846002)(8676002)(4326008)(42186005)(5003940100001)(2950100002)(36756003)(6116002)(25786009)(6666003)(4720700003)(86362001)(5660300001)(81166006)(53936002)(6486002)(6506006)(305945005)(66066001)(7736002)(47776003)(5009440100003)(189998001)(53416004)(33646002)(38730400002)(50986999)(76176999)(110136004)(6512007)(50466002)(48376002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1690;H:mypc.caveonetworks.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1690;23:3ZYsSToQr3s0zNgxheborh3AJQovpMuUDBeIWQy?= =?us-ascii?Q?T3scp824MNVNhDK1AfDsdbqg4wzdVg2Xaj8jgNpx7PvK9WGCkfk23jkhQPVq?= =?us-ascii?Q?Yi7A8sjy3uSnEys4/xN2274QJa3jB6SXsctfLNFwXLWJe2QLI7ITYQXI5pV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uYxadMRWMHv7cqC2CPNi8siwDJPN?= =?us-ascii?Q?GySFHvL4=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1690;6:CC9NKpgzDsbYmjBL/V6v5QHnGgLqOz09dB+4uBDCDpYMcGxt193tso9i3cl/uDqHIS+ZepSt4/G61z6kEJEo2cPdoHvrJBtCcvFRbTagHqNHwOACJgk5wSJhAoNVXJAiHWSmgFw3H1zo5V2IbeIR8K0zCO5KDcllP15yNbsYJidIJ2/ae3TXWL7B1X5wGdPdwfHJYsDzrT6P5wRzlChfln6ODr06JebzhKgQbcT+jID+Ba+KnggyIBnhMLePb5JOg9LEIeQVsOSJ/srQh4fvXdjNbEa6MxhlQ1u4JptUODBdu53HRyfJr/3ORCEFEPClQeB+rmIimqbnuRaSisehUzWh6E29QFhSAZCL9dxGJC+2yg9CMRO4uo/UOQV7B2U29hhZGBWgDl4plvINGo4rFA==;5:WuOWYPzui63JIV4e4LYe7l+9oUM3S/gGzwqy6/IRNMnm1OD5Oy7SgnAGooqEixUbNVU+JKHt0PsfKx75G8ANoq51w6Xpzr7ZO97AehInxgIpjVnD+pRVpEg2ccSMEawSeHSV0O1pr6Lv6llvovfqvg==;24:gKx85JIZfdpl+rVMoOyz0FiT7gfhOCF+66dD9aTx8zfebsybXaywRr96XbIBTjyvNFNWjgXV1aTP86SVsgflKFOb0ZKUejKQRYHvCTrKPVA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1690;7:4kCBxSVJn+hCzjATTbrvsNgV8LeTJvrnMqrUAToz8ha/VkriBKCo60oPoHFshoWB4nUqsavlqRnt7OFHDBAVsuZa/o0fIcwu4KwjgbzxZEI+1pwrSJg6VMHndywtKcrtt5FnZwCw3ZWmQ9p4wl9CKBWDGemJZ9HAM6LAJkROPDSEEqq7iczB7qzES/5YcdITWo6dToW65o4oq4L0YdEOQWz6MK0tnbODlnIAgPTzFlvLXFwopUWuUKNe3lHXwUHOy2Ez3sLq3IuzqYDDm+8fbR8z+c0s4LbJXs7WB6i90wvjErAv5cX1LaZv7Yd1RUWCuOXODovahavfulKllX34Gw== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2017 07:37:14.8836 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1690 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1968 Lines: 78 function get_cpuid_str returns midr_el1 value from first online cpu available. Signed-off-by: Ganapatrao Kulkarni --- tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/header.c | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 tools/perf/arch/arm64/util/header.c diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build index cef6fb3..b1ab72d 100644 --- a/tools/perf/arch/arm64/util/Build +++ b/tools/perf/arch/arm64/util/Build @@ -1,3 +1,4 @@ +libperf-y += header.o libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o diff --git a/tools/perf/arch/arm64/util/header.c b/tools/perf/arch/arm64/util/header.c new file mode 100644 index 0000000..c0468fe --- /dev/null +++ b/tools/perf/arch/arm64/util/header.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include +#include +#include +#include "header.h" +#include "util.h" + +#define LINUX_SYS_CPU_DIRECTORY "/sys/devices/system/cpu/" +#define MIDR "/regs/identification/midr_el1" + +char *get_cpuid_str(void) +{ + char *buf = malloc(128); + FILE *file; + char *ret = NULL; + int cpu , nr_cpu; + char sys_file[256]; + + sprintf(sys_file, LINUX_SYS_CPU_DIRECTORY"kernel_max"); + + file = fopen(sys_file, "r"); + if (!file) + return ret; + + if (fscanf(file, "%d", &nr_cpu) != 1) + return ret; + + /* kernel_max returns nr_cpu -1 */ + nr_cpu++; + + /*iterate till you read midr of first online cpu */ + for(cpu = 0; cpu < nr_cpu; cpu++) + { + sprintf(sys_file, LINUX_SYS_CPU_DIRECTORY"cpu%d"MIDR, cpu); + file = fopen(sys_file, "r"); + if (file) { + ret = fgets(buf, 128, file); + if (ret) { + buf[strlen(buf)-1] ='\0'; + fclose(file); + return buf; + } + fclose(file); + } + } + free(buf); + return ret; +} -- 1.8.1.4