Messages in this thread Patch in this message | | | Date | Fri, 14 Feb 2003 07:51:42 -0500 (EST) | From | Zwane Mwaikambo <> | Subject | Re: [PATCH][2.5][11/14] smp_call_function_on_cpu - PARISC |
| |
One liner to fix num_cpus == 0 on SMP kernel w/ UP box
Index: linux-2.5.60/arch/parisc/kernel/smp.c =================================================================== RCS file: /build/cvsroot/linux-2.5.60/arch/parisc/kernel/smp.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 smp.c --- linux-2.5.60/arch/parisc/kernel/smp.c 10 Feb 2003 22:15:32 -0000 1.1.1.1 +++ linux-2.5.60/arch/parisc/kernel/smp.c 14 Feb 2003 12:20:11 -0000 @@ -304,31 +304,40 @@ void smp_send_reschedule(int cpu) { send_IPI_single(cpu, IPI_RESCHEDULE); } - -/** - * Run a function on all other CPUs. - * <func> The function to run. This must be fast and non-blocking. - * <info> An arbitrary pointer to pass to the function. - * <retry> If true, keep retrying until ready. - * <wait> If true, wait until function has completed on other CPUs. - * [RETURNS] 0 on success, else a negative status code. +/* + * smp_call_function_on_cpu - Runs func on all processors in the mask + * + * @func: The function to run. This must be fast and non-blocking. + * @info: An arbitrary pointer to pass to the function. + * @wait: If true, wait (atomically) until function has completed on other CPUs. + * @mask: The bitmask of CPUs to call the function + * + * Returns 0 on success, else a negative status code. Does not return until + * remote CPUs are nearly ready to execute func or have executed it. * - * Does not return until remote CPUs are nearly ready to execute <func> - * or have executed. */ int -smp_call_function (void (*func) (void *info), void *info, int retry, int wait) +smp_call_function_on_cpu (void (*func) (void *info), void *info, int wait, + unsigned long mask) { struct smp_call_struct data; long timeout; static spinlock_t lock = SPIN_LOCK_UNLOCKED; + int num_cpus, cpu, i, ret; + cpu = get_cpu(); + mask &= ~(1UL << cpu); + num_cpus = hweight64(mask); + if (num_cpus == 0) { + ret = 0; + goto out; + } data.func = func; data.info = info; data.wait = wait; - atomic_set(&data.unstarted_count, smp_num_cpus - 1); - atomic_set(&data.unfinished_count, smp_num_cpus - 1); + atomic_set(&data.unstarted_count, num_cpus); + atomic_set(&data.unfinished_count, num_cpus); if (retry) { spin_lock (&lock); @@ -339,15 +348,19 @@ spin_lock (&lock); if (smp_call_function_data) { spin_unlock (&lock); - return -EBUSY; + ret = -EBUSY; + goto out; } } smp_call_function_data = &data; spin_unlock (&lock); - /* Send a message to all other CPUs and wait for them to respond */ - send_IPI_allbutself(IPI_CALL_FUNC); + /* Send a message to the target CPUs and wait */ + for (i = 0; i < NR_CPUS; i++) { + if (cpu_online(i) && (mask & (1UL << i))) + send_IPI_single(i, IPI_CALL_FUNC); + } /* Wait for response */ timeout = jiffies + HZ; @@ -361,17 +374,25 @@ smp_call_function_data = NULL; if (atomic_read (&data.unstarted_count) > 0) { printk(KERN_CRIT "SMP CALL FUNCTION TIMED OUT! (cpu=%d)\n", - smp_processor_id()); - return -ETIMEDOUT; + cpu); + ret = -ETIMEDOUT; + goto out; } while (wait && atomic_read (&data.unfinished_count) > 0) barrier (); - - return 0; + ret = 0; +out: + put_cpu_no_resched(); + return ret; } - +int +smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wait, + unsigned long mask) +{ + return smp_call_function_on_cpu(func, info, wait, cpu_online_map); +} /* * Setup routine for controlling SMP activation - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |