Skip to content

Commit

Permalink
tests: mem_protect: syscalls: Convert CONFIG_MP_NUM_CPUS handling
Browse files Browse the repository at this point in the history
Move runtime checks to use arch_num_cpus() and build checks
to use CONFIG_MP_MAX_NUM_CPUS.  This is to allow runtime
determination of the number of CPUs in the future.

Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
galak authored and carlescufi committed Oct 31, 2022
1 parent ab02bbc commit b5ec410
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/kernel/mem_protect/syscalls/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,12 @@ ZTEST_USER(syscalls, test_more_args)
"syscall didn't match impl");
}

#define NR_THREADS (CONFIG_MP_NUM_CPUS * 4)
#define NR_THREADS (arch_num_cpus() * 4)
#define MAX_NR_THREADS (CONFIG_MP_MAX_NUM_CPUS * 4)
#define STACK_SZ (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

struct k_thread torture_threads[NR_THREADS];
K_THREAD_STACK_ARRAY_DEFINE(torture_stacks, NR_THREADS, STACK_SZ);
struct k_thread torture_threads[MAX_NR_THREADS];
K_THREAD_STACK_ARRAY_DEFINE(torture_stacks, MAX_NR_THREADS, STACK_SZ);

void syscall_torture(void *arg1, void *arg2, void *arg3)
{
Expand Down Expand Up @@ -376,7 +377,7 @@ ZTEST(syscalls, test_syscall_torture)
uintptr_t i;

printk("Running syscall torture test with %d threads on %d cpu(s)\n",
NR_THREADS, CONFIG_MP_NUM_CPUS);
NR_THREADS, arch_num_cpus());

for (i = 0; i < NR_THREADS; i++) {
k_thread_create(&torture_threads[i], torture_stacks[i],
Expand Down Expand Up @@ -437,7 +438,7 @@ ZTEST(syscalls, test_syscall_context)
k_thread_user_mode_enter(test_syscall_context_user, NULL, NULL, NULL);
}

K_HEAP_DEFINE(test_heap, BUF_SIZE * (4 * NR_THREADS));
K_HEAP_DEFINE(test_heap, BUF_SIZE * (4 * MAX_NR_THREADS));

void *syscalls_setup(void)
{
Expand Down

0 comments on commit b5ec410

Please sign in to comment.