Commit Graph

78 Commits

Author SHA1 Message Date
cem
e26092ad11 sleep(9), sleepqueue(9): const'ify wchan pointers
_sleep(9), wakeup(9), sleepqueue(9), et al do not dereference or modify the
channel pointers provided in any way; they are merely used as intptrs into a
dictionary structure to match waiters with wakers.  Correctly annotate this
such that _sleep() and wakeup() may be used on const pointers without
invoking ugly patterns like __DECONST().  Plumb const through all of the
underlying sleepqueue bits.

No functional change.

Reviewed by:	rlibby
Discussed with:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D22914
2019-12-24 16:19:33 +00:00
mav
da627eba88 Add wakeup_any(), cheaper wakeup_one() for taskqueue(9).
wakeup_one() and underlying sleepq_signal() spend additional time trying
to be fair, waking thread with highest priority, sleeping longest time.
But in case of taskqueue there are many absolutely identical threads, and
any fairness between them is quite pointless.  It makes even worse, since
round-robin wakeups not only make previous CPU affinity in scheduler quite
useless, but also hide from user chance to see CPU bottlenecks, when
sequential workload with one request at a time looks evenly distributed
between multiple threads.

This change adds new SLEEPQ_UNFAIR flag to sleepq_signal(), making it wakeup
thread that went to sleep last, but no longer in context switch (to avoid
immediate spinning on the thread lock).  On top of that new wakeup_any()
function is added, equivalent to wakeup_one(), but setting the flag.
On top of that taskqueue(9) is switchied to wakeup_any() to wakeup its
threads.

As result, on 72-core Xeon v4 machine sequential ZFS write to 12 ZVOLs
with 16KB block size spend 34% less time in wakeup_any() and descendants
then it was spending in wakeup_one(), and total write throughput increased
by ~10% with the same as before CPU usage.

Reviewed by:	markj, mmacy
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D20669
2019-06-20 01:15:33 +00:00
hselasky
ef1e592a79 Document pause_sig(9) and update prototypes for existing pause(9) and
pause_sbt(9) functions.

MFC after:	1 week
Suggested by:	cem@
Sponsored by:	Mellanox Technologies
2018-03-03 23:08:49 +00:00
vangyzen
47fc9e6df6 Add missing pieces of r315280
I moved this branch from github to a private server, and pulled from the
wrong one when committing r315280, so I failed to include two recent commits.
Thankfully, they were only cosmetic and were included in the review.
Specifically:

Add documentation, polish comments, and improve style(9).

Tested by:	pho (r315280)
MFC after:	2 weeks
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D9791
2017-03-14 22:02:02 +00:00
markj
ebd4141174 Remove a reference to the PBDRY flag, which itself was removed in r248470.
MFC after:	3 days
2015-05-25 01:09:18 +00:00
bapt
21f6fe7ae4 use .Mt to mark up email addresses consistently (part6)
PR:		191174
Submitted by:	Franco Fichtner <franco at lastsummer.de>
2014-06-26 21:44:30 +00:00
mjacob
68a04d4c0b Correct sentence syntax too. 2013-08-17 01:17:51 +00:00
obrien
e5edc7c263 Correct spelling. 2013-08-17 01:02:04 +00:00
davide
2c8bc5c70c MFcalloutng:
Dcoument the new functions added to condvar(9), sleep(9), sleepqueue(9)
KPIs. Also document recent changes in timeout(9) and eventtimers(4).
2013-03-04 19:10:39 +00:00
bjk
604b10857d Fix some minor inaccuracies introduced in r243251.
Also correct the comment in kern_synch.c which was the source of the
problematic text.

Reviewed by:	kib (previous version)
Approved by:	hrs (mentor)
2013-01-05 00:23:26 +00:00
bjk
3566a308c1 Improve grammar.
Approved by:	hrs (mentor)
2012-11-18 22:52:17 +00:00
eadler
1ef5fe44d3 Remove trailing whitespace per mdoc lint warning
Disussed with:	gavin
No objection from:	doc
Approved by:	joel
MFC after:	3 days
2012-03-29 05:02:12 +00:00
jmg
b9c3284acc document that even when wakeup_one is used to wakeup, msleep and friends
may still return a non-zero value... You are not guaranteed to get a one
to one mapping between wakeup_one and zero return values...

Reviewed by:	kib
MFC after:	3 days
2011-01-19 22:16:42 +00:00
uqs
3960614646 mdoc: order prologue macros consistently by Dd/Dt/Os
Although groff_mdoc(7) gives another impression, this is the ordering
most widely used and also required by mdocml/mandoc.

Reviewed by:	ru
Approved by:	philip, ed (mentors)
2010-04-14 19:08:06 +00:00
kib
061d83630f Document PBDRY and SLEEPQ_STOP_ON_BDRY.
Requested and reviewed by:	attilio
MFC after:	3 days
2009-12-12 22:08:37 +00:00
jhb
e306c86e1b Permit Giant to be passed as the explicit interlock either to
msleep/mtx_sleep or the various cv_*wait*() routines.  Currently, the
"unlock" behavior of PDROP and cv_wait_unlock() with Giant is not
permitted as it is will be confusing since Giant is fully unrecursed and
unlocked during a thread sleep.

This is handy for subsystems which wish to allow unlocked drivers to
continue to use Giant such as CAM, the new TTY layer, and the new USB
stack.  CAM currently uses a hack that I told Scott to use because I
really didn't want to permit this behavior, and the TTY and USB patches
both have various patches to permit this.

MFC after:	2 weeks
2008-08-07 21:00:13 +00:00
imp
30afe603df Add note about PZERO being obsolete, because so much code uses it.
Feel free to improve the verbage, since this was a compromise between
conflicting feedback I got on my original version.
2008-04-04 16:59:58 +00:00
julian
3f8481620d Add some cross references to locking.9 from related pages. 2007-03-30 18:07:26 +00:00
grog
c2c65e0dd6 Typo. 2007-03-13 03:56:16 +00:00
jhb
f5e3969340 Allow threads to atomically release rw and sx locks while waiting for an
event.  Locking primitives that support this (mtx, rw, and sx) now each
include their own foo_sleep() routine.
- Rename msleep() to _sleep() and change it's 'struct mtx' object to a
  'struct lock_object' pointer.  _sleep() uses the recently added
  lc_unlock() and lc_lock() function pointers for the lock class of the
  specified lock to release the lock while the thread is suspended.
- Add wrappers around _sleep() for mutexes (mtx_sleep()), rw locks
  (rw_sleep()), and sx locks (sx_sleep()).  msleep() still exists and
  is now identical to mtx_sleep(), but it is deprecated.
- Rename SLEEPQ_MSLEEP to SLEEPQ_SLEEP.
- Rewrite much of sleep.9 to not be msleep(9) centric.
- Flesh out the 'RETURN VALUES' section in sleep.9 and add an 'ERRORS'
  section.
- Add __nonnull(1) to _sleep() and msleep_spin() so that the compiler will
  warn if you try to pass a NULL wait channel.  The functions already have
  a KASSERT to that effect.
2007-03-09 22:41:01 +00:00
grog
15babbae24 Another typo.
Spotted by:             ru
Another pointy hat to:  grog
2007-03-05 05:59:49 +00:00
grog
7df8cf04c7 Cosmetics: remove trailing white space, wrap over-long lines.
Pointy hat to:  grog
2007-03-05 00:27:30 +00:00
grog
3204d2429d Rearrange function descriptions in more logical order.
Be less alarmist about the dangers of abusing wakeup_one().

Requested by: kris, imp
2007-03-04 23:42:58 +00:00
grog
2b6f6866c4 Furhter clarifications:
- the issues with wakeup_one are due to address space clashes between
  unrelated groups of threads.
- sleep() was removed in FreeBSD 2.2.
- date the page today, not 4 days ago.
- replace grammatically correct "woken" with "woken up" for
  consistency with the function name.
2007-02-27 23:09:31 +00:00
jhb
efdf2cb2b3 In FreeBSD 5.x+, sleep/wakeup operate on threads, not processes. 2007-02-27 16:32:55 +00:00
ru
b8587b0055 Fix markup and grammar bugs in recent revisions. 2007-02-27 16:21:01 +00:00
grog
128ac1d595 Update HISTORY.
Reviewed by:	dmr
2007-02-27 05:39:22 +00:00
grog
502eb2ec0e Add warning about deadlocks created by use of wakeup_one. 2007-02-27 02:51:41 +00:00
jhb
401f7aaf8a Add a new kernel sleep function pause(9). pause(9) is for places that
want an equivalent of DELAY(9) that sleeps instead of spins.  It accepts
a wmesg and a timeout and is not interrupted by signals.  It uses a private
wait channel that should never be woken up by wakeup(9) or wakeup_one(9).

Glanced at by:	phk
2007-02-23 16:22:09 +00:00
ru
5b7cf06c1d Markup fixes. 2006-09-18 15:24:20 +00:00
jhb
d989c9d478 - Sleep/wakeup operate on threads now, not processes.
- Describe msleep() as the primary sleep function now rather than tsleep()
  and describe tsleep() and msleep_spin() as variations.
- Try to make the description of msleep() a bit closer to English
  (sentences with actual subjects, etc.)
- Document that a priority of 0 now prevents the thread's priority from
  being altered.
- Add a history note for wakeup_one().
2006-04-17 19:11:12 +00:00
jmg
e38adb7f1e allow timo to be 0 when mtx is not NULL (KASSERT allowed this as
pointed out by jhb)

Reviewed by:	jhb
MFC after:	3 days
2006-02-22 20:50:33 +00:00
jhb
834b4a427c - Don't list sleep() in the NAME section as we haven't had a sleep()
function in years.
- Change the 'ident' paramters to 'wchan' to match <sys/systm.h>.
- Use 'otherwise' in place of 'else' in one place so that this reads like
  English rather than C.
- Document the new msleep_spin() function.
- Add history notes for msleep() and msleep_spin().
2006-01-03 17:00:38 +00:00
hmp
6b954a1933 Use 'manual page' instead of 'man page' for consistency.
Approved by:	re (hrs)
2005-06-28 20:15:19 +00:00
cperciva
69e3b33000 Point out that tsleep(... , 0) is not permitted if the Giant lock is not
held.  (It causes a "sleeping without a mutex" assertion failure in
msleep.)

MFC after:	3 days
2005-01-07 02:41:45 +00:00
maxim
180ac35cac o Be consistent with the declaration: pri -> priority.
Spotted by:	Dmitry Rzhavin
MFC after:	1 week
2004-02-17 13:31:36 +00:00
hmp
9b05395427 Mdoc Janitor:
* Fix hard sentence breaks.
2003-10-23 02:33:03 +00:00
hmp
5d71788a05 Some mdoc(7) fixes:
Nuke incorrect usage of .Ar; replace it with .Vt, .Va or .Fa appropriately.
The .Ar mdoc(7) specifier should only be used when displaying command line
arguments.

Approved by:	des (mentor)
2003-05-31 14:07:25 +00:00
jhb
15ba1fce6f - Use better terminology when describing mutex operations in msleep(9)'s
description.
- Remove some bogus commas.
- Use the past tense when referring to the removal of the sleep() function
  since it happened quite a while ago and since the previous sentence in the
  paragraph already uses the past tense.

Approved by:	re (rwatson)
2003-05-16 15:52:32 +00:00
ru
0dea541567 mdoc(7) police: Scheduled sweep. 2003-02-24 22:53:26 +00:00
guido
99ddf819f9 sleep -> msleep 2003-02-04 08:53:45 +00:00
trhodes
3d5980933a mdoc(4) police: Markup. Fix 1 hard sentence break. 2003-01-03 23:06:10 +00:00
trhodes
96f6c756ae mdoc(7) police: Remove hard sentence breaks. 2003-01-03 22:39:39 +00:00
trhodes
0c2fa737a7 mdoc(7) police: markup nits. 2003-01-03 22:37:10 +00:00
ru
22b01e0e54 mdoc(7) police: macroize UNIX. 2002-03-18 10:43:49 +00:00
jdp
636727a3bb Fix speling errur. 2001-12-05 02:55:23 +00:00
ru
623da62a5a mdoc(7) police: Use the new .In macro for #include statements. 2001-10-01 16:09:29 +00:00
jhb
98adb2ab0c Remove references to asleep/await. 2001-08-23 23:37:31 +00:00
ru
4345758876 mdoc(7) police:
Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text.
Not only this slows down the mdoc(7) processing significantly, but it also
has an undesired (in this case) effect of disabling hyphenation within the
entire enclosed block.
2001-08-07 15:48:51 +00:00
schweikh
511e378b14 Removed whitespace at end-of-line; no content changes. I simply did
cd src/share; find man[1-9] -type f|xargs perl -pi -e 's/[ \t]+$//'

BTW, what editors are the culprits? I'm using vim and it shows
me whitespace at EOL in troff files with a thick blue block...

Reviewed by:	Silence from cvs diff -b
MFC after:	7 days
2001-07-14 19:41:16 +00:00