Commit Graph

129 Commits

Author SHA1 Message Date
uebayasi 9d567f003d Include internal definitions (uvm/uvm.h) only where necessary. 2011-01-17 07:13:31 +00:00
pgoyette 8be3483a20 Keep condvar wmesg within 8-char limit 2010-08-11 11:46:32 +00:00
dsl 2a54322c7b If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567
2009-12-20 09:36:05 +00:00
dsl bc86c9b425 Don't ERESTART write() calls for now.
I suspect some programs don't allow for the partial transfer.
2009-12-15 18:35:18 +00:00
dsl 723a159171 Another, better, fix for PR/26567.
Only sleep once within each pipe_read/pipe_write call.
If there is no data/space available after we wakeup return ERESTART so
then the 'fd' number is validated again.
A simple broadcast of the cvs is then enough to evict the correct threads
when close() is called from an active thread.
2009-12-13 20:02:23 +00:00
dsl e19cad8fcc Revert most of the previous change.
Only one fd needs clobbering, not all fds that reference the pipe.
This may be what ad@ realised when he tried to add the same code to
sockets. Unfixes part of PR/26567.
2009-12-13 18:27:02 +00:00
dsl c7517e0921 Add support for unblocking read/write when close called.
Fixes PR/26567 for pipes.
(NB ad backed out the fix for sockets)
2009-12-12 21:28:04 +00:00
dsl eff3e2124a Avoid leaking a mutex_obj when pipe_create() fails for the read pipe.
Remove the unused argument from pipeclose().
2009-12-10 20:55:17 +00:00
dsl 7a42c833db Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.
2009-12-09 21:32:58 +00:00
dsl 43bac9730d Correct comment, pipelock() no longer releases the mutex. 2009-12-06 20:26:55 +00:00
rmind e24f6c0896 Turn off pipe's direct I/O again, it corrupts the data (although build and
various activity survived while testing this).  Corruptions also happen on
sparc64 where emap is not in effect, therefore bugs are in direct I/O code.
2009-08-31 20:48:14 +00:00
rmind 924c9047ea - Re-enable direct I/O with emap for pipe.
- While not used, #ifdef KVA allocation in emap (so it wont burn the space).
2009-08-29 00:06:43 +00:00
rmind 569aa0de8b Revert previous: disable direct I/O on pipe, it cought a problem with emap. 2009-07-15 21:09:41 +00:00
rmind f80b636295 Re-enable direct I/O for pipe:
- Larger writes (2 or more pages) will use emap.
- Might help to catch rare hang (some very old bug).
2009-07-13 02:49:08 +00:00
rmind 5c68e5d0ee Ephemeral mapping (emap) implementation. Concept is based on the idea that
activity of other threads will perform the TLB flush for the processes using
emap as a side effect.  To track that, global and per-CPU generation numbers
are used.  This idea was suggested by Andrew Doran; various improvements to
it by me.  Notes:

- For now, zero-copy on pipe is not yet enabled.
- TCP socket code would likely need more work.
- Additional UVM loaning improvements are needed.

Proposed on <tech-kern>, silence there.
Quickly reviewed by <ad>.
2009-06-28 15:18:50 +00:00
rmind 7b7c187a92 Amend previous. 2009-06-28 14:34:48 +00:00
rmind 39b52425ff - Convert some #ifdefs to KASSERT()s.
- KNF, style, no parameters in function declarations.
- No functional changes.
2009-06-28 14:22:11 +00:00
christos 86ba58fd64 Fix locking as Andy explained. Also fill in uid and gid like sys_pipe did. 2009-04-11 23:05:26 +00:00
christos bb55634e9d rename ctime to btime for consistency. 2009-04-11 15:46:18 +00:00
christos bb2d65e097 - maintain timespec internally.
- set birthtime too.
2009-04-11 14:42:28 +00:00
ad c6367674d6 Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0	accept(fd, ...)
thr1	close(fd)
2009-04-04 10:12:51 +00:00
enami 60ebbc4e81 The knote objects attached by peer will still be linked in our list
if we are closed before the peer.  So, remove them.  It didn't matter
when pipe objects are directly returned to pool, but nowadays they
are cached.
2009-02-15 00:07:54 +00:00
enami e1be06d405 Instead of missing NULL check in pipe_create, let the pipe_ctor to wait
on buffer allocation.  The other allocation is simply an optimization,
so leave it as is.
2009-02-06 23:04:57 +00:00
ad 58fb9db514 Apply pipe patch posted to tech-kern, slightly updated:
- Cache kva.
- Convert to use mutex_obj_alloc().
- Make better use of pool_cache.

Also:

Disable direct transfers for the moment. I believe there may be a bug that
can cause transfers to stall when switching between direct/buffered access.
I think this has most recently been run into on 'denver' but I have seen it
as far back as 3.1.

(As an aside, direct is a not a clear win on modern systems with large cache
and high TLB invalidation overhead. Particularly so on MP systems, although
micro benchmarks may report otherwise because they typically do not tax the
system. Anyone want to write a decent benchmark?)
2009-02-01 18:23:04 +00:00
yamt e80f4e9ccb fix inverted POLL_ directions. 2009-01-20 14:51:43 +00:00
yamt 62bd2e85ef pipeselwakeup: now POLL_HUP != POLL_ERR. remove unnecessary #if. 2009-01-20 14:50:22 +00:00
pooka 66523e99f5 remove M_PIPE (hi rmind!) 2008-09-17 14:00:41 +00:00
rmind 7e456140b3 Replace malloc with kmem. 2008-09-06 23:05:52 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad feb4783fdf Replace use of CACHE_LINE_SIZE in some obvious places. 2008-03-27 18:30:15 +00:00
ad a9ca7a3734 Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
2008-03-21 21:54:58 +00:00
rmind c6186face4 Welcome to 4.99.55:
- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call.  It will
  indicate which event (POLL_IN, POLL_OUT, etc) happen.  If unknown,
  zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
2008-03-01 14:16:49 +00:00
yamt cfc68c3385 fix a livelock with multiple readers by separating condvar. 2008-02-29 12:04:48 +00:00
chris 2ff98bbc26 Add missing pmap_update(pmap_kernel()); calls after pmap_kenter_pa and
pmap_remove.
2008-02-23 16:05:17 +00:00
ad 5ba557a53c - Update global counters using atomics before allocating. When freeing,
update the couters afterwards.
- Cosmetic / code generation changes.
2008-01-28 20:01:50 +00:00
ad 0664a0459b Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
2008-01-04 21:17:40 +00:00
yamt c68e4b1c69 remove PIPE_WANTW, PIPE_WANTR and PIPE_WANTCLOSE. cv_waiters is enough.
this fixes a deadlock between pipe_direct_write and pipeclose.

XXX this code should be simplified.
it's mostly pointless to have two struct pipes linked together,
esp. when we don't support bi-directional pipes.
2008-01-02 19:16:00 +00:00
ad afb5e69ead Pull up 1.87.2.8. 2007-12-28 13:11:16 +00:00
ad fb0185d80e pipe_direct_write: kill a mutex_exit() that escaped. 2007-12-27 15:25:22 +00:00
ad ea3f10f7e0 Merge more changes from vmlocking2, mainly:
- Locking improvements.
- Use pool_cache for more items.
2007-12-26 16:01:34 +00:00
dsl 7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
pooka 4e38160d4d Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
2007-12-05 17:19:46 +00:00
ad d18c6ca4de Merge from vmlocking:
- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
2007-11-07 00:23:13 +00:00
ad 604692c130 Use selinit() / seldestroy(). 2007-09-25 13:53:31 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
hubertf 3bfc0c42ee Remove duplicate #include's
From: Slava Semushin <php-coder@altlinux.ru>
2007-03-26 22:52:44 +00:00
ad bb25376cda Fix a deadlock w/kqueue that was introduced with the last set of changes.
Spotted by yamt@.
2007-03-23 18:33:43 +00:00
ad c81da4c01d Put a lock around pipe->pipe_peer. 2007-03-12 21:31:03 +00:00
ad b171797731 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 19:05:05 +00:00
ad 7888016cf9 Use mutexes & condvars. 2007-03-12 16:20:53 +00:00