From 24e1c4df6fb2cf17e8c768ff13f5d553b45b0ef6 Mon Sep 17 00:00:00 2001 From: hujun5 Date: Fri, 16 May 2025 15:51:49 +0800 Subject: [PATCH] testing/ostest/smp_call.c: fix smp_call cpu_set inconsistency issue If we set CONFIG_SMP_DEFAULT_CPUSET=1 This will cause the value of cpuset to be 0x1, ((1 << CONFIG_SMP_NCPUS) - 1) will result in the cpuset being 0x11, leading to test case errors. Signed-off-by: hujun5 --- testing/ostest/smp_call.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/testing/ostest/smp_call.c b/testing/ostest/smp_call.c index 18f030977..9893cec9b 100644 --- a/testing/ostest/smp_call.c +++ b/testing/ostest/smp_call.c @@ -38,6 +38,7 @@ ****************************************************************************/ static struct smp_call_data_s g_call_data; +static cpu_set_t g_cpuset; /**************************************************************************** * Private Functions @@ -53,10 +54,8 @@ static int smp_call_func(void *arg) static void wdg_wdentry(wdparm_t arg) { - cpu_set_t cpus = (1 << CONFIG_SMP_NCPUS) - 1; - nxsched_smp_call_init(&g_call_data, smp_call_func, (FAR void *)arg); - nxsched_smp_call_async(cpus, &g_call_data); + nxsched_smp_call_async(g_cpuset, &g_call_data); } /**************************************************************************** @@ -65,7 +64,6 @@ static void wdg_wdentry(wdparm_t arg) void smp_call_test(void) { - cpu_set_t cpuset; struct smp_call_data_s call_data; sem_t sem; int cpucnt; @@ -111,10 +109,10 @@ void smp_call_test(void) printf("smp_call_test: Call multi cpu, nowait\n"); - sched_getaffinity(0, sizeof(cpu_set_t), &cpuset); - cpucnt = CPU_COUNT(&cpuset); + sched_getaffinity(0, sizeof(cpu_set_t), &g_cpuset); + cpucnt = CPU_COUNT(&g_cpuset); - nxsched_smp_call_async(cpuset, &call_data); + nxsched_smp_call_async(g_cpuset, &call_data); for (cpu = 0; cpu < cpucnt; cpu++) { @@ -142,7 +140,7 @@ void smp_call_test(void) printf("smp_call_test: Call multi cpu, wait\n"); - nxsched_smp_call(cpuset, smp_call_func, &sem); + nxsched_smp_call(g_cpuset, smp_call_func, &sem); sem_getvalue(&sem, &value); if (value != cpucnt)