summaryrefslogtreecommitdiff
path: root/sys/kern/kern_cpu.c
AgeCommit message (Collapse)Author
2023-07-07heartbeat(9): New mechanism to check progress of kernel.riastradh
This uses hard interrupts to check progress of low-priority soft interrupts, and one CPU to check progress of another CPU. If no progress has been made after a configurable number of seconds (kern.heartbeat.max_period, default 15), then the system panics -- preferably on the CPU that is stuck so we get a stack trace in dmesg of where it was stuck, but if the stuckness was detected by another CPU and the stuck CPU doesn't acknowledge the request to panic within one second, the detecting CPU panics instead. This doesn't supplant hardware watchdog timers. It is possible for hard interrupts to be stuck on all CPUs for some reason too; in that case heartbeat(9) has no opportunity to complete. Downside: heartbeat(9) relies on hardclock to run at a reasonably consistent rate, which might cause trouble for the glorious tickless future. However, it could be adapted to take a parameter for an approximate number of units that have elapsed since the last call on the current CPU, rather than treating that as a constant 1. XXX kernel revbump -- changes struct cpu_info layout
2023-02-26ci_data.cpu_kcpuset -> ci_kcpusetskrll
NFCI.
2020-10-08PR kern/45117rin
Work around regression introduced in rev 1.92: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_cpu.c#rev1.92 by which ``cpuctl offline n'' became broken on architectures without __HAVE_INTR_CONTROL (i.e., everything other than alpha and x86); cpu_setintr() always fails on these archs, and we had neglected return value from that function until rev 1.91. XXX As martin pointed out in the PR, I'm not sure whether fix in rev 1.92 itself is correct or not. Insert XXX comment referring the PR there....
2020-07-13Do not allow disabling interrupts on the primary CPU. Fixes PR kern/45117.jruoho
2020-05-28At least panic with a useful message if there are too many CPUs.ad
2020-05-23Move proc_lock into the data segment. It was dynamically allocated becausead
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2019-12-21Fix build failure.ad
2019-12-20Split subr_cpu.c out of kern_cpu.c, to contain routines shared with rump.ad
2019-12-20Some more CPU topology stuff:ad
- Use cegger@'s ACPI SRAT parsing code to figure out NUMA node ID for each CPU as it is attached. - For scheduler experiments with SMT, flag CPUs with the lowest numbered SMT IDs as "primaries", link back to the primaries from secondaries, and build a circular list of CPUs in each package with identical SMT IDs. - No need for package/core/smt/numa IDs to be anything other than a u_int.
2019-12-18Passify rump build.ad
2019-12-17More rump-ing. I will split this into two files during the week.ad
2019-12-17Rump is living up to its namead
2019-12-17Hopefully unbreak the build - now that this is included in rump.ad
2019-12-16- Extend the per-CPU counters matt@ did to include all of the hot countersad
in UVM, excluding uvmexp.free, which needs special treatment and will be done with a separate commit. Cuts system time for a build by 20-25% on a 48 CPU machine w/DIAGNOSTIC. - Avoid 64-bit integer divide on every fault (for rnd_add_uint32).
2019-12-04Fix typo in comment (typlogy)wiz
2019-12-03- Add some more failsafes to the CPU topology stuff, and build a 3rdad
circular list of peer CPUs in other packages, so we might scroll through them in the scheduler when looking to distribute or steal jobs. - Fold the run queue data structure into spc_schedstate. Makes kern_runq.c a far more pleasant place to work. - Remove the code in sched_nextlwp() that tries to steal jobs from other CPUs. It's not needed, because we do the very same thing in the idle LWP anyway. Outside the VM system this was one of the the main causes of L3 cache misses I saw during builds. On my machine, this change yields a 60%-70% drop in time on the "hackbench" benchmark (there's clearly a bit more going on here, but basically being less aggressive helps).
2019-12-02Take the basic CPU topology information we already collect, and use itad
to make circular lists of CPU siblings in the same core, and in the same package. Nothing fancy, just enough to have a bit of fun in the scheduler trying out different tactics.
2019-12-01Fix false sharing problems with cpu_info. Identified with tprof(8).ad
This was a very nice win in my tests on a 48 CPU box. - Reorganise cpu_data slightly according to usage. - Put cpu_onproc into struct cpu_info alongside ci_curlwp (now is ci_onproc). - On x86, put some items in their own cache lines according to usage, like the IPI bitmask and ci_want_resched.
2019-11-13put the ucode not found message under #ifdef DEBUG. use printf()mrg
instead of aprint_error(). there's an error returned to userland and displayed by cpuctl.
2019-10-06Define cpu_xc_* functions with unused second argument to make themuwe
conform to xcfunc_t callback typedef (-Wcast-function-type). Same object code is generated.
2018-11-13Fix/add KASSERTS to work with a system of MAXCPUS. Add some comments toskrll
explain things. Discussed with rmind
2018-07-04 Don't allocate memory and return EFTYPE if sc->sc_blobsize==0 to preventmsaitoh
panic in firmware_malloc().
2018-03-18finish MD glue for compat ucode module.christos
2018-03-17move the compat code in compat.christos
2015-08-29Don't decrement the number of offline cpus if we fail to shut down one.maxv
ok christos@, via tech-kern@
2015-08-20include ioconf.h instead of locally declaring the prototype of the attachchristos
function
2015-08-20Mark pseudo attach unused arg with __unused.uebayasi
2015-08-18Convert pseudo attach functions to take no arguments, as some functionsuebayasi
(pppattach(), putterattach(), etc.) already do. This means that pseudo attach function will be able to become a constructor.
2015-01-07Pass a correct firmware size (instead of 0) to firmware_freeozaki-r
firmware_free now uses kmem_free(9) instead of free(9), so we need to pass a correct size to it.
2014-07-25Add d_discard to all struct cdevsw instances I could find.dholland
All have been set to "nodiscard"; some should get a real implementation.
2014-03-25snprintf -> vsnprintf in cpu_setmodel()macallan
now this can actually work hi christos
2014-03-24- create cpu_{g,s}etmodel() and hide cpu_model from direct access.christos
2014-03-16Change (mostly mechanically) every cdevsw/bdevsw I can find to usedholland
designated initializers. I have not built every extant kernel so I have probably broken at least one build; however I've also found and fixed some wrong cdevsw/bdevsw entries so even if so I think we come out ahead.
2013-12-19cpu_infos is a NULL terminated array, not an array followed by a 0 byte.mlelstv
2013-11-24Remove cpu_queue (and thus eleminate another use of CIRCLEQ) by replacingrmind
its uses with cpu_infos array. Extra testing by christos@.
2013-08-22-extend the pcu(9) API by a function which saves all context on thedrochner
current CPU, and use it if a CPU is taken offline -add a bool argument to pcu_discard which tells whether the internal "LWP has used the coprocessor" flag should be set or reset. The flag is reported by pcu_used_p(). If set, future accesses should use the state stored in the PCB. If reset, it should be reset to default. The former case is useful for setmcontext(). With that, it should not be necessary anymore to manage the "FPU used" state by an additional MD variable. approved by matt
2012-10-17put binary compatibility support for the old AMD-only CPU microcodedrochner
update API inside COMPAT_60
2012-09-01Add a kcpuset_t which just includes ourself.matt
Add a ci_cpuname for convenience
2012-08-29Extend the CPU microcode update framework to support Intel x86 CPUs.drochner
Contrary to the AMD implementation, it doesn't use xcalls to distribute the update to all CPUs but relies on cpuctl(8) to bind itself to the right CPU -- to keep it simple and avoid possible problems with hyperthreading. Also, it doesn't parse the vendor supplied file to pick the right part for the present CPU model but relies on userland to prepare files with specific filenames. I'll commit a pkg for this in a minute (pkgsrc/sysutils/intel-microcode). The ioctl interface changed; compatibility is provided (should be limited to COMPAT_NETBSD6 as soon as this is available).
2012-06-13Kill conditionals that are always true. Drop a dead assignment.joerg
2012-01-29- Add mi_cpu_init() and initialise cpu_lock and kcpuset_attached/running there.rmind
- Add kcpuset_running which gets set in idle_loop(). - Use kcpuset_running in pserialize_perform().
2012-01-17fix secmodel implementation of CPU_UCODE.cegger
ok wiz@ for the manpages ok elad@
2012-01-13Support CPU microcode loading via cpuctl(8).cegger
Implemented and enabled via CPU_UCODE kernel config option for x86 and Xen Dom0. Tested on different AMD machines with different CPU families. ok wiz@ for the manpages ok releng@ ok core@ via releng@
2011-10-29Fix comment.jym
2011-09-11Add a cs_hwid field to cpustate and use this to store the ci_cpuid (hardwarejdc
ID). Report this as the HwID in cpuctl. OK jruoho@.
2011-08-07- Add an argument to kcpuset_create() for zeroing.rmind
- Add kcpuset_atomic_set(), kcpuset_atomic_clear() and kcpuset_merge().
2011-08-07Remove LW_AFFINITY flag and fix some bugs affinity mask handling.rmind
2011-08-07Add kcpuset(9) - a reworked dynamic CPU set implementation for kernel.rmind
Suitable for use during the early boot. MD and other implementations should be replaced with this interface. Discussed on: tech-kern@
2011-06-29Add the new ci to cpu_infos *before* calling routines which may want tomatt
cpu_lookup.
2011-05-13Sprinkle __cacheline_aligned and __read_mostly.rmind