summaryrefslogtreecommitdiffstats
path: root/sys/ddb
Commit message (Collapse)AuthorAgeFilesLines
* Move UPCALL related data structure out of kse, introduce a newdavidxu2003-01-261-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | data structure called kse_upcall to manage UPCALL. All KSE binding and loaning code are gone. A thread owns an upcall can collect all completed syscall contexts in its ksegrp, turn itself into UPCALL mode, and takes those contexts back to userland. Any thread without upcall structure has to export their contexts and exit at user boundary. Any thread running in user mode owns an upcall structure, when it enters kernel, if the kse mailbox's current thread pointer is not NULL, then when the thread is blocked in kernel, a new UPCALL thread is created and the upcall structure is transfered to the new UPCALL thread. if the kse mailbox's current thread pointer is NULL, then when a thread is blocked in kernel, no UPCALL thread will be created. Each upcall always has an owner thread. Userland can remove an upcall by calling kse_exit, when all upcalls in ksegrp are removed, the group is atomatically shutdown. An upcall owner thread also exits when process is in exiting state. when an owner thread exits, the upcall it owns is also removed. KSE is a pure scheduler entity. it represents a virtual cpu. when a thread is running, it always has a KSE associated with it. scheduler is free to assign a KSE to thread according thread priority, if thread priority is changed, KSE can be moved from one thread to another. When a ksegrp is created, there is always N KSEs created in the group. the N is the number of physical cpu in the current system. This makes it is possible that even an userland UTS is single CPU safe, threads in kernel still can execute on different cpu in parallel. Userland calls kse_create to add more upcall structures into ksegrp to increase concurrent in userland itself, kernel is not restricted by number of upcalls userland provides. The code hasn't been tested under SMP by author due to lack of hardware. Reviewed by: julian
* Revert previous and move the prototype for db_alt_break to ddb.h.jake2002-12-312-7/+4
| | | | Requested by: bde (I think)
* - Add a function db_alt_break which recognizes the character sequence used tojake2002-12-312-1/+51
| | | | | | | | | | implement ALT_BREAK_TO_DEBUGGER. The caller provides a pointer to a state variable to allow different state to be maintained for separate instances of a device. - Use struct vm_map * instead of vm_map_t in db_break.h to avoid its users needing to include vm headers. Requested by: njl
* Add code to ddb to allow backtracing an arbitrary thread.julian2002-12-283-55/+96
| | | | | | | | | | | | | | | | | | | | | | | | (show thread {address}) Remove the IDLE kse state and replace it with a change in the way threads sahre KSEs. Every KSE now has a thread, which is considered its "owner" however a KSE may also be lent to other threads in the same group to allow completion of in-kernel work. n this case the owner remains the same and the KSE will revert to the owner when the other work has been completed. All creations of upcalls etc. is now done from kse_reassign() which in turn is called from mi_switch or thread_exit(). This means that special code can be removed from msleep() and cv_wait(). kse_release() does not leave a KSE with no thread any more but converts the existing thread into teh KSE's owner, and sets it up for doing an upcall. It is just inhibitted from being scheduled until there is some reason to do an upcall. Remove all trace of the kse_idle queue since it is no-longer needed. "Idle" KSEs are now on the loanable queue.
* - Rename the DDB specific %z printf format to %y.mux2002-10-251-2/+2
| | | | | | | | | | - Make DDB use %y instead of %z. - Teach GCC about %y. - Implement support for the C99 %z format modifier. Approved by: re@ Reviewed by: peter Tested on: i386, sparc64
* Remove the process state PRS_WAIT.julian2002-10-211-3/+0
| | | | | | It is never used. I left it there from pre-KSE days as I didn't know if I'd need it or not but now I know I don't.. It's functionality is in TDI_IWAIT in the thread.
* Round out the facilty for a 'bound' thread to loan out its KSEjulian2002-10-091-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | in specific situations. The owner thread must be blocked, and the borrower can not proceed back to user space with the borrowed KSE. The borrower will return the KSE on the next context switch where teh owner wants it back. This removes a lot of possible race conditions and deadlocks. It is consceivable that the borrower should inherit the priority of the owner too. that's another discussion and would be simple to do. Also, as part of this, the "preallocatd spare thread" is attached to the thread doing a syscall rather than the KSE. This removes the need to lock the scheduler when we want to access it, as it's now "at hand". DDB now shows a lot mor info for threaded proceses though it may need some optimisation to squeeze it all back into 80 chars again. (possible JKH project) Upcalls are now "bound" threads, but "KSE Lending" now means that other completing syscalls can be completed using that KSE before the upcall finally makes it back to the UTS. (getting threads OUT OF THE KERNEL is one of the highest priorities in the KSE system.) The upcall when it happens will present all the completed syscalls to the KSE for selection.
* Rename the mutex thread and process states to use a more generic 'LOCK'jhb2002-10-021-3/+3
| | | | | | | | | name instead. (e.g., SLOCK instead of SMTX, TD_ON_LOCK() instead of TD_ON_MUTEX()) Eventually a turnstile abstraction will be added that will be shared with mutexes and other types of locks. SLOCK/TDI_LOCK will be used internally by the turnstile code and will not be specific to mutexes. Making the change now ensures that turnstiles can be dropped in at a later date without affecting the ABI of userland applications.
* Indentation indicates missing braces.phk2002-10-011-1/+2
| | | | Spotted by: FlexeLint
* Be consistent about "static" functions: if the function is markedphk2002-09-282-7/+7
| | | | | | static in its prototype, mark it static at the definition too. Inspired by: FlexeLint warning #512
* Constify to kill some warnings.markm2002-09-212-2/+2
|
* Implement db_print_backtrace() if DDB is compiled into the kernel. Thisjhb2002-09-191-0/+3
| | | | | | | | | | | | | | | | | | | | MD function is just a wrapper around db_stack_trace_cmd() that prints out a backtrace of curthread. Currently, this function is only implemented on i386 and alpha (and the alpha version isn't quite tested yet, will do that in a bit). Other changes: - For i386, fix a bug in the raw frame address case. The eip we extract from the passed in frame address does not match the frame we received. Thus, instead of printing a bogus frame with the wrong eip, go ahead and advance frame down to the same frame as the eip we are using. - For alpha, attempt to add a way of doing a raw trace for alpha. Instead of passing a frame address in 'addr', pass in a pointer to a structure containing PC and KSP and use those to start the backtrace. The alpha db_print_backtrace() uses asm to read in the current PC and KSP values into such a request. Tested on: i386 Requested by: many
* Garbage-collected __ELF__ ifdefs.bde2002-09-151-10/+2
| | | | Fixed some style bugs (mainly unused includes).
* Don't use the ELF symbol type to summarily reject symbols inbde2002-09-151-4/+0
| | | | | | | | | | | | | | | X_db_search_symbol(). Otherwise we don't see important symbols in non-verbosely written assembler code. NetBSD already has this. The kld version already has a stronger form of it without really trying -- linker_ddb_search_symbol() doesn't support ddb's symbol search strategy parameter, so the kld X_db_search_symbol() doesn't pass the parameter to linker_ddb...() and linker_ddb...() doesn't make distinctions based on the symbol type. db_elf.c now works better than db_kld.c when it works (which is essentially when there are no modules except the kernel). It works after booting with -d. db_kld.c doesn't work until lots of SYSINIT()s have run.
* Made this work on i386's at least. It wants ELF section headers forbde2002-09-151-2/+34
| | | | | | | | | | | | | | | | | symbol table sections. Reconstruct the necessary section headers from (ksym_start, ksym_end). This was much easier than converting to use module metadata, and just works for static symbols, unlike db_kld when there is no module metadata. Initialize (ksym_start, ksym_end) from bootinfo on i386's only. The boot loader should load section headers for all sections that it loads, and apparently did this for at least the symbol table sections when this file last worked under FreeBSD (on alphas only) and always did this under NetBSD (where this file was obtained from). At least on i386's, boot2 discards the section headers (except for converting them to (bootinfo.bi_symtab, bootinfo.bi_esymtab), and as far as I can tell, loader(8) discards them apart from converting them to the bootinfo values and module metadata.
* Made this compile (but not work). This involved mainly const poisoningbde2002-09-151-8/+18
| | | | | | | | | | | and renaming ALIGNED_POINTER() to _ALIGNED_POINTER() plus the following hacks for i386's: - define _ALIGNED_POINTER() if it is not already defined. Most non-i386 arches define it <machine/param.h> define it in <machine/param.h>, although none actually used it in the kernel. - define ksym_start and ksym_end. Most non-i386 arches still define and initialize these in machdep.c although they didn't used them. Here is a better place to define them but not to initialize them.
* Completely redo thread states.julian2002-09-111-25/+48
| | | | Reviewed by: davidxu@freebsd.org
* db_ps.c:bde2002-08-311-5/+6
| | | | | | | | | | | | | | | | | | | | | | | Don't attempt to follow null pointers for zombie processes in db_ps(). Style fix: use explicit an comparison with NULL for all null pointer checks in db_ps() instead of for half of them. db_interface.c: Fixed ddb's handling of traps from with ddb on i386's only. This was mostly fixed in rev.1.27 (by longjmp()'ing back to the top level) but was completly broken in rev.1.48 (by not unwinding the new state (mainly db_active) either before or after the longjmp(). This mostly never worked for other arches, since rev.1.27 has not been ported and lower level longjmp()'s only handle traps for memory accesses. All cases should be handled at a lower level to provided better control and simplify unwinding of state. Implementation details: don't pretend to maintain db_active in a nested way -- ddb cannot be reentered in a nested way. Use db_active instead of the db_global_jmpbuf_valid flag and longjmp()'s return value for things related to reentering ddb. [re]entering is still not atomic enough.
* When talking about c_db_sym_t, mention that it is not just like db_sym_t:jmallett2002-08-141-1/+1
| | | | | | it's const. Inspired by: bde
* Realign columns in DDB's ps output. Don't waste more horizontal space thanphk2002-08-131-9/+9
| | | | necessary.
* Part 1 of KSE-IIIjulian2002-06-291-8/+30
| | | | | | | | | | | | | 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..
* Remove a couple of __P() stragglers.peter2002-06-291-1/+1
|
* Don't assume that pointers are 4 bytes or sizeof(int) in size. This fixestmm2002-06-252-6/+3
| | | | | | the indirection operator ('*') and address examination ('x/a') on big-endian platoforms for which the above is not true, as well as on little-endian platforms if the cut-off bits are not 0.
* Split the declaration and the initialization of two variables.mux2002-06-231-4/+4
| | | | | | | This has the fortunate side effect of stopping GCC from reporting warnings about unused variables on sparc64. Reviewed by: bde
* Allow DB_SET() to set all fields in the ddb command structure. Thisgibbs2002-06-051-5/+5
| | | | | allows external ddb commands to do anyting an internal command can do, including non-standard argument parsing if desired.
* Reconnect db_elf.c to the build (now under "options DDB_NOKLDSYM"). Itbde2002-05-072-2/+12
| | | | doesn't actually build yet.
* Restored db_elf.c from the Attic. This will be used for a quick fix forbde2002-05-061-0/+381
| | | | | the longstanding brokenness of symbols in ddb at boot time. It doesn't compile and is not attached to the build yet.
* Commented out locking that would be used in the ps command if locks werejhb2002-04-111-0/+5
| | | | used in ddb.
* Fixed some style bugs in the removal of __P(()). Continuation linesbde2002-03-233-23/+15
| | | | | were not outdented to preserve non-KNF lining up of code with parentheses. Switch to KNF formatting.
* Remove __P.alfred2002-03-2019-113/+108
|
* Allow '.' in identifiers - some ia64 register names contain '.'.dfr2002-03-101-1/+1
|
* ^U kills an entire input line in most applications,yar2002-02-121-5/+6
| | | | | | | including the default terminal canonical mode. So let ddb(4) be no exception from this rule. Pointed out by: Mark Peek <mark@peek.org>
* Teach ddb(4) to delete to the beginning of its command line on ^U.yar2002-02-111-0/+5
| | | | | PR: kern/28976 Submitted by: Nickolai Zeldovich <kolya@orbit.zepa.net>
* Pre-KSE/M3 commit.julian2002-02-071-1/+1
| | | | | | | | | | 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,
* pid is 'long' on alpha.mjacob2002-01-171-2/+2
|
* Implement a "kill" DDB command which is an interface to psignal() thatdd2001-11-271-0/+59
| | | | | | | | | | | | | | | respects locks. Before SMPng, one was able to call psignal() using the "call" command, but this is no longer possible because it does not respect locks by itself. This is very useful when one has gotten their machine into a state where it is impossible to spawn ps/kill or su to root. In this case, respecting locks essentially means trying to aquire the proc lock before calling psignal(). We can't block in the debugger, so if trylock fails, the operation fails. This also means that we can't use pfind(), since that will attempt to lock the process for us. Reviewed by: jhb
* GC the a.out support in DDB, nothing anywhere would pull thisphk2001-11-051-402/+0
| | | | file into a build.
* - Include machine/md_var.h to get rid of cpu_reset() warning. (-Wall)arr2001-11-051-0/+1
| | | | Approved by: jhb
* Add a 'reset' command. This is useful for panics really early beforepeter2001-11-031-0/+13
| | | | any symbols are loaded. Especially for unattended machines.
* Make the flag field in the ps output one char wider to account for recentjhb2001-10-201-6/+13
| | | | | growth in the number of flags used. Also, if a thread is blocked on a mutex, print the mutex name in the wait channel column.
* Fill out some gaps in ia64 DDB support. This involves generalising DDB'sdfr2001-09-153-25/+36
| | | | | breakpoint handling slightly to cope with the fact that ia64 instructions are not located on byte boundaries.
* - Whitespace fixes.jhb2001-09-121-16/+9
| | | | - Fix an old bug: p_comm is an array not a pointer, so it can't be NULL.`
* KSE Milestone 2julian2001-09-121-8/+30
| | | | | | | | | | | | | | 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
* No tokens should follow #endif.obrien2001-08-151-2/+2
|
* Quiet a variable format-string warning.kris2001-07-191-1/+1
| | | | MFC after: 1 week
* Add 'hwatch' and 'dhwatch' ddb commands analogous to 'watch' andbsd2001-07-113-0/+49
| | | | | | | | | | 'dwatch'. The new commands install hardware watchpoints if supported by the architecture and if there are enough registers to cover the desired memory area. No objection by: audit@, hackers@ MFC after: 2 weeks
* A set of changes to reduce the number of include files the kerneljulian2001-07-082-2/+3
| | | | | | takes from /usr/include. I cannot check them on alpha.. (will try beast) Briefly looked at by: Warner Losh <imp@harmony.village.org>
* With this commit, I hereby pronounce gensetdefs past its use-by date.peter2001-06-131-14/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the a.out emulation of 'struct linker_set' with something a little more flexible. <sys/linker_set.h> now provides macros for accessing elements and completely hides the implementation. The linker_set.h macros have been on the back burner in various forms since 1998 and has ideas and code from Mike Smith (SET_FOREACH()), John Polstra (ELF clue) and myself (cleaned up API and the conversion of the rest of the kernel to use it). The macros declare a strongly typed set. They return elements with the type that you declare the set with, rather than a generic void *. For ELF, we use the magic ld symbols (__start_<setname> and __stop_<setname>). Thanks to Richard Henderson <rth@redhat.com> for the trick about how to force ld to provide them for kld's. For a.out, we use the old linker_set struct. NOTE: the item lists are no longer null terminated. This is why the code impact is high in certain areas. The runtime linker has a new method to find the linker set boundaries depending on which backend format is in use. linker sets are still module/kld unfriendly and should never be used for anything that may be modular one day. Reviewed by: eivind
* o Merge contents of struct pcred into struct ucred. Specifically, add therwatson2001-05-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | real uid, saved uid, real gid, and saved gid to ucred, as well as the pcred->pc_uidinfo, which was associated with the real uid, only rename it to cr_ruidinfo so as not to conflict with cr_uidinfo, which corresponds to the effective uid. o Remove p_cred from struct proc; add p_ucred to struct proc, replacing original macro that pointed. p->p_ucred to p->p_cred->pc_ucred. o Universally update code so that it makes use of ucred instead of pcred, p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo, cr_{r,sv}{u,g}id instead of p_*, etc. o Remove pcred0 and its initialization from init_main.c; initialize cr_ruidinfo there. o Restruction many credential modification chunks to always crdup while we figure out locking and optimizations; generally speaking, this means moving to a structure like this: newcred = crdup(oldcred); ... p->p_ucred = newcred; crfree(oldcred); It's not race-free, but better than nothing. There are also races in sys_process.c, all inter-process authorization, fork, exec, and exit. o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid; remove comments indicating that the old arrangement was a problem. o Restructure exec1() a little to use newcred/oldcred arrangement, and use improved uid management primitives. o Clean up exit1() so as to do less work in credential cleanup due to pcred removal. o Clean up fork1() so as to do less work in credential cleanup and allocation. o Clean up ktrcanset() to take into account changes, and move to using suser_xxx() instead of performing a direct uid==0 comparision. o Improve commenting in various kern_prot.c credential modification calls to better document current behavior. In a couple of places, current behavior is a little questionable and we need to check POSIX.1 to make sure it's "right". More commenting work still remains to be done. o Update credential management calls, such as crfree(), to take into account new ruidinfo reference. o Modify or add the following uid and gid helper routines: change_euid() change_egid() change_ruid() change_rgid() change_svuid() change_svgid() In each case, the call now acts on a credential not a process, and as such no longer requires more complicated process locking/etc. They now assume the caller will do any necessary allocation of an exclusive credential reference. Each is commented to document its reference requirements. o CANSIGIO() is simplified to require only credentials, not processes and pcreds. o Remove lots of (p_pcred==NULL) checks. o Add an XXX to authorization code in nfs_lock.c, since it's questionable, and needs to be considered carefully. o Simplify posix4 authorization code to require only credentials, not processes and pcreds. Note that this authorization, as well as CANSIGIO(), needs to be updated to use the p_cansignal() and p_cansched() centralized authorization routines, as they currently do not take into account some desirable restrictions that are handled by the centralized routines, as well as being inconsistent with other similar authorization instances. o Update libkvm to take these changes into account. Obtained from: TrustedBSD Project Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-1/+2
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
OpenPOWER on IntegriCloud