diff --git a/sched/sched/sched_smp.c b/sched/sched/sched_smp.c index 98437cbb83..b9315ba91a 100644 --- a/sched/sched/sched_smp.c +++ b/sched/sched/sched_smp.c @@ -239,7 +239,8 @@ int nxsched_smp_call(cpu_set_t cpuset, nxsched_smp_call_t func, CPU_CLR(this_cpu(), &cpuset); } - if (CPU_COUNT(&cpuset) == 0) + remote_cpus = CPU_COUNT(&cpuset); + if (remote_cpus == 0) { goto out; } @@ -261,22 +262,17 @@ int nxsched_smp_call(cpu_set_t cpuset, nxsched_smp_call_t func, call_data->func = func; call_data->arg = arg; + call_data->refcount = remote_cpus; for (i = 0; i < CONFIG_SMP_NCPUS; i++) { if (CPU_ISSET(i, &cpuset)) { nxsched_smp_call_add(i, call_data); - remote_cpus++; } } - call_data->refcount = remote_cpus; - - if (remote_cpus > 0) - { - up_send_smp_call(cpuset); - } + up_send_smp_call(cpuset); if (wait) {