summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
Commit message (Collapse)AuthorAgeFilesLines
* o Lock accesses to the page queues.alc2002-07-131-0/+11
| | | | | o Add a comment explaining why hoisting the page queue lock outside of a particular loop is not possible.
* More caddr_t removal, make fo_ioctl take a void * instead of a caddr_t.alfred2002-06-291-2/+3
|
* document that the pipe fo_stat routine doesn't need locks because it'salfred2002-06-281-0/+4
| | | | | | a read operation. Requested by: rwatson
* Make funsetown() take a 'struct sigio **' so that the locking canalfred2002-05-061-1/+1
| | | | | | | | | | | | | | | | be done internally. Ensure that no one can fsetown() to a dying process/pgrp. We need to check the process for P_WEXIT to see if it's exiting. Process groups are already safe because there is no such thing as a pgrp zombie, therefore the proctree lock completely protects the pgrp from having sigio structures associated with it after it runs funsetownlst. Add sigio lock to witness list under proctree and allproc, but over proc and pgrp. Seigo Tanimura helped with this.
* Redo the sigio locking.alfred2002-05-011-1/+1
| | | | | | | | | | | Turn the sigio sx into a mutex. Sigio lock is really only needed to protect interrupts from dereferencing the sigio pointer in an object when the sigio itself is being destroyed. In order to do this in the most unintrusive manner change pgsigio's sigio * argument into a **, that way we can lock internally to the function.
* Use pmap_extract() instead of pmap_kextract() to retrieve the physicaltmm2002-04-131-1/+2
| | | | | | | address associated with a user virtual address in pipe_build_write_buffer(). Reviewed by: alc
* Back out the last revision - it does not work correctly when one oftmm2002-04-131-17/+6
| | | | | | | | the pages in question is not in the top-level vm object, but in one of the shadow ones. Pointed out by: alc Pointy hat to: tmm
* Do not use pmap_kextract() to find out the physical address of a usertmm2002-04-121-6/+17
| | | | | | | | | | | belong to a user virtual address; while this happens to work on some architectures, it can't on sparc64, since user and kernel virtual address spaces overlap there (the distinction between them is done via separate address space identifiers). Instead, look up the page in the vm_map of the process in question. Reviewed by: jake
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-1/+1
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* Allow resursion on the pipe mutex because filt_piperead() and filt_pipewrite()alc2002-03-271-1/+1
| | | | | | | | can be called both with and without the pipe mutex held. (For example, if called by pipeselwakeup(), it is held. Whereas, if called by kqueue_scan(), it is not.) Reviewed by: alfred
* When "cloning" a pipe's buffer bcopy the data after dropping the pipe'salfred2002-03-221-2/+2
| | | | lock as the data may be paged out and cause a fault.
* Remove references to vm_zone.h and switch over to the new uma API.jeff2002-03-201-4/+4
| | | | | Also, remove maxsockets. If you look carefully you'll notice that the old zone allocator never honored this anyway.
* This is the first part of the new kernel memory allocator. This replacesjeff2002-03-191-2/+2
| | | | | | malloc(9) and vm_zone with a slab like allocator. Reviewed by: arch@
* Bug fixes:alfred2002-03-151-5/+10
| | | | | | | | | | | Missed a place where the pipe sleep lock was needed in order to safely grab Giant, fix it and add an assertion to make sure this doesn't happen again. Fix typos in the PIPE_GET_GIANT/PIPE_DROP_GIANT that could cause the wrong mutex to get passed to PIPE_LOCK/PIPE_UNLOCK. Fix a location where the wrong pipe was being passed to PIPE_GET_GIANT/PIPE_DROP_GIANT.
* Don't deref NULL mutex pointer when pipeclose()'ing a pipe that is notalfred2002-03-091-30/+51
| | | | | | | | | | | | | | | | | | fully instaniated. Revert the logic in pipeclose so that we don't have the entire function pretty much under a single if() statement, instead invert the test and just return if it fails. Submitted (in different form) by: bde Don't use pool mutexes for pipes. We can not use pool mutexes because we will need to grab the select lock while holding a pipe lock which is not allowed because you may not aquire additional mutexes when holding a pool mutex. Instead malloc(9) space for the mutex that is shared between the pipes.
* Track the number of wired pages to avoid unwiring unwired pages.tanimura2002-03-051-0/+1
| | | | Reviewed by: alfred
* kill __P.alfred2002-02-271-22/+22
|
* add assertions in the places where giant is required to catch whenalfred2002-02-271-0/+12
| | | | | | | | | | | the pipe is locked and shouldn't be. initialize pipe->pipe_mtxp to NULL when creating pipes in order not to trip the above assertions. swap pipe lock with giant around calls to pipe_destroy_write_buffer() pipe_destroy_write_buffer issue noticed by: jhb
* Fix a NULL deref panic in pipe_write, we can't blindly lockalfred2002-02-271-12/+12
| | | | | pipe->pipe_peer->pipe_mtxp because it may be NULL, so lock the passed in pipe's mutex instead.
* MPsafe fixes:alfred2002-02-271-4/+23
| | | | | use SYSINIT to initialize pipe_zone. use PIPE_LOCK to protect kevent ops.
* First rev at making pipe(2) pipe's MPsafe.alfred2002-02-271-22/+68
| | | | | | | | | | | Both ends of the pipe share a pool_mutex, this makes allocation and deadlock avoidance easy. Remove some un-needed FILE_LOCK ops while I'm here. There are some issues wrt to select and the f{s,g}etown code that we'll have to deal with, I think we may also need to move the calls to vfs_timestamp outside of the sections covered by PIPE_LOCK.
* SMP Lock struct file, filedesc and the global file list.alfred2002-01-131-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Seigo Tanimura (tanimura) posted the initial delta. I've polished it quite a bit reducing the need for locking and adapting it for KSE. Locks: 1 mutex in each filedesc protects all the fields. protects "struct file" initialization, while a struct file is being changed from &badfileops -> &pipeops or something the filedesc should be locked. 1 mutex in each struct file protects the refcount fields. doesn't protect anything else. the flags used for garbage collection have been moved to f_gcflag which was the FILLER short, this doesn't need locking because the garbage collection is a single threaded container. could likely be made to use a pool mutex. 1 sx lock for the global filelist. struct file * fhold(struct file *fp); /* increments reference count on a file */ struct file * fhold_locked(struct file *fp); /* like fhold but expects file to locked */ struct file * ffind_hold(struct thread *, int fd); /* finds the struct file in thread, adds one reference and returns it unlocked */ struct file * ffind_lock(struct thread *, int fd); /* ffind_hold, but returns file locked */ I still have to smp-safe the fget cruft, I'll get to that asap.
* Make kevents on pipes work as described in the manpage - when the lastsobomax2001-11-191-0/+1
| | | | | | | reader/writer disconnects, ensure that anybody who is waiting for the kevent on the other end of the pipe gets EV_EOF. MFC after: 2 weeks
* Use the passed in thread to selrecord() instead of curthread.jhb2001-09-211-2/+2
|
* KSE Milestone 2julian2001-09-121-32/+32
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* cleanup: GIANT macros, rename DEPRECIATE to DEPRECATEdillon2001-07-041-3/+0
| | | | | Move p_giant_optional to proc zero'd section Remove (old) XXX zfree comment in pipe code
* With Alfred's permission, remove vm_mtx in favor of a fine-grained approachdillon2001-07-041-11/+7
| | | | | | | | | (this commit is just the first stage). Also add various GIANT_ macros to formalize the removal of Giant, making it easy to test in a more piecemeal fashion. These macros will allow us to test fine-grained locks to a degree before removing Giant, and also after, and to remove Giant in a piecemeal fashion via sysctl's on those subsystems which the authors believe can operate without Giant.
* Correctly hook up the write kqfilter to pipes.jlemon2001-06-151-5/+7
| | | | Submitted by: Niels Provos <provos@citi.umich.edu>
* The pipe_write() code was locking the pipe without busying it first indillon2001-06-041-5/+20
| | | | | | | certain cases, and a close() by another process could potentially rip the pipe out from under the (blocked) locking operation. Reported-by: Alexander Viro <viro@math.psu.edu>
* whitespace/stylealfred2001-05-241-1/+2
|
* aquire vm_mutex a little bit earlier to protect a pmap call.alfred2001-05-231-1/+1
|
* - Assert that the vm mutex is held in pipe_free_kmem().jhb2001-05-211-1/+6
| | | | | | | | - Don't release the vm mutex early in pipespace() but instead hold it across vm_object_deallocate() if vm_map_find() returns an error and across pipe_free_kmem() if vm_map_find() succeeds. - Add a XXX above a zfree() since zalloc already has its own locking, one would hope that zfree() wouldn't need the vm lock.
* Introduce a global lock for the vm subsystem (vm_mtx).alfred2001-05-191-1/+10
| | | | | | | | | | | | | | | | | | | vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb
* Cleanupalfred2001-05-171-54/+50
| | | | | | | | | | | | | | | | | | | | | Remove comment about setting error for reads on EOF, read returns 0 on EOF so the code should be ok. Remove non-effective priority boost, PRIO+1 doesn't do anything (according to McKusick), if a real priority boost is needed it should have been +4. Style fixes: .) return foo -> return (foo) .) FLAG1|FlAG2 -> FLAG1 | FlAG2 .) wrap long lines .) unwrap short lines .) for(i=0;i=foo;i++) -> for (i = 0; i=foo; i++) .) remove braces for some conditionals with a single statement .) fix continuation lines. md5 couldn't verify the binary because some code had to be shuffled around to address the style issues.
* initialize pipe pointersalfred2001-05-171-0/+1
|
* pipe_create has to zero out the select record earlier to avoidalfred2001-05-171-1/+1
| | | | | | | returning a half-initialized pipe and causing pipeclose() to follow a junk pointer. Discovered by: "Nick S" <snicko@noid.org>
* Remove an 'optimization' I hope to never see again.alfred2001-05-081-89/+111
| | | | | | | | | | | | | | | | | | The pipe code could not handle running out of kva, it would panic if that happened. Instead return ENFILE to the application which is an acceptable error return from pipe(2). There was some slightly tricky things that needed to be worked on, namely that the pipe code can 'realloc' the size of the buffer if it detects that the pipe could use a bit more room. However if it failed the reallocation it could not cope and would panic. Fix this by attempting to grow the pipe while holding onto our old resources. If all goes well free the old resources and use the new ones, otherwise continue to use the smaller buffer already allocated. While I'm here add a few blank lines for style(9) and remove 'register'.
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-2/+2
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
* Extend kqueue down to the device layer.jlemon2001-02-151-8/+23
| | | | Backwards compatible approach suggested by: peter
* Style improvements for last fix. Should be functionally the same.dwmalone2001-01-111-19/+19
| | | | Submitted by: bde
* select() DKI is now in <sys/selinfo.h>.wollman2001-01-091-1/+1
|
* If we failed to allocate the file discriptor for the write end ofdwmalone2001-01-081-0/+8
| | | | | | | | the pipe, then we were corrupting the pipe_zone free list by calling pipeclose on rpipe twice. NULL out rpipe to avoid this. Reviewed by: dillon Reviewed by: iedowse
* This patchset fixes a large number of file descriptor race conditions.dillon2000-11-181-2/+7
| | | | | | | | | | | | Pre-rfork code assumed inherent locking of a process's file descriptor array. However, with the advent of rfork() the file descriptor table could be shared between processes. This patch closes over a dozen serious race conditions related to one thread manipulating the table (e.g. closing or dup()ing a descriptor) while another is blocked in an open(), close(), fcntl(), read(), write(), etc... PR: kern/11629 Discussed with: Alexander Viro <viro@math.psu.edu>
* Pipes are not writeable while a direct write is in progress. However,jlemon2000-09-141-1/+1
| | | | | | the kqueue filter got the sense of the test reversed, so fix it. Spotted by: Michael Elkins <me@sigpipe.org>
* Back out the previous change to the queue(3) interface.jake2000-05-261-1/+1
| | | | | | It was not discussed and should probably not happen. Requested by: msmith and others
* Change the way that the queue(3) structures are declared; don't assume thatjake2000-05-231-1/+1
| | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd
* Include UID and GID information for stat() calls using the values filledchris2000-05-111-2/+3
| | | | | | into the file descriptor data by falloc(). Reviewed by: phk
* Introduce kqueue() and kevent(), a kernel event notification facility.jlemon2000-04-161-0/+67
|
* Fix in-kernel infinite loop in pipe_write() when the reader goes awaydillon2000-03-241-3/+15
| | | | at just the wrong time.
* Use vfs_timestamp() instead of getnanotime() to set timestamps. Thisbde1999-12-261-3/+4
| | | | | | | fixee incoherency of pipe timestamps relative to file timestamps in the usual case where getnanotime() is not used for the latter. (File and pipe timestamps are still incoherent relative to real time unless the vfs_timestamp_precision sysctl is set to 2 or 3).
OpenPOWER on IntegriCloud