From patchwork Thu Jun 25 09:05:02 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: 50305 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 90683228FC for ; Thu, 25 Jun 2015 09:22:32 +0000 (UTC) Received: by laar3 with SMTP id r3sf17499021laa.1 for ; Thu, 25 Jun 2015 02:22:31 -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=ajXxwAP6nijlFhUdhCEagRh7FPVoQJtyueZjaa1hJGw=; b=Wh1p8ze1tBOk8IE2TmqEZmByqIObDhG9U2gshO/LXWn2KUcYkiNnlbhCw3FG+k/UOY sXoXCgwFaOx6LlxVZhjpOHp3S9Ah4hxgeNe9TjKS4vgyQg9wW9UdsZFSLa2cEjJtwmGI sGv0YQ7sD0oDESUurVKEN4EHxAqWq7u1bQ2SDt6bXuMvieW/iIkYa+Dp6oKcjmiSVN4P xHP0zdPnMwMYY7U19dZ3hFzh78nz9kfBw7U1HwnbhQCZGZBCqM1/wCErLRFY4CzNSZzg ZQxEXWhnez4VWb+nPwIWiZdvvOxPeAIg0QM3rI4Szh5sNCLgkyylmyFjRxNrqbCef+vU jjqA== X-Gm-Message-State: ALoCoQnfwjDOIuiNmmP1+lt8qZeP5pYnM0+rGCyjbePlIKw7HLSpEudus0ub7+7xRarZ42xjj89u X-Received: by 10.194.179.42 with SMTP id dd10mr31628941wjc.7.1435224151517; Thu, 25 Jun 2015 02:22:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.7 with SMTP id js7ls296114lab.34.gmail; Thu, 25 Jun 2015 02:22:31 -0700 (PDT) X-Received: by 10.152.121.42 with SMTP id lh10mr28294180lab.0.1435224151376; Thu, 25 Jun 2015 02:22:31 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id x5si24195318laj.129.2015.06.25.02.22.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 02:22:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lagx9 with SMTP id x9so41214162lag.1 for ; Thu, 25 Jun 2015 02:22:31 -0700 (PDT) X-Received: by 10.112.155.197 with SMTP id vy5mr43481396lbb.29.1435224150937; Thu, 25 Jun 2015 02:22:30 -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 hn6csp463733lbb; Thu, 25 Jun 2015 02:22:29 -0700 (PDT) X-Received: by 10.55.18.14 with SMTP id c14mr66619843qkh.51.1435224149258; Thu, 25 Jun 2015 02:22:29 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g124si7321473qhc.60.2015.06.25.02.22.28; Thu, 25 Jun 2015 02:22:29 -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 7021B61DA6; Thu, 25 Jun 2015 09:22:28 +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 B922961DEC; Thu, 25 Jun 2015 09:22:02 +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 1A23561DD5; Thu, 25 Jun 2015 09:21:56 +0000 (UTC) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0130.outbound.protection.outlook.com [65.55.169.130]) by lists.linaro.org (Postfix) with ESMTPS id 682FF61DA0 for ; Thu, 25 Jun 2015 09:21:53 +0000 (UTC) Received: from DM2PR03CA0025.namprd03.prod.outlook.com (10.141.96.24) by BL2PR03MB276.namprd03.prod.outlook.com (10.255.231.25) with Microsoft SMTP Server (TLS) id 15.1.201.11; Thu, 25 Jun 2015 09:21:52 +0000 Received: from BL2FFO11OLC009.protection.gbl (2a01:111:f400:7c09::154) by DM2PR03CA0025.outlook.office365.com (2a01:111:e400:2428::24) with Microsoft SMTP Server (TLS) id 15.1.201.16 via Frontend Transport; Thu, 25 Jun 2015 09:21:52 +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 BL2FFO11OLC009.mail.protection.outlook.com (10.173.160.145) with Microsoft SMTP Server (TLS) id 15.1.201.10 via Frontend Transport; Thu, 25 Jun 2015 09:21:52 +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 t5P9Li8w032447; Thu, 25 Jun 2015 02:21:50 -0700 From: hongbo.zhang@freescale.com To: lng-odp@lists.linaro.org Date: Thu, 25 Jun 2015 17:05:02 +0800 Message-ID: <1435223104-15434-2-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; BL2FFO11OLC009; 1:t7eAa5RP3wP6OumNa1SJtJLqx6nrZJj+bdFuUdwp7azv/XSI9KamjpWfud1FJgZR5hnapWDunfTRnaVwCLGbHHlDznJNvdRSK7cjUTuxmtLUB+0HzF33kH8xd0992XFTFSiYCU/YA4XMlwfHfZVGGOLOTA7gTERmQG3Ab0VN0y02RkGaEGbrXUXGl8ExH66sVSNUJMULz9tIZ5NgilG8ae2w4Ai4JlKBPT2Q9sDBtIHxEqMpxfoCPtMQHrHvrz/vd6cjkHIRePQReyyYnC2O45mAF0hTiwBR72Q1kg/tqkY33wyHxajzmkewcjJvrYEk X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(92566002)(50466002)(76176999)(50986999)(46102003)(47776003)(48376002)(50226001)(77096005)(19580405001)(36756003)(85426001)(105606002)(189998001)(33646002)(104016003)(87936001)(86362001)(85782001)(19580395003)(110136002)(2950100001)(5001960100002)(6806004)(229853001)(77156002)(62966003)(106466001)(2351001)(2361001)(85772001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB276; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB276; 2:LFcf+9zkaU/TBRvIehiK8CbKn8/Ue2Ba5qQhC8irqTQ88/m/pCG8xfssMb8w9eC2; 3:pWxC7DZ8TUsjdwdzEu3+tiPye3kYAqosh+T1LfRq1ZkBkCN37cjBZe5t7XeJ9FZhkywzj/RBVZapG8N0M/dxXV/VkBunl1nHXoMhCObHLIFiIRX2BQMtg11bBRMFXdP95PKPi511l1/kZiQ71Vq4IXcJBRONS0zE3rIpDorBu0n9Viax10mPxL6itMZrrB5Qe9epXimhnmXg/pKwiFh91Q2vAjmTLZHHvaJhXv0vuVc=; 20:Gw+Da+N4VV2PXxurXxLg8uJBQkfy9WKOYcE3K7sp0332hdqHAd4F9XfNBKzg/Jt2E7YHPLW4A4FdY4x+kk5DXlASbsPw3Fd8HpOl6VuEahRLEEC413ORRjZWDzNtEyXP3++fakCY3LB3+mp/2cOtBi8UNaxPu0Md3It4iqr+ol4GWum+WC3k1y3ZlfR6Ler4TEGZ8pVTUO1XYvlNbPTJryP8BgJVlm4Bght5Rs80bn4Ag19RPHJ85Jr84Ym+jzQj4uRcva5LEYVAE1Zg7IKuaGHBSgjBcl8yiHuH+bivzfbmjo75Q1Zay9enf5nWLvxrjkvonuANyx8hEp0KLkN+a6XM9ix7ULQQm2opXijQb2M=; 4:MYQelKDa8MW9f1GFpfFSPSHJXNRp6+nbD1NvK0dz/T6t/8rCKppJIPOS48t2ZevR2y58uurbF7Z/nLjhalkjQURvbrxAZ/VIOal8yqyrbBAcwKlHlq+wLujyvLprgBuPWfhAnCsvC9zwsBo0R81Vf90svbqBZOR4kC8KBtHU0ZmBKhoTWFX50C1YB5kC5VHmXIdH8CsIPymlByz75uFrhFD2Mb2CT8Rv/LjQg/tNO+1btMdvc2LP+mFeqV0Q45zbDrZZMnDy0T2w8/fLxWhtyXc938mar/ggOGa4cY3NOMk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB276; 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:BL2PR03MB276; BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB276; X-For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ZGvuU8OmDkcAwgbjGZV2l94M3Hugxsk5x55DakI9WmDpFE/oLJ7FiWjfeinGydlafcBBpr9B4LtNf3qKtcwlgjfUa2A/jTbwdVDWqZIDrxcVHKvScX1xLnSgYyr8LMcBJXkxhJe1L4L0Q==; 24:YKKWAKEjEgzoocyVW4hIdBCr6ZLrQrPYLknHeXBZNFhaA05Aa0OYnYrpaUjN4qCzoIAl+5DWWewsxcYu0O4lR1vGHwmP1+rmVQdWO4wibKw=; 20:H8MTYporPxsI844wjMeh/2bllLxjvIa2tQhGEDb2Pv78MJY2Cb9zDJdX0knveVluPRLSKMmzocq+L+R7+0i9TQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2015 09:21:52.3705 (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: BL2PR03MB276 X-Topics: patch Subject: [lng-odp] [PATCH 1/3] linux-generic: sysinfo: make cpu_hz and model_str 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.215.50 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, so cpu_hz and model_str should be different too, so this patch changes variable cpu_hz and model_str to data array to contain data for each different core, while for the common SMP system, we can simply use the cpu_hz[0] and model[0] to contain data for all cores because they are all same, but if like, we can use each item in the data array too. Accordingly, odp_sys_cpu_hz_amp(cpu) and odp_sys_cpu_model_str_amp(cpu) are added for AMP system, while the original version interfaces without any parameter are kept for SMP systems. Currently, all the platforms implemented are all SMP, so only cpu_hz[0] and model[0] are 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 | 4 ++ platform/linux-generic/include/odp_internal.h | 6 ++- platform/linux-generic/odp_system_info.c | 55 +++++++++++++++++---------- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/include/odp/api/system_info.h b/include/odp/api/system_info.h index 1f3294b..55a4180 100644 --- a/include/odp/api/system_info.h +++ b/include/odp/api/system_info.h @@ -30,6 +30,8 @@ extern "C" { */ uint64_t odp_sys_cpu_hz(void); +uint64_t odp_sys_cpu_hz_amp(int cpu); + /** * Huge page size in bytes * @@ -51,6 +53,8 @@ uint64_t odp_sys_page_size(void); */ const char *odp_sys_cpu_model_str(void); +const char *odp_sys_cpu_model_str_amp(int cpu); + /** * Cache line size in bytes * diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 8c5d339..7388128 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -22,13 +22,15 @@ extern "C" { extern __thread int __odp_errno; +#define MAX_CPU_NUMBER 1024 + 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; int cpu_count; - char model_str[128]; + char model_str[MAX_CPU_NUMBER][128]; } odp_system_info_t; struct odp_global_data_s { diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 31df29e..c9f6be1 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -36,7 +36,6 @@ typedef struct { #define HUGE_PAGE_DIR "/sys/kernel/mm/hugepages" - /* * Report the number of CPUs in the affinity mask of the main thread */ @@ -139,17 +138,17 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) if (pos) { int len; pos = strchr(str, ':'); - strncpy(sysinfo->model_str, pos+2, - sizeof(sysinfo->model_str)); - len = strlen(sysinfo->model_str); - sysinfo->model_str[len - 1] = 0; + 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; model = 1; count--; } } } - sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0); + sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); return 0; } @@ -188,10 +187,10 @@ static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo) if (pos) { int len; pos = strchr(str, ':'); - strncpy(sysinfo->model_str, pos+2, - sizeof(sysinfo->model_str)); - len = strlen(sysinfo->model_str); - sysinfo->model_str[len - 1] = 0; + 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; model = 1; count--; } @@ -199,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; } @@ -228,16 +227,16 @@ static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo) if (pos) { int len; pos = strchr(str, ':'); - strncpy(sysinfo->model_str, pos+2, - sizeof(sysinfo->model_str)); - len = strlen(sysinfo->model_str); - sysinfo->model_str[len - 1] = 0; + 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; model = 1; count--; } } - sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0); + sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); } @@ -330,10 +329,10 @@ 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, "UNKNOWN", sizeof(sysinfo->model_str)); + strncpy(sysinfo->model_str[0], "UNKNOWN", sizeof(sysinfo->model_str)); return 0; } @@ -376,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_global_data.system_info.cpu_hz[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) @@ -391,7 +398,15 @@ uint64_t odp_sys_page_size(void) const char *odp_sys_cpu_model_str(void) { - return odp_global_data.system_info.model_str; + return odp_global_data.system_info.model_str[0]; +} + +const char *odp_sys_cpu_model_str_amp(int cpu) +{ + if (cpu >= 0 && cpu < MAX_CPU_NUMBER) + return odp_global_data.system_info.model_str[cpu]; + else + return NULL; } int odp_sys_cache_line_size(void)