summaryrefslogtreecommitdiffstats
path: root/sys/kern
Commit message (Collapse)AuthorAgeFilesLines
* In revision 1.228, I accidentally broke the "total number of processes incperciva2004-07-261-1/+2
| | | | | | | | | | | | the system" resource limit code: When checking if the caller has superuser privileges, we should be checking the *real* user, not the *effective* user. (In general, resource limiting is done based on the real user, in order to avoid resource-exhaustion-by-setuid-program attacks.) Now that a SUSER_RUID flag to suser_cred exists, use it here to return this code to its correct behaviour. Pointed out by: rwatson
* Rename suser_cred()'s PRISON_ROOT flag to SUSER_ALLOWJAIL. This iscperciva2004-07-2612-60/+60
| | | | | | | | | | | somewhat clearer, but more importantly allows for a consistent naming scheme for suser_cred flags. The old name is still defined, but will be removed in a few days (unless I hear any complaints...) Discussed with: rwatson, scottl Requested by: jhb
* Revert modification of subr_turnstile.c accidentally included in therwatson2004-07-251-1/+0
| | | | | last commit; this assertion was provided by jhb for local debugging and not intended for broader consumption.
* In uipc_connect(), assert that the passed thread is curthread, and passrwatson2004-07-252-1/+4
| | | | td into unp_connect() instead of reading curthread.
* Do some initial locking on accept filter registration and attach. Whilerwatson2004-07-251-29/+76
| | | | | | here, close some races that existed in the pre-locking world during low memory conditions. This locking isn't perfect, but it's closer than before.
* Eliminate unused second argument to reassignbuf() and simplify itphk2004-07-253-34/+15
| | | | accordingly.
* Add netatalk mutexes to hard-coded WITNESS lock order.rwatson2004-07-251-0/+6
|
* Expand the generic, but bogusly formed, copyright notice to includeimp2004-07-251-1/+21
| | | | | | | | | | | the license from /usr/src/COPYRIGHT. Since cvs annotate shows that this was written by jasone, julian, jhb, peter, bmilekic and obrien. cvs log shows that many others may have contributed to this file. As such, go ahead and use the author of 'FreeBSD Project' for this file. If this is a problem, please notify me. # this eliminates the last file in the kernel with an indirect reference # to /usr/src/COPYRIGHT in the kernel. A few more in userland remain.
* Neuter this warning for now, I think I know the remaining issues.phk2004-07-251-1/+2
|
* White space fix..julian2004-07-241-3/+3
| | | | diff reduction for upcoming commit.
* Clean up whitespace, increase consistency and correctness.scottl2004-07-232-13/+9
| | | | Submitted by: bde
* Don't include a "\n" in KTR output, it confuses automatic parsing.rwatson2004-07-231-1/+1
|
* Remove the previous hack since it doesn't make a difference and is gettingscottl2004-07-231-2/+0
| | | | in the way of debugging.
* Use kmem_alloc_nofault() rather than kmem_alloc_pageable() for allocatingalc2004-07-231-1/+1
| | | | | KVA for explicitly managed mappings, i.e., mappings created with pmap_qenter().
* Export KTR_COMPILE as a sysctl so you can easily check from user spacerwatson2004-07-231-0/+3
| | | | what event mask has been compiled into the kernel.
* Don't perform pipe endpoint locking during pipe_create(), as the piperwatson2004-07-231-11/+20
| | | | | | | | | | can't yet be referenced by other threads. In microbenchmarks, this appears to reduce the cost of pipe();close();close() on UP by 10%, and SMP by 7%. The vast majority of the cost of allocating a pipe remains VM magic. Suggested by: silby
* In setpgid(), since td is passed in as a system call argument, use itrwatson2004-07-231-1/+1
| | | | in preference to curthread, which costs slightly more.
* Push Giant acquisition down into fo_stat() from most callers. Acquirerwatson2004-07-224-7/+8
| | | | | | | | | | | Giant conditional on debug.mpsafenet in the socket soo_stat() routine, unconditionally in vn_statfile() for VFS, and otherwise don't acquire Giant. Accept an unlocked read in kqueue_stat(), and cryptof_stat() is a no-op. Don't acquire Giant in fstat() system call. Note: in fdescfs, fo_stat() is called while holding Giant due to the VFS stack sitting on top, and therefore there will still be Giant recursion in this case.
* Push acquisition of Giant from fdrop_closed() into fo_close() so thatrwatson2004-07-224-6/+9
| | | | | | | | | | | | | | | | | | | | | | | individual file object implementations can optionally acquire Giant if they require it: - soo_close(): depends on debug.mpsafenet - pipe_close(): Giant not acquired - kqueue_close(): Giant required - vn_close(): Giant required - cryptof_close(): Giant required (conservative) Notes: Giant is still acquired in close() even when closing MPSAFE objects due to kqueue requiring Giant in the calling closef() code. Microbenchmarks indicate that this removal of Giant cuts 3%-3% off of pipe create/destroy pairs from user space with SMP compiled into the kernel. The cryptodev and opencrypto code appears MPSAFE, but I'm unable to test it extensively and so have left Giant over fo_close(). It can probably be removed given some testing and review.
* suser() accepts a thread argument; as suser() dereferences td_ucred, arwatson2004-07-221-0/+12
| | | | | | | | | thread-local pointer, in practice that thread needs to be curthread. If we're running with INVARIANTS, generate a warning if not. If we have KDB compiled in, generate a stack trace. This doesn't fire at all in my local test environment, but could be irritating if it fires frequently for someone, so there will be motivation to fix things quickly when it does.
* Disable the PREEMPTION-enabled code in critical_exit() that encouragesscottl2004-07-221-0/+2
| | | | | switching to a different thread. This is just a hack to try to improve stability some more, but likely points closer to the real culprit.
* Back out just a portion of Alfred's last commit. Remove the MBUF_CHECKbmilekic2004-07-211-2/+0
| | | | | | | | (WITNESS) for code paths that always call uma_zalloc_arg() shortly after where the check was, because uma_zalloc_arg() already does a similar check. No objections from Alfred. Thanks Alfred.
* Don't sync the file system on panic by default. This seems to basicallyrwatson2004-07-211-1/+1
| | | | | | | | work very infrequently, and often results in a compound panic which confuses debugging; locking/SMP have made the layering violation (and risks) of this more obvious over time. Discussed with: green, bde, et al.
* put several of the options for DEBUG_VFS_LOCKS under control of sysctls.alfred2004-07-211-0/+14
|
* Make sure we don't call mbuf allocation functions with mutexes held.alfred2004-07-212-0/+12
| | | | Discussed with: rwatson
* Add kdb_thr_from_pid(), which given a PID returns the first threadmarcel2004-07-211-1/+15
| | | | in the process. This is useful when working from or with a process.
* Fix a minor error in pipe_stat - st_size was always reported as 0silby2004-07-201-1/+4
| | | | | when direct writes kicked in. Whether this affected any applications is unknown.
* #ifdef __i386__ -> __i386__ || __amd64__peter2004-07-201-5/+5
|
* You always spot the typos after you have committed.. Start sentencejulian2004-07-191-1/+1
| | | | with a Cap.
* Allow the user who calls doadump() from the kernel debuggerjulian2004-07-191-2/+11
| | | | | | | | | | to not get a page fault if he has not defined a dump device. Panic can often not do a dump as it can hang forever in some cases. The original PR was for amd64 only. This is a generalised version of that change. PR: amd64/67712 Submitted by: wjw@withagen.nl <Willen Jan Withagen>
* Reimplement contigmalloc(9) with an algorithm which stands a greatly-green2004-07-191-27/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | improved chance of working despite pressure from running programs. Instead of trying to throw a bunch of pages out to swap and hope for the best, only a range that can potentially fulfill contigmalloc(9)'s request will have its contents paged out (potentially, not forcibly) at a time. The new contigmalloc operation still operates in three passes, but it could potentially be tuned to more or less. The first pass only looks at pages in the cache and free pages, so they would be thrown out without having to block. If this is not enough, the subsequent passes page out any unwired memory. To combat memory pressure refragmenting the section of memory being laundered, each page is removed from the systems' free memory queue once it has been freed so that blocking later doesn't cause the memory laundered so far to get reallocated. The page-out operations are now blocking, as it would make little sense to try to push out a page, then get its status immediately afterward to remove it from the available free pages queue, if it's unlikely to have been freed. Another change is that if KVA allocation fails, the allocated memory segment will be freed and not leaked. There is a sysctl/tunable, defaulting to on, which causes the old contigmalloc() algorithm to be used. Nonetheless, I have been using vm.old_contigmalloc=0 for over a month. It is safe to switch at run-time to see the difference it makes. A new interface has been used which does not require mapping the allocated pages into KVA: vm_page.h functions vm_page_alloc_contig() and vm_page_release_contig(). These are what vm.old_contigmalloc=0 uses internally, so the sysctl/tunable does not affect their operation. When using the contigmalloc(9) and contigfree(9) interfaces, memory is now tracked with malloc(9) stats. Several functions have been exported from kern_malloc.c to allow other subsystems to use these statistics, as well. This invalidates the BUGS section of the contigmalloc(9) manpage.
* When calling scheduler entrypoints for creating new threads and processes,julian2004-07-187-37/+40
| | | | | | | | | | | 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
* Now we have NO_ADAPTIVE_MUTEXES option, so use it here too.pjd2004-07-181-1/+1
| | | | Missed by: scottl
* After maintaining previous behaviour in writing out the core notes, it'smarcel2004-07-181-8/+5
| | | | | | | | | | | | | | | | | time now to break with the past: do not write the PID in the first note. Rationale: 1. [impact of the breakage] Process IDs in core files serve no immediate purpose to the debugger itself. They are only useful to relate a core file to a process. This can provide context to the person looking at the core file, provided one keeps track of this. Overall, not having the PID in the core file is only in very rare occasions unfortunate. 2. [reason of the breakage] Having one PRSTATUS note contain the PID, while all others contain the LWPID of the corresponding kernel thread creates an irregularity for the debugger that cannot easily be worked around. This is caused by libthread_db correlating user thread IDs to kernel thread (aka LWP) IDs and thus aware of the actual LWPIDs. Update comments accordingly.
* The recent changes to control message passing broke some thingsdwmalone2004-07-181-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | that get certain types of control messages (ping6 and rtsol are examples). This gets the new code closer to working: 1) Collect control mbufs for processing in the controlp == NULL case, so that they can be freed by externalize. 2) Loop over the list of control mbufs, as the externalize function may not know how to deal with chains. 3) In the case where there is no externalize function, remember to add the control mbuf to the controlp list so that it will be returned. 4) After adding stuff to the controlp list, walk to the end of the list of stuff that was added, incase we added a chain. This code can be further improved, but this is enough to get most things working again. Reviewed by: rwatson
* Add doxygen doc comments for most of newbus and the BUS interface.dfr2004-07-182-152/+1241
|
* Enable ADAPTIVE_MUTEXES by default by changing the sense of the option toscottl2004-07-181-3/+3
| | | | | | | | | NO_ADAPTIVE_MUTEXES. This option has been enabled by default on amd64 for quite some time, and has been extensively tested on i386 and sparc64. It shows measurable performance gains in many circumstances, and few negative effects. It would be nice in t he future if adaptive mutexes actually went to sleep after a certain amount of spinning, but that will require quite a bit more testing.
* Remove GIANT_REQUIRED from vmapbuf().alc2004-07-181-2/+0
|
* Drop Giant and acquire the UNIX domain socket subsystem lock a bitrwatson2004-07-181-4/+4
| | | | | | | | | earlier in unp_connect() so that vp->v_socket can't change between our copying its value to a local variable and later use of that variable. This may have been responsible for a panic during shutdown that I experienced where simultaneous closing of a listen socket by rpcbind and a new connection being made to rpcbind by mountd.
* Fix typo.davidxu2004-07-171-1/+1
|
* Add a kern_setsockopt and kern_getsockopt which can read the optiondwmalone2004-07-171-34/+86
| | | | | | values from either user land or from the kernel. Use them for [gs]etsockopt and to clean up some calls to [gs]etsockopt in the Linux emulation code that uses the stackgap.
* - Move TDF_OWEPREEMPT, TDF_OWEUPC, and TDF_USTATCLOCK over to td_pflagsjhb2004-07-167-19/+25
| | | | | | | | | since they are only accessed by curthread and thus do not need any locking. - Move pr_addr and pr_ticks out of struct uprof (which is per-process) and directly into struct thread as td_profil_addr and td_profil_ticks as these variables are really per-thread. (They are used to defer an addupc_intr() that was too "hard" until ast()).
* Whitespace fix.jhb2004-07-161-1/+1
|
* Improve readability a bit by changing some code at the end of a functionjhb2004-07-161-6/+2
| | | | | | | | | | | | | | | | that did: if (foo) return else blah to just do the simpler if (!foo) blah instead.
* Add a SUSER_RUID flag to suser_cred. This flag indicates that we want tocperciva2004-07-161-3/+2
| | | | | | | check if the *real* user is the superuser (vs. the normal behaviour, which checks the effective user). Reviewed by: rwatson
* When entering soclose(), assert that SS_NOFDREF is not already set.rwatson2004-07-161-0/+2
|
* Preparation commit for the tty cleanups that will follow in the nearphk2004-07-155-10/+10
| | | | | | | | | future: rename ttyopen() -> tty_open() and ttyclose() -> tty_close(). We need the ttyopen() and ttyclose() for the new generic cdevsw functions for tty devices in order to have consistent naming.
* Do a pass over all modules in the kernel and make them return EOPNOTSUPPphk2004-07-155-2/+12
| | | | | | | | for unknown events. A number of modules return EINVAL in this instance, and I have left those alone for now and instead taught MOD_QUIESCE to accept this as "didn't do anything".
* Cleanup shutdown output.alfred2004-07-152-7/+4
|
* Tidy up system shutdown.alfred2004-07-152-6/+24
|
OpenPOWER on IntegriCloud