summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_shutdown.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Update for the KDB framework:marcel2004-07-101-33/+15
| | | | | | | | | | | | | | | | | | | | | | o Make debugging code conditional upon KDB instead of DDB. o Call kdb_enter() instead of Debugger(). o Call kdb_backtrace() instead of db_print_backtrace() or backtrace(). kern_mutex.c: o Replace checks for db_active with checks for kdb_active and make them unconditional. kern_shutdown.c: o s/DDB_UNATTENDED/KDB_UNATTENDED/g o s/DDB_TRACE/KDB_TRACE/g o Save the TID of the thread doing the kernel dump so the debugger knows which thread to select as the current when debugging the kernel core file. o Clear kdb_active instead of db_active and do so unconditionally. o Remove backtrace() implementation. kern_synch.c: o Call kdb_reenter() instead of db_error().
* Implement preemption of kernel threads natively in the scheduler ratherjhb2004-07-021-13/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | than as one-off hacks in various other parts of the kernel: - Add a function maybe_preempt() that is called from sched_add() to determine if a thread about to be added to a run queue should be preempted to directly. If it is not safe to preempt or if the new thread does not have a high enough priority, then the function returns false and sched_add() adds the thread to the run queue. If the thread should be preempted to but the current thread is in a nested critical section, then the flag TDF_OWEPREEMPT is set and the thread is added to the run queue. Otherwise, mi_switch() is called immediately and the thread is never added to the run queue since it is switch to directly. When exiting an outermost critical section, if TDF_OWEPREEMPT is set, then clear it and call mi_switch() to perform the deferred preemption. - Remove explicit preemption from ithread_schedule() as calling setrunqueue() now does all the correct work. This also removes the do_switch argument from ithread_schedule(). - Do not use the manual preemption code in mtx_unlock if the architecture supports native preemption. - Don't call mi_switch() in a loop during shutdown to give ithreads a chance to run if the architecture supports native preemption since the ithreads will just preempt DELAY(). - Don't call mi_switch() from the page zeroing idle thread for architectures that support native preemption as it is unnecessary. - Native preemption is enabled on the same archs that supported ithread preemption, namely alpha, i386, and amd64. This change should largely be a NOP for the default case as committed except that we will do fewer context switches in a few cases and will avoid the run queues completely when preempting. Approved by: scottl (with his re@ hat)
* - Change mi_switch() and sched_switch() to accept an optional thread tojhb2004-07-021-1/+1
| | | | | | | | | | | | | switch to. If a non-NULL thread pointer is passed in, then the CPU will switch to that thread directly rather than calling choosethread() to pick a thread to choose to. - Make sched_switch() aware of idle threads and know to do TD_SET_CAN_RUN() instead of sticking them on the run queue rather than requiring all callers of mi_switch() to know to do this if they can be called from an idlethread. - Move constants for arguments to mi_switch() and thread_single() out of the middle of the function prototypes and up above into their own section.
* Second half of the dev_t cleanup.phk2004-06-171-1/+1
| | | | | | | | | | | The big lines are: NODEV -> NULL NOUDEV -> NODEV udev_t -> dev_t udev2dev() -> findcdev() Various minor adjustments including handling of userland access to kernel space struct cdev etc.
* Remove filename+line number from panic messages.phk2004-06-061-3/+3
|
* Remove advertising clause from University of California Regent's license,imp2004-04-051-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core
* - Add a flags parameter to mi_switch. The value of flags may be SW_VOL orjeff2004-01-251-2/+4
| | | | | | | | | | SW_INVOL. Assert that one of these is set in mi_switch() and propery adjust the rusage statistics. This is to simplify the large number of users of this interface which were previously all required to adjust the proper counter prior to calling mi_switch(). This also facilitates more switch and locking optimizations. - Change all callers of mi_switch() to pass the appropriate paramter and remove direct references to the process statistics.
* Add linenumber and source filename to panic(9) output.phk2004-01-191-3/+3
| | | | Ideally a traceback should be printed too, any takers ?
* Further cleanup <machine/cpu.h> and <machine/md_var.h>: move the MImarcel2003-08-161-1/+1
| | | | | | | | | | | | | | | | | | | prototypes of cpu_halt(), cpu_reset() and swi_vm() from md_var.h to cpu.h. This affects db_command.c and kern_shutdown.c. ia64: move all MD prototypes from cpu.h to md_var.h. This affects madt.c, interrupt.c and mp_machdep.c. Remove is_physical_memory(). It's not used (vm_machdep.c). alpha: the MD prototypes have been left in cpu.h with a comment that they should be there. Moving them is left for later. It was expected that the impact would be significant enough to be done in a seperate commit. powerpc: MD prototypes left in cpu.h. Comment added. Suggested by: bde Tested with: make universe (pc98 incomplete)
* Don't overwrite the static panicstr buffer for secondary and furtheriedowse2003-06-151-3/+8
| | | | | | | | | panics. Before revision 1.38, we used to just point panicstr at the format string if panicstr was NULL, but since we now use a static buffer for the formatted panic message, we have to be careful to only write to it during the first panic. Pointed out by: bde
* Use __FBSDID().obrien2003-06-111-1/+3
|
* Lock the sched_lock while setting TDF_INPANIC.jhb2003-04-171-0/+2
|
* Don't include <sys/disklabel.h>phk2003-04-161-1/+0
|
* style.alfred2003-02-141-8/+20
|
* Print "Stack backtrace:" right before dumping the backtrace. We cannotpeter2003-02-131-1/+2
| | | | expect end users to automatically recognize a stack trace for what it is.
* - Update a printf format for b_flags.jeff2003-02-091-1/+1
|
* Introduce thephk2003-01-041-0/+14
| | | | | | | | | | | | | void backtrace(void); function which will print a backtrace if DDB is in the kernel and an explanation if not. This is useful for recording backtraces in non-fatal circumstances and does not require pollution with DDB #includes in the files where it is used. It would of course be nice to have a non-DDB dependent version too, but since the meat of a backtrace is MD it is probably not worth it.
* During shutdown explain what the numbers following the 'syncingalfred2002-11-181-1/+1
| | | | disks' message mean, specifically, 'buffers remaining...'.
* Hook up mac_check_system_reboot(), a MAC Framework entry point thatrwatson2002-10-271-3/+12
| | | | | | | | | permits MAC modules to augment system security decisions regarding the reboot() system call, if MAC is compiled into the kernel. Approved by: re Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Add kernel dump support, based on the ia64 version (which was committedtmm2002-10-201-1/+1
| | | | | | | | | | as sparc64/sparc64/dump_machdep.c a while back). Other than ia64 (which uses ELF), sparc64 uses a homegrown format for the dumps (headers are required because the physical address and size of the tsb must be noted, and because physical memory may be discontiguous); ELF would not offer any advantages here. Reviewed by: jake
* Add ability to dump stacktraces on kernel panics when DDB is compiled intojhb2002-09-191-2/+17
| | | | | | | | | | | | | | | the kernel. By default this is turned off since otherwise it could scroll valuable panic messages off of the screen. This option can be turned on by the DDB_TRACE kernel option as well as the debug.trace_on_panic sysctl. Also, fix the DDB_UNATTENDED option to use its own header instead of abusing opt_ddb.h. This way turning that one option on or off doesn't force you to recompile all of ddb. Requested by: many (1), bde (2*) * - I know bde prefers !abusing option headers in general but can't remember if he as brought up this specific case.
* Revert previous revision which was accidentally committed and has not beenjhb2002-08-011-11/+9
| | | | tested yet.
* If we fail to write to a vnode during a ktrace write, then we drop alljhb2002-08-011-9/+11
| | | | | | | | | other references to that vnode as a trace vnode in other processes as well as in any pending requests on the todo list. Thus, it is possible for a ktrace request structure to have a NULL ktr_vp when it is destroyed in ktr_freerequest(). We shouldn't call vrele() on the vnode in that case. Reported by: bde
* Allow alphas to do crashdumps: Refuse to run anything in choosethread()gallatin2002-07-171-0/+2
| | | | | | | | | | after a panic which is not an interrupt thread, or the thread which caused the panic. Also, remove panicstr checks from msleep() and from cv_wait() in order to allow threads to go to sleep and yeild the cpu to the panicing thread, or to an interrupt thread which might be doing the crashdump. Reviewed by: jhb (and it was mostly his idea too)
* Add a missing newline during panic printf's for SMP systems that don'tjhb2002-07-111-0/+2
| | | | have APICS. (Like all the !i386 archs).
* Part 1 of KSE-IIIjulian2002-06-291-1/+0
| | | | | | | | | | | | | 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..
* Fix alpha build. The alpha has dumpsys implemented.marcel2002-05-121-1/+1
| | | | | | | While here, revert the condition to list the machines for which dumpsys has not been implemented. Reported by: wilko
* Put back dumppcb, but this time we put a comment to tell what it is for.phk2002-04-081-4/+12
| | | | Brucifixion by: bde
* Added the new kernel dumping support for pc98.nyan2002-04-061-1/+1
|
* Don't compile the dummy dumpsys for ia64.marcel2002-04-021-1/+1
|
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-1/+1
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Extend a hack to also hack around PC98's definition of __i386__phk2002-04-011-1/+1
|
* Here follows the new kernel dumping infrastructure.phk2002-03-311-173/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Caveats: The new savecore program is not complete in the sense that it emulates enough of the old savecores features to do the job, but implements none of the options yet. I would appreciate if a userland hacker could help me out getting savecore to do what we want it to do from a users point of view, compression, email-notification, space reservation etc etc. (send me email if you are interested). Currently, savecore will scan all devices marked as "swap" or "dump" in /etc/fstab _or_ any devices specified on the command-line. All architectures but i386 lack an implementation of dumpsys(), but looking at the i386 version it should be trivial for anybody familiar with the platform(s) to provide this function. Documentation is quite sparse at this time, more to come. Details: ATA and SCSI drivers should work as the dump formatting code has been removed. The IDA, TWE and AAC have not yet been converted. Dumpon now opens the device and uses ioctl(DIOCGKERNELDUMP) to set the device as dumpdev. To implement the "off" argument, /dev/null is used as the device. Savecore will fail if handed any options since they are not (yet) implemented. All devices marked "dump" or "swap" in /etc/fstab will be scanned and dumps found will be saved to diskfiles named from the MD5 hash of the header record. The header record is dumped in readable format in the .info file. The kernel is not saved. Only complete dumps will be saved. All maintainer rights for this code are disclaimed: feel free to improve and extend. Sponsored by: DARPA, NAI Labs
* Centralize the "bootdev" and "dumpdev" variables. They are still prettyphk2002-03-311-0/+1
| | | | | bogus all things considered, but at least now they don't camouflage as being MD variables.
* Add needed includes of machine/smp.h, remove nested include in sys/smp.hjake2002-03-071-0/+1
| | | | so that inlines in machine/smp.h can use variables declared in sys/smp.h.
* Replace accidentally removed setrunqueue()julian2002-02-091-0/+1
| | | | | solves problem with machines failing to sync in booting. Submitted by: Tor.Egge@cvsup.no.freebsd.org
* Pre-KSE/M3 commit.julian2002-02-071-3/+2
| | | | | | | | | | this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out. Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
* Allow dump device be configured as early as possible using loader(8) tunable.sobomax2002-01-211-0/+11
| | | | | | | This allows obtaining crash dumps from the panics occured during late stages of kernel initialisation before system enters into single-user mode. MFC after: 2 weeks
* Explain that the admin can safely power down the system as well asnik2002-01-181-1/+2
| | | | rebooting.
* Change the preemption code for software interrupt thread schedules andjhb2002-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mutex releases to not require flags for the cases when preemption is not allowed: The purpose of the MTX_NOSWITCH and SWI_NOSWITCH flags is to prevent switching to a higher priority thread on mutex releease and swi schedule, respectively when that switch is not safe. Now that the critical section API maintains a per-thread nesting count, the kernel can easily check whether or not it should switch without relying on flags from the programmer. This fixes a few bugs in that all current callers of swi_sched() used SWI_NOSWITCH, when in fact, only the ones called from fast interrupt handlers and the swi_sched of softclock needed this flag. Note that to ensure that swi_sched()'s in clock and fast interrupt handlers do not switch, these handlers have to be explicitly wrapped in critical_enter/exit pairs. Presently, just wrapping the handlers is sufficient, but in the future with the fully preemptive kernel, the interrupt must be EOI'd before critical_exit() is called. (critical_exit() can switch due to a deferred preemption in a fully preemptive kernel.) I've tested the changes to the interrupt code on i386 and alpha. I have not tested ia64, but the interrupt code is almost identical to the alpha code, so I expect it will work fine. PowerPC and ARM do not yet have interrupt code in the tree so they shouldn't be broken. Sparc64 is broken, but that's been ok'd by jake and tmm who will be fixing the interrupt code for sparc64 shortly. Reviewed by: peter Tested on: i386, alpha
* Fix a signed bug in the crashdump code for systems with > 2GB of ram.ps2001-11-131-2/+2
| | | | Reviewed by: peter
* Add a sysctl for preventing the sync() in panic() recovery. This canpeter2001-10-191-0/+6
| | | | | | be so dangerous it isn't funny. eg: if you panic inside NFS or softdep, and then try and sync you run into held locks and cause either deadlocks, recursive panics or other interesting chaos. Default is unchanged.
* decrement the dumping variable after use so we can call it several timespeter2001-09-201-4/+6
| | | | if needed.
* KSE Milestone 2julian2001-09-121-7/+7
| | | | | | | | | | | | | | 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
* - Axe holding_giant as it is not used now anyways and was ok'd byjhb2001-09-101-35/+4
| | | | | | | | | | dillon in an earlier e-mail. - We don't need to test the console right before we vfprintf() the panicstr message. The printing of the panic message is a fine console test by itself and doesn't make useful messages scroll off the screen or tick developers off in quite the same. Requested by: jlemon, imp, bmilekic, chris, gsutter, jake (2)
* Sigh. Dig up text from a signature in a 1994 Usenet post I made and redopeter2001-09-051-5/+12
| | | | the ..uhh... ``console test'' to avoid another 50 emails about GPL issues.
* The !RESTARTABLE_PANICS code has some loose ends.peter2001-09-021-0/+8
|
* Giant Pushdown. Saved the worst P4 tree breakage for last.dillon2001-09-011-9/+28
| | | | | | | | | | | | reboot() getpriority() setpriority() rtprio() osetrlimit() ogetrlimit() setrlimit() getrlimit() getrusage() getpid() getppid() getpgrp() getpgid() getsid() getgid() getegid() getgroups() setsid() setpgid() setuid() seteuid() setgid() setegid() setgroups() setreuid() setregid() setresuid() setresgid() getresuid() getresgid () __setugid() getlogin() setlogin() modnext() modfnext() modstat() modfind() kldload() kldunload() kldfind() kldnext() kldstat() kldfirstmod() kldsym() getdtablesize() dup2() dup() fcntl() close() ofstat() fstat() nfsstat() fpathconf() flock()
* Add a new kernel option RESTARTABLE_PANICS. If this option is present,jhb2001-08-231-0/+2
| | | | | | | | then one can restart from a panic by resetting the panicstr variable to NULL. This commit conditionalizes the previously committed functionality on this variable. It also removes the __dead2 attribute from the panic() function so that when one continues from a panic() the behavior will be predictable.
* Clear db_active in boot() so that one can call the boot function (as welljhb2001-08-211-0/+8
| | | | | as use the panic command) w/o having to manually clear db_active first to avoid the db_error() in mi_switch().
OpenPOWER on IntegriCloud