Commit Graph

33 Commits

Author SHA1 Message Date
christos
0b60c7be7c If a signal did not fire, restore the original signal mask for pselect/pollts
using a signal mask. Tested by tron.
2011-05-28 15:33:40 +00:00
christos
fc6147c605 No need to mask twice. The setup function does it. 2011-05-18 14:48:04 +00:00
christos
e2543d0362 PR/43625: Mark Davies: Fix pselect(2) to honor the temporary mask. pselect(2)
(and pollts(2)) are similar to sigsuspend(2) in that they temporarily change
the process signal mask and wait for signal delivery. Factor out and share the
code that does this.
2011-05-18 03:51:41 +00:00
rmind
ae3b98c1b5 In a case of direct select, set only masked events, do not wakeup LWP
if no polled/selected events were set; also, count the correct return
value for the select.
2011-03-06 04:41:58 +00:00
rmind
11a35aed4d - Fix a few possible locking issues in execve1() and exit1(). Add a note
that scheduler locks are special in this regard - adaptive locks cannot
  be in the path due to turnstiles.  Randomly spotted/reported by uebayasi@.
- Remove unused lwp_relock() and replace lwp_lock_retry() by simplifying
  lwp_lock() and sleepq_enter() a little.
- Give alllwp its own cache-line and mark lwp_cache pointer as read-mostly.

OK ad@
2010-12-18 01:36:19 +00:00
rmind
0698446b8c Re-enable direct select. 2010-10-15 05:39:19 +00:00
rmind
25ce398524 sel_setevents: fix error - match event-set, as intended.
Spotted by Enami Tsugutomo.
2010-07-12 11:04:25 +00:00
rmind
6269e5af55 Disable direct select for now, since it still brings problems. 2010-07-11 11:17:58 +00:00
rmind
2903a8dcf1 sel_setevents: fix direct injecting of fd bit for select() case. 2010-07-10 17:04:25 +00:00
rmind
21b26eb64e sel_do_scan: do not bother to assert for SEL_SCANNING state before blocking,
as it might also be SEL_BLOCKING due to spurious wake-ups.  That has no harm.
2010-07-08 23:15:23 +00:00
rmind
ce9dfd6a44 Implement direct select/poll support, currently effective for socket and
pipe subsystems.  Avoids overhead of second selscan() on wake-up, and thus
improves performance on certain workloads (especially when polling on many
file-descriptors).  Also, clean-up sys/fd_set.h header and improve macros.

Welcome to 5.99.36!
2010-07-08 12:23:31 +00:00
ad
2e2855a6f2 Make select/poll work with more than 32 CPUs.
No ABI change.
2010-04-25 15:55:24 +00:00
rmind
4fff15550a Add comment about locking. 2009-12-20 23:00:59 +00:00
dsl
ef379fcb95 Bounding the 'nfds' arg to poll() at the current process limit for actual
open files is rather gross - the poll map isn't required to be dense.
Instead limit to a much larger value (1000 + dt_nfiles) so that user
programs cannot allocate indefinite sized blocks of kvm.
If the limit is exceeded, then return EINVAL instead of silently truncating
the list.
(The silent truncation in select isn't quite as bad - although even there
any high bits that are set ought to generate an EBADF response.)
Move the code that converts ERESTART and EWOULDBLOCK into common code.
Effectively fixes PR/17507 since the new limit is unlikely to be detected.
2009-12-12 17:47:05 +00:00
rmind
1283950019 - selcommon/pollcommon: drop redundant l argument.
- Use cached curlwp->l_fd, instead of p->p_fd.
- Inline selscan/pollscan.
2009-11-11 09:48:50 +00:00
rmind
b9a294cf04 - Move inittimeleft() and gettimeleft() to subr_time.c, where they belong.
- Move abstimeout2timo() there too and export.  Use it in lwp_park().
2009-11-01 21:46:09 +00:00
rmind
1ceff942e5 Move common logic in selcommon() and pollcommon() into sel_do_scan().
Avoids code duplication.  XXX: pollsock() should be converted too, except
it's a bit ugly.
2009-11-01 21:14:21 +00:00
rmind
40cf6f3659 Remove uarea swap-out functionality:
- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code.  Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
2009-10-21 21:11:57 +00:00
ad
d991fcb3b6 More changes to improve kern_descrip.c.
- Avoid atomics in more places.
- Remove the per-descriptor mutex, and just use filedesc_t::fd_lock.
  It was only being used to synchronize close, and in any case we needed
  to take fd_lock to free the descriptor slot.
- Optimize certain paths for the <NDFDFILE case.
- Sprinkle more comments and assertions.
- Cache more stuff in filedesc_t.
- Fix numerous minor bugs spotted along the way.
- Restructure how the open files array is maintained, for clarity and so
  that we can eliminate the membar_consumer() call in fd_getfile().  This is
  mostly syntactic sugar; the main functional change is that fd_nfiles now
  lives alongside the open file array.

Some measurements with libmicro:

- simple file syscalls are like close() are between 1 to 10% faster.
- some nice improvements, e.g. poll(1000) which is ~50% faster.
2009-05-24 21:41:25 +00:00
christos
2b1b4bc6ef Move the internal poll/select related API's to use timespec instead
of timeval (rides the uvm bump).
2009-03-29 19:21:19 +00:00
ad
7364cd36a3 Allocate sleep queue locks with mutex_obj_alloc. Reduces memory usage
on !MP kernels, and reduces false sharing on MP ones.
2009-03-21 13:11:14 +00:00
christos
461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
yamt
bd2755f5a1 pollcommon: use a more appropriate type than char[]. 2008-11-20 01:25:28 +00:00
ad
1ec58d56ef - Rename cpu_lookup_byindex() to cpu_lookup(). The hardware ID isn't of
interest to MI code. No functional change.
- Change /dev/cpu to operate on cpu index, not hardware ID. Now cpuctl
  shouldn't print confused output.
2008-10-15 08:13:17 +00:00
rmind
af4e8e9ea7 Check the result of allocation in the cases where size is passed by user. 2008-06-04 13:02:41 +00:00
ad
93e0e98369 Take the mutex pointer and waiters count out of sleepq_t: the values can
be or are maintained elsewhere. Now a sleepq_t is just a TAILQ_HEAD.
2008-05-26 12:08:38 +00:00
ad
83bf8c56bb PR kern/38547 select/poll do not set l_kpriority
Among other things this could have made X11 seem sluggish.
2008-04-30 12:45:21 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad
284c2b9aef Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
2008-04-24 18:39:20 +00:00
yamt
70f8f58cac s/selwakeup/selnotify/ in a comment. 2008-04-17 14:02:24 +00:00
ad
bd9b59aafe selwakeup: convert a while() loop into a do/while() since the first test
isn't needed.
2008-03-29 14:08:35 +00:00
ad
feb4783fdf Replace use of CACHE_LINE_SIZE in some obvious places. 2008-03-27 18:30:15 +00:00
ad
3acbed8e48 Split select/poll into their own file. 2008-03-23 14:02:49 +00:00