From patchwork Thu Jul 2 10:45:21 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: 50565 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DA154214B3 for ; Thu, 2 Jul 2015 10:47:34 +0000 (UTC) Received: by lbbui3 with SMTP id ui3sf12308197lbb.2 for ; Thu, 02 Jul 2015 03:47:33 -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=HQrP/bU+CZvxz19QNy0fEkpO/cHo4UQ5KY3Z9oyWLUY=; b=HvE9yeiciklzRvsoasapnI4/1dghCkbA3jJwY9W7GujP7UzrQDKyUSawg0rVpfC28f LCL1PLCfeM2htPcUtlNfs30kiXz6E/M41TSVW4XHKoTut2qgu1KEWUsLkC3XHdE9HcpO wbtuafZDWw/490UO0uickz2OXF61NzwnHMNzV03vY9OtlplqkerV0OtWTQX99L9cy1Nn fiAb2eR2yaSVuHEM+hj9oKR8qt+4MdgJ2OR8zYRmyq2/xB3C3dKIVO+wB51kFz7VxDdQ vhMo9MH2n2vw0XvHn2AogayvliW71ire/RBGa79W/XXYDnEwzpup+JUbVEAJ+MalIV9J Fiag== X-Gm-Message-State: ALoCoQlsjvFVqJYQkfxNNnh9WiUZpMmIZ2DuKV1J2CjJdjGwWn/8uWt4ZMIUtGTICuihgUnHS58F X-Received: by 10.194.5.229 with SMTP id v5mr2984886wjv.0.1435834053824; Thu, 02 Jul 2015 03:47:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.168 with SMTP id kz8ls270123lac.105.gmail; Thu, 02 Jul 2015 03:47:33 -0700 (PDT) X-Received: by 10.152.116.49 with SMTP id jt17mr29583142lab.82.1435834053676; Thu, 02 Jul 2015 03:47:33 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id t10si4149653laa.17.2015.07.02.03.47.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 03:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbnk3 with SMTP id k3so29440947lbn.1 for ; Thu, 02 Jul 2015 03:47:33 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr29787667lbc.19.1435834053534; Thu, 02 Jul 2015 03:47:33 -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 hn6csp385954lbb; Thu, 2 Jul 2015 03:47:32 -0700 (PDT) X-Received: by 10.140.238.22 with SMTP id j22mr42556605qhc.98.1435834052002; Thu, 02 Jul 2015 03:47:32 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f9si5836591qka.100.2015.07.02.03.47.26; Thu, 02 Jul 2015 03:47:31 -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 6F61B61F0D; Thu, 2 Jul 2015 10:47:26 +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=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 A00FB61F65; Thu, 2 Jul 2015 10:45:47 +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 E7A3261820; Thu, 2 Jul 2015 10:45:34 +0000 (UTC) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0104.outbound.protection.outlook.com [207.46.100.104]) by lists.linaro.org (Postfix) with ESMTPS id B2D07615AF for ; Thu, 2 Jul 2015 10:45:33 +0000 (UTC) Received: from CO2PR03CA0021.namprd03.prod.outlook.com (10.141.194.148) by BLUPR03MB277.namprd03.prod.outlook.com (10.255.213.15) with Microsoft SMTP Server (TLS) id 15.1.207.12; Thu, 2 Jul 2015 10:45:32 +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:31 +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:31 +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 t62AjPm2012040; Thu, 2 Jul 2015 03:45:30 -0700 From: To: Date: Thu, 2 Jul 2015 18:45:21 +0800 Message-ID: <1435833923-28361-4-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:47a7ZhFbmOYaxx4vYxMzDZBmLR6oHEz3ePN7RMgm7a5XMC6nBYyTse30BFnIm9ChDIgLNwYd7c8XQtkKd9M3ggoLOzPZNRdpw2Nwn8WOyJmbkZznFSrGpibGneHKQ3+7yXcrIvjzEx0G+KwRt8U9kNmaJzhGna9CYbJxVMvBavOyIYvtsskFgFLc8TnnB0R7LdjoC/f00TeLmhrYisGeo1PuLITYhc/KfVw1yPfu/KPa/qTDoH4mlw68tzdbgucswocdBi6Xo7X4YQ8j0fcjSbOhCN9+fQWcdTn3dtyAaKVRLeAJYHwlHKtprw2Pghm2 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(50226001)(50466002)(77156002)(87936001)(48376002)(92566002)(19580405001)(19580395003)(50986999)(76176999)(62966003)(189998001)(85426001)(6806004)(47776003)(5001960100002)(86152002)(86362001)(110136002)(229853001)(77096005)(2950100001)(46102003)(33646002)(105606002)(104016003)(2351001)(106466001)(36756003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB277; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB277; 2:8wJBqB7HshFXTJIupJGd3YyBqSCWWXam+iIzpWtVe9MT8sRUL/QSSEJhCGgFO4QY; 3:8qFXI+AqLEH1sDjGbTI21Xy39sY8AM3uhJwRQh5VF9EhoQ+/w4JA9nxz4KJ9zQ6S9V2uZNhuN6DhuCcfxDmbhuYFfPhf8FceOubi1xSMJSbTe24QSqjoScrYD/fa8uZC8TRl21rKT+ls2lhJL64U7AHwERusKfinOAKjZgf21db2VRXfGMxGv+jYzmbId5WYBax6PYiwDPxPIOAQkL32MJ2QAkkUfeQNMrk2me05c/0=; 25:ymaLb2Jmtm3LIziF39bEBpcohE+d1Tqzk+MBrMAGgsOVP6Y+wzJPz6DytpltnKlvtfi5RYaQwhCxyNV0TaokzkZnMs7nN/rinbEKw8wE8LTsF6cHMvDRplcOvb7FVduXWGylAQYRvwVWuWvu4Rfr7z/yC84/j0A0Mx+CfhJQ70jo8MhZ5etzjSm9PHwvqUh77jDiG5Z1tcPsmWLoZXI2i4qbhuhOzGvwtES0gnmSAm6mGfA557fnV2h453sDHVmMTMcdt/NqPCAGTOM6T7QKKg==; 20:wajty6F3r8Ph9tFJt4bxL6J1TNiRlEvaFpr9wF733ddrZNtxdHNeXdhq8hm0Yn5MEkhfSbD7Ewcv1Rdky27kXNpUuCgXhgEdVBgKC/CtttsNn+6vuEc9dOdnd2s1sSCPegs/X6RKUe2Iz4MFVpuCPG0ENJqrAZlWjE4zMkacDKx+WxfdN8JNjOTGb7lCvuQdk3tY3HuAjQJpkTO3G8/iH74NwprtTHaLZeZ8Kbcfzyh8kSM2jmjcgAt3XGJ3PNJlgBBwkrLecpglXpmla9xo4cBwSCPhcqesJnaQ8vEEoBIyz8ViH4m1C9jQIqIE9TkzvMzZCUurG4wu4rXtfVwXEYObxjkvi/nQ4Oz9gpIG4qk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB277; 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:BLUPR03MB277; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB277; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB277; 4:kmroYmgap3ug2PPYYKeaHXaZDdDggb3v1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Hi7sO7FjWgvdFS5LAHJHpjpltT3SlWOqVGPjxFjFbirXaxNuf8Ti8eTmihkC9pM5yoZAGeObcbEMY7R8RaPY891oxtXTHZv3rrZ6WyG4B29iynEcOBnWKDK4TgafIrxHQk4VsjIJbVG0rgVBmgKIkzVusRHgbuoqmL5dt7e1iD8VVXei3cW5Kr/OGU= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB277; 5:xeIHNjulgvunXoVt0Rg3tFiR7zAwgIvsqFhZDhK/3gWjJG+BrypnsG/Y03iyqzhOFjUczyaTgtiN8eCuNRnOzMLFGjfqAlBXmh9PCb4enq2PcEwDYQ2l2Nomu6ASKqzX1APqPR+VVE5TALJS9q/E3Q==; 24:l3u7dAy1aJU6aGn/yu68svlxcWGGDuqmibPvqUBXZbb6cbXfHelhA0x2XkeovJpXBch2hj9cjR+mCULVYPDwR0YYAxpGYCilg1mhZXGfByk=; 20:RXNQvwnBSSR5JW4f3k5nx2K9ziQAu+jLrf2exs1yAwQZZ5+SpGTUGsaLns9J0bhNTgywWwueX517ysAel8Tg1g== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2015 10:45:31.4715 (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: BLUPR03MB277 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v2 3/5] linux-generic: sysinfo: make cpu_hz stand for max CPU frequency 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.175 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 In the previous x86 platform code, the variable is acquired from segment "cpu MHz" of /proc/cpuinfo, this is the current CPU frequency when acquired, and it may be scaled from time to time. But most of the use cases when odp_sys_cpu_hz() is called, users just want to show the max capacity of CPU, so this patch makes it clear that the cpu_hz stand for max CPU frequency. While there may still be some use case of acquiring the current CPU frequency, another new API for this is introduced for this in the next patch. As to platforms other than x86, if their cpu_hz's don't stand for max CPU frequency, they should be changed following up this patch, and then max or current frequency of CPU should be clear. Signed-off-by: Hongbo Zhang --- platform/linux-generic/odp_system_info.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 8ade5a6..00b8d4d 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -120,35 +120,27 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) { char str[1024]; char *pos; - double mhz = 0.0; + double ghz = 0.0; int model = 0; - int count = 2; + int count = 1; while (fgets(str, sizeof(str), file) != NULL && count > 0) { - if (!mhz) { - pos = strstr(str, "cpu MHz"); - if (pos) { - sscanf(pos, "cpu MHz : %lf", &mhz); - count--; - } - } - if (!model) { pos = strstr(str, "model name"); if (pos) { - int len; pos = strchr(str, ':'); strncpy(sysinfo->model_str[0], pos + 2, sizeof(sysinfo->model_str[0])); - len = strlen(sysinfo->model_str[0]); - sysinfo->model_str[0][len - 1] = 0; + pos = strchr(sysinfo->model_str[0], '@'); + *(pos - 1) = '\0'; + sscanf(pos, "@ %lfGHz", &ghz); model = 1; count--; } } } - sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); + sysinfo->cpu_hz[0] = (uint64_t)(ghz * 1000000000.0); return 0; }