From patchwork Thu Jul 2 10:45:19 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: 50563 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 50758214B3 for ; Thu, 2 Jul 2015 10:46:18 +0000 (UTC) Received: by lbbui3 with SMTP id ui3sf12299675lbb.2 for ; Thu, 02 Jul 2015 03:46:17 -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=DBq8YpFhLNhv768sFpkxmPuF7eHm18TF6a/Q/9i8Ehg=; b=AocwJfx1E8adA3nBYy+WZSVuVon1Q3Z0MAwMz4KSv+yoYI2k46lIqx0xcgc7puAis/ mN6HwHI+h7MnygfgKgNczOAcJlaX10ZLeO1pA3/IsFf78FxxD99gQt7ZlqKOp27ntLxK E2idfU64N6JAD5i6qgdvJAnp9PBXPAcEhwes+5RGnb+09bUVs4R4OjR8Ge+wN5AD4drJ ByFLQ3AO5vD4o+EB3a3i+qhVgxWuxPKKmb/MPUE6OpmE2oWHkHidHrNnzcXDZaqSFUfE 9SLOPqYuLlvPPY6HAhsdN0rKskbUe1h7wslMkZ1V43q+sP89+q/MASyj4ugEsPuE4hpf W1wA== X-Gm-Message-State: ALoCoQk8djceaZ11reF2c0LrmO9VIYSQ5YLtJbOiDGRR+7i8HOTOcIV8y0mHpv9vkJJjRKtzBrXk X-Received: by 10.112.253.135 with SMTP id aa7mr8828585lbd.11.1435833977152; Thu, 02 Jul 2015 03:46:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.201 with SMTP id p9ls321045lae.42.gmail; Thu, 02 Jul 2015 03:46:16 -0700 (PDT) X-Received: by 10.152.87.33 with SMTP id u1mr30531679laz.78.1435833976894; Thu, 02 Jul 2015 03:46:16 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id x10si4120740lbo.118.2015.07.02.03.46.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 03:46:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lagh6 with SMTP id h6so58271791lag.2 for ; Thu, 02 Jul 2015 03:46:16 -0700 (PDT) X-Received: by 10.152.88.68 with SMTP id be4mr27352633lab.76.1435833976602; Thu, 02 Jul 2015 03:46:16 -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 hn6csp385257lbb; Thu, 2 Jul 2015 03:46:15 -0700 (PDT) X-Received: by 10.140.233.70 with SMTP id e67mr27024974qhc.7.1435833975110; Thu, 02 Jul 2015 03:46:15 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k21si5882997qkh.12.2015.07.02.03.46.13; Thu, 02 Jul 2015 03:46:15 -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 E28C161F7F; Thu, 2 Jul 2015 10:46:13 +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 0085A617FC; Thu, 2 Jul 2015 10:45:40 +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 9857E61E50; Thu, 2 Jul 2015 10:45:31 +0000 (UTC) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0115.outbound.protection.outlook.com [65.55.169.115]) by lists.linaro.org (Postfix) with ESMTPS id 780ED61DEF for ; Thu, 2 Jul 2015 10:45:30 +0000 (UTC) Received: from CH1PR03CA006.namprd03.prod.outlook.com (10.255.156.151) by BL2PR03MB606.namprd03.prod.outlook.com (10.255.109.40) with Microsoft SMTP Server (TLS) id 15.1.201.16; Thu, 2 Jul 2015 10:45:29 +0000 Received: from BN1BFFO11FD004.protection.gbl (10.255.156.132) by CH1PR03CA006.outlook.office365.com (10.255.156.151) with Microsoft SMTP Server (TLS) id 15.1.201.16 via Frontend Transport; Thu, 2 Jul 2015 10:45:29 +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 BN1BFFO11FD004.mail.protection.outlook.com (10.58.144.67) with Microsoft SMTP Server (TLS) id 15.1.201.10 via Frontend Transport; Thu, 2 Jul 2015 10:45:29 +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 t62AjPm0012040; Thu, 2 Jul 2015 03:45:27 -0700 From: To: Date: Thu, 2 Jul 2015 18:45:19 +0800 Message-ID: <1435833923-28361-2-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; BN1BFFO11FD004; 1:MtGw7BGX8NMzTMUsWXEC9ce4a7sWxHEpWNsn5fRInRxOPJWYQZd0+EnrYsqH0/LuCCdD2/kPDI/zGO/sgjZzFuqwktT4V4dFLHTifoAlmkngbYKOfOJW34sftm9K2LVDxSW3JEMA9zNTQzuz3z29E2fGIxo7eTd3F2j4+UqSRJKFUTvv1YreHbrh6AqVesC2TzTY24RWKIcxmjERPlWmAB3mscrfmGx14n6UONd/rRupI/go3+zaE5WKU5On8mzcoQuCpNKdJm+n7xP0cFBv2UTJniHugNMVjMoKRH9616dyhgk82uccqml08MMGacpK 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)(50466002)(19580405001)(36756003)(85426001)(6806004)(50986999)(76176999)(19580395003)(106466001)(86152002)(189998001)(105606002)(87936001)(229853001)(86362001)(77156002)(50226001)(575784001)(33646002)(2950100001)(62966003)(2351001)(104016003)(47776003)(46102003)(77096005)(92566002)(5001960100002)(110136002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB606; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB606; 2:nJlnpRziAdeSHZE7hHWqsHOMnvhds1TP0zIHCpijFHYoEONaOAHIObOR0g+51oeZ; 3:PMLdFmwk0uV+VAb6tE+5K+KYJDC8sjlsiNgDOKORPI2PRXeZgT4Co84oya3Fu0DuPiBaPluSwPBGimR4MowvJAkX7qg0JTS2V3c0FhTrIad+63Dfzatg12fT0NMfJgO2BDvnU3KKzkOrVAabIKKPfpj78BCAUTqHzE+smmlpguXoQapbUBsmDcHVIge5vAvyvsCe7aHKAo44a183/udoyhgbwvcg+hyqkzaexivVEUg=; 25:1Ms+MssMSI8TzEmhpiBS5K4T2Rquw4CpIq6SOHeFAQ2OmDGB0BGCN5/+IKqyqMAEziOjPz4s5ykLG090PIe5F7H+u0CUF8pzZhw746gUACj7m1VpqNdcj+K2+nExRTcSnWO4gQuQ0Ro3xLFL76jZpMUyuZRY2ia3IcwLN7nu6BMO/EI4/FgGoDXEVRCizicFR2oh21Yrmn8Fn1uvbjChsX21WX+EtxDat/+CFbX+y1XuWpLHC0MjXRdhlxtU1ZfH1YOJUBs60jAZlFPUPcoNzw==; 20:CG/L79nDhBka5ZVILScrEyJhUTelk7ND08gep/Gr0xIr05wjKH0Lo7IevVnxjmYTdOsICBxYRZuhWGGgGdUx/KVVNhtES9aa9QTBq31jc42SKBZaEJb/bhsQiAZMIkmK+Ka+3rMHgUddJVRQTrYaeQBc++Qi40awgCpuQAbV+rdKed6IZhTu6QQl+QMli5t0BTDJ4Seocpa5FxZ3QuNJFwXm4S7l3JgShf+OJT1EWMt64SaJZo9kNxX7aipu08ChCW0SohE0X3M22E/IzB4e/uZ1Wt6D34u3jr5MnNfBywK196NKjZsouMfv/4br9sVYKMTXCnE8BEI1elt5zPlSUqSigx3zJOiaZSpr457pyBo= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB606; 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:BL2PR03MB606; BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB606; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB606; 4:dJ0w59xqvhDG/KxLA9YvzArkhe/XiBuw36FJuTxy6pECj3D5v0pywXkIld0HNpANiXcaYtaBLB9+93cT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WWT0M0Mke00inna4CA6K954EwSpwc2q9vgrLyYSD0XG9OGNL/6fYBjCqjjDknvggi1Tua+51QR+rwxqnobzBUptoo6ouGHMTBp+fIIfm6aVh62nbIAaCrGs8JKBN/JMcdbnb0qQEOWdgG3/sv0V4b+5uVVBGf1 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB606; 5:sh8RbIBeTiDbYybJbnu3ZzWSexnJfrML2ryDc6wtd0ojfgkHXQ9j9i35fhNkAKoXoTsnXPf410qShPqKwgDh8DoRXxnVxYvkHYnQ69IQd6KuDUqVoPzj3AmSNCuOH2fyOE5o5o3YGYY0PvrzenoiPA==; 24:qR4idlbYnS/FSHUec8WlXnmB/zqN8whu2gzIVwDqTz431snFGxIrXeE1EEd4/xM7ezsLz0y2c8hvaUusq/xGSoQkSEgDPUvw4pgBQhXh2d0=; 20:+n/jYdKddV0XOi1oALbMdlSAs71YWMO2XIRtHe6wgNK8psmCiXj8yCsxMaeyMiEJRVV0B0nZpTOdGxNmX754rw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2015 10:45:29.1757 (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: BL2PR03MB606 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v2 1/5] linux-generic: sysinfo: make the 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.54 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 the model_str for each core may be different too, so this patch changes the model_str to data array model_str[] to contain data for each different core, while for the common SMP system, we can simply use the model_str[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. Accordingly, odp_sys_cpu_model_str_amp(cpu) is introduced for AMP system, while the original version interfaces without any parameter is kept for the SMP systems. Currently, all the platforms implemented are all SMP, so only the model_str[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 | 4 ++- platform/linux-generic/odp_system_info.c | 37 ++++++++++++++++----------- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/include/odp/api/system_info.h b/include/odp/api/system_info.h index 1f3294b..86b4556 100644 --- a/include/odp/api/system_info.h +++ b/include/odp/api/system_info.h @@ -52,6 +52,13 @@ uint64_t odp_sys_page_size(void); const char *odp_sys_cpu_model_str(void); /** + * CPU model name for AMP system + * + * @return Pointer to CPU model name string + */ +const char *odp_sys_cpu_model_str_amp(int cpu); + +/** * Cache line size in bytes * * @return 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..bcf7e63 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 128 + typedef struct { uint64_t cpu_hz; 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..181a0c7 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,10 +138,10 @@ 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--; } @@ -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--; } @@ -228,10 +227,10 @@ 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--; } @@ -333,7 +332,7 @@ static int systemcpu(odp_system_info_t *sysinfo) sysinfo->cpu_hz = 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; } @@ -391,7 +390,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_sys_cpu_model_str_amp(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)