From: Dongwoo Lee Date: Wed, 23 Feb 2022 07:58:04 +0000 (+0900) Subject: util: kernel: Read stationary values once X-Git-Tag: submit/tizen/20220302.025412~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=085b6e558e1b92f3da18c32bc04d10e9aa7f8214;p=platform%2Fcore%2Fsystem%2Fpass.git util: kernel: Read stationary values once 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 --- diff --git a/src/util/kernel.c b/src/util/kernel.c index 490432f..41c1637 100644 --- a/src/util/kernel.c +++ b/src/util/kernel.c @@ -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)