summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_smp.c
Commit message (Collapse)AuthorAgeFilesLines
* Allow a rendezvous with just a specified CPU too.jb2008-05-231-19/+61
| | | | | | Make the API work in the non-smp case too so that a kernel module can work the same regardless of whether or not it is loaded on a SMP kernel or not.
* In keeping with style(9)'s recommendations on macros, use a ';'rwatson2008-03-161-3/+3
| | | | | | | | | after each SYSINIT() macro invocation. This makes a number of lightweight C parsers much happier with the FreeBSD kernel source, including cflow's prcc and lxr. MFC after: 1 month Discussed with: imp, rink
* - Add the missing '2' case to the switch table for kern.smp.topology andjeff2008-03-101-0/+4
| | | | | assign it to create the flat 'none' topology where all cpus are scheduled as if they are equal and unrelated.
* - Remove the old smp cpu topology specification with a new, more flexiblejeff2008-03-021-14/+188
| | | | | | | | | | | | | | | | | tree structure that encodes the level of cache sharing and other properties. - Provide several convenience functions for creating one and two level cpu trees as well as a default flat topology. The system now always has some topology. - On i386 and amd64 create a seperate level in the hierarchy for HTT and multi-core cpus. This will allow the scheduler to intelligently load balance non-uniform cores. Presently we don't detect what level of the cache hierarchy is shared at each level in the topology. - Add a mechanism for testing common topologies that have more information than the MD code is able to provide via the kern.smp.topology tunable. This should be considered a debugging tool only and not a stable api. Sponsored by: Nokia
* A few whitespace fixes.jhb2008-01-021-12/+11
|
* Initial checkin for rmlock (read mostly lock) a multi reader single writerups2007-11-081-16/+37
| | | | | | | | lock optimized for almost exclusive reader access. (see also rmlock.9) TODO: Convert to per cpu variables linkerset as soon as it is available. Optimize UP (single processor) case.
* This is a follow-up, cleaning-up commit about recent changes involvingattilio2007-09-111-1/+1
| | | | | | | | | | | | | | | | topology foo functions. Working at the patch for topology problems in ia32/amd64 evicted some problems regarding functions ordering in the SI_SUB_CPU family of SYSINIT'ed subsystems. In order to avoid problems with new modified to involved functions, a correct ordering is not semantically specified for SI_SUB_CPU functions (for a larger view of the issue please visit: http://lists.freebsd.org/pipermail/freebsd-current/2007-July/075409.html ) Discussed with: peter Tested by: kris, Rui Paulo <rpaulo@FreeBSD.org> Approved by: jeff Approved by: re
* Tweak the low-level MI SMP code some:jhb2007-07-031-11/+23
| | | | | | | | | | | | | - Use cpu_spinwait() in the spin loops in stop_cpus(), restart_cpus(), and smp_rendezvous_action(). - Remove unneeded acq memory barriers in stop_cpus(), restart_cpus(), and smp_rendezvous_action(). - Add an additional synch point in smp_rendezvous() to ensure that all the CPUs will always see an up-to-date value of smp_rv_setup_func. Reviewed by: attilio Approved by: re (kensmith) Tested on: alpha, amd64, i386, sparc64 SMP (for several years)
* Commit 14/14 of sched_lock decomposition.jeff2007-06-051-3/+1
| | | | | | | | | | | - Use thread_lock() rather than sched_lock for per-thread scheduling sychronization. - Use the per-process spinlock rather than the sched_lock for per-process scheduling synchronization. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
* Instead of doing comparisons using the pcpu area to see ifjulian2007-03-081-1/+1
| | | | | | | a thread is an idle thread, just see if it has the IDLETD flag set. That flag will probably move to the pflags word as it's permenent and never chenges for the life of the system so it doesn't need locking.
* Rename the KDB_STOP_NMI kernel option to STOP_NMI and make it apply to alljhb2005-10-241-32/+0
| | | | | | | | | | | | | | | | | | | | | | IPI_STOP IPIs. - Change the i386 and amd64 MD IPI code to send an NMI if STOP_NMI is enabled if an attempt is made to send an IPI_STOP IPI. If the kernel option is enabled, there is also a sysctl to change the behavior at runtime (debug.stop_cpus_with_nmi which defaults to enabled). This includes removing stop_cpus_nmi() and making ipi_nmi_selected() a private function for i386 and amd64. - Fix ipi_all(), ipi_all_but_self(), and ipi_self() on i386 and amd64 to properly handle bitmapped IPIs as well as IPI_STOP IPIs when STOP_NMI is enabled. - Fix ipi_nmi_handler() to execute the restart function on the first CPU that is restarted making use of atomic_readandclear() rather than assuming that the BSP is always included in the set of restarted CPUs. Also, the NMI handler didn't clear the function pointer meaning that subsequent stop and restarts could execute the function again. - Define a new macro HAVE_STOPPEDPCBS on i386 and amd64 to control the use of stoppedpcbs[] and always enable it for i386 and amd64 instead of being dependent on KDB_STOP_NMI. It works fine in both the NMI and non-NMI cases.
* Second part of commit for moving KDB_STOP_NMI from opt_global.h topeter2005-06-301-0/+2
| | | | | | | opt_kdb.h. Found by: kris Approved by: re
* Implement an alternate method to stop CPUs when entering DDB. Normally we usedwhite2005-04-301-0/+29
| | | | | | | | | | | | | | a regular IPI vector, but this vector is blocked when interrupts are disabled. With "options KDB_STOP_NMI" and debug.kdb.stop_cpus_with_nmi set, KDB will send an NMI to each CPU instead. The code also has a context-stuffing feature which helps ddb extract the state of processes running on the stopped CPUs. KDB_STOP_NMI is only useful with SMP and complains if SMP is not defined. This feature only applies to i386 and amd64 at the moment, but could be used on other architectures with the appropriate MD bits. Submitted by: ups
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Move 4bsd specific experimental IP code into the 4bsd file.julian2004-09-031-130/+1
| | | | Move the sysctls into kern.sched
* *Blush* forgot to test non SMP builds.. oddly enough some UP code (particularlyjulian2004-09-011-1/+2
| | | | | in the acpi code) seems to want this in a UP build. (I guess so you can have a sigle kernel module that works for both)
* Give the 4bsd scheduler the ability to wake up idle processorsjulian2004-09-011-1/+135
| | | | | | when there is new work to be done. MFC after: 5 days
* s/smp_rv_mtx/smp_ipi_mtx/gobrien2004-08-281-4/+4
| | | | Requested by: jhb
* Commit Doug White and Alan Cox's fix for the cross-ipi smp deadlock.peter2004-08-231-1/+8
| | | | | | | | | | | | | | | We were obtaining different spin mutexes (which disable interrupts after aquisition) and spin waiting for delivery. For example, KSE processes do LDT operations which use smp_rendezvous, while other parts of the system are doing things like tlb shootdowns with a different mutex. This patch uses the common smp_rendezvous mutex for all MD home-grown IPIs that spinwait for delivery. Having the single mutex means that the spinloop to aquire it will enable interrupts periodically, thus avoiding the cross-ipi deadlock. Obtained from: dwhite, alc Reviewed by: jhb
* Don't keep evaluating our own cpu mask..julian2004-08-131-2/+3
| | | | it's not likely to have changed....
* Move the CPU newbus attachment to i386 legacy. The acpi_cpu device willnjl2004-05-061-70/+0
| | | | | | become just "cpu" and provide attachments in the !legacy case. Tested by: des
* Change the type of the various CPU masks to cpumask_t. Note that asmarcel2004-03-271-7/+7
| | | | | | | long as there are still explicit uses of int, whether in types or in function names (such as atomic_set_int() in sched_ule.c), we can not change cpumask_t to be anything other than u_int. See also the commit log for sys/sys/types.h, revision 1.84.
* Add powerpc to temporary fix. The new cpu device claims allgrehan2004-03-161-2/+2
| | | | | 'generic' OpenFirmware nexus nodes, since it uses bus_generic_probe. Maybe the cpu device probe should be MD.
* This is a temporary fix to solve a regression issue on sparc64 thatkensmith2004-03-121-0/+4
| | | | | | | is caused by the way sparc64 registers its CPUs. Nate will work on a real fix shortly. Approved by: njl
* Hook CPUs up to newbus. CPUs will ultimately be a bus driver so thatnjl2004-03-091-0/+67
| | | | | | | multiple CPU-specific drivers can attach. This is a work in progress so children aren't supported yet. Help from: jhb
* - Move smp_topology to subr_smp.c so that it is defined on all architectures.jeff2004-01-241-0/+1
|
* Introduce mp_maxcpus which can be used by libkvm utils to find outalfred2003-12-231-0/+5
| | | | | how many CPUs the system was compiled for. Export the variable via a sysctl node 'kern.smp.maxcpus' as well.
* Export a few SMP related symbols in UP kernels as well. This is needed tojhb2003-12-031-0/+36
| | | | | | | | | | aid other kernel code, especially code which can be in a module such as the acpi_cpu(4) driver, to work properly with both SMP and UP kernels. The exported symbols include mp_ncpus, all_cpus, mp_maxid, smp_started, and the smp_rendezvous() function. This also means that CPU_ABSENT() is now always implemented the same on all kernels. Approved by: re (scottl)
* - Split cpu_mp_probe() into two parts. cpu_mp_setmaxid() is still calledjhb2003-11-211-6/+6
| | | | | | | | | | | | | | | | | | | | very early (SI_SUB_TUNABLES - 1) and is responsible for setting mp_maxid. cpu_mp_probe() is now called at SI_SUB_CPU and determines if SMP is actually present and sets mp_ncpus and all_cpus. Splitting these up allows an architecture to probe CPUs later than SI_SUB_TUNABLES by just setting mp_maxid to MAXCPU in cpu_mp_setmaxid(). This could allow the CPU probing code to live in a module, for example, since modules sysinit's in modules cannot be invoked prior to SI_SUB_KLD. This is needed to re-enable the ACPI module on i386. - For the alpha SMP probing code, use LOCATE_PCS() instead of duplicating its contents in a few places. Also, add a smp_cpu_enabled() function to avoid duplicating some code. There is room for further code reduction later since much of this code is also present in cpu_mp_start(). - All archs besides i386 still set mp_maxid to the same values they set it to before this change. i386 now sets mp_maxid to MAXCPU. Tested on: alpha, amd64, i386, ia64, sparc64 Approved by: re (scottl)
* Ensure that mp_ncpus is set to 1 if mp_cpu_probe() fails.jhb2003-10-301-1/+3
|
* Change all SYSCTLS which are readonly and have a related TUNABLEsilby2003-10-211-1/+1
| | | | | from CTLFLAG_RD to CTLFLAG_RDTUN so that sysctl(8) can provide more useful error messages.
* Document some sysctl variables.des2003-06-121-5/+10
| | | | Submitted by: hmp
* Use __FBSDID().obrien2003-06-111-2/+3
|
* Move the _oncpu entry from the KSE to the thread.julian2003-04-101-1/+1
| | | | | The entry in the KSE still exists but it's purpose will change a bit when we add the ability to lock a KSE to a cpu.
* - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread withjeff2003-03-311-2/+2
| | | | | | | a follow on commit to kern_sig.c - signotify() now operates on a thread since unmasked pending signals are stored in the thread. - PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.
* Move a bunch of flags from the KSE to the thread.julian2003-02-171-2/+2
| | | | | | | | I was in two minds as to where to put them in the first case.. I should have listenned to the other mind. Submitted by: parts by davidxu@ Reviewed by: jeff@ mini@
* Add a tunable kern.smp.disabled for disabling explicitly smp on an smpjake2002-12-281-1/+5
| | | | kernel.
* Completely redo thread states.julian2002-09-111-1/+1
| | | | Reviewed by: davidxu@freebsd.org
* Part 1 of KSE-IIIjulian2002-06-291-2/+2
| | | | | | | | | | | | | The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals..
* Updated a doubly stale comment about signotify(). Fixed a nearby long line.bde2002-04-051-4/+5
|
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-1/+1
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* - Remove a semi-colon from after SYSINIT that was introduced in rev. 1.163.arr2002-03-201-1/+1
|
* Remove __P.alfred2002-03-191-1/+1
|
* Add needed includes of machine/smp.h, remove nested include in sys/smp.hjake2002-03-071-0/+2
| | | | so that inlines in machine/smp.h can use variables declared in sys/smp.h.
* Add a new variable mp_maxid. This is used so that per cpu datastructures mayjeff2002-03-051-2/+14
| | | | | | | | | | | | | be allocated as arrays indexed by the cpu id. Previously the only reliable way to know the max cpu id was through MAXCPU. mp_ncpus isn't useful here because cpu ids may be sparsely mapped, although x86 and alpha do not do this. Also, call cpu_mp_probe much earlier so the max cpu id is known before the VM starts up. This is intended to help support per cpu queues for the new allocator, but may be useful elsewhere. Reviewed by: jake Approved by: jake
* Fix forward_roundrobin(). It was mistakenly using the cpu number aspeter2002-01-051-2/+2
| | | | | | | though it was a mask. As a result, we sent AST IPI's to the wrong cpu and/or left out some. Spotted by: jake
* Overhaul the per-CPU support a bit:jhb2001-12-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | - The MI portions of struct globaldata have been consolidated into a MI struct pcpu. The MD per-CPU data are specified via a macro defined in machine/pcpu.h. A macro was chosen over a struct mdpcpu so that the interface would be cleaner (PCPU_GET(my_md_field) vs. PCPU_GET(md.md_my_md_field)). - All references to globaldata are changed to pcpu instead. In a UP kernel, this data was stored as global variables which is where the original name came from. In an SMP world this data is per-CPU and ideally private to each CPU outside of the context of debuggers. This also included combining machine/globaldata.h and machine/globals.h into machine/pcpu.h. - The pointer to the thread using the FPU on i386 was renamed from npxthread to fpcurthread to be identical with other architectures. - Make the show pcpu ddb command MI with a MD callout to display MD fields. - The globaldata_register() function was renamed to pcpu_init() and now init's MI fields of a struct pcpu in addition to registering it with the internal array and list. - A pcpu_destroy() function was added to remove a struct pcpu from the internal array and list. Tested on: alpha, i386 Reviewed by: peter, jake
* Don't remove the tentative declaration. It's the only one...marcel2001-10-311-0/+1
| | | | Pointy hat: marcel (self-sponsoring)
* Make smp_started volatile in sys/smp.h and remove the volatilemarcel2001-10-311-1/+0
| | | | | | | declaration in subr_smp.c. This solves a compile problem with gcc 3.0.1 (ia64 cross-build). Reviewed: jhb
* KSE Milestone 2julian2001-09-121-9/+9
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
OpenPOWER on IntegriCloud