aboutsummaryrefslogtreecommitdiff
path: root/sys/ddb/db_ps.c
Commit message (Collapse)AuthorAgeFilesLines
* Use FOREACH_PROC_IN_SYSTEM instead of using its unrolled form.Sergey Kandaurov2011-12-181-1/+1
| | | | | | | Reviewed by: kib Notes: svn path=/head/; revision=228687
* Add 'findstack' ddb command to search either the thread kernel stackKonstantin Belousov2011-12-161-0/+37
| | | | | | | | | | or cached stack containing the specified kernel virtual address. Discussed with: pho MFC after: 1 week Notes: svn path=/head/; revision=228569
* Trim some additional unnecessary <linker_set.h> includes.John Baldwin2011-04-281-1/+0
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=221179
* Replace several instances of 'if (!a & b)' with 'if (!(a &b))' in orderEdward Tomasz Napierala2010-01-081-2/+2
| | | | | | | to silence newer GCC versions. Notes: svn path=/head/; revision=201794
* Put square backets ([]) around process names for system processes to patchJohn Baldwin2009-10-011-4/+10
| | | | | | | the behavior of ps(1). Notes: svn path=/head/; revision=197684
* Print out the container lock when showing the thread state in DDB.Attilio Rao2008-06-181-0/+3
| | | | | | | Tested by: benjsc Notes: svn path=/head/; revision=179861
* enable dynamic addition of "show all" commandsSam Leffler2008-03-251-0/+9
| | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=177615
* Print the stack bounds of the thread.Marcel Moolenaar2007-10-161-0/+2
| | | | Notes: svn path=/head/; revision=172705
* - Move all of the PS_ flags into either p_flag or td_flags.Jeff Roberson2007-09-171-1/+1
| | | | | | | | | | | | | | | | | - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or previously the sched_lock. These bugs have existed for some time. - Allow swapout to try each thread in a process individually and then swapin the whole process if any of these fail. This allows us to move most scheduler related swap flags into td_flags. - Keep ki_sflag for backwards compat but change all in source tools to use the new and more correct location of P_INMEM. Reported by: pho Reviewed by: attilio, kib Approved by: re (kensmith) Notes: svn path=/head/; revision=172207
* Threading cleanup.. part 2 of several.Julian Elischer2006-12-061-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Make part of John Birrell's KSE patch permanent.. Specifically, remove: Any reference of the ksegrp structure. This feature was never fully utilised and made things overly complicated. All code in the scheduler that tried to make threaded programs fair to unthreaded programs. Libpthread processes will already do this to some extent and libthr processes already disable it. Also: Since this makes such a big change to the scheduler(s), take the opportunity to rename some structures and elements that had to be moved anyhow. This makes the code a lot more readable. The ULE scheduler compiles again but I have no idea if it works. The 4bsd scheduler still reqires a little cleaning and some functions that now do ALMOST nothing will go away, but I thought I'd do that as a separate commit. Tested by David Xu, and Dan Eischen using libthr and libpthread. Notes: svn path=/head/; revision=164936
* Make KSE a kernel option, turned on by default in all GENERICJohn Birrell2006-10-261-0/+4
| | | | | | | | | | kernel configs except sun4v (which doesn't process signals properly with KSE). Reviewed by: davidxu@ Notes: svn path=/head/; revision=163709
* Fix two nits in the ps header that offset each other making them largelyJohn Baldwin2006-08-011-6/+6
| | | | | | | unnoticable. Notes: svn path=/head/; revision=160893
* Some cosmetic tweaks:John Baldwin2006-08-011-10/+10
| | | | | | | | | | | | | - Right justify 'pid' label. - Move the uid column to the right 2 columns so that the 3 process id columns (pid, ppid, pgrp) are grouped together. - Expand the uid column to 5 chars. - Don't indent the tid for multithreaded processes. Requested by: bde (1, 2, 4) Notes: svn path=/head/; revision=160878
* Simplify the pager support in DDB. Allowing different db commands toJohn Baldwin2006-07-121-9/+5
| | | | | | | | | | | | | | | | | | | install custom pager functions didn't actually happen in practice (they all just used the simple pager and passed in a local quit pointer). So, just hardcode the simple pager as the only pager and make it set a global db_pager_quit flag that db commands can check when the user hits 'q' (or a suitable variant) at the pager prompt. Also, now that it's easy to do so, enable paging by default for all ddb commands. Any command that wishes to honor the quit flag can do so by checking db_pager_quit. Note that the pager can also be effectively disabled by setting $lines to 0. Other fixes: - 'show idt' on i386 and pc98 now actually checks the quit flag and terminates early. - 'show intr' now actually checks the quit flag and terminates early. Notes: svn path=/head/; revision=160312
* Use __LP64__ rather than the PTR64 hack.John Baldwin2006-05-111-14/+3
| | | | | | | Suggested by: ru Notes: svn path=/head/; revision=158456
* Sort includes.John Baldwin2006-04-271-2/+2
| | | | Notes: svn path=/head/; revision=158092
* A whitespace fix.John Baldwin2006-04-271-1/+1
| | | | | | | Submitted by: bde Notes: svn path=/head/; revision=158091
* Drop locking comments. ddb functions should never use locking anyway andJohn Baldwin2006-04-271-6/+0
| | | | | | | | | | no other ddb functions try to annotate what locking would otherwise be appropriate in comments. Prodded by: bde Notes: svn path=/head/; revision=158090
* - Overhaul the 'ps' command in ddb to be mostly readable again. :) It isJohn Baldwin2006-04-251-55/+319
| | | | | | | | | | | | | | | | | | | | | | now back to using fixed-size columns for output and each line of output should fit in 80 columns on both 32-bit and 64-bit architectures. In general the output is close to that of the userland ps(1) with the exception that the 'wmesg' field is mostly similar to the "state" field in top(1) in that it will show either a wmesg, a lock name (prefixed with an *), "CPU xx" (for a running thread), or nothing if none of those three conditions are true. It also respects td_name when listing threads in a multithreaded process. There is a somewhat evilly-defined PTR64 macro I use to make account for the change in the size of the 'wchan' column in the formatted output (wchan is now the only pointer in the ps output and is available so it can be passed to 'show sleepq', 'show turnstile', or 'show lock'). - Add two new commands "show proc [process]" and "show thread [thread]" that show details about the specified process or thread (specified either by pid/tid or pointer), respectively. If an address it not specified, it uses the current kdb thread. Notes: svn path=/head/; revision=158032
* Remove the uarea column from the DDB 'ps' display, and from grog's gdbDavid Schultz2004-11-201-3/+3
| | | | | | | | | scripts. Reviewed by: arch@ Notes: svn path=/head/; revision=137923
* - Change the ddb paging "support" to use a variable (db_lines_per_page) toJohn Baldwin2004-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | control the number of lines per page rather than a constant. The variable can be examined and changed in ddb as '$lines'. Setting the variable to 0 will effectively turn off paging. - Change db_putchar() to force out pending whitespace before outputting newlines and carriage returns so that one can rub out content on the current line via '\r \r' type strings. - Change the simple pager to rub out the --More-- prompt explicitly when the routine exits. - Add some aliases to the simple pager to make it more compatible with more(1): 'e' and 'j' do a single line. 'd' does half a page, and 'f' does a full page. MFC after: 1 month Inspired by: kris Notes: svn path=/head/; revision=137117
* Refactor a bunch of scheduler code to give basically the same behaviourJulian Elischer2004-09-051-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | but with slightly cleaned up interfaces. The KSE structure has become the same as the "per thread scheduler private data" structure. In order to not make the diffs too great one is #defined as the other at this time. The KSE (or td_sched) structure is now allocated per thread and has no allocation code of its own. Concurrency for a KSEGRP is now kept track of via a simple pair of counters rather than using KSE structures as tokens. Since the KSE structure is different in each scheduler, kern_switch.c is now included at the end of each scheduler. Nothing outside the scheduler knows the contents of the KSE (aka td_sched) structure. The fields in the ksegrp structure that are to do with the scheduler's queueing mechanisms are now moved to the kg_sched structure. (per ksegrp scheduler private data structure). In other words how the scheduler queues and keeps track of threads is no-one's business except the scheduler's. This should allow people to write experimental schedulers with completely different internal structuring. A scheduler call sched_set_concurrency(kg, N) has been added that notifies teh scheduler that no more than N threads from that ksegrp should be allowed to be on concurrently scheduled. This is also used to enforce 'fainess' at this time so that a ksegrp with 10000 threads can not swamp a the run queue and force out a process with 1 thread, since the current code will not set the concurrency above NCPU, and both schedulers will not allow more than that many onto the system run queue at a time. Each scheduler should eventualy develop their own methods to do this now that they are effectively separated. Rejig libthr's kernel interface to follow the same code paths as linkse for scope system threads. This has slightly hurt libthr's performance but I will work to recover as much of it as I can. Thread exit code has been cleaned up greatly. exit and exec code now transitions a process back to 'standard non-threaded mode' before taking the next step. Reviewed by: scottl, peter MFC after: 1 week Notes: svn path=/head/; revision=134791
* Mega update for the KDB framework: turn DDB into a KDB backend.Marcel Moolenaar2004-07-101-26/+0
| | | | | | | | | | | | | | | | | | | Most of the changes are a direct result of adding thread awareness. Typically, DDB_REGS is gone. All registers are taken from the trapframe and backtraces use the PCB based contexts. DDB_REGS was defined to be a trapframe on all platforms anyway. Thread awareness introduces the following new commands: thread X switch to thread X (where X is the TID), show threads list all threads. The backtrace code has been made more flexible so that one can create backtraces for any thread by giving the thread ID as an argument to trace. With this change, ia64 has support for breakpoints. Notes: svn path=/head/; revision=131952
* Remove advertising clause from University of California Regent'sWarner Losh2004-04-071-4/+0
| | | | | | | | | | license, per letter dated July 22, 1999 and email from Peter Wemm, Alan Cox and Robert Watson. Approved by: core, peter, alc, rwatson Notes: svn path=/head/; revision=128019
* Switch the sleep/wakeup and condition variable implementations to use theJohn Baldwin2004-02-271-16/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sleep queue interface: - Sleep queues attempt to merge some of the benefits of both sleep queues and condition variables. Having sleep qeueus in a hash table avoids having to allocate a queue head for each wait channel. Thus, struct cv has shrunk down to just a single char * pointer now. However, the hash table does not hold threads directly, but queue heads. This means that once you have located a queue in the hash bucket, you no longer have to walk the rest of the hash chain looking for threads. Instead, you have a list of all the threads sleeping on that wait channel. - Outside of the sleepq code and the sleep/cv code the kernel no longer differentiates between cv's and sleep/wakeup. For example, calls to abortsleep() and cv_abort() are replaced with a call to sleepq_abort(). Thus, the TDF_CVWAITQ flag is removed. Also, calls to unsleep() and cv_waitq_remove() have been replaced with calls to sleepq_remove(). - The sched_sleep() function no longer accepts a priority argument as sleep's no longer inherently bump the priority. Instead, this is soley a propery of msleep() which explicitly calls sched_prio() before blocking. - The TDF_ONSLEEPQ flag has been dropped as it was never used. The associated TDF_SET_ONSLEEPQ and TDF_CLR_ON_SLEEPQ macros have also been dropped and replaced with a single explicit clearing of td_wchan. TD_SET_ONSLEEPQ() would really have only made sense if it had taken the wait channel and message as arguments anyway. Now that that only happens in one place, a macro would be overkill. Notes: svn path=/head/; revision=126326
* Label the uarea address as such in DDB's ps outputPoul-Henning Kamp2003-08-301-1/+1
| | | | Notes: svn path=/head/; revision=119594
* Update the 'ps', 'show pci', and 'show ktr' ddb commands to use the newJohn Baldwin2003-07-311-28/+6
| | | | | | | pager callout instead of homerolling their own paging facility. Notes: svn path=/head/; revision=118269
* Whitespace nit.John Baldwin2003-07-301-0/+1
| | | | Notes: svn path=/head/; revision=118228
* Rename P_THREADED to P_SA. P_SA means a process is using schedulerDavid Xu2003-06-151-3/+3
| | | | | | | activations. Notes: svn path=/head/; revision=116361
* Use __FBSDID().David E. O'Brien2003-06-101-2/+4
| | | | Notes: svn path=/head/; revision=116176
* Attempt to crunch down the thread state info so that it is more likely toJulian Elischer2003-06-061-6/+15
| | | | | | | | | | | | | | | fit on one line. Account for threads better. * No need to report that it is on a sleep queue if it is actually sleeping * "Normal" state is almost ubiquitous.. only report abnormal states. * increment the #lines count for each separate thread shown in threaded programs. makes it less likely that a threaded program will make all the data on a screen overflow off the top of the screen. Notes: svn path=/head/; revision=115911
* Handle the TDS_INACTIVE state by printing '[INACTIVE]' instead ofJohn Baldwin2003-06-061-1/+4
| | | | | | | | panic'ing. Also, for unknown thread states, print out the value rather than panic. Panic'ing in the debugger is pointless at best. Notes: svn path=/head/; revision=115904
* Whitespace nits.John Baldwin2003-06-061-2/+3
| | | | Notes: svn path=/head/; revision=115903
* Move the _oncpu entry from the KSE to the thread.Julian Elischer2003-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. Notes: svn path=/head/; revision=113339
* Change the process flags P_KSES to be P_THREADED.Julian Elischer2003-02-271-3/+3
| | | | | | | This is just a cosmetic change but I've been meaning to do it for about a year. Notes: svn path=/head/; revision=111585
* - Split the struct kse into struct upcall and struct kse. struct kse willJeff Roberson2003-02-171-9/+0
| | | | | | | | | | soon be visible only to schedulers. This greatly simplifies much the KSE code. Submitted by: davidxu Notes: svn path=/head/; revision=111028
* Reversion of commit by Davidxu plus fixes since applied.Julian Elischer2003-02-011-0/+9
| | | | | | | | | | | I'm not convinced there is anything major wrong with the patch but them's the rules.. I am using my "David's mentor" hat to revert this as he's offline for a while. Notes: svn path=/head/; revision=110190
* Move UPCALL related data structure out of kse, introduce a newDavid Xu2003-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 Notes: svn path=/head/; revision=109877
* Add code to ddb to allow backtracing an arbitrary thread.Julian Elischer2002-12-281-52/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | (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. Notes: svn path=/head/; revision=108338
* Remove the process state PRS_WAIT.Julian Elischer2002-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. Notes: svn path=/head/; revision=105663
* Round out the facilty for a 'bound' thread to loan out its KSEJulian Elischer2002-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. Notes: svn path=/head/; revision=104695
* Rename the mutex thread and process states to use a more generic 'LOCK'John Baldwin2002-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. Notes: svn path=/head/; revision=104387
* Completely redo thread states.Julian Elischer2002-09-111-25/+48
| | | | | | | Reviewed by: davidxu@freebsd.org Notes: svn path=/head/; revision=103216
* db_ps.c:Bruce Evans2002-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. Notes: svn path=/head/; revision=102667
* Realign columns in DDB's ps output. Don't waste more horizontal space thanPoul-Henning Kamp2002-08-131-9/+9
| | | | | | | necessary. Notes: svn path=/head/; revision=101784
* Part 1 of KSE-IIIJulian Elischer2002-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.. Notes: svn path=/head/; revision=99072
* Commented out locking that would be used in the ps command if locks wereJohn Baldwin2002-04-111-0/+5
| | | | | | | used in ddb. Notes: svn path=/head/; revision=94456
* Pre-KSE/M3 commit.Julian Elischer2002-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, Notes: svn path=/head/; revision=90361
* Make the flag field in the ps output one char wider to account for recentJohn Baldwin2001-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. Notes: svn path=/head/; revision=85207
* - Whitespace fixes.John Baldwin2001-09-121-16/+9
| | | | | | | - Fix an old bug: p_comm is an array not a pointer, so it can't be NULL.` Notes: svn path=/head/; revision=83383