From patchwork Wed Apr 1 22:29:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 46668 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B42D2159A for ; Wed, 1 Apr 2015 22:30:12 +0000 (UTC) Received: by lajy8 with SMTP id y8sf14137039laj.3 for ; Wed, 01 Apr 2015 15:30:10 -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:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=JdkqP/6NnS8B5+zyaLGak3OcNiP0/y7+glEGiPAyevk=; b=gAoupw6AUnDUXjzEENoxekko2BOH6F17IGz3eEVSO5H28XuL5MNrqU73pa2RPcgU1h wmYFGh2bP0LJJ+8Ogjf4VY1RCBgP2M6LTrXwuUDKYddiNQ0aI7bFw7uxTAZU3q7q9yxv ppLhHpvGkPAQScEGGvx894Qv9JApLx9r3rbBsMaP0z29cnUkfMeWtK0MhfsT70hjRfay DLAdRMbo0frLY6Pr5w8ZtFAXH0Gvs9pYklshWsgR0cQxI6MHphDeJpWljqwWjv9OiMlx l/SEDkSZU0+EYrLx3f6ry2igrIBhjcb7zA+1O31ZjPu9UScGxmMFRkbsevOAle6T37UC q16A== X-Gm-Message-State: ALoCoQlV2pcMk+Lso985BEbgY4ByEy90kXedogUZ1tQWWyWqW/ipaUCeZuQNF6rimfIrGUNkIeKd X-Received: by 10.152.37.231 with SMTP id b7mr2894191lak.5.1427927410590; Wed, 01 Apr 2015 15:30:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.228.169 with SMTP id sj9ls147060lac.35.gmail; Wed, 01 Apr 2015 15:30:10 -0700 (PDT) X-Received: by 10.153.4.12 with SMTP id ca12mr9159025lad.90.1427927410410; Wed, 01 Apr 2015 15:30:10 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id n5si2672123laj.150.2015.04.01.15.30.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 15:30:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lboc7 with SMTP id c7so46893438lbo.1 for ; Wed, 01 Apr 2015 15:30:10 -0700 (PDT) X-Received: by 10.152.116.11 with SMTP id js11mr37990584lab.106.1427927410206; Wed, 01 Apr 2015 15:30:10 -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.57.201 with SMTP id k9csp951728lbq; Wed, 1 Apr 2015 15:30:09 -0700 (PDT) X-Received: by 10.55.49.147 with SMTP id x141mr8268523qkx.23.1427927408919; Wed, 01 Apr 2015 15:30:08 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 125si3225285qhy.111.2015.04.01.15.30.07; Wed, 01 Apr 2015 15:30:08 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 814B265044; Wed, 1 Apr 2015 22:30:07 +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=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=unavailable autolearn_force=no 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 58A3B65034; Wed, 1 Apr 2015 22:30:04 +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 D130365040; Wed, 1 Apr 2015 22:30:02 +0000 (UTC) Received: from mail-qc0-f171.google.com (mail-qc0-f171.google.com [209.85.216.171]) by lists.linaro.org (Postfix) with ESMTPS id A584F65034 for ; Wed, 1 Apr 2015 22:30:01 +0000 (UTC) Received: by qcbii10 with SMTP id ii10so31388786qcb.2 for ; Wed, 01 Apr 2015 15:30:01 -0700 (PDT) X-Received: by 10.229.65.8 with SMTP id g8mr59759837qci.15.1427927401444; Wed, 01 Apr 2015 15:30:01 -0700 (PDT) Received: from mike-desktop.?.holmesfamily.ws (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by mx.google.com with ESMTPSA id w130sm2228709qha.25.2015.04.01.15.30.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 15:30:01 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 1 Apr 2015 18:29:53 -0400 Message-Id: <1427927394-15702-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH 1/2] linux-generic: system_info: use global data struct 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@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.171 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 Don't store ODP global data in multiple locations, gather global data into odp_global_data. Move the static odp_system_info into odp_global_data Signed-off-by: Mike Holmes Reviewed-by: Taras Kondratiuk --- platform/linux-generic/include/odp_internal.h | 11 +++++++++ platform/linux-generic/odp_system_info.c | 33 +++++++++------------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 0961cce..64dee42 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -22,9 +22,20 @@ extern "C" { extern __thread int __odp_errno; +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]; + +} odp_system_info_t; + struct odp_global_data_s { odp_log_func_t log_fn; odp_abort_func_t abort_fn; + odp_system_info_t odp_system_info; }; extern struct odp_global_data_s odp_global_data; diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 6b6c723..cae310f 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -20,15 +20,7 @@ #include #include -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]; -} odp_system_info_t; typedef struct { const char *cpu_arch_str; @@ -36,9 +28,6 @@ typedef struct { } odp_compiler_info_t; -static odp_system_info_t odp_system_info; - - #define CACHE_LNSZ_FILE \ "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size" @@ -310,7 +299,7 @@ static int systemcpu(odp_system_info_t *sysinfo) return -1; } - odp_system_info.huge_page_size = huge_page_size(); + odp_global_data.odp_system_info.huge_page_size = huge_page_size(); return 0; } @@ -354,9 +343,9 @@ int odp_system_info_init(void) { FILE *file; - memset(&odp_system_info, 0, sizeof(odp_system_info_t)); + memset(&odp_global_data.odp_system_info, 0, sizeof(odp_system_info_t)); - odp_system_info.page_size = ODP_PAGE_SIZE; + odp_global_data.odp_system_info.page_size = ODP_PAGE_SIZE; file = fopen("/proc/cpuinfo", "rt"); if (file == NULL) { @@ -364,11 +353,11 @@ int odp_system_info_init(void) return -1; } - compiler_info.cpuinfo_parser(file, &odp_system_info); + compiler_info.cpuinfo_parser(file, &odp_global_data.odp_system_info); fclose(file); - if (systemcpu(&odp_system_info)) { + if (systemcpu(&odp_global_data.odp_system_info)) { ODP_ERR("systemcpu failed\n"); return -1; } @@ -383,30 +372,30 @@ int odp_system_info_init(void) */ uint64_t odp_sys_cpu_hz(void) { - return odp_system_info.cpu_hz; + return odp_global_data.odp_system_info.cpu_hz; } uint64_t odp_sys_huge_page_size(void) { - return odp_system_info.huge_page_size; + return odp_global_data.odp_system_info.huge_page_size; } uint64_t odp_sys_page_size(void) { - return odp_system_info.page_size; + return odp_global_data.odp_system_info.page_size; } const char *odp_sys_cpu_model_str(void) { - return odp_system_info.model_str; + return odp_global_data.odp_system_info.model_str; } int odp_sys_cache_line_size(void) { - return odp_system_info.cache_line_size; + return odp_global_data.odp_system_info.cache_line_size; } int odp_cpu_count(void) { - return odp_system_info.cpu_count; + return odp_global_data.odp_system_info.cpu_count; }