From patchwork Thu Jul 2 10:45:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hongbo.zhang@freescale.com X-Patchwork-Id: 50564 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 57805214B3 for ; Thu, 2 Jul 2015 10:46:54 +0000 (UTC) Received: by lbbpo10 with SMTP id po10sf12322686lbb.1 for ; Thu, 02 Jul 2015 03:46:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:mime-version:subject:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=EagMkasoSVKYieNSSKSBOLH2riKZbaoQIQ33Ah9E/Mk=; b=eJcWfdInF2EMmaHgB1i6A6fMpAmoq/Sw7pnxIt2AXHQfHcT6yPwkRe39EzLQebWghk sW3w+r0fg3YG84X+uvUjP2oOqR6vhiLetOWvemeGAy3DKtI12oULJOy0yxbWnW50Utfh hazOJ8dyuJt+JC6BYmKq737dEoeva5KOp2RzI1bXAbDk7zjkXMziW2SuiCaUxmeZ/lL4 BB3QDI5Gzl1CmlTMQzrM+ZSiSNM6IyA5auws4AmMDN28v24Szg169+UtrrfThUHQnMYt 6fHrgSe5VIdpdeUbLAApiE3+1G0hsrGQFKrlTpdhcMtvzTbJWph4px2PdGuqP0SyHq9H v6Qg== X-Gm-Message-State: ALoCoQnkNx/rvl4XW/InhiKNQKj6nH9vtJN6EBupFHaYvVzw/t7++3MF/mJxeYz6Crn6pQghEcV/ X-Received: by 10.180.86.98 with SMTP id o2mr17448356wiz.4.1435834013316; Thu, 02 Jul 2015 03:46:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.178.164 with SMTP id cz4ls332738lac.3.gmail; Thu, 02 Jul 2015 03:46:52 -0700 (PDT) X-Received: by 10.152.87.97 with SMTP id w1mr18887779laz.124.1435834012923; Thu, 02 Jul 2015 03:46:52 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id o7si4145376lbw.36.2015.07.02.03.46.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 03:46:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbcpe5 with SMTP id pe5so29400995lbc.2 for ; Thu, 02 Jul 2015 03:46:52 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr29805280lbc.86.1435834012726; Thu, 02 Jul 2015 03:46:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp385582lbb; Thu, 2 Jul 2015 03:46:51 -0700 (PDT) X-Received: by 10.55.43.170 with SMTP id r42mr63331257qkr.95.1435834011289; Thu, 02 Jul 2015 03:46:51 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n35si5836990qge.91.2015.07.02.03.46.50; Thu, 02 Jul 2015 03:46:51 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 442FF61DEF; Thu, 2 Jul 2015 10:46:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 5872B61F1B; Thu, 2 Jul 2015 10:45:44 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id AEBD961E50; Thu, 2 Jul 2015 10:45:32 +0000 (UTC) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0142.outbound.protection.outlook.com [65.55.169.142]) by lists.linaro.org (Postfix) with ESMTPS id AF27E61B53 for ; Thu, 2 Jul 2015 10:45:31 +0000 (UTC) Received: from CO2PR03CA0021.namprd03.prod.outlook.com (10.141.194.148) by BL2PR03MB605.namprd03.prod.outlook.com (10.255.109.39) with Microsoft SMTP Server (TLS) id 15.1.201.16; Thu, 2 Jul 2015 10:45:30 +0000 Received: from BY2FFO11FD018.protection.gbl (2a01:111:f400:7c0c::105) by CO2PR03CA0021.outlook.office365.com (2a01:111:e400:1414::20) with Microsoft SMTP Server (TLS) id 15.1.207.19 via Frontend Transport; Thu, 2 Jul 2015 10:45:30 +0000 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD018.mail.protection.outlook.com (10.1.14.106) with Microsoft SMTP Server (TLS) id 15.1.201.10 via Frontend Transport; Thu, 2 Jul 2015 10:45:30 +0000 Received: from hongbo.ap.freescale.net (hongbo.ap.freescale.net [10.193.20.1]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t62AjPm1012040; Thu, 2 Jul 2015 03:45:28 -0700 From: To: Date: Thu, 2 Jul 2015 18:45:20 +0800 Message-ID: <1435833923-28361-3-git-send-email-hongbo.zhang@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435833923-28361-1-git-send-email-hongbo.zhang@freescale.com> References: <1435833923-28361-1-git-send-email-hongbo.zhang@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD018; 1:uam9PEJWDBnv8isSvkouhh2GsYKV4S2A2kh/CXBkwvy3mOtqMFYuHt7F+4UtGJwM7ZVknG6nqZXQK2Go6s+rKPUBfElahjQ4hkc5C6rwQHEtNQ7ez46JNV6qT+xHNJENG01B9hmhR2XjI27O1Od1IUpTRN5UUIdkxYV3Q500zfuPxcuGNm/09mgMxqWgucM3MybSbcgxS+zHaDpK5pBVPVieIJ19h4PHlbPHqrqddPu6OEjcDqfjr9DimbZKBQ7+jn3D0qygSKgVotSq4c+XV8mQKzyG7qRu5ubG03OnfdE7i3bpR4JsylEMhwox6yql X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(48376002)(36756003)(62966003)(85426001)(50986999)(33646002)(46102003)(76176999)(77096005)(77156002)(2351001)(2950100001)(50226001)(6806004)(19580395003)(5001920100001)(106466001)(86362001)(575784001)(50466002)(92566002)(110136002)(47776003)(87936001)(105606002)(104016003)(229853001)(5001960100002)(189998001)(19580405001)(86152002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB605; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB605; 2:h0pS85p7eUFVkkIRO0XSU8Db2F+P80U+qH/yK49H2ckpOtZgLdZFCSVLixdcU/Zu; 3:btEJO9eUTsEIaVKZ3IqOxTu307Ue3p1jRPwyuRYyFpNo7WSD5lM9OjDdz99QnaRro9d41rXy4z3Ka8IHUluJ3u7Ltqu3YU7NEZl8cvrhiORSzrmF5KTBkF9gY0cyYP+97SbgjkvrfdsgoUeWxuY4AZZ5AqseX1GXkAogi3k8kl8e/HBpxzuZz1CaX+cNnEHmrFY5uFeH5sLocJZsbIYknCCGuV0Rr42xy52lf9REdbU=; 25:js8+AzQjaZWTQW+dNi+EfYlSw1LQmXQbP9ZB0GFzvTyDxj3cb+Nqt6IyBk0mJi7nlMPH8BZEhv5cP57MJFz5ZTM+xwSCHCQoH/D1eXsEO7Jjeo6P3rP4haokeVqimaRxCfviQ0kJrsHg0V5+09TAPfkvd8LHfjuXZXrUGyAjCeIfl29kMeivtCCfByL0Iq81CPAtZ61XItTYcTEzWl7oMd0E30/IoDO5t3vKbaGXsBBRU5T8eAvJic8JURb8YGpl; 20:Y+Y+d4S2Fm3EbCi3bty5CjVZu6BCf3kMZrTxDC4+e+40jYnMoZB+fanmx7e86L9CMdQmPcWBVdfAnTlyQ/5seXzbZ6LKuu1MTB3HXKpwup53DIcnECCpFFPLU21GCs/FUJ3a3ZsgQ5mYwsYNs2XZm2slt/ttDp3q3O7zxUHJ9/1TdkQWJgKG9URRr3TqOAswWXdolr7qDlgBOBd+rFlAo30e1E4vxw6kI6/7vK94rkef6EUsciqTJyg9WEcWpWZ8T5VDzS8jRGzr2sLQmSz1B17mWtm5+LKnUVuZBS9ocYMUWmolCItKeMdlq1qWJXLDkLIvH+1YkxtY5IAi/iboX6QXtwviqTYFd28ZAyTPKgk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB605; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BL2PR03MB605; BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB605; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB605; 4:u4FiCK51AU22iFtG7DtenPVjNZCNgUFUgWGq9RwOUKbKy3OJshBEcMUqk1UhyCLZM7pec4cuP17Ybci9WZHPyH3LOvOXAEk24JYJREAKZaFatbeIPaHQ5Hblq8t/1bdtOAk8PzmeNIfTfnwSFAABUr15t+Zrob+GamDsu/QybSkDZAey1Et9UTTdN8rcoQocYfrQznLl8pyG4Z5xUGcq0JM0s3tkmcZEtMKzxP0xtDqr/gHawuh1aBrRuKaxOPygEwgBE773SWVUpBA4iaHX5NlUnXOCvKoViLDYA7pJIRQ= X-Forefront-PRVS: 06259BA5A2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB605; 23:LwfDKYtiiR6yxXpq4BKe88AtTjkB19/fJW2T/jRmWq?= =?us-ascii?Q?70i1phz4SulQPFj/uaUv7WjpLUANhrnu2RbxMPuK7pJQ8EZRW0aw7iYQ9rGv?= =?us-ascii?Q?VUjgHenpSJdjGIep6B/yUXstzHA17N0KmruxK1KzVHe6wo3ppd6AwohHFkne?= =?us-ascii?Q?nvtTJG7ans1xsE/ZCqesg4fVm0Cm8TSzKjf1U3ZMcOXwDaiD2ckGMTDHNp9W?= =?us-ascii?Q?HeydfBc9AGr3o0PSBUwA7w1va795F+Dif+09uPXENDCACjwpjWVB1AYdK0aF?= =?us-ascii?Q?LDuuPEqpan1nmWxE6mYpti5Jhc5k8Zf8rsnrBPJLkn+jsuFnCgp79d9PP9Nr?= =?us-ascii?Q?uV0EM+/xB72rWlOwuH/fSXlajjL1TJPMidmccabZh0FhoJrqswa8mARMcOLX?= =?us-ascii?Q?Ev3/iCfpXi1138XMvKkf57kJrOq3Paa4/IGgs3LG74sWnDne6dCLDpkEQf7V?= =?us-ascii?Q?9v3f+kQT7X7QHeqRiKxbPTbyVTGv1+pd0L2esg2PxqPThRU6ZBqklsgxDC3z?= =?us-ascii?Q?mocdfKi+7FuWN3Y/3L3iQ9llmFIFUR4PAhIVvdWs92qZ1vGJY1T+Y/XrWsI+?= =?us-ascii?Q?2KsdlpeEH+p5KTVUjXd+B7IkQTDTCst6Ob29ev42AujXaMjjhD1RyNA8Ia4J?= =?us-ascii?Q?MPmPxna1OTwXYl6VIjemZAhiYRyuOUq33cTsCpk8DrFjSeIVuNL+lQAOWKHO?= =?us-ascii?Q?XTYlW/GH6Ik+UmrCtTbBIV655t1/4CzjjG5zb3F1hEtnfHnKNRhTfuDuzQFB?= =?us-ascii?Q?CzJluKDPrFb7bsA5LWYBXpL2g/gI4N4s5BFcMEPg1dL7NTUNVYAnUgRKtnGK?= =?us-ascii?Q?7QZbDpqZpIT7pktGQkHePo2/Nu0bB9udx2PB+rm6Uf/p8Hkt11fCsjTYat5C?= =?us-ascii?Q?DjPIoLpcSMkDYQavfRPf/CEhgxV1HZ9IDKpV8WePmGheYOxFQIg8Z8Ob7ORg?= =?us-ascii?Q?6jxaOmqAcR45v8kmU87rR1I/coEvQkU0d9KbY2uw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB605; 5:JrjtizN7U2T9Irul1v6ylSfaTm0/uoBb9Q2feLUQKf/zbbVOLXas5t4w6RfUA0iV4Om9/Fnn5zYEBU0J++utRdk/G8IQA6CgU+Zx9mCytCedzGM9mQt0UkfFRKT7/yVhAEk4RUifVJZi5jqnuQ4WoQ==; 24:xj7VZDAha/DMbtdluqhtDPE2lFFit/0OCHbaTziTsZfaq1KPvWzHhjOw7SxsCBtyu93edODPlgzSI3Q1pP7q2p/BUPle5o2moeJvPVV+6TU=; 20:hOvwFsYrWuJWAz6wp9ZhtXWFS3+oOfSepdDtdixPor+8UH/LmrO5wfFQ8Q8EfAXMORUCqovU2azLktGdKJ0OyQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2015 10:45:30.2547 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB605 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v2 2/5] linux-generic: sysinfo: make the cpu_hz per-CPU data X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Hongbo Zhang For AMP system such as ARM big.LITTLE, cores are heterogeneous, and cpu_hz for each core may be different too, so this patch changes the cpu_hz to data array cpu_hz[] to contain data for each different core, while for the common SMP system, we can simply use the cpu_hz[0] to contain data for all cores because they are all same, but if like, we can fill each item in the data array too. And the odp_sys_cpu_hz_amp(cpu) is added for AMP system, while the original version interfaces without any parameter is kept for SMP systems. Currently, all the platforms implemented are all SMP, so only cpu_hz[0] is used, but when cpuinfo_arm() is implemented, this per-CPU feature should not be missed because of its big.LITTLE. Signed-off-by: Hongbo Zhang --- include/odp/api/system_info.h | 7 +++++++ platform/linux-generic/include/odp_internal.h | 2 +- platform/linux-generic/odp_system_info.c | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/odp/api/system_info.h b/include/odp/api/system_info.h index 86b4556..8627d97 100644 --- a/include/odp/api/system_info.h +++ b/include/odp/api/system_info.h @@ -31,6 +31,13 @@ extern "C" { uint64_t odp_sys_cpu_hz(void); /** + * CPU frequency in Hz for AMP system + * + * @return CPU frequency in Hz + */ +uint64_t odp_sys_cpu_hz_amp(int cpu); + +/** * Huge page size in bytes * * @return Huge page size in bytes diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index bcf7e63..8df8c23 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -25,7 +25,7 @@ extern __thread int __odp_errno; #define MAX_CPU_NUMBER 128 typedef struct { - uint64_t cpu_hz; + uint64_t cpu_hz[MAX_CPU_NUMBER]; uint64_t huge_page_size; uint64_t page_size; int cache_line_size; diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 181a0c7..8ade5a6 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -148,7 +148,7 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) } } - sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0); + sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); return 0; } @@ -198,7 +198,7 @@ static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo) } /* bogomips seems to be 2x freq */ - sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0 / 2.0); + sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0 / 2.0); return 0; } @@ -236,7 +236,7 @@ static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo) } } - sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0); + sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); } @@ -329,7 +329,7 @@ static int systemcpu(odp_system_info_t *sysinfo) sysinfo->huge_page_size = huge_page_size(); /* Dummy values */ - sysinfo->cpu_hz = 1400000000; + sysinfo->cpu_hz[0] = 1400000000; sysinfo->cache_line_size = 64; strncpy(sysinfo->model_str[0], "UNKNOWN", sizeof(sysinfo->model_str)); @@ -375,7 +375,15 @@ int odp_system_info_init(void) */ uint64_t odp_sys_cpu_hz(void) { - return odp_global_data.system_info.cpu_hz; + return odp_sys_cpu_hz_amp(0); +} + +uint64_t odp_sys_cpu_hz_amp(int cpu) +{ + if (cpu >= 0 && cpu < MAX_CPU_NUMBER) + return odp_global_data.system_info.cpu_hz[cpu]; + else + return -1; } uint64_t odp_sys_huge_page_size(void)