diff mbox

[API-NEXT,v4,02/10] linux-generic: sysinfo: make the cpu_hz per-CPU data

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

Commit Message

hongbo.zhang@freescale.com Aug. 11, 2015, 7:33 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 eac642c..8a1a219 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -26,7 +26,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 cf6d5a7..83226f8 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -149,7 +149,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;
 }
@@ -199,7 +199,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;
 }
@@ -237,7 +237,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);
 	}
 
 
@@ -330,7 +330,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));
@@ -376,7 +376,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)