util: kernel: Read stationary values once 06/271606/1
authorDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 23 Feb 2022 07:58:04 +0000 (16:58 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 23 Feb 2022 08:45:01 +0000 (17:45 +0900)
Since statinary kernel sysfs or procfs nodes is not have to be
read every time, it lets them being read once.

Change-Id: Icee5f825694867ecb84847fd46830274fe8219d3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/util/kernel.c

index 490432f..41c1637 100644 (file)
@@ -105,7 +105,12 @@ int kernel_get_online_cpu_num(void)
 
 int kernel_get_possible_cpu_num(void)
 {
-       return __get_cpu_num("/sys/devices/system/cpu/possible");
+       static int possible = 0;
+
+       if (!possible)
+               possible = __get_cpu_num("/sys/devices/system/cpu/possible");
+
+       return possible;
 }
 
 int kernel_get_total_cpu_stat(struct cpu_stat *total)