diff mbox

[API-NEXT,v3,2/8] linux-generic: sysinfo: make the cpu_hz per-CPU data

Message ID 1436438768-4258-3-git-send-email-hongbo.zhang@freescale.com
State New
Headers show

Commit Message

hongbo.zhang@freescale.com July 9, 2015, 10:46 a.m. UTC
From: Hongbo Zhang <hongbo.zhang@linaro.org>

For AMP system such as ARM big.LITTLE, cores are heterogeneous, and cpu_hz
for each core may be different too, so this patch changes the cpu_hz to
data array cpu_hz[] to contain data for each different core, while for the
common SMP system, we can simply use the cpu_hz[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.

The new API to get cpu_hz for each core on AMP system will be added later.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
---
 platform/linux-generic/include/odp_internal.h |  2 +-
 platform/linux-generic/odp_system_info.c      | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index bcf7e63..8df8c23 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -25,7 +25,7 @@  extern __thread int __odp_errno;
 #define MAX_CPU_NUMBER 128
 
 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;
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 3add081..ab741eb 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -148,7 +148,7 @@  static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo)
 		}
 	}
 
-	sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0);
+	sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0);
 
 	return 0;
 }
@@ -198,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;
 }
@@ -236,7 +236,7 @@  static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo)
 			}
 		}
 
-		sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0);
+		sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0);
 	}
 
 
@@ -329,7 +329,7 @@  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[0], "UNKNOWN", sizeof(sysinfo->model_str));
@@ -375,7 +375,7 @@  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_huge_page_size(void)