Commit Graph

182 Commits

Author SHA1 Message Date
Julian Elischer
ac2e415327 Change the process flags P_KSES to be P_THREADED.
This is just a cosmetic change but I've been meaning to do it for about a year.
2003-02-27 02:05:19 +00:00
Jeff Roberson
5215b1872f - Split the struct kse into struct upcall and struct kse. struct kse will
soon be visible only to schedulers.  This greatly simplifies much the
   KSE code.

Submitted by:	davidxu
2003-02-17 05:14:26 +00:00
Poul-Henning Kamp
029f0b69a4 Change "dev_t gdbdev" to "void *gdb_arg", some possible paths for GDB
will not have a dev_t.
2003-02-16 19:22:21 +00:00
Julian Elischer
6f8132a867 Reversion of commit by Davidxu plus fixes since applied.
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.
2003-02-01 12:17:09 +00:00
David Xu
0dbb100b9b Move UPCALL related data structure out of kse, introduce a new
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
2003-01-26 11:41:35 +00:00
Jake Burkholder
d43f696c1c Revert previous and move the prototype for db_alt_break to ddb.h.
Requested by:	bde (I think)
2002-12-31 18:30:53 +00:00
Jake Burkholder
edb333eef8 - Add a function db_alt_break which recognizes the character sequence used to
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
2002-12-31 06:51:19 +00:00
Julian Elischer
93a7aa79d6 Add code to ddb to allow backtracing an arbitrary thread.
(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.
2002-12-28 01:23:07 +00:00
Maxime Henrion
4578a2e652 - Rename the DDB specific %z printf format to %y.
- 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
2002-10-25 19:41:32 +00:00
Julian Elischer
1dab89f156 Remove the process state PRS_WAIT.
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.
2002-10-21 22:27:36 +00:00
Julian Elischer
48bfcddd94 Round out the facilty for a 'bound' thread to loan out its KSE
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.
2002-10-09 02:33:36 +00:00
John Baldwin
551cf4e150 Rename the mutex thread and process states to use a more generic 'LOCK'
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.
2002-10-02 20:31:47 +00:00
Poul-Henning Kamp
c2476fafad Indentation indicates missing braces.
Spotted by:	FlexeLint
2002-10-01 21:59:46 +00:00
Poul-Henning Kamp
37c841831f Be consistent about "static" functions: if the function is marked
static in its prototype, mark it static at the definition too.

Inspired by:    FlexeLint warning #512
2002-09-28 17:15:38 +00:00
Mark Murray
bda9921d3f Constify to kill some warnings. 2002-09-21 17:29:36 +00:00
John Baldwin
c79408a059 Implement db_print_backtrace() if DDB is compiled into the kernel. This
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
2002-09-19 18:46:29 +00:00
Bruce Evans
1d47f58a3d Garbage-collected __ELF__ ifdefs.
Fixed some style bugs (mainly unused includes).
2002-09-15 22:28:39 +00:00
Bruce Evans
2ac73c2ce3 Don't use the ELF symbol type to summarily reject symbols in
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.
2002-09-15 22:17:40 +00:00
Bruce Evans
abd368f09a Made this work on i386's at least. It wants ELF section headers for
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.
2002-09-15 21:49:13 +00:00
Bruce Evans
f05c39e9d5 Made this compile (but not work). This involved mainly const poisoning
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.
2002-09-15 20:48:08 +00:00
Julian Elischer
71fad9fdee Completely redo thread states.
Reviewed by:	davidxu@freebsd.org
2002-09-11 08:13:56 +00:00
Bruce Evans
efdfb8fea3 db_ps.c:
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.
2002-08-31 04:25:44 +00:00
Juli Mallett
c96c380580 When talking about c_db_sym_t, mention that it is not just like db_sym_t:
it's const.

Inspired by:	bde
2002-08-14 17:56:47 +00:00
Poul-Henning Kamp
8ede8cbc50 Realign columns in DDB's ps output. Don't waste more horizontal space than
necessary.
2002-08-13 11:06:54 +00:00
Julian Elischer
e602ba25fd Part 1 of KSE-III
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..
2002-06-29 17:26:22 +00:00
Peter Wemm
160554fbf4 Remove a couple of __P() stragglers. 2002-06-29 02:32:34 +00:00
Thomas Moestl
358ad31d9a Don't assume that pointers are 4 bytes or sizeof(int) in size. This fixes
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.
2002-06-25 15:59:24 +00:00
Maxime Henrion
53b3e91200 Split the declaration and the initialization of two variables.
This has the fortunate side effect of stopping GCC from
reporting warnings about unused variables on sparc64.

Reviewed by:	bde
2002-06-23 20:03:03 +00:00
Justin T. Gibbs
7102c89a86 Allow DB_SET() to set all fields in the ddb command structure. This
allows external ddb commands to do anyting an internal command can
do, including non-standard argument parsing if desired.
2002-06-05 19:00:02 +00:00
Bruce Evans
7085e70878 Reconnect db_elf.c to the build (now under "options DDB_NOKLDSYM"). It
doesn't actually build yet.
2002-05-07 10:59:52 +00:00
Bruce Evans
5eb6f4bc21 Restored db_elf.c from the Attic. This will be used for a quick fix for
the longstanding brokenness of symbols in ddb at boot time.  It doesn't
compile and is not attached to the build yet.
2002-05-06 00:05:44 +00:00
John Baldwin
5a882ddd66 Commented out locking that would be used in the ps command if locks were
used in ddb.
2002-04-11 21:01:34 +00:00
Bruce Evans
763df83622 Fixed some style bugs in the removal of __P(()). Continuation lines
were not outdented to preserve non-KNF lining up of code with parentheses.
Switch to KNF formatting.
2002-03-23 11:53:03 +00:00
Alfred Perlstein
14e10f9952 Remove __P. 2002-03-20 05:14:42 +00:00
Doug Rabson
a094749d89 Allow '.' in identifiers - some ia64 register names contain '.'. 2002-03-10 17:08:24 +00:00
Yaroslav Tykhiy
09ffa9ad5e ^U kills an entire input line in most applications,
including the default terminal canonical mode.
So let ddb(4) be no exception from this rule.

Pointed out by: Mark Peek <mark@peek.org>
2002-02-12 23:38:40 +00:00
Yaroslav Tykhiy
732681a789 Teach ddb(4) to delete to the beginning of its command line on ^U.
PR:		kern/28976
Submitted by:	Nickolai Zeldovich <kolya@orbit.zepa.net>
2002-02-11 14:14:42 +00:00
Julian Elischer
079b7badea Pre-KSE/M3 commit.
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,
2002-02-07 20:58:47 +00:00
Matt Jacob
e30e3e9e48 pid is 'long' on alpha. 2002-01-17 02:14:44 +00:00
Dima Dorfman
19d2c78f34 Implement a "kill" DDB command which is an interface to psignal() that
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
2001-11-27 19:56:28 +00:00
Poul-Henning Kamp
9653928c02 GC the a.out support in DDB, nothing anywhere would pull this
file into a build.
2001-11-05 21:55:42 +00:00
Andrew R. Reiter
99b95aa20b - Include machine/md_var.h to get rid of cpu_reset() warning. (-Wall)
Approved by: jhb
2001-11-05 21:50:55 +00:00
Peter Wemm
5370c3b634 Add a 'reset' command. This is useful for panics really early before
any symbols are loaded.  Especially for unattended machines.
2001-11-03 04:55:48 +00:00
John Baldwin
c516499ad4 Make the flag field in the ps output one char wider to account for recent
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.
2001-10-20 03:22:23 +00:00
Doug Rabson
3a0b4f259c Fill out some gaps in ia64 DDB support. This involves generalising DDB's
breakpoint handling slightly to cope with the fact that ia64 instructions
are not located on byte boundaries.
2001-09-15 11:06:07 +00:00
John Baldwin
14b418e7e9 - Whitespace fixes.
- Fix an old bug: p_comm is an array not a pointer, so it can't be NULL.`
2001-09-12 22:32:03 +00:00
Julian Elischer
b40ce4165d KSE Milestone 2
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
2001-09-12 08:38:13 +00:00
David E. O'Brien
680169040b No tokens should follow #endif. 2001-08-15 03:38:49 +00:00
Kris Kennaway
58d9a05948 Quiet a variable format-string warning.
MFC after:	1 week
2001-07-19 02:05:00 +00:00
Brian S. Dean
17bbfb5897 Add 'hwatch' and 'dhwatch' ddb commands analogous to 'watch' and
'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
2001-07-11 03:15:25 +00:00