CVS log for src/sys/kern/kern_thr.c
Up to [FreeBSD] / src / sys / kern
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
Revision 1.98: download - view: text, markup, annotated - select for diffs
Tue Dec 13 00:38:50 2011 UTC (8 weeks, 3 days ago) by eadler
Branches: MAIN
CVS tags: HEAD
Diff to: previous 1.97: preferred, colored
Changes since revision 1.97: +2 -2 lines
SVN rev 228449 on 2011-12-13 00:38:50Z by eadler Document a large number of currently undocumented sysctls. While here fix some style(9) issues and reduce redundancy. PR: kern/155491 PR: kern/155490 PR: kern/155489 Submitted by: Galimov Albert <wtfcrap@mail.ru> Approved by: bde Reviewed by: jhb MFC after: 1 week
Revision 1.97: download - view: text, markup, annotated - select for diffs
Fri Dec 9 17:19:41 2011 UTC (2 months ago) by pho
Branches: MAIN
Diff to: previous 1.96: preferred, colored
Changes since revision 1.96: +2 -2 lines
SVN rev 228360 on 2011-12-09 17:19:41Z by pho Move cpu_set_upcall(newtd, td) up before the first call of thread_free(newtd). This to avoid a possible page fault in cpu_thread_clean() as seen on amd64 with syscall fuzzing. Reviewed by: kib MFC after: 1 week
Revision 1.96: download - view: text, markup, annotated - select for diffs
Sat Dec 3 12:35:13 2011 UTC (2 months, 1 week ago) by pho
Branches: MAIN
Diff to: previous 1.95: preferred, colored
Changes since revision 1.95: +1 -5 lines
SVN rev 228221 on 2011-12-03 12:35:13Z by pho Use umtx_copyin_timeout() to copy and check timeout parameter. In collaboration with: kib MFC after: 1 week
Revision 1.95: download - view: text, markup, annotated - select for diffs
Fri Nov 18 19:14:42 2011 UTC (2 months, 3 weeks ago) by pho
Branches: MAIN
Diff to: previous 1.94: preferred, colored
Changes since revision 1.94: +2 -1 lines
SVN rev 227674 on 2011-11-18 19:14:42Z by pho Added check for negative seconds value. Found by syscall() fuzzing. MFC after: 1 week
Revision 1.94: download - view: text, markup, annotated - select for diffs
Mon Nov 7 15:43:11 2011 UTC (3 months ago) by ed
Branches: MAIN
Diff to: previous 1.93: preferred, colored
Changes since revision 1.93: +2 -1 lines
SVN rev 227309 on 2011-11-07 15:43:11Z by ed Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static.
Revision 1.93: download - view: text, markup, annotated - select for diffs
Fri Sep 16 13:58:51 2011 UTC (4 months, 3 weeks ago) by kmacy
Branches: MAIN
CVS tags: RELENG_9_BP, RELENG_9
Diff to: previous 1.92: preferred, colored
Changes since revision 1.92: +9 -9 lines
SVN rev 225617 on 2011-09-16 13:58:51Z by kmacy In order to maximize the re-usability of kernel code in user space this patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz)
Revision 1.92: download - view: text, markup, annotated - select for diffs
Wed Jul 6 20:06:44 2011 UTC (7 months ago) by trasz
Branches: MAIN
Diff to: previous 1.91: preferred, colored
Changes since revision 1.91: +4 -0 lines
SVN rev 223825 on 2011-07-06 20:06:44Z by trasz All the racct_*() calls need to happen with the proc locked. Fixing this won't happen before 9.0. This commit adds "#ifdef RACCT" around all the "PROC_LOCK(p); racct_whatever(p, ...); PROC_UNLOCK(p)" instances, in order to avoid useless locking/unlocking in kernels built without "options RACCT".
Revision 1.91: download - view: text, markup, annotated - select for diffs
Thu Mar 31 19:22:11 2011 UTC (10 months, 1 week ago) by trasz
Branches: MAIN
Diff to: previous 1.90: preferred, colored
Changes since revision 1.90: +24 -5 lines
SVN rev 220222 on 2011-03-31 19:22:11Z by trasz Enable accounting for RACCT_NPROC and RACCT_NTHR. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version)
Revision 1.90: download - view: text, markup, annotated - select for diffs
Wed Feb 23 13:50:24 2011 UTC (11 months, 2 weeks ago) by kib
Branches: MAIN
Diff to: previous 1.89: preferred, colored
Changes since revision 1.89: +11 -3 lines
SVN rev 218972 on 2011-02-23 13:50:24Z by kib Move the max_threads_per_proc and max_threads_hits variables to the file where they are used. Declare the kern.threads sysctl node at the same location. Since no external use for the variables exists, make them static. Discussed with: dchagin MFC after: 1 week
Revision 1.89: download - view: text, markup, annotated - select for diffs
Wed Feb 23 13:25:42 2011 UTC (11 months, 2 weeks ago) by jhb
Branches: MAIN
Diff to: previous 1.88: preferred, colored
Changes since revision 1.88: +1 -1 lines
SVN rev 218971 on 2011-02-23 13:25:42Z by jhb Revert previous change, the existing check was correct. Pointy hat to: jhb
Revision 1.88: download - view: text, markup, annotated - select for diffs
Wed Feb 23 12:56:25 2011 UTC (11 months, 2 weeks ago) by jhb
Branches: MAIN
Diff to: previous 1.87: preferred, colored
Changes since revision 1.87: +1 -1 lines
SVN rev 218967 on 2011-02-23 12:56:25Z by jhb Fix off-by-one error in check against max_threads_per_proc. Submitted by: arundel MFC after: 1 week
Revision 1.87: download - view: text, markup, annotated - select for diffs
Sat Oct 23 13:16:39 2010 UTC (15 months, 2 weeks ago) by davidxu
Branches: MAIN
Diff to: previous 1.86: preferred, colored
Changes since revision 1.86: +7 -6 lines
SVN rev 214238 on 2010-10-23 13:16:39Z by davidxu In thr_exit() and kthread_exit(), only remove thread from hash if it can directly exit, otherwise let exit1() do it. The change should be in r213950, but for unknown reason, it was lost.
Revision 1.86: download - view: text, markup, annotated - select for diffs
Wed Oct 20 00:41:38 2010 UTC (15 months, 3 weeks ago) by davidxu
Branches: MAIN
Diff to: previous 1.85: preferred, colored
Changes since revision 1.85: +11 -12 lines
SVN rev 214091 on 2010-10-20 00:41:38Z by davidxu - Don't include sx.h, it is not needed. - Check NULL pointer, move timeout calculation code outside of process lock.
Revision 1.85: download - view: text, markup, annotated - select for diffs
Sat Oct 9 02:50:23 2010 UTC (16 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.84: preferred, colored
Changes since revision 1.84: +61 -66 lines
SVN rev 213642 on 2010-10-09 02:50:23Z by davidxu Create a global thread hash table to speed up thread lookup, use rwlock to protect the table. In old code, thread lookup is done with process lock held, to find a thread, kernel has to iterate through process and thread list, this is quite inefficient. With this change, test shows in extreme case performance is dramatically improved. Earlier patch was reviewed by: jhb, julian
Revision 1.84: download - view: text, markup, annotated - select for diffs
Tue Aug 24 07:29:55 2010 UTC (17 months, 2 weeks ago) by davidxu
Branches: MAIN
Diff to: previous 1.83: preferred, colored
Changes since revision 1.83: +14 -9 lines
SVN rev 211733 on 2010-08-24 07:29:55Z by davidxu Optimize thr_suspend, if timeout is zero, don't call msleep, just return immediately.
Revision 1.83: download - view: text, markup, annotated - select for diffs
Tue Aug 24 07:22:24 2010 UTC (17 months, 2 weeks ago) by davidxu
Branches: MAIN
Diff to: previous 1.82: preferred, colored
Changes since revision 1.82: +2 -2 lines
SVN rev 211732 on 2010-08-24 07:22:24Z by davidxu - According to specification, SI_USER code should only be generated by standard kill(). On other systems, SI_LWP is generated by lwp_kill(). This will allow conforming applications to differentiate between signals generated by standard events and those generated by other implementation events in a manner compatible with existing practice. - Bump __FreeBSD_version
Revision 1.82: download - view: text, markup, annotated - select for diffs
Tue Jun 29 20:41:52 2010 UTC (19 months, 1 week ago) by jhb
Branches: MAIN
Diff to: previous 1.81: preferred, colored
Changes since revision 1.81: +4 -5 lines
SVN rev 209592 on 2010-06-29 20:41:52Z by jhb Tweak the in-kernel API for sending signals to threads: - Rename tdsignal() to tdsendsignal() and make it private to kern_sig.c. - Add tdsignal() and tdksignal() routines that mirror psignal() and pksignal() except that they accept a thread as an argument instead of a process. They send a signal to a specific thread rather than to an individual process. Reviewed by: kib
Revision 1.81: download - view: text, markup, annotated - select for diffs
Thu Mar 11 14:49:06 2010 UTC (23 months ago) by nwhitehorn
Branches: MAIN
Diff to: previous 1.80: preferred, colored
Changes since revision 1.80: +1 -1 lines
SVN rev 205014 on 2010-03-11 14:49:06Z by nwhitehorn Provide groundwork for 32-bit binary compatibility on non-x86 platforms, for upcoming 64-bit PowerPC and MIPS support. This renames the COMPAT_IA32 option to COMPAT_FREEBSD32, removes some IA32-specific code from MI parts of the kernel and enhances the freebsd32 compatibility code to support big-endian platforms. Reviewed by: kib, jhb
Revision 1.80: download - view: text, markup, annotated - select for diffs
Mon Mar 1 14:27:16 2010 UTC (23 months, 1 week ago) by bruno
Branches: MAIN
Diff to: previous 1.79: preferred, colored
Changes since revision 1.79: +17 -4 lines
SVN rev 204519 on 2010-03-01 14:27:16Z by bruno Deliver siginfo when signal is generated by thr_kill(2) (SI_USER with properly filled si_uid and si_pid). Reported by: Joel Bertrand <joel.bertrand systella fr> PR: 141956 Reviewed by: kib MFC after: 2 weeks
Revision 1.79: download - view: text, markup, annotated - select for diffs
Sun Oct 11 16:49:30 2009 UTC (2 years, 3 months ago) by kib
Branches: MAIN
Diff to: previous 1.78: preferred, colored
Changes since revision 1.78: +1 -1 lines
SVN rev 197963 on 2009-10-11 16:49:30Z by kib Currently, when signal is delivered to the process and there is a thread not blocking the signal, signal is placed on the thread sigqueue. If the selected thread is in kernel executing thr_exit() or sigprocmask() syscalls, then signal might be not delivered to usermode for arbitrary amount of time, and for exiting thread it is lost. Put process-directed signals to the process queue unconditionally, selecting the thread to deliver the signal only by the thread returning to usermode, since only then the thread can handle delivery of signal reliably. For exiting thread or thread that has blocked some signals, check whether the newly blocked signal is queued for the process, and try to find a thread to wakeup for delivery, in reschedule_signal(). For exiting thread, assume that all signals are blocked. Change cursig() and postsig() to look both into the thread and process signal queues. When there is a signal that thread returning to usermode could consume, TDF_NEEDSIGCHK flag is not neccessary set now. Do unlocked read of p_siglist and p_pendingcnt to check for queued signals. Note that thread that has a signal unblocked might get spurious wakeup and EINTR from the interruptible system call now, due to the possibility of being selected by reschedule_signals(), while other thread returned to usermode earlier and removed the signal from process queue. This should not cause compliance issues, since the thread has not blocked a signal and thus should be ready to receive it anyway. Reported by: Justin Teller <justin.teller gmail com> Reviewed by: davidxu, jilles MFC after: 1 month
Revision 1.78: download - view: text, markup, annotated - select for diffs
Tue Sep 1 11:41:51 2009 UTC (2 years, 5 months ago) by kib
Branches: MAIN
Diff to: previous 1.77: preferred, colored
Changes since revision 1.77: +1 -1 lines
SVN rev 196730 on 2009-09-01 11:41:51Z by kib Reintroduce the r196640, after fixing the problem with my testing. Remove the altkstacks, instead instantiate threads with kernel stack allocated with the right size from the start. For the thread that has kernel stack cached, verify that requested stack size is equial to the actual, and reallocate the stack if sizes differ [1]. This fixes the bug introduced by r173361 that was committed several days after r173004 and consisted of kthread_add(9) ignoring the non-default kernel stack size. Also, r173361 removed the caching of the kernel stacks for a non-first thread in the process. Introduce separate kernel stack cache that keeps some limited amount of preallocated kernel stacks to lower the latency of thread allocation. Add vm_lowmem handler to prune the cache on low memory condition. This way, system with reasonable amount of the threads get lower latency of thread creation, while still not exhausting significant portion of KVA for unused kstacks. Submitted by: peter [1] Discussed with: jhb, julian, peter Reviewed by: jhb Tested by: pho (and retested according to new test scenarious) MFC after: 1 week
Revision 1.77: download - view: text, markup, annotated - select for diffs
Sat Aug 29 21:53:08 2009 UTC (2 years, 5 months ago) by kib
Branches: MAIN
Diff to: previous 1.76: preferred, colored
Changes since revision 1.76: +1 -1 lines
SVN rev 196648 on 2009-08-29 21:53:08Z by kib Reverse r196640 and r196644 for now.
Revision 1.76: download - view: text, markup, annotated - select for diffs
Sat Aug 29 13:28:02 2009 UTC (2 years, 5 months ago) by kib
Branches: MAIN
Diff to: previous 1.75: preferred, colored
Changes since revision 1.75: +1 -1 lines
SVN rev 196640 on 2009-08-29 13:28:02Z by kib Remove the altkstacks, instead instantiate threads with kernel stack allocated with the right size from the start. For the thread that has kernel stack cached, verify that requested stack size is equial to the actual, and reallocate the stack if sizes differ [1]. This fixes the bug introduced by r173361 that was committed several days after r173004 and consisted of kthread_add(9) ignoring the non-default kernel stack size. Also, r173361 removed the caching of the kernel stacks for a non-first thread in the process. Introduce separate kernel stack cache that keeps some limited amount of preallocated kernel stacks to lower the latency of thread allocation. Add vm_lowmem handler to prune the cache on low memory condition. This way, system with reasonable amount of the threads get lower latency of thread creation, while still not exhausting significant portion of KVA for unused kstacks. Submitted by: peter [1] Discussed with: jhb, julian, peter Reviewed by: jhb Tested by: pho MFC after: 1 week
Revision 1.75: download - view: text, markup, annotated - select for diffs
Sat Jun 27 13:58:44 2009 UTC (2 years, 7 months ago) by rwatson
Branches: MAIN
CVS tags: RELENG_8_BP, RELENG_8
Diff to: previous 1.74: preferred, colored
Changes since revision 1.74: +2 -2 lines
SVN rev 195104 on 2009-06-27 13:58:44Z by rwatson Replace AUDIT_ARG() with variable argument macros with a set more more specific macros for each audit argument type. This makes it easier to follow call-graphs, especially for automated analysis tools (such as fxr). In MFC, we should leave the existing AUDIT_ARG() macros as they may be used by third-party kernel modules. Suggested by: brooks Approved by: re (kib) Obtained from: TrustedBSD Project MFC after: 1 week
Revision 1.74: download - view: text, markup, annotated - select for diffs
Thu Feb 26 15:51:54 2009 UTC (2 years, 11 months ago) by ed
Branches: MAIN
Diff to: previous 1.73: preferred, colored
Changes since revision 1.73: +1 -3 lines
SVN rev 189074 on 2009-02-26 15:51:54Z by ed Remove even more unneeded variable assignments. kern_time.c: - Unused variable `p'. kern_thr.c: - Variable `error' is always caught immediately, so no reason to initialize it. There is no way that error != 0 at the end of create_thread(). kern_sig.c: - Unused variable `code'. kern_synch.c: - `rval' is always assigned in all different cases. kern_rwlock.c: - `v' is always overwritten with RW_UNLOCKED further on. kern_malloc.c: - `size' is always initialized with the proper value before being used. kern_exit.c: - `error' is always caught and returned immediately. abort2() never returns a non-zero value. kern_exec.c: - `len' is always assigned inside the if-statement right below it. tty_info.c: - `td' is always overwritten by FOREACH_THREAD_IN_PROC(). Found by: LLVM's scan-build
Revision 1.73: download - view: text, markup, annotated - select for diffs
Sat Nov 22 12:36:15 2008 UTC (3 years, 2 months ago) by kib
Branches: MAIN
Diff to: previous 1.72: preferred, colored
Changes since revision 1.72: +1 -3 lines
SVN rev 185169 on 2008-11-22 12:36:15Z by kib Add sv_flags field to struct sysentvec with intention to provide description of the ABI of the currently executing image. Change some places to test the flags instead of explicit comparing with address of known sysentvec structures to determine ABI features. Discussed with: dchagin, imp, jhb, peter
Revision 1.72: download - view: text, markup, annotated - select for diffs
Wed Nov 5 03:01:23 2008 UTC (3 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.71: preferred, colored
Changes since revision 1.71: +2 -1 lines
SVN rev 184667 on 2008-11-05 03:01:23Z by davidxu Revert rev 184216 and 184199, due to the way the thread_lock works, it may cause a lockup. Noticed by: peter, jhb
Revision 1.71: download - view: text, markup, annotated - select for diffs
Wed Oct 29 12:11:48 2008 UTC (3 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.70: preferred, colored
Changes since revision 1.70: +4 -1 lines
SVN rev 184438 on 2008-10-29 12:11:48Z by davidxu If threads limit is exceeded, increase the totoal number of failures.
Revision 1.70: download - view: text, markup, annotated - select for diffs
Thu Oct 23 07:55:38 2008 UTC (3 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.69: preferred, colored
Changes since revision 1.69: +1 -2 lines
SVN rev 184199 on 2008-10-23 07:55:38Z by davidxu Actually, for signal and thread suspension, extra process spin lock is unnecessary, the normal process lock and thread lock are enough. The spin lock is still needed for process and thread exiting to mimic single sched_lock.
Revision 1.69: download - view: text, markup, annotated - select for diffs
Mon Oct 13 21:04:52 2008 UTC (3 years, 3 months ago) by rdivacky
Branches: MAIN
Diff to: previous 1.68: preferred, colored
Changes since revision 1.68: +2 -0 lines
SVN rev 183846 on 2008-10-13 21:04:52Z by rdivacky Check the result of copyin and in a case of error return one. This prevents setting wrong priority or (more likely) returning EINVAL. Approved by: kib (mentor)
Revision 1.68: download - view: text, markup, annotated - select for diffs
Tue Apr 29 05:48:05 2008 UTC (3 years, 9 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.67: preferred, colored
Changes since revision 1.67: +1 -1 lines
Fix compiling problem.
Revision 1.67: download - view: text, markup, annotated - select for diffs
Sun Mar 23 02:03:06 2008 UTC (3 years, 10 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.66: preferred, colored
Changes since revision 1.66: +1 -2 lines
Remove commented out code, thread suspension is done in thread library.
Revision 1.66: download - view: text, markup, annotated - select for diffs
Fri Mar 21 08:23:25 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.65: preferred, colored
Changes since revision 1.65: +2 -0 lines
- Add a new td flag TDF_NEEDSUSPCHK that is set whenever a thread needs to enter thread_suspend_check(). - Set TDF_ASTPENDING along with TDF_NEEDSUSPCHK so we can move the thread_suspend_check() to ast() rather than userret(). - Check TDF_NEEDSUSPCHK in the sleepq_catch_signals() optimization so that we don't miss a suspend request. If this is set use the expensive signal path. - Set NEEDSUSPCHK when creating a new thread in thr in case the creating thread is due to be suspended as well but has not yet. Reviewed by: davidxu (Authored original patch)
Revision 1.65: download - view: text, markup, annotated - select for diffs
Wed Mar 19 06:19:00 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.64: preferred, colored
Changes since revision 1.64: +0 -2 lines
- Relax requirements for p_numthreads, p_threads, p_swtick, and p_nice from requiring the per-process spinlock to only requiring the process lock. - Reflect these changes in the proc.h documentation and consumers throughout the kernel. This is a substantial reduction in locking cost for these fields and was made possible by recent changes to threading support.
Revision 1.64: download - view: text, markup, annotated - select for diffs
Thu Nov 15 06:35:26 2007 UTC (4 years, 2 months ago) by julian
Branches: MAIN
Diff to: previous 1.63: preferred, colored
Changes since revision 1.63: +1 -0 lines
This time REALLY copy the name from the proc to the thread as a default.
Revision 1.63: download - view: text, markup, annotated - select for diffs
Mon Nov 5 11:36:14 2007 UTC (4 years, 3 months ago) by kib
Branches: MAIN
Diff to: previous 1.62: preferred, colored
Changes since revision 1.62: +2 -0 lines
Fix for the panic("vm_thread_new: kstack allocation failed") and
silent NULL pointer dereference in the i386 and sparc64 pmap_pinit()
when the kmem_alloc_nofault() failed to allocate address space. Both
functions now return error instead of panicing or dereferencing NULL.
As consequence, vmspace_exec() and vmspace_unshare() returns the errno
int. struct vmspace arg was added to vm_forkproc() to avoid dealing
with failed allocation when most of the fork1() job is already done.
The kernel stack for the thread is now set up in the thread_alloc(),
that itself may return NULL. Also, allocation of the first process
thread is performed in the fork1() to properly deal with stack
allocation failure. proc_linkup() is separated into proc_linkup()
called from fork1(), and proc_linkup0(), that is used to set up the
kernel process (was known as swapper).
In collaboration with: Peter Holm
Reviewed by: jhb
Revision 1.62: download - view: text, markup, annotated - select for diffs
Thu Aug 16 05:26:41 2007 UTC (4 years, 5 months ago) by davidxu
Branches: MAIN
CVS tags: RELENG_7_BP, RELENG_7_0_BP, RELENG_7_0, RELENG_7
Diff to: previous 1.61: preferred, colored
Changes since revision 1.61: +55 -0 lines
Add thr_kill2 syscall which sends a signal to a thread in another process. Submitted by: Tijl Coosemans tijl at ulyssis dot org Approved by: re (kensmith)
Revision 1.61: download - view: text, markup, annotated - select for diffs
Thu Jun 7 19:45:19 2007 UTC (4 years, 8 months ago) by jhb
Branches: MAIN
Diff to: previous 1.60: preferred, colored
Changes since revision 1.60: +1 -2 lines
- Remove unused variable from create_thread(). - Move kern_thr_*() prototype to <sys/syscallsubr.h> where all the other kern_*() prototypes live.
Revision 1.60: download - view: text, markup, annotated - select for diffs
Tue Jun 5 00:00:54 2007 UTC (4 years, 8 months ago) by jeff
Branches: MAIN
Diff to: previous 1.59: preferred, colored
Changes since revision 1.59: +13 -10 lines
Commit 14/14 of sched_lock decomposition. - Use thread_lock() rather than sched_lock for per-thread scheduling sychronization. - Use the per-process spinlock rather than the sched_lock for per-process scheduling synchronization. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
Revision 1.59: download - view: text, markup, annotated - select for diffs
Tue Jan 23 08:46:50 2007 UTC (5 years ago) by jeff
Branches: MAIN
Diff to: previous 1.58: preferred, colored
Changes since revision 1.58: +1 -1 lines
- Remove setrunqueue and replace it with direct calls to sched_add().
setrunqueue() was mostly empty. The few asserts and thread state
setting were moved to the individual schedulers. sched_add() was
chosen to displace it for naming consistency reasons.
- Remove adjustrunqueue, it was 4 lines of code that was ifdef'd to be
different on all three schedulers where it was only called in one place
each.
- Remove the long ifdef'd out remrunqueue code.
- Remove the now redundant ts_state. Inspect the thread state directly.
- Don't set TSF_* flags from kern_switch.c, we were only doing this to
support a feature in one scheduler.
- Change sched_choose() to return a thread rather than a td_sched. Also,
rely on the schedulers to return the idlethread. This simplifies the
logic in choosethread(). Aside from the run queue links kern_switch.c
mostly does not care about the contents of td_sched.
Discussed with: julian
- Move the idle thread loop into the per scheduler area. ULE wants to
do something different from the other schedulers.
Suggested by: jhb
Tested on: x86/amd64 sched_{4BSD, ULE, CORE}.
Revision 1.58: download - view: text, markup, annotated - select for diffs
Wed Dec 6 06:34:55 2006 UTC (5 years, 2 months ago) by julian
Branches: MAIN
Diff to: previous 1.57: preferred, colored
Changes since revision 1.57: +1 -35 lines
Threading cleanup.. part 2 of several. 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.
Revision 1.57: download - view: text, markup, annotated - select for diffs
Mon Dec 4 14:15:12 2006 UTC (5 years, 2 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.56: preferred, colored
Changes since revision 1.56: +11 -0 lines
if a thread blocked on userland condition variable is pthread_cancel()ed, it is expected that the thread will not consume a pthread_cond_signal(), therefor, we use thr_wake() to mark a flag, the flag tells a thread calling do_cv_wait() in umtx code to not block on a condition variable. Thread library is expected that once a thread detected itself is in pthread_cond_wait, it will call the thr_wake() for itself in its SIGCANCEL handler.
Revision 1.56: download - view: text, markup, annotated - select for diffs
Sat Nov 11 16:46:31 2006 UTC (5 years, 3 months ago) by trhodes
Branches: MAIN
Diff to: previous 1.55: preferred, colored
Changes since revision 1.55: +1 -2 lines
Update includes for sys/posix4 move. Approved by: silence on -arch and -standards
Revision 1.55: download - view: text, markup, annotated - select for diffs
Mon Nov 6 13:42:01 2006 UTC (5 years, 3 months ago) by rwatson
Branches: MAIN
Diff to: previous 1.54: preferred, colored
Changes since revision 1.54: +2 -1 lines
Sweep kernel replacing suser(9) calls with priv(9) calls, assigning specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
Revision 1.54: download - view: text, markup, annotated - select for diffs
Thu Oct 26 21:42:20 2006 UTC (5 years, 3 months ago) by jb
Branches: MAIN
Diff to: previous 1.53: preferred, colored
Changes since revision 1.53: +24 -0 lines
Make KSE a kernel option, turned on by default in all GENERIC kernel configs except sun4v (which doesn't process signals properly with KSE). Reviewed by: davidxu@
Revision 1.53: download - view: text, markup, annotated - select for diffs
Fri Sep 22 15:04:28 2006 UTC (5 years, 4 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.52: preferred, colored
Changes since revision 1.52: +64 -25 lines
Add compatible code to let 32bit libthr work on 64bit kernel.
Revision 1.52: download - view: text, markup, annotated - select for diffs
Thu Sep 21 04:18:46 2006 UTC (5 years, 4 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.51: preferred, colored
Changes since revision 1.51: +21 -198 lines
Replace system call thr_getscheduler, thr_setscheduler, thr_setschedparam with rtprio_thread, while rtprio system call is for process only, the new system call rtprio_thread is responsible for LWP.
Revision 1.51: download - view: text, markup, annotated - select for diffs
Fri Aug 25 10:05:30 2006 UTC (5 years, 5 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.50: preferred, colored
Changes since revision 1.50: +2 -2 lines
Same as previous change, the user provided priority should be reversed too.
Revision 1.50: download - view: text, markup, annotated - select for diffs
Wed Aug 23 07:22:25 2006 UTC (5 years, 5 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.49: preferred, colored
Changes since revision 1.49: +39 -39 lines
POSIX requires that higher numerical values for the priority represent higher priorities, so we should reverse the passed value here.
Revision 1.49: download - view: text, markup, annotated - select for diffs
Thu Jul 13 06:26:43 2006 UTC (5 years, 6 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.48: preferred, colored
Changes since revision 1.48: +158 -2 lines
Add syscalls thr_setscheduler, thr_getscheduler, and thr_setschedparam, these syscalls are designed to set thread's scheduling parameters and policy, because each syscall contains a size parameter, it is possible to support future scheduling option, e.g SCHED_SPORADIC, this option needs other fields in structure sched_param, current they are not avaiblable.
Revision 1.48: download - view: text, markup, annotated - select for diffs
Wed Jul 12 07:02:28 2006 UTC (5 years, 7 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.47: preferred, colored
Changes since revision 1.47: +1 -2 lines
Use newkg to check if SCHED_OTHER is already inherited.
Revision 1.47: download - view: text, markup, annotated - select for diffs
Tue Jul 11 08:19:57 2006 UTC (5 years, 7 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.46: preferred, colored
Changes since revision 1.46: +9 -7 lines
Don't forget to check invalid policy!
Revision 1.46: download - view: text, markup, annotated - select for diffs
Tue Jul 11 06:01:14 2006 UTC (5 years, 7 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.45: preferred, colored
Changes since revision 1.45: +10 -6 lines
For SCHED_OTHER, we always inherit current thread's interactive priority unless current thread is realtime thread, in such case, we set a new zero priority for it, notice we don't have per-thread nice, the priority passed by userland is ignored here.
Revision 1.45: download - view: text, markup, annotated - select for diffs
Tue Jul 11 05:34:35 2006 UTC (5 years, 7 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.44: preferred, colored
Changes since revision 1.44: +57 -4 lines
Add POSIX scheduler parameters support to thr_new syscall, this permits privileged process to create realtime thread.
Revision 1.44: download - view: text, markup, annotated - select for diffs
Mon Jul 10 23:14:07 2006 UTC (5 years, 7 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.43: preferred, colored
Changes since revision 1.43: +11 -75 lines
Create thread in separated ksegrp, so they always get correct user level priority.
Revision 1.43: download - view: text, markup, annotated - select for diffs
Mon Apr 17 18:20:37 2006 UTC (5 years, 9 months ago) by jhb
Branches: MAIN
Diff to: previous 1.42: preferred, colored
Changes since revision 1.42: +2 -2 lines
Change msleep() and tsleep() to not alter the calling thread's priority if the specified priority is zero. This avoids a race where the calling thread could read a snapshot of it's current priority, then a different thread could change the first thread's priority, then the original thread would call sched_prio() inside msleep() undoing the change made by the second thread. I used a priority of zero as no thread that calls msleep() or tsleep() should be specifying a priority of zero anyway. The various places that passed 'curthread->td_priority' or some variant as the priority now pass 0.
Revision 1.42: download - view: text, markup, annotated - select for diffs
Fri Feb 10 03:34:29 2006 UTC (6 years ago) by davidxu
Branches: MAIN
Diff to: previous 1.41: preferred, colored
Changes since revision 1.41: +1 -0 lines
Call thread_stopped in thr_exit to notify parent that the child process is now fully stopped, this was already in kse_exit().
Revision 1.41: download - view: text, markup, annotated - select for diffs
Sun Feb 5 02:18:46 2006 UTC (6 years ago) by davidxu
Branches: MAIN
Diff to: previous 1.40: preferred, colored
Changes since revision 1.40: +29 -0 lines
Implement thr_set_name to set a name for thread. Reviewed by: julian
Revision 1.40: download - view: text, markup, annotated - select for diffs
Sat Jan 7 03:15:21 2006 UTC (6 years, 1 month ago) by davidxu
Branches: MAIN
Diff to: previous 1.39: preferred, colored
Changes since revision 1.39: +27 -12 lines
Add a new feature to thr_kill, if thread ID argument is -1, send signals to all threads except current sender.
Revision 1.39: download - view: text, markup, annotated - select for diffs
Thu Nov 3 04:49:16 2005 UTC (6 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.38: preferred, colored
Changes since revision 1.38: +1 -1 lines
Cleanup some signal interfaces. Now the tdsignal function accepts both proc pointer and thread pointer, if thread pointer is NULL, tdsignal automatically finds a thread, otherwise it sends signal to given thread. Add utility function psignal_event to send a realtime sigevent to a process according to the delivery requirement specified in struct sigevent.
Revision 1.38: download - view: text, markup, annotated - select for diffs
Thu Nov 3 01:38:49 2005 UTC (6 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.37: preferred, colored
Changes since revision 1.37: +1 -1 lines
Oops, don't change tdsignal call.
Revision 1.37: download - view: text, markup, annotated - select for diffs
Thu Nov 3 01:34:08 2005 UTC (6 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.36: preferred, colored
Changes since revision 1.36: +8 -12 lines
Add thread_find() function to search a thread by lwpid.
Revision 1.36: download - view: text, markup, annotated - select for diffs
Wed Oct 26 06:55:46 2005 UTC (6 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.35: preferred, colored
Changes since revision 1.35: +5 -1 lines
do umtx_wake at userland thread exit address, so that others userland threads can wait for a thread to exit, and safely assume that the thread has left userland and is no longer using its userland stack, this is necessary for pthread_join when a thread is waiting for another thread to exit which has user customized stack, after pthread_join returns, the userland stack can be reused for other purposes, without this change, the joiner thread has to spin at the address to ensure the thread is really exited.
Revision 1.35: download - view: text, markup, annotated - select for diffs
Fri Oct 14 12:43:46 2005 UTC (6 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.34: preferred, colored
Changes since revision 1.34: +2 -1 lines
1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, most changes in MD code are trivial, before this change, trapsignal and sendsig use discrete parameters, now they uses member fields of ksiginfo_t structure. For sendsig, this change allows us to pass POSIX realtime signal value to user code. 2. Remove cpu_thread_siginfo, it is no longer needed because we now always generate ksiginfo_t data and feed it to libpthread. 3. Add p_sigqueue to proc structure to hold shared signals which were blocked by all threads in the proc. 4. Add td_sigqueue to thread structure to hold all signals delivered to thread. 5. i386 and amd64 now return POSIX standard si_code, other arches will be fixed. 6. In this sigqueue implementation, pending signal set is kept as before, an extra siginfo list holds additional siginfo_t data for signals. kernel code uses psignal() still behavior as before, it won't be failed even under memory pressure, only exception is when deleting a signal, we should call sigqueue_delete to remove signal from sigqueue but not SIGDELSET. Current there is no kernel code will deliver a signal with additional data, so kernel should be as stable as before, a ksiginfo can carry more information, for example, allow signal to be delivered but throw away siginfo data if memory is not enough. SIGKILL and SIGSTOP have fast path in sigqueue_add, because they can not be caught or masked. The sigqueue() syscall allows user code to queue a signal to target process, if resource is unavailable, EAGAIN will be returned as specification said. Just before thread exits, signal queue memory will be freed by sigqueue_flush. Current, all signals are allowed to be queued, not only realtime signals. Earlier patch reviewed by: jhb, deischen Tested on: i386, amd64
Revision 1.34: download - view: text, markup, annotated - select for diffs
Sun Jul 10 23:31:10 2005 UTC (6 years, 7 months ago) by davidxu
Branches: MAIN
CVS tags: RELENG_6_BP, RELENG_6_0_BP, RELENG_6_0_0_RELEASE, RELENG_6_0, RELENG_6
Diff to: previous 1.33: preferred, colored
Changes since revision 1.33: +6 -1 lines
Validate if the value written into {FS,GS}.base is a canonical
address, writting non-canonical address can cause kernel a panic,
by restricting base values to 0..VM_MAXUSER_ADDRESS, ensuring
only canonical values get written to the registers.
Reviewed by: peter, Josepha Koshy < joseph.koshy at gmail dot com >
Approved by: re (scottl)
Revision 1.33: download - view: text, markup, annotated - select for diffs
Sat Apr 23 02:36:07 2005 UTC (6 years, 9 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.32: preferred, colored
Changes since revision 1.32: +136 -53 lines
Add new syscall thr_new to create thread in atomic, it will inherit signal mask from parent thread, setup TLS and stack, and user entry address. Also support POSIX thread's PTHREAD_SCOPE_PROCESS and PTHREAD_SCOPE_SYSTEM, sysctl is also provided to control the scheduler scope.
Revision 1.23.2.8: download - view: text, markup, annotated - select for diffs
Sat Feb 5 01:04:45 2005 UTC (7 years ago) by das
Branches: RELENG_5
CVS tags: RELENG_5_5_BP, RELENG_5_5_0_RELEASE, RELENG_5_5, RELENG_5_4_BP, RELENG_5_4_0_RELEASE, RELENG_5_4
Diff to: previous 1.23.2.7: preferred, colored; branchpoint 1.23: preferred, colored; next MAIN 1.24: preferred, colored
Changes since revision 1.23.2.7: +4 -10 lines
MFC: 2004-11-20 23:00:59 UTC Remove local definitions of RANGEOF() and use __rangeof() instead. Also remove a few bogus casts.
Revision 1.23.2.7: download - view: text, markup, annotated - select for diffs
Mon Jan 31 23:26:16 2005 UTC (7 years ago) by imp
Branches: RELENG_5
Diff to: previous 1.23.2.6: preferred, colored; branchpoint 1.23: preferred, colored
Changes since revision 1.23.2.6: +1 -1 lines
MFC: /*- and related license changes
Revision 1.32: download - view: text, markup, annotated - select for diffs
Thu Jan 6 23:35:39 2005 UTC (7 years, 1 month ago) by imp
Branches: MAIN
Diff to: previous 1.31: preferred, colored
Changes since revision 1.31: +1 -1 lines
/* -> /*- for copyright notices, minor format tweaks as necessary
Revision 1.31: download - view: text, markup, annotated - select for diffs
Wed Dec 1 13:50:04 2004 UTC (7 years, 2 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.30: preferred, colored
Changes since revision 1.30: +15 -5 lines
If a thread is resumed by thr_wake, it should return 0, especially it should not return ERESTART after it caught a signal, otherwise thr_wake() call will be lost, also a timeout wait should not be restarted. Final, using wakeup not wakeup_one to be safeness.
Revision 1.30: download - view: text, markup, annotated - select for diffs
Sat Nov 20 23:00:59 2004 UTC (7 years, 2 months ago) by das
Branches: MAIN
Diff to: previous 1.29: preferred, colored
Changes since revision 1.29: +4 -10 lines
Remove local definitions of RANGEOF() and use __rangeof() instead. Also remove a few bogus casts.
Revision 1.23.2.6: download - view: text, markup, annotated - select for diffs
Sat Oct 9 15:12:33 2004 UTC (7 years, 4 months ago) by mtm
Branches: RELENG_5
CVS tags: RELENG_5_3_BP, RELENG_5_3_0_RELEASE, RELENG_5_3
Diff to: previous 1.23: preferred, colored
Changes since revision 1.23: +5 -1 lines
MFC:
Revision 1.15: download - view: text, markup, annotated - select for diffs
Fri Oct 8 14:48:02 2004 UTC (7 years, 4 months ago) by mtm
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +1 -4 lines
Separate thread synchronization from signals in libthr. Instead use msleep() and wakeup_one(). Discussed with: jhb, peter, tjr Remove a reference to a non-existent syscall: _thr_exit(). The actual name is thr_exit(). How this ever worked is beyond me.
Revision 1.15: download - view: text, markup, annotated - select for diffs
Fri Oct 8 14:48:02 2004 UTC (7 years, 4 months ago) by mtm
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +1 -4 lines
Separate thread synchronization from signals in libthr. Instead use msleep() and wakeup_one(). Discussed with: jhb, peter, tjr Remove a reference to a non-existent syscall: _thr_exit(). The actual name is thr_exit(). How this ever worked is beyond me.
Revision 1.29: download - view: text, markup, annotated - select for diffs
Wed Oct 6 14:20:57 2004 UTC (7 years, 4 months ago) by mtm
Branches: MAIN
Diff to: previous 1.28: preferred, colored
Changes since revision 1.28: +5 -1 lines
Close a race between a thread exiting and the freeing of it's stack. After some discussion the best option seems to be to signal the thread's death from within the kernel. This requires that thr_exit() take an argument. Discussed with: davidxu, deischen, marcel MFC after: 3 days
Revision 1.14: download - view: text, markup, annotated - select for diffs
Wed Oct 6 14:20:57 2004 UTC (7 years, 4 months ago) by mtm
Branches: MAIN
CVS tags: RELENG_5_2_BP, RELENG_5_2_1_RELEASE, RELENG_5_2_0_RELEASE, RELENG_5_2
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +2 -3 lines
Update powerpc to use the (old thread,new thread) calling convention for cpu_throw() and cpu_switch(). Close a race between a thread exiting and the freeing of it's stack. After some discussion the best option seems to be to signal the thread's death from within the kernel. This requires that thr_exit() take an argument. Discussed with: davidxu, deischen, marcel MFC after: 3 days
Revision 1.14: download - view: text, markup, annotated - select for diffs
Wed Oct 6 14:20:57 2004 UTC (7 years, 4 months ago) by mtm
Branches: MAIN
CVS tags: RELENG_5_2_BP, RELENG_5_2_1_RELEASE, RELENG_5_2_0_RELEASE, RELENG_5_2
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +2 -3 lines
Update powerpc to use the (old thread,new thread) calling convention for cpu_throw() and cpu_switch(). Close a race between a thread exiting and the freeing of it's stack. After some discussion the best option seems to be to signal the thread's death from within the kernel. This requires that thr_exit() take an argument. Discussed with: davidxu, deischen, marcel MFC after: 3 days
Revision 1.28: download - view: text, markup, annotated - select for diffs
Wed Oct 6 02:29:19 2004 UTC (7 years, 4 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.27: preferred, colored
Changes since revision 1.27: +10 -7 lines
Close a race between thr_create and sysctl -w, the thr_scope_sys could be changed when thr_create is running, and we tested it for several times.
Revision 1.27: download - view: text, markup, annotated - select for diffs
Tue Sep 7 07:04:47 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.26: preferred, colored
Changes since revision 1.26: +1 -1 lines
fix typo MFC after: 2 days
Revision 1.26: download - view: text, markup, annotated - select for diffs
Tue Sep 7 06:33:39 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.25: preferred, colored
Changes since revision 1.25: +37 -10 lines
Give libthr a choice (per system) of scope_system or scope_thread scheduling. MFC after: 4 days
Revision 1.25: download - view: text, markup, annotated - select for diffs
Sun Sep 5 02:09:53 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.24: preferred, colored
Changes since revision 1.24: +56 -103 lines
Refactor a bunch of scheduler code to give basically the same behaviour 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
Revision 1.24: download - view: text, markup, annotated - select for diffs
Wed Sep 1 02:11:27 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.23: preferred, colored
Changes since revision 1.23: +1 -1 lines
Give setrunqueue() and sched_add() more of a clue as to where they are coming from and what is expected from them. MFC after: 2 days
Revision 1.23: download - view: text, markup, annotated - select for diffs
Sun Jul 18 23:36:12 2004 UTC (7 years, 6 months ago) by julian
Branches: MAIN
CVS tags: RELENG_5_BP
Branch point for: RELENG_5
Diff to: previous 1.22: preferred, colored
Changes since revision 1.22: +2 -2 lines
When calling scheduler entrypoints for creating new threads and processes, specify "us" as the thread not the process/ksegrp/kse. You can always find the others from the thread but the converse is not true. Theorotically this would lead to runtime being allocated to the wrong entity in some cases though it is not clear how often this actually happenned. (would only affect threaded processes and would probably be pretty benign, but it WAS a bug..) Reviewed by: peter
Revision 1.22: download - view: text, markup, annotated - select for diffs
Mon Jul 12 15:28:31 2004 UTC (7 years, 7 months ago) by mtm
Branches: MAIN
Diff to: previous 1.21: preferred, colored
Changes since revision 1.21: +2 -5 lines
writers must hold both sched_lock and the process lock; therefore, readers need only obtain the process lock.
Revision 1.21: download - view: text, markup, annotated - select for diffs
Fri Jul 2 00:40:07 2004 UTC (7 years, 7 months ago) by marcel
Branches: MAIN
Diff to: previous 1.20: preferred, colored
Changes since revision 1.20: +16 -13 lines
Change the thread ID (thr_id_t) used for 1:1 threading from being a pointer to the corresponding struct thread to the thread ID (lwpid_t) assigned to that thread. The primary reason for this change is that libthr now internally uses the same ID as the debugger and the kernel when referencing to a kernel thread. This allows us to implement the support for debugging without additional translations and/or mappings. To preserve the ABI, the 1:1 threading syscalls, including the umtx locking API have not been changed to work on a lwpid_t. Instead the 1:1 threading syscalls operate on long and the umtx locking API has not been changed except for the contested bit. Previously this was the least significant bit. Now it's the most significant bit. Since the contested bit should not be tested by userland, this change is not expected to be visible. Just to be sure, UMTX_CONTESTED has been removed from <sys/umtx.h>. Reviewed by: mtm@ ABI preservation tested on: i386, ia64
Revision 1.20: download - view: text, markup, annotated - select for diffs
Sat Jun 26 18:58:22 2004 UTC (7 years, 7 months ago) by marcel
Branches: MAIN
Diff to: previous 1.19: preferred, colored
Changes since revision 1.19: +0 -1 lines
Allocate TIDs in thread_init() and deallocate them in thread_fini(). The overhead of unconditionally allocating TIDs (and likewise, unconditionally deallocating them), is amortized across multiple thread creations by the way UMA makes it possible to have type-stable storage. Previously the cost was kept down by having threads created as part of a fork operation use the process' PID as the TID. While this had some nice properties, it also introduced complexity in the way TIDs were allocated. Most importantly, by using the type-stable storage that UMA gives us this was also unnecessary. This change affects how core dumps are created and in particular how the PRSTATUS notes are dumped. Since we don't have a thread with a TID equalling the PID, we now need a different way to preserve the old and previous behavior. We do this by having the given thread (i.e. the thread passed to the core dump code in td) dump it's state first and fill in pr_pid with the actual PID. All other threads will have pr_pid contain their TIDs. The upshot of all this is that the debugger will now likely select the right LWP (=TID) as the initial thread. Credits to: julian@ for spotting how we can utilize UMA. Thanks to: all who provided julian@ with test results.
Revision 1.19: download - view: text, markup, annotated - select for diffs
Mon Apr 19 14:20:01 2004 UTC (7 years, 9 months ago) by mtm
Branches: MAIN
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +4 -4 lines
If you're trying to find out if a thread is valid and in the same process as the current thread it makes absolutely no sense to lock the parent process through the pointer in said thread. Submitted by: pho (with minor correction) Pointy Hat To: mtm
Revision 1.18: download - view: text, markup, annotated - select for diffs
Sat Apr 3 15:59:12 2004 UTC (7 years, 10 months ago) by marcel
Branches: MAIN
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +1 -0 lines
Assign thread IDs to kernel threads. The purpose of the thread ID (tid) is twofold: 1. When a 1:1 or M:N threaded process dumps core, we need to put the register state of each of its kernel threads in the core file. This can only be done by differentiating the pid field in the respective note. For this we need the tid. 2. When thread support is present for remote debugging the kernel with gdb(1), threads need to be identified by an integer due to limitations in the remote protocol. This requires having a tid. To minimize the impact of having thread IDs, threads that are created as part of a fork (i.e. the initial thread in a process) will inherit the process ID (i.e. tid=pid). Subsequent threads will have IDs larger than PID_MAX to avoid interference with the pid allocation algorithm. The assignment of tids is handled by thread_new_tid(). The thread ID allocation algorithm has been written with 3 assumptions in mind: 1. IDs need to be created as fast a possible, 2. Reuse of IDs may happen instantaneously, 3. Someone else will write a better algorithm.
Revision 1.17: download - view: text, markup, annotated - select for diffs
Fri Apr 2 04:57:40 2004 UTC (7 years, 10 months ago) by kris
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +1 -1 lines
Add missing comment terminator.
Revision 1.16: download - view: text, markup, annotated - select for diffs
Fri Apr 2 01:01:34 2004 UTC (7 years, 10 months ago) by julian
Branches: MAIN
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +2 -5 lines
The comment complained about not having a thread_unlink() and did the work itself, but thread_unink() has existed for a while... use it.
Revision 1.13: download - view: text, markup, annotated - select for diffs
Tue Aug 12 19:33:36 2003 UTC (8 years, 6 months ago) by jhb
Branches: MAIN
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +1 -1 lines
- Convert Alpha over to the new calling conventions for cpu_throw() and cpu_switch() where both the old and new threads are passed in as arguments. Only powerpc uses the old conventions now. - Update comments in the Alpha swtch.s to reflect KSE changes. Tested by: obrien, marcel
Revision 1.12: download - view: text, markup, annotated - select for diffs
Fri Jul 4 06:59:28 2003 UTC (8 years, 7 months ago) by mtm
Branches: MAIN
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +2 -8 lines
style(9) o Remove double-spacing, and while I'm here add a couple of braces as well. Requested by: bde
Revision 1.11: download - view: text, markup, annotated - select for diffs
Thu Jul 3 19:09:58 2003 UTC (8 years, 7 months ago) by mtm
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +1 -5 lines
Signals sent specifically to a particular thread must be delivered to that thread, regardless of whether it has it masked or not. Previously, if the targeted thread had the signal masked, it would be put on the processes' siglist. If another thread has the signal umasked or unmasks it before the target, then the thread it was intended for would never receive it. This patch attempts to solve the problem by requiring callers of tdsignal() to say whether the signal is for the thread or for the process. If it is for the process, then normal processing occurs and any thread that has it unmasked can receive it. But if it is destined for a specific thread, it is put on that thread's pending list regardless of whether it is currently masked or not. The new behaviour still needs more work, though. If the signal is reposted for some reason it is always posted back to the thread that handled it because the information regarding the target of the signal has been lost by then. Reviewed by: jdp, jeff, bde (style)
Revision 1.10: download - view: text, markup, annotated - select for diffs
Wed Jun 11 00:56:57 2003 UTC (8 years, 8 months ago) by obrien
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +3 -3 lines
Use __FBSDID().
Revision 1.9: download - view: text, markup, annotated - select for diffs
Wed Jun 4 21:13:20 2003 UTC (8 years, 8 months ago) by marcel
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +1 -2 lines
Change the second (and last) argument of cpu_set_upcall(). Previously we were passing in a void* representing the PCB of the parent thread. Now we pass a pointer to the parent thread itself. The prime reason for this change is to allow cpu_set_upcall() to copy (parts of) the trapframe instead of having it done in MI code in each caller of cpu_set_upcall(). Copying the trapframe cannot always be done with a simply bcopy() or may not always be optimal that way. On ia64 specifically the trapframe contains information that is specific to an entry into the kernel and can only be used by the corresponding exit from the kernel. A trapframe copied verbatim from another frame is in most cases useless without some additional normalization. Note that this change removes the assignment to td->td_frame in some implementations of cpu_set_upcall(). The assignment is redundant. A previous call to cpu_thread_setup() already did the exact same assignment. An added benefit of removing the redundant assignment is that we can now change td_pcb without nasty side-effects. This change officially marks the ability on ia64 for 1:1 threading. Not tested on: amd64, powerpc Compile & boot tested on: alpha, sparc64 Functionally tested on: i386, ia64
Revision 1.8: download - view: text, markup, annotated - select for diffs
Fri May 16 21:26:42 2003 UTC (8 years, 8 months ago) by marcel
Branches: MAIN
CVS tags: RELENG_5_1_BP, RELENG_5_1_0_RELEASE, RELENG_5_1
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +1 -1 lines
Revamp of the syscall path, exception and context handling. The prime objectives are: o Implement a syscall path based on the epc inststruction (see sys/ia64/ia64/syscall.s). o Revisit the places were we need to save and restore registers and define those contexts in terms of the register sets (see sys/ia64/include/_regset.h). Secundairy objectives: o Remove the requirement to use contigmalloc for kernel stacks. o Better handling of the high FP registers for SMP systems. o Switch to the new cpu_switch() and cpu_throw() semantics. o Add a good unwinder to reconstruct contexts for the rare cases we need to (see sys/contrib/ia64/libuwx) Many files are affected by this change. Functionally it boils down to: o The EPC syscall doesn't preserve registers it does not need to preserve and places the arguments differently on the stack. This affects libc and truss. o The address of the kernel page directory (kptdir) had to be unstaticized for use by the nested TLB fault handler. The name has been changed to ia64_kptdir to avoid conflicts. The renaming affects libkvm. o The trapframe only contains the special registers and the scratch registers. For syscalls using the EPC syscall path no scratch registers are saved. This affects all places where the trapframe is accessed. Most notably the unaligned access handler, the signal delivery code and the debugger. o Context switching only partly saves the special registers and the preserved registers. This affects cpu_switch() and triggered the move to the new semantics, which additionally affects cpu_throw(). o The high FP registers are either in the PCB or on some CPU. context switching for them is done lazily. This affects trap(). o The mcontext has room for all registers, but not all of them have to be defined in all cases. This mostly affects signal delivery code now. The *context syscalls are as of yet still unimplemented. Many details went into the removal of the requirement to use contigmalloc for kernel stacks. The details are mostly CPU specific and limited to exception_save() and exception_restore(). The few places where we create, destroy or switch stacks were mostly simplified by not having to construct physical addresses and additionally saving the virtual addresses for later use. Besides more efficient context saving and restoring, which of course yields a noticable speedup, this also fixes the dreaded SMP bootup problem as a side-effect. The details of which are still not fully understood. This change includes all the necessary backward compatibility code to have it handle older userland binaries that use the break instruction for syscalls. Support for break-based syscalls has been pessimized in favor of a clean implementation. Due to the overall better performance of the kernel, this will still be notived as an improvement if it's noticed at all. Approved by: re@ (jhb)
Revision 1.7: download - view: text, markup, annotated - select for diffs
Wed Apr 30 21:45:03 2003 UTC (8 years, 9 months ago) by peter
Branches: MAIN
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +1 -1 lines
AMD64 uses the new-style cpu_switch()/cpu_throw() calling conventions.
Revision 1.6: download - view: text, markup, annotated - select for diffs
Thu Apr 17 22:21:57 2003 UTC (8 years, 9 months ago) by jhb
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +2 -0 lines
Protect td_sigmask with the proc lock.
Revision 1.5: download - view: text, markup, annotated - select for diffs
Fri Apr 11 19:24:37 2003 UTC (8 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +6 -0 lines
- Call sched_exit_{kse,thread} and sched_fork{kse,thread} so that thr works
with ULE. This was not strictly required by sched_4bsd.
Revision 1.4: download - view: text, markup, annotated - select for diffs
Tue Apr 8 08:13:47 2003 UTC (8 years, 10 months ago) by jake
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +2 -0 lines
Merged from kern_thread.c 1.113, avoid a panic in cpu_throw when the first thread of a multithreaded process exits. This unrelated and possibly wrong change was not mentioned in the commit message for kern_thread.c 1.113.
Revision 1.3: download - view: text, markup, annotated - select for diffs
Wed Apr 2 23:53:29 2003 UTC (8 years, 10 months ago) by peter
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +4 -0 lines
Commit a partial lazy thread switch mechanism for i386. it isn't as lazy as it could be and can do with some more cleanup. Currently its under options LAZY_SWITCH. What this does is avoid %cr3 reloads for short context switches that do not involve another user process. ie: we can take an interrupt, switch to a kthread and return to the user without explicitly flushing the tlb. However, this isn't as exciting as it could be, the interrupt overhead is still high and too much blocks on Giant still. There are some debug sysctls, for stats and for an on/off switch. The main problem with doing this has been "what if the process that you're running on exits while we're borrowing its address space?" - in this case we use an IPI to give it a kick when we're about to reclaim the pmap. Its not compiled in unless you add the LAZY_SWITCH option. I want to fix a few more things and get some more feedback before turning it on by default. This is NOT a replacement for Bosko's lazy interrupt stuff. This was more meant for the kthread case, while his was for interrupts. Mine helps a little for interrupts, but his helps a lot more. The stats are enabled with options SWTCH_OPTIM_STATS - this has been a pseudo-option for years, I just added a bunch of stuff to it. One non-trivial change was to select a new thread before calling cpu_switch() in the first place. This allows us to catch the silly case of doing a cpu_switch() to the current process. This happens uncomfortably often. This simplifies a bit of the asm code in cpu_switch (no longer have to call choosethread() in the middle). This has been implemented on i386 and (thanks to jake) sparc64. The others will come soon. This is actually seperate to the lazy switch stuff. Glanced at by: jake, jhb
Revision 1.2: download - view: text, markup, annotated - select for diffs
Tue Apr 1 02:32:53 2003 UTC (8 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +0 -2 lines
- thr_exit() should no longer be called with Giant held.
Revision 1.1: download - view: text, markup, annotated - select for diffs
Tue Apr 1 00:30:30 2003 UTC (8 years, 10 months ago) by jeff
Branches: MAIN
- Add two files to support the thr threading interface. - sys/thr.h contains the user space visible api that is intended only for use in threading library packages. - kern/kern_thr.c contains thr system calls and other thr specific code.
