summaryrefslogtreecommitdiffstats
path: root/sys/kern
Commit message (Collapse)AuthorAgeFilesLines
* Add the SF_NODISKIO flag to sendfile. This flag causes sendfile to besilby2004-02-081-19/+22
| | | | | | | | | | | | | | | mindful of blocking on disk I/O and instead return EBUSY when such blocking would occur. Results from the DeBox project indicate that blocking on disk I/O can slow the performance of a kqueue/poll based webserver. Using a flag such as SF_NODISKIO and throwing connections that would block to helper processes/threads helped increase performance. Currently, only the Flash webserver uses this flag, although it could probably be applied to thttpd with relative ease. Idea by: Yaoping Ruan & Vivek Pai
* swp_pager_async_iodone() no longer requires Giant. Modify bufdone()alc2004-02-071-1/+0
| | | | | | and swapgeom_done() to perform swp_pager_async_iodone() without Giant. Reviewed by: tegge
* - Convert the plimit lock to a pool mutex lock.jhb2004-02-061-3/+3
| | | | | | - Hide struct plimit from userland. Submitted by: bde (2)
* - Correct the translation of old rlimit values to properly handle the oldjhb2004-02-061-21/+28
| | | | | | | | | | | | | RLIM_INFINITY case for ogetrlimit(). - Use %jd and intmax_t to output negative time in usec in calcru(). - Rework getrusage() to make a copy of the rusage struct into a local variable while holding Giant and then do the copyout from the local variable to avoid having to have the original process rusage struct locked while doing the copyout (which would not be safe). This also includes a few style fixes from Bruce to getrusage(). Submitted by: bde (1, parts of 3) Suggested by: bde (2)
* A few more style fixes from Bruce including a few I missed last time.jhb2004-02-061-18/+12
| | | | Submitted by: bde
* Always set a process' state to normal when it is fully constructed injhb2004-02-052-6/+9
| | | | | fork1() rather than only doing it for the RFSTOPPED case and then having to fix it up in other places later on.
* - A lot of style and whitespace fixes.jhb2004-02-051-60/+53
| | | | | | - Update a few comments regarding locking notes. Submitted by: bde (1, mostly)
* Correct a reference counting bug in shmat(2). If vm_map_find(9)nectar2004-02-051-0/+1
| | | | | | | | failed, the reference count for the virtual memory object referenced by the specified shared memory segment would have been erroneously incremented. Reported by: Joost Pol <joost@pine.nl>
* Rename cn_unavailable to cnunavailable for little more consistency.kan2004-02-051-14/+2
| | | | | | Garbage collect unused cndebug() function. Suggested by: bde
* Style fixes: don't indent variable names.silby2004-02-051-6/+6
| | | | Submitted by: bde
* Eliminate global cons_unavailable flag and replace it by the statuskan2004-02-051-3/+42
| | | | | bit maintained on a per-device basis. Single variable is inadequate on machines running with multiple consoles enabled.
* Locking for the per-process resource limits structure.jhb2004-02-0414-123/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - struct plimit includes a mutex to protect a reference count. The plimit structure is treated similarly to struct ucred in that is is always copy on write, so having a reference to a structure is sufficient to read from it without needing a further lock. - The proc lock protects the p_limit pointer and must be held while reading limits from a process to keep the limit structure from changing out from under you while reading from it. - Various global limits that are ints are not protected by a lock since int writes are atomic on all the archs we support and thus a lock wouldn't buy us anything. - All accesses to individual resource limits from a process are abstracted behind a simple lim_rlimit(), lim_max(), and lim_cur() API that return either an rlimit, or the current or max individual limit of the specified resource from a process. - dosetrlimit() was renamed to kern_setrlimit() to match existing style of other similar syscall helper functions. - The alpha OSF/1 compat layer no longer calls getrlimit() and setrlimit() (it didn't used the stackgap when it should have) but uses lim_rlimit() and kern_setrlimit() instead. - The svr4 compat no longer uses the stackgap for resource limits calls, but uses lim_rlimit() and kern_setrlimit() instead. - The ibcs2 compat no longer uses the stackgap for resource limits. It also no longer uses the stackgap for accessing sysctl's for the ibcs2_sysconf() syscall but uses kernel_sysctl() instead. As a result, ibcs2_sysconf() no longer needs Giant. - The p_rlimit macro no longer exists. Submitted by: mtm (mostly, I only did a few cleanups and catchups) Tested on: i386 Compiled on: alpha, amd64
* Rename iov_to_uio to uiofromiov to be more consistent with othersilby2004-02-042-2/+2
| | | | | | uio* functions. Suggested by: bde
* Allow assert that the current thread does not hold the sx(9) lock.pjd2004-02-041-0/+11
| | | | | | Reviewed by: jhb In cooperation with: juli, jhb Approved by: jhb, scottl (mentor)
* Style fixessilby2004-02-042-35/+29
| | | | Submitted by: bde
* A variety of further cleanups to ttyinfo():rwatson2004-02-041-77/+84
| | | | | | | | | | | | | | | | | | | | | | | | | - Rename temporary variable names ("tmp", "tmp2") to more informative names ("load", "pctcpu", "rss", ...) - Unclutter indentation and return paths: rather than lots of nested ifs, simply return earlier if it's not going to work out. Simplify general structure and avoid "deep" code. - Comment on the thread/process selection and locking. - Correct handling of "running"/"runnable" states, avoid "unknown" that people were seeing for running processes. This was due to a misunderstanding of the more complex state machine / inhibitors behavior of KSE. - Do perform ttyinfo() printing on KSE (P_SA) processes, it seems generally to work. While I initially attempted to formulate this as two commits (one layout, the other content), I concluded that the layout changes were really structural changes. Many elements submitted by: bde
* Remove a bogus assertion.jhb2004-02-031-1/+0
| | | | | Noticed by: bde Pointy hat to: jhb
* Regen after adding ksem_timedwait().deischen2004-02-032-2/+4
|
* Add ksem_timedwait() to complement ksem_wait().deischen2004-02-032-6/+62
| | | | Glanced at by: alfred
* Don't dec/inc the amountpipes counter every time we resize a pipe --rwatson2004-02-031-2/+3
| | | | | | | | | | instead, just dec/inc in the ctor/dtor. For now, increment/decrement in two's, since we're now performing the operation once per pair, not once per pipe. Not really any measurable performance change in my micro-benchmarks, but doing less work is good, especially when it comes to atomic operations. Suggested by: alc
* Catch instances of (pipe == NULL) that were obsoleted with recentrwatson2004-02-031-6/+6
| | | | | | | | changes to jointly allocated pipe pairs. Replace these checks with pipe_present checks. This avoids a NULL pointer dereference when a pipe is half-closed. Submitted by: Peter Edwards <peter.edwards@openet-telecom.com>
* - Assert that witness_cold is not true in enroll().jhb2004-02-021-1/+2
| | | | | | - Only check witness_watch once in enroll(). Reported by: ru (2)
* Fix many issues related to mount/unmount:pjd2004-02-021-8/+33
| | | | | | | | | | | | | | | | | | | | | 1. Root from inside a jail was able to unmount any file system (except /). 2. Unprivileged root was able to unmount file systems mounted by privileged root (execpt /). 3. User from inside a jail was able to mount file system when sysctl vfs.usermount was set to 1. 4. User was able to mount file system when vfs.usermount was set to 1 (that's ok) and unmount it even if vfs.usermount was equal to 0 (that's not correct). Possibility from point 1 was reported by: Dariusz Kowalski <darek@76.pl> Only a part of this fix will be MFC'ed (if approved). PR: kern/60149 Reviewed by: rwatson Approved by: scottl (mentor) MFC after: 3 days
* Remove debugging code that slipped into the previous commit.silby2004-02-021-3/+0
| | | | Spotted by: bde
* - style fixes to the critical_exit() KASSERT().jeff2004-02-021-1/+2
| | | | Submitted by: bde
* - Allow interactive tasks to use the maximum time-slice. This is not asjeff2004-02-011-1/+1
| | | | | | detrimental as I thought it would be in the case of massive process storms from a shell and it makes regular desktop usage noticeably better.
* Rewrite sendfile's header support so that headers are now sent in the firstsilby2004-02-013-12/+141
| | | | | | | | | | | | packet along with data, instead of in their own packet. When serving files of size (packetsize - headersize) or smaller, this will result in one less packet crossing the network. Quick testing with thttpd and http_load has shown a noticeable performance improvement in this case (350 vs 330 fetches per second.) Included in this commit are two support routines, iov_to_uio, and m_uiotombuf; these routines are used by sendfile to construct the header mbuf chain that will be linked to the rest of the data in the socket buffer.
* - Disable ithread binding in all cases for now. This doesn't make as muchjeff2004-02-011-13/+5
| | | | | | sense with sched_4bsd as it does with sched_ule. - Use P_NOLOAD instead of the absence of td->td_ithd to determine whether or not a thread should be accounted for in sched_tdcnt.
* Coalesce pipe allocations and frees. Previously, the pipe coderwatson2004-02-012-94/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | would allocate two 'struct pipe's from the pipe zone, and malloc a mutex. - Create a new "struct pipepair" object holding the two 'struct pipe' instances, struct mutex, and struct label reference. Pipe structures now have a back-pointer to the pipe pair, and a 'pipe_present' flag to indicate whether the half has been closed. - Perform mutex init/destroy in zone init/destroy, avoiding reallocating the mutex for each pipe. Perform most pipe structure setup in zone constructor. - VM memory mappings for pageable buffers are still done outside of the UMA zone. - Change MAC API to speak 'struct pipepair' instead of 'struct pipe', update many policies. MAC labels are also handled outside of the UMA zone for now. Label-only policy modules don't have to be recompiled, but if a module is recompiled, its pipe entry points will need to be updated. If a module actually reached into the pipe structures (unlikely), that would also need to be modified. These changes substantially simplify failure handling in the pipe code as there are many fewer possible failure modes. On half-close, pipes no longer free the 'struct pipe' for the closed half until a full-close takes place. However, VM mapped buffers are still released on half-close. Some code refactoring is now possible to clean up some of the back references, etc; this patch attempts not to change the structure of most of the pipe implementation, only allocation/free code paths, so as to avoid introducing bugs (hopefully). This cuts about 8%-9% off the cost of sequential pipe allocation and free in system call tests on UP and SMP in my micro-benchmarks. May or may not make a difference in macro-benchmarks, but doing less work is good. Reviewed by: juli, tjr Testing help: dwhite, fenestro, scottl, et al
* - Revert rev 1.240 we no longer need a kthread for loadav().jeff2004-02-011-31/+12
|
* - Use sched_load() rather than grabbing the sx lock and traversing the procjeff2004-02-011-20/+2
| | | | table to discover the load.
* - Add a new member to struct kseq called ksq_sysload. This is intended tojeff2004-02-011-3/+27
| | | | | | | | track the load for the sched_load() function. In the SMP case this member is not defined because it would be redundant with the ksg_load member which already tracks the non ithd load. - For sched_load() in the UP case simply return ksq_sysload. In the SMP case traverse the list of kseq groups and sum up their ksg_load fields.
* - Keep a variable 'sched_tdcnt' that is used for the local implementationjeff2004-02-011-2/+19
| | | | | | of sched_load(). This variable tracks the number of running and runnable non ithd threads. This removes the need to traverse the proc table and discover how many threads are runnable.
* Move KASSERT regarding td_critnest to after the value of td is set torwatson2004-02-011-2/+1
| | | | | | curthread, to avoid warning and incorrect behavior. Hoped not to mind: jeff
* - Assert that td_critnest > 0 in critical_exit() to catch cases ofjeff2004-02-011-0/+2
| | | | unbalanced uses of the critical_* api.
* Fix an error in a KASSERT string: it's pipe_free_kmem(), notrwatson2004-01-311-1/+1
| | | | pipespace(), that contains this KASSERT.
* Introduce the SO_BINTIME option which takes a high-resolution timestampphk2004-01-311-0/+2
| | | | | | | | | | | | at packet arrival. For benchmarking purposes SO_BINTIME is preferable to SO_TIMEVAL since it has higher resolution and lower overhead. Simultaneous use of the two options is possible and they will return consistent timestamps. This introduces an extra test and a function call for SO_TIMEVAL, but I have not been able to measure that.
* Assert process lock in ptracestop(), since we're going to relyrwatson2004-01-291-0/+1
| | | | on it, and later unlock it.
* Add a reset sysctl for mutex profiling: zeros all of the mutexrwatson2004-01-281-0/+27
| | | | | | | | profiling buffers and hash table. This makes it a lot easier to do multiple profiling runs without rebooting or performing gratuitous arithmetic. Sysctl is named debug.mutex.prof.reset. Reviewed by: jake
* Move the loadav() callout into its own kthread since it uses allproc_lockjhb2004-01-281-12/+31
| | | | | which is a sleepable lock and thus is not safe to acquire from a callout routine.
* Rework witness_lock() to make it slightly more useful and flexible.jhb2004-01-283-108/+187
| | | | | | | | | | | | | | | | | | | | | | | | | | | - witness_lock() is split into two pieces: witness_checkorder() and witness_lock(). Witness_checkorder() determines if acquiring a specified lock at the time it is called would result in a lock order. It optionally adds a new lock order relationship as well. witness_lock() updates witness's data structures to assume that a lock has been acquired by stick a new lock instance in the appropriate lock instance list. - The mutex and sx lock functions now call checkorder() prior to trying to acquire a lock and continue to call witness_lock() after the acquire is completed. This will let witness catch a deadlock before it happens rather than trying to do so after the threads have deadlocked (i.e. never actually report it). - A new function witness_defineorder() has been added that adds a lock order between two locks at runtime without having to acquire the locks. If the lock order cannot be added it will return an error. This function is available to programmers via the WITNESS_DEFINEORDER() macro which accepts either two mutexes or two sx locks as its arguments. - A few simple wrapper macros were added to allow developers to call witness_checkorder() anywhere as a way of enforcing locking assertions in code that might acquire a certain lock in some situations. The macros are: witness_check_{mutex,shared_sx,exclusive_sx} and take an appropriate lock as the sole argument. - The code to remove a lock instance from a lock list in witness_unlock() was unnested by using a goto to vastly improve the readability of this function.
* Use mtx_assert() rather than using a home-rolled version.jhb2004-01-282-2/+2
|
* Move the part of the comment which applies to osigsuspend wherekan2004-01-281-2/+5
| | | | | | | it belongs. The current sigsuspend syscall does expect a pointer to the mask as argument. Submitted by: Igor Sysoev <is at rambler-co dot ru>
* Rename the kern.vm.kmem.size tunable to the more logical vm.kmem_size. Todes2004-01-271-1/+7
| | | | | | | | | | | assure backward compatibility (conditional on !BURN_BRIDGES), look it up by its old name first, and log a warning (but accept the setting) if it was found. If both the old and new name are defined, the new name takes precedence. Also export vm.kmem_size as a read-only sysctl variable; I find it hard to tune a parameter when I don't know its default value, especially when that default value is computed at boot time.
* When aborting fork() due to a failure, if using MAC, make sure to cleanrwatson2004-01-251-0/+3
| | | | | | | up the p_label field. Obtained from: TrustedBSD Project Sponsored by: DARPA, McAfee Research
* Register the uart(4)'s spin lock with witness(4).ru2004-01-251-0/+1
|
* - sched_strict has been dead for a long time now. Get rid of it.jeff2004-01-251-3/+0
|
* - Clean up KASSERTS.jeff2004-01-251-4/+4
|
* - Correct function names listed in KASSERTs. These were copied from otherjeff2004-01-251-10/+11
| | | | code and it was sloppy of me not to adjust these sooner.
* - Implement cpu pinning and binding. This is acomplished by keeping a per-jeff2004-01-251-12/+128
| | | | | | cpu run queue that is only used for pinned or bound threads. Submitted by: Chris Bradfield <chrisb@ation.org>
OpenPOWER on IntegriCloud