···676676static int kgdb_smp_call_kgdb_wait(void)677677{678678#ifdef CONFIG_SMP679679+ cpumask_t mask = cpu_online_map;679680 struct call_data_struct data;680680- int i, cpus = num_online_cpus() - 1;681681 int cpu = smp_processor_id();682682+ int cpus;682683683684 /*684685 * Can die spectacularly if this CPU isn't yet marked online685686 */686687 BUG_ON(!cpu_online(cpu));687688689689+ cpu_clear(cpu, mask);690690+ cpus = cpus_weight(mask);688691 if (!cpus)689692 return 0;690693···714711 call_data = &data;715712 mb();716713717717- /* Send a message to all other CPUs and wait for them to respond */718718- for (i = 0; i < NR_CPUS; i++)719719- if (cpu_online(i) && i != cpu)720720- core_send_ipi(i, SMP_CALL_FUNCTION);714714+ core_send_ipi_mask(mask, SMP_CALL_FUNCTION);721715722716 /* Wait for response */723717 /* FIXME: lock-up detection, backtrace on lock-up */
+16-35
arch/mips/kernel/smp.c
···97979898/*9999 * Run a function on all other CPUs.100100+ *101101+ * <mask> cpuset_t of all processors to run the function on.100102 * <func> The function to run. This must be fast and non-blocking.101103 * <info> An arbitrary pointer to pass to the function.102104 * <retry> If true, keep retrying until ready.···123121 * Spin waiting for call_lock124122 * Deadlock Deadlock125123 */126126-int smp_call_function (void (*func) (void *info), void *info, int retry,127127- int wait)124124+int smp_call_function_mask(cpumask_t mask, void (*func) (void *info),125125+ void *info, int retry, int wait)128126{129127 struct call_data_struct data;130130- int i, cpus = num_online_cpus() - 1;131128 int cpu = smp_processor_id();129129+ int cpus;132130133131 /*134132 * Can die spectacularly if this CPU isn't yet marked online135133 */136134 BUG_ON(!cpu_online(cpu));137135136136+ cpu_clear(cpu, mask);137137+ cpus = cpus_weight(mask);138138 if (!cpus)139139 return 0;140140···155151 smp_mb();156152157153 /* Send a message to all other CPUs and wait for them to respond */158158- for_each_online_cpu(i)159159- if (i != cpu)160160- core_send_ipi(i, SMP_CALL_FUNCTION);154154+ core_send_ipi_mask(mask, SMP_CALL_FUNCTION);161155162156 /* Wait for response */163157 /* FIXME: lock-up detection, backtrace on lock-up */···171169 return 0;172170}173171172172+int smp_call_function(void (*func) (void *info), void *info, int retry,173173+ int wait)174174+{175175+ return smp_call_function_mask(cpu_online_map, func, info, retry, wait);176176+}174177175178void smp_call_function_interrupt(void)176179{···206199int smp_call_function_single(int cpu, void (*func) (void *info), void *info,207200 int retry, int wait)208201{209209- struct call_data_struct data;210210- int me;202202+ int ret, me;211203212204 /*213205 * Can die spectacularly if this CPU isn't yet marked online···225219 return 0;226220 }227221228228- /* Can deadlock when called with interrupts disabled */229229- WARN_ON(irqs_disabled());230230-231231- data.func = func;232232- data.info = info;233233- atomic_set(&data.started, 0);234234- data.wait = wait;235235- if (wait)236236- atomic_set(&data.finished, 0);237237-238238- spin_lock(&smp_call_lock);239239- call_data = &data;240240- smp_mb();241241-242242- /* Send a message to the other CPU */243243- core_send_ipi(cpu, SMP_CALL_FUNCTION);244244-245245- /* Wait for response */246246- /* FIXME: lock-up detection, backtrace on lock-up */247247- while (atomic_read(&data.started) != 1)248248- barrier();249249-250250- if (wait)251251- while (atomic_read(&data.finished) != 1)252252- barrier();253253- call_data = NULL;254254- spin_unlock(&smp_call_lock);222222+ ret = smp_call_function_mask(cpumask_of_cpu(cpu), func, info, retry,223223+ wait);255224256225 put_cpu();257226 return 0;
+9
include/asm-mips/smp.h
···6060 */6161extern void core_send_ipi(int cpu, unsigned int action);62626363+static inline void core_send_ipi_mask(cpumask_t mask, unsigned int action)6464+{6565+ unsigned int i;6666+6767+ for_each_cpu_mask(i, mask)6868+ core_send_ipi(i, action);6969+}7070+7171+6372/*6473 * Firmware CPU startup hook6574 */