summaryrefslogtreecommitdiff
path: root/sys/kern
Commit message (Collapse)AuthorAgeFilesLines
* Always deliver synchronous signal to UTS for SA threads.David Xu2003-07-211-2/+14
| | | | Notes: svn path=/head/; revision=117814
* Turn a KASSERT back into an EINVAL return value. So, next time someoneMike Makonnen2003-07-191-2/+4
| | | | | | | | | | comes across it, it will turn into a core dump in userland instead of a kernel panic. I had also inverted the sense of the test, so Double pointy hat to: mtm Notes: svn path=/head/; revision=117778
* Three fixes:Mike Silbersack2003-07-191-2/+10
| | | | | | | | | | | | | | | | - Make m_prepend use m_gethdr instead of m_get where appropriate - Make m_copym use m_gethdr instead of m_get where appropriate - Add a call to m_fixhdr in m_defrag; m_defrag can't deal with corrupted pkthdr.len counts. MFC after: 3 days Notes: svn path=/head/; revision=117770
* Remove a lock held across casuptr() that snuck in last commit.Mike Makonnen2003-07-181-2/+5
| | | | Notes: svn path=/head/; revision=117745
* Move the decision on whether to unset the contestedMike Makonnen2003-07-181-48/+40
| | | | | | | | | bit or not from lock to unlock time. Suggested by: jhb Notes: svn path=/head/; revision=117743
* To avoid a kernel panic provoked by a NULL pointer dereference,Robert Drehmel2003-07-171-1/+7
| | | | | | | | | | | | | | | | | | | do not clear the `sb_sel' member of the sockbuf structure while invalidating the receive sockbuf in sorflush(), called from soshutdown(). The panic was reproduceable from user land by attaching a knote with EVFILT_READ filters to a socket, disabling further reads from it using shutdown(2), and then closing it. knote_remove() was called to remove all knotes from the socket file descriptor by detaching each using its associated filterops' detach call- back function, sordetach() in this case, which tried to remove itself from the invalidated sockbuf's klist (sb_sel.si_note). PR: kern/54331 Notes: svn path=/head/; revision=117708
* Fix sigwait to conform to POSIX.David Xu2003-07-171-67/+109
| | | | | | | | | | | | | | When a signal is being delivered to process, first find a sigwait thread to deliver, POSIX's argument is speed of delivering signal to sigwait thread is faster than other ways. A signal in its wait set will cause sigwait to return the signal number, a signal not in its wait set but in not blocked by the thread also causes sigwait to return, but sigwait returns EINTR, sigwait is oneshot operation, only one signal can be delivered to its wait set, when a signal is delivered to the sigwait thread, the thread's sigwait state is canceled. Notes: svn path=/head/; revision=117705
* o Refine kse_thr_interrupt to allow it to handle different commands.David Xu2003-07-175-127/+125
| | | | | | | | | | o Remove TDF_NOSIGPOST. o Add a member td_waitset to proc structure, it will be used for sigwait. Tested by: deischen Notes: svn path=/head/; revision=117704
* Correct six return statements which returned zero instead ofRobert Drehmel2003-07-171-9/+10
| | | | | | | | | | | | | an appropriate error number after a failure condition. In particular, three of the changed statements return ESRCH for a failed pfind(), and in also three places a non-zero return from p_cansee() will be passed back, Also noticed by: rwatson Notes: svn path=/head/; revision=117703
* Fix umtx locking, for libthr, in the kernel.Mike Makonnen2003-07-171-24/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. There was a race condition between a thread unlocking a umtx and the thread contesting it. If the unlocking thread won the race it may try to wakeup a thread that was not yet in msleep(). The contesting thread would then go to sleep to await a wakeup that would never come. It's not possible to close the race by using a lock because calls to casuptr() may have to fault a page in from swap. Instead, the race was closed by introducing a flag that the unlocking thread will set when waking up a thread. The contesting thread will check for this flag before going to sleep. For now the flag is kept in td_flags, but it may be better to use some other member or create a new one because of the possible performance/contention issues of having to own sched_lock. Thanks to jhb for pointing me in the right direction on this one. 2. Once a umtx was contested all future locks and unlocks were happening in the kernel, regardless of whether it was contested or not. To prevent this from happening, when a thread locks a umtx it checks the queue for that umtx and unsets the contested bit if there are no other threads waiting on it. Again, this is slightly more complicated than it needs to be because we can't hold a lock across casuptr(). So, the thread has to check the queue again after unseting the bit, and reset the contested bit if it finds that another thread has put itself on the queue in the mean time. 3. Remove the if... block for unlocking an uncontested umtx, and replace it with a KASSERT. The _only_ time a thread should be unlocking a umtx in the kernel is if it is contested. Notes: svn path=/head/; revision=117685
* Change the style of the english used to print accounting enabledBosko Milekic2003-07-161-2/+2
| | | | | | | | | | and disabled. This means no period at the end and changing "Process accounting <foo>" to "Accounting <foo>". Pointed out by: bde Notes: svn path=/head/; revision=117673
* Log process accounting activation/deactivation.Bosko Milekic2003-07-161-0/+2
| | | | | | | | | | Useful for some auditing purposes. Submitted by: Christian S.J. Peron <maneo@bsdpro.com> PR: kern/54529 Notes: svn path=/head/; revision=117664
* Rearrange the SYSINIT order to call lockmgr_init() earlier so thatDon Lewis2003-07-162-28/+4
| | | | | | | | | the runtime lockmgr initialization code in lockinit() can be eliminated. Reviewed by: jhb Notes: svn path=/head/; revision=117660
* If initial thread is still a bound thread, don't change its signal mask.David Xu2003-07-152-2/+2
| | | | Notes: svn path=/head/; revision=117637
* Add a facility for devices, specifically network interfaces, that requireHartmut Brandt2003-07-151-0/+399
| | | | | | | | | | | | | | large to huge amounts of small or medium sized receive buffers. The problem with these situations is that they eat up the available DMA address space very quickly when using mbufs or even mbuf clusters. Additionally this facility provides a direct mapping between 32-bit integers and these buffers. This is needed for devices originally designed for 32-bit systems. Ususally the virtual address of the buffer is used as a handle to find the buffer as soon as it is returned by the card. This does not work for 64-bit machines and hence this mapping is needed. Notes: svn path=/head/; revision=117624
* Rename thread_siginfo to cpu_thread_siginfoDavid Xu2003-07-153-3/+3
| | | | Notes: svn path=/head/; revision=117607
* Rev 1.121 meant to pass the value 1 to soalloc() to indicate waitok.Jeffrey Hsu2003-07-141-1/+1
| | | | | | | Reported by: arr Notes: svn path=/head/; revision=117595
* Extend the mutex pool implementation to permit the creation and use ofDon Lewis2003-07-136-60/+139
| | | | | | | | | | | | | | | | | | | multiple mutex pools with different options and sizes. Mutex pools can be created with either the default sleep mutexes or with spin mutexes. A dynamically created mutex pool can now be destroyed if it is no longer needed. Create two pools by default, one that matches the existing pool that uses the MTX_NOWITNESS option that should be used for building higher level locks, and a new pool with witness checking enabled. Modify the users of the existing mutex pool to use the appropriate pool in the new implementation. Reviewed by: jhb Notes: svn path=/head/; revision=117494
* Make the system call vector name of a process accessible to userRobert Drehmel2003-07-121-0/+29
| | | | | | | | land applications by introducing the KERN_PROC_SV_NAME sysctl node, which is searchable by PID. Notes: svn path=/head/; revision=117464
* If a thread is sending signal to its process, if the thread can handleDavid Xu2003-07-111-3/+4
| | | | | | | the signal itself, it should get it without looking for other threads. Notes: svn path=/head/; revision=117444
* Add init_param3() to subr_param. This function is calledMike Silbersack2003-07-112-26/+21
| | | | | | | | | | | immediately after the kernel map has been sized, and is the optimal place for the autosizing of memory allocations which occur within the kernel map to occur. Suggested by: bde Notes: svn path=/head/; revision=117391
* unifdef -DLAZY_SWITCH and start to tidy up the associated glue.Peter Wemm2003-07-102-7/+1
| | | | Notes: svn path=/head/; revision=117372
* A few minor changes:Mike Silbersack2003-07-091-6/+7
| | | | | | | | | | - Use atomic ops to update the bigpipe count - Make the bigpipe count sysctl readable - Remove a duplicate comparison in an if statement - Comment two SYSCTLs. Notes: svn path=/head/; revision=117364
* Pull in the entire kmem_map size calculation from kern_malloc, ratherMike Silbersack2003-07-081-3/+11
| | | | | | | | | | | | | than the shortcircuited version I had been using, which only worked properly on i386 & amd64. Also, change an autoscale constant to account for the more correct kmem_map size. Problem noticed by: mux Notes: svn path=/head/; revision=117338
* - When stealing a kse in kseq_move() ignore the current kseq's min niceJeff Roberson2003-07-081-7/+13
| | | | | | | | value. We want to steal any thread, even one that is not given a slice on its current queue. Notes: svn path=/head/; revision=117326
* Put some concrete limits on pipe memory consumption:Mike Silbersack2003-07-082-17/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Limit the total number of pipes so that we do not exhaust all vm objects in the kernel map. When this limit is reached, a ratelimited message will be printed to the console. - Put a soft limit on the amount of memory consumable by pipes. Once the limit has been reached, all new pipes will be limited to 4K in size, rather than the default of 16K. - Put a limit on the number of pages that may be used for high speed page flipping in order to reduce the amount of wired memory. Pipe writes that occur while this limit is exceeded will fall back to non-page flipping mode. The above values are auto-tuned in subr_param.c and are scaled to take into account both the size of physical memory and the size of the kernel map. These limits help to reduce the "kernel resources exhausted" panics that could be caused by opening a large number of pipes. (Pipes alone are no longer able to exhaust all resources, but other kernel memory hogs in league with pipes may still be able to do so.) PR: 53627 Ideas / comments from: hsu, tjr, dillon@apollo.backplane.com MFC after: 1 week Notes: svn path=/head/; revision=117325
* - Clean up an unused variable.Jeff Roberson2003-07-071-0/+2
| | | | | | | Submitted by: Steve Kargl <skg@routmask.apl.washington.edu> Notes: svn path=/head/; revision=117313
* Make the conditional, which decides what siglist to put a signal on,Mike Makonnen2003-07-051-8/+5
| | | | | | | | | more concise and improve the comment. Submitted by: bde Notes: svn path=/head/; revision=117255
* I was so happy I found the semi-colon from hell that I didn'tMike Makonnen2003-07-041-1/+1
| | | | | | | | | notice another typo in the same line. This typo makes libthr unuseable, but it's effects where counter-balanced by the extra semicolon, which made libthr remarkably useable for the past several months. Notes: svn path=/head/; revision=117244
* - Parse the cpu topology map in sched_setup().Jeff Roberson2003-07-041-13/+53
| | | | | | | | | | | - Associate logical CPUs on the same physical core with the same kseq. - Adjust code that assumed there would only be one running thread in any kseq. - Wrap the HTT code with a ULE_HTT_EXPERIMENTAL ifdef. This is a start towards HyperThreading support but it isn't quite there yet. Notes: svn path=/head/; revision=117237
* Use the f_vnode field to tell which file descriptors have a vnode.Poul-Henning Kamp2003-07-043-19/+15
| | | | Notes: svn path=/head/; revision=117222
* It's unfair how one extraneous semi-colon can cause so much grief.Mike Makonnen2003-07-041-1/+1
| | | | Notes: svn path=/head/; revision=117219
* style(9)Mike Makonnen2003-07-041-8/+2
| | | | | | | | | | o Remove double-spacing, and while I'm here add a couple of braces as well. Requested by: bde Notes: svn path=/head/; revision=117215
* In setpgrp(), don't assume a pgrp won't exist if the provided pgid is the sameOlivier Houchard2003-07-041-12/+13
| | | | | | | | | | as the target process' pid, it may exist if the process forked before leaving the pgrp. Thix fixes a panic that happens when calling setpgid to make a process re-enter the pgrp with the same pgid as its pid if the pgrp still exists. Notes: svn path=/head/; revision=117214
* kse_thr_interrupt should target the thread, specifically.Mike Makonnen2003-07-042-2/+2
| | | | | | | Requested by: davidxu Notes: svn path=/head/; revision=117212
* Signals sent specifically to a particular thread mustMike Makonnen2003-07-034-19/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=117205
* - Add comments about the maintenance of the per-thread list of contestedJohn Baldwin2003-07-022-8/+18
| | | | | | | | | | | | | | | | locks held by each thread. - Fix a bug in the original BSD/OS code where a contested lock was not properly handed off from the old thread to the new thread when a contested lock with more than one blocked thread was transferred from one thread to another. - Don't use an atomic operation to write the MTX_CONTESTED value to mtx_lock in the aforementioned special case. The memory barriers and exclusion provided by sched_lock are sufficient. Spotted by: alc (2) Notes: svn path=/head/; revision=117168
* Add a resource_disabled() helper function that returns true (non-zero) ifJohn Baldwin2003-07-021-0/+14
| | | | | | | | a specified resource has been disabled via a non-zero 'disabled' hint and false otherwise. Notes: svn path=/head/; revision=117166
* typo fix in comment.Poul-Henning Kamp2003-07-021-1/+1
| | | | Notes: svn path=/head/; revision=117148
* Allow SA process unblocks a thread blocked in condition variable.David Xu2003-07-021-2/+8
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=117141
* Add a new mount flag MNT_BYFSID that can be used to unmount a fileIan Dowse2003-07-011-23/+32
| | | | | | | | | | | | | | | | | | | | | system by specifying the file system ID instead of a path. Use this by default in umount(8). This avoids the need to perform any vnode operations to look up the mount point, so it makes it possible to unmount a file system whose root vnode cannot be looked up (e.g. due to a dead NFS server, or a file system that has become detached from the hierarchy because an underlying file system was unmounted). It also provides an unambiguous way to specify which file system is to be unmunted. Since the ability to unmount using a path name is retained only for compatibility, that case now just uses a simple string comparison of the supplied path against f_mntonname of each mounted file system. Discussed on: freebsd-arch mdoc help from: ru Notes: svn path=/head/; revision=117132
* Make swi_vm be INTR_MPSAFE. On all platforms, it is only used to activateScott Long2003-07-011-1/+1
| | | | | | | | busdma_swi(). Now that busdma_swi() uses driver-provided locking, this should be safe. Notes: svn path=/head/; revision=117128
* Fix typo.David Xu2003-06-302-2/+2
| | | | Notes: svn path=/head/; revision=117069
* Don't use fuword() and suword() on struct members of type int. ThisMarcel Moolenaar2003-06-282-8/+8
| | | | | | | | | | | | | | | happens to work on 32-bit platforms as sizeof(long)=sizeof(int), but wrecks all kinds of havoc (garbage reads, corrupting writes and misaligned loads/stores) on 64-bit architectures. The fix for now is to use fuword32() and suword32() and change the type of the applicable int fields to int32. This is to make it explicit that we depend on these fields being 32-bit. We may want to revisit this later. Reviewed by: deischen Notes: svn path=/head/; revision=117000
* - Don't migrate to stopped cpus.Jeff Roberson2003-06-281-4/+4
| | | | Notes: svn path=/head/; revision=116970
* o Change kse_thr_interrupt to allow send a signal to a specified thread,David Xu2003-06-286-144/+343
| | | | | | | | | | | | | | | | | | | | or unblock a thread in kernel, and allow UTS to specify whether syscall should be restarted. o Add ability for UTS to monitor signal comes in and removed from process, the flag PS_SIGEVENT is used to indicate the events. o Add a KMF_WAITSIGEVENT for KSE mailbox flag, UTS call kse_release with this flag set to wait for above signal event. o For SA based thread, kernel masks all signal in its signal mask, let UTS to use kse_thr_interrupt interrupt a thread, and install a signal frame in userland for the thread. o Add a tm_syncsig in thread mailbox, when a hardware trap occurs, it is used to deliver synchronous signal to userland, and upcall is schedule, so UTS can process the synchronous signal for the thread. Reviewed by: julian (mentor) Notes: svn path=/head/; revision=116963
* - If smp is not started yet don't try to load balance or we'll put threadsJeff Roberson2003-06-281-0/+3
| | | | | | | on cpus that aren't running yet. Notes: svn path=/head/; revision=116962
* Fix POSIX compatible bug for sigwaitinfo and sigtimedwait.David Xu2003-06-281-4/+11
| | | | | | | | | | POSIX says siginfo pointer parameter can be NULL and if the function success, it should return signal number but not zero. The waitset it past should be negatived before it can be used as thread signal mask. Notes: svn path=/head/; revision=116961
* - Throttle the inherited sleep and run time in sched_fork_kseg(). ThisJeff Roberson2003-06-281-4/+4
| | | | | | | | allows us to learn the behavior of a thread much more quickly after it starts up. Notes: svn path=/head/; revision=116955
* - Adjust the default maximum slice value to ~140ms. This has improved theJeff Roberson2003-06-281-2/+2
| | | | | | | | | nice distribution without significantly impacting interactive response. As a side effect it should also allow batch processes to run for a slightly longer period which will positively impact their performance. Notes: svn path=/head/; revision=116946