Deleted Added
sdiff udiff text old ( 244444 ) new ( 255726 )
full compact
1/*-
2 * Copyright (c) 2001, John Baldwin <jhb@FreeBSD.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 */
29
30/*
31 * This module holds the global variables and machine independent functions
32 * used for the kernel SMP support.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/kern/subr_smp.c 244444 2012-12-19 20:08:06Z jeff $");
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/kernel.h>
41#include <sys/ktr.h>
42#include <sys/proc.h>
43#include <sys/bus.h>
44#include <sys/lock.h>

--- 175 unchanged lines hidden (view full) ---

220 ("%s: invalid stop type", __func__));
221
222 if (!smp_started)
223 return (0);
224
225 CTR2(KTR_SMP, "stop_cpus(%s) with %u type",
226 cpusetobj_strprint(cpusetbuf, &map), type);
227
228 if (stopping_cpu != PCPU_GET(cpuid))
229 while (atomic_cmpset_int(&stopping_cpu, NOCPU,
230 PCPU_GET(cpuid)) == 0)
231 while (stopping_cpu != NOCPU)
232 cpu_spinwait(); /* spin */
233
234 /* send the stop IPI to all CPUs in map */
235 ipi_selected(map, type);

--- 11 unchanged lines hidden (view full) ---

247 cpu_spinwait();
248 i++;
249 if (i == 100000000) {
250 printf("timeout stopping cpus\n");
251 break;
252 }
253 }
254
255 stopping_cpu = NOCPU;
256 return (1);
257}
258
259int
260stop_cpus(cpuset_t map)
261{
262

--- 24 unchanged lines hidden (view full) ---

287 * - Signals all CPUs in map to restart.
288 * - Waits for each to restart.
289 *
290 * Returns:
291 * -1: error
292 * 0: NA
293 * 1: ok
294 */
295int
296restart_cpus(cpuset_t map)
297{
298#ifdef KTR
299 char cpusetbuf[CPUSETBUFSIZ];
300#endif
301
302 if (!smp_started)
303 return 0;
304
305 CTR1(KTR_SMP, "restart_cpus(%s)", cpusetobj_strprint(cpusetbuf, &map));
306
307 /* signal other cpus to restart */
308 CPU_COPY_STORE_REL(&map, &started_cpus);
309
310 /* wait for each to clear its bit */
311 while (CPU_OVERLAP(&stopped_cpus, &map))
312 cpu_spinwait();
313
314 return 1;
315}
316
317/*
318 * All-CPU rendezvous. CPUs are signalled, all execute the setup function
319 * (if specified), rendezvous, execute the action function (if specified),
320 * rendezvous again, execute the teardown function (if specified), and then
321 * resume.
322 *
323 * Note that the supplied external functions _must_ be reentrant and aware
324 * that they are running in parallel and in an unknown lock context.

--- 463 unchanged lines hidden ---