From patchwork Thu Jun 25 09:05:03 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: 50307 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 565B4228FC for ; Thu, 25 Jun 2015 09:23:50 +0000 (UTC) Received: by wgbbj7 with SMTP id bj7sf17625108wgb.2 for ; Thu, 25 Jun 2015 02:23:49 -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=krlQRLGqpHDJH++aQ3Vr84qU+nqszlsoi8qNFuBQV68=; b=D7T2YqbBSV5tmPxv/AaE2bvL/vrJvnIdCwiV9XU06+fafNgO0S1UkRey7iVkkRCwOr AJQRQT6zXV+7oO3LyupriNJrbHXHvfme5CJDcNWlWzK8ImLSec3iXoZ7lBUiSqar/j0W xnj/mwf9xupIZUrH3bBx9OYQuVREWMsc+fEDpbloCOPVX51F3RmQ2PHLHzbyeYhTRTYr PEbO3KbQZ8H7YPIt80hGFgCAhmlQ/ABCML0+yD2Mfjs8HstHAFqThA46C2Aq3Y5XuHrF DBNm53IJ+7wQWCLGw1m29W0NlThbSr+CdyIKuyWT4iVxBLd5T2lgnNWpYJW25mpU+k1w HvQg== X-Gm-Message-State: ALoCoQnHe+tVk8ZAvTLgqGk7o0BhcHBq5L7b35u4uWWsHy0XUQ0+MMnqxkx/iPEvqvT6Q/UpsecT X-Received: by 10.112.203.168 with SMTP id kr8mr39056254lbc.10.1435224229603; Thu, 25 Jun 2015 02:23:49 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.182.228 with SMTP id eh4ls301065lac.45.gmail; Thu, 25 Jun 2015 02:23:49 -0700 (PDT) X-Received: by 10.112.28.74 with SMTP id z10mr43612143lbg.48.1435224229480; Thu, 25 Jun 2015 02:23:49 -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 rn3si24232919lbb.5.2015.06.25.02.23.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 02:23:49 -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 lbbvz5 with SMTP id vz5so41701352lbb.0 for ; Thu, 25 Jun 2015 02:23:49 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr44077521lbc.19.1435224229325; Thu, 25 Jun 2015 02:23:49 -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 hn6csp464448lbb; Thu, 25 Jun 2015 02:23:48 -0700 (PDT) X-Received: by 10.55.23.17 with SMTP id i17mr73024444qkh.39.1435224228044; Thu, 25 Jun 2015 02:23:48 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id o28si28782369qkh.46.2015.06.25.02.23.46; Thu, 25 Jun 2015 02:23:48 -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 353DA61DA1; Thu, 25 Jun 2015 09:23:46 +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 D8AB461E1B; Thu, 25 Jun 2015 09:22:31 +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 A2E9061DB1; Thu, 25 Jun 2015 09:22:25 +0000 (UTC) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0111.outbound.protection.outlook.com [207.46.100.111]) by lists.linaro.org (Postfix) with ESMTPS id 6DD8461DA1 for ; Thu, 25 Jun 2015 09:21:59 +0000 (UTC) Received: from CO2PR03CA0037.namprd03.prod.outlook.com (10.141.194.164) by BLUPR03MB603.namprd03.prod.outlook.com (10.255.124.40) with Microsoft SMTP Server (TLS) id 15.1.195.15; Thu, 25 Jun 2015 09:21:58 +0000 Received: from BN1AFFO11FD011.protection.gbl (2a01:111:f400:7c10::161) by CO2PR03CA0037.outlook.office365.com (2a01:111:e400:1414::36) with Microsoft SMTP Server (TLS) id 15.1.190.14 via Frontend Transport; Thu, 25 Jun 2015 09:21:57 +0000 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD011.mail.protection.outlook.com (10.58.52.71) with Microsoft SMTP Server (TLS) id 15.1.201.10 via Frontend Transport; Thu, 25 Jun 2015 09:21:53 +0000 Received: from hongbo.ap.freescale.net (hongbo.ap.freescale.net [10.193.20.1]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t5P9Li8x032447; Thu, 25 Jun 2015 02:21:52 -0700 From: To: Date: Thu, 25 Jun 2015 17:05:03 +0800 Message-ID: <1435223104-15434-3-git-send-email-hongbo.zhang@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435223104-15434-1-git-send-email-hongbo.zhang@freescale.com> References: <1435223104-15434-1-git-send-email-hongbo.zhang@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD011; 1:ceRIfqWZasy//J5DnPaMv7Gpx6Tzi3Vr0Wn0DjkmQlqCGPhS3q2lUyS2WqaZ06G9nn7qe2y3uLyQB7O+1lxV1mpY570+auPAzWBY5wfMazEGA4axcMGQSSHzZPeGgoul92fVVO15w5TtLVELfSuIFCQreNLeI0Tn1sWQ70VVaRhI+Apnmho59YgoxRFWEj8hM7Ig1QVyJTMp6+NL/eNugE3AZNR5h2Ch5BgyJkMJrSwYM8fXf3vvQ+92qMtrU42Quzfh8dPrAiCj7HBmTyxGC6jQLpZOxG2R/+K7aXKDFmtmEh6mkWsMkwwJZ+abBAoC X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(106466001)(5001960100002)(50466002)(104016003)(105606002)(48376002)(19580405001)(19580395003)(77096005)(47776003)(110136002)(2950100001)(189998001)(33646002)(50226001)(92566002)(36756003)(76176999)(77156002)(6806004)(62966003)(50986999)(85426001)(2351001)(86152002)(229853001)(87936001)(86362001)(46102003); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB603; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB603; 2:GHlrjl5OB/Sg7/onuL/o+B+PZ+aEzn1k5WJgj4LtC76Nir/nM8S2hlZvlPbIvE7m; 3:nbxebnp8zndaIjfFQC1zgFrmF3QDSXeDacbSkXU6vyHHw8dMp+cp65jqDH+LwrbOSFO1EYOrPLNZa/0Q3XQ3sY57k6kJNqNIMtgK1Dwv1nwqUlj1pnX+CoCCgt2sC+boGYTZOQpLnbvqh5tSTUfPgivZlco15jL3AvbWid1dzM7EMy5z8RWbGKi7ARxHRJnJQkUlNGGU3NSLSJNvHP8WBE9gxBuSqrKjyJAsypBq9fQ=; 20:A7LvFTZBUXSxpibruwZ9bgE6RezNmBLXH3jnMOsbOZ8116l/uMmvh279wD/EPwZFTxIqo1Or9AQg8cfZcjGgt52c5Z6Q5V28bZ91QS3cxR0If+mbXONSGD2jozbOBaFwWwvQRsmXFMxbaNNJzNj3wK5LZKs5+OlGaLib/gaTcIlfY5gm54fmCCgL3bCryNGHAvypVZxBFyo0cL28xPLjY7pZdDS7vDudEap/G7OalIdfmOS5gE6urqbFobR07xTMnNH8wr1vztljAocylynJmbTkwqi2a+ZXvHaPe1KbvrSFawX2dqBS/xEClH8H3HcQUSrKpTZMoArYj4Ifec0pX3tyjLEtaIe63+kmtDmC4vQ=; 4:iLZYweBYeazJOe2yAmdJa/DyFV/jOf/bAg3gNsLRXNBmNlWU5Qsh2yUo3KHM6cCvJCJkgS0IwPeC+edACr2M2Ath0jOEIlS7VGPfu5ggd7e2VqSAno/F3+4qdhXDf7//8eCXM00Llev4Ls1linjqbuskcnsr+BOn1UaqSA64MnNX6ixz1QMHmkJAZWLFbYc0lZeUZOzr6+G4YgjGxRbmizvPO4rgQ+u9LRG2XDjathI9G3KPRuaGE5FdXuryl44ltBMlWC5eNEsXbR9BUhoCeksu3sqo0leZU1yLn5yCjgY= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB603; 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:BLUPR03MB603; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB603; X-Forefront-PRVS: 0618E4E7E1 X-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D+aaGIasxwLRSAr/Nli0TxdKm3BuNhlBnXawEOs/r1vN9MLNmDGksi9V5b7UqIurFhLiPMTdmjw==; 24:OpxiP3jQ0x8mVnyELMjLSBHZ+q4Ja2jT0BiCYbHu/9T2EUsGYxJdWa2A7kpswsBez1H9PZzEu/Caww4mcJrg+bmt7RVXtNsbTyTriICdjL8=; 20:v7gHeBiLMheK+mDzeCs2DRC5xqwA5S1dWoPJphudoyYpnN5Z3SbeU1OAnJYn3Y5y4x76sCl1dnAocfQVlkFJDA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2015 09:21:53.9508 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB603 X-Topics: patch Subject: [lng-odp] [PATCH 2/3] 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.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 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 frequecy. While there may still be some use case of aquiring the current CPU frequecy, 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 c9f6be1..3ca8b27 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; }