smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS

Change for loops of the form:

for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
   ...

to

unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
   ...

We do the call outside of the for loop so that it only happens once,
rather than on every iteration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
This commit is contained in:
Kumar Gala 2022-10-18 09:45:13 -05:00 committed by Carles Cufí
commit a1195ae39b
26 changed files with 121 additions and 44 deletions

View file

@ -120,8 +120,9 @@ static void control_load(void)
uint64_t idle_cycles = 0;
k_thread_runtime_stats_t rt_stats_all;
int err = 0;
unsigned int num_cpus = arch_num_cpus();
for (int i = 0; i < CONFIG_MP_NUM_CPUS; i++) {
for (int i = 0; i < num_cpus; i++) {
k_thread_runtime_stats_t thread_stats;
err = k_thread_runtime_stats_get(idle_tid[i], &thread_stats);