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

@ -211,7 +211,9 @@ static int cmd_kernel_stacks(const struct shell *shell,
* kernel support, including dumping arch-specific exception-related
* stack buffers.
*/
for (int i = 0; i < CONFIG_MP_NUM_CPUS; i++) {
unsigned int num_cpus = arch_num_cpus();
for (int i = 0; i < num_cpus; i++) {
size_t unused;
const uint8_t *buf = Z_KERNEL_STACK_BUFFER(z_interrupt_stacks[i]);
size_t size = K_KERNEL_STACK_SIZEOF(z_interrupt_stacks[i]);