Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Aug 2018 10:34:53 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r337034 - in stable/10: share/man/man9 sys/kern sys/sys
Message-ID:  <201808011034.w71AYrVX069341@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Wed Aug  1 10:34:53 2018
New Revision: 337034
URL: https://svnweb.freebsd.org/changeset/base/337034

Log:
  MFC r330349 and r330362:
  
  Allow pause_sbt() to catch signals during sleep by passing C_CATCH flag.
  Define pause_sig() function macro helper similarly to other kernel functions
  which catch signals. Update outdated function description.
  
  Document pause_sig(9) and update prototypes for existing pause(9) and
  pause_sbt(9) functions.
  
  Discussed with:	kib@
  Suggested by:	cem@
  Sponsored by:	Mellanox Technologies

Modified:
  stable/10/share/man/man9/Makefile
  stable/10/share/man/man9/sleep.9
  stable/10/sys/kern/kern_synch.c
  stable/10/sys/sys/callout.h
  stable/10/sys/sys/systm.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man9/Makefile
==============================================================================
--- stable/10/share/man/man9/Makefile	Wed Aug  1 08:24:34 2018	(r337033)
+++ stable/10/share/man/man9/Makefile	Wed Aug  1 10:34:53 2018	(r337034)
@@ -1249,6 +1249,7 @@ MLINKS+=sleep.9 msleep.9 \
 	sleep.9 msleep_spin.9 \
 	sleep.9 msleep_spin_sbt.9 \
 	sleep.9 pause.9 \
+	sleep.9 pause_sig.9 \
 	sleep.9 pause_sbt.9 \
 	sleep.9 tsleep.9 \
 	sleep.9 tsleep_sbt.9 \

Modified: stable/10/share/man/man9/sleep.9
==============================================================================
--- stable/10/share/man/man9/sleep.9	Wed Aug  1 08:24:34 2018	(r337033)
+++ stable/10/share/man/man9/sleep.9	Wed Aug  1 10:34:53 2018	(r337034)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 19, 2013
+.Dd August 1, 2018
 .Dt SLEEP 9
 .Os
 .Sh NAME
@@ -34,6 +34,7 @@
 .Nm msleep_spin ,
 .Nm msleep_spin_sbt ,
 .Nm pause ,
+.Nm pause_sig ,
 .Nm pause_sbt ,
 .Nm tsleep ,
 .Nm tsleep_sbt ,
@@ -53,9 +54,11 @@
 .Ft int
 .Fn msleep_spin_sbt "void *chan" "struct mtx *mtx" "const char *wmesg" \
 "sbintime_t sbt" "sbintime_t pr" "int flags"
-.Ft void
+.Ft int
 .Fn pause "const char *wmesg" "int timo"
-.Ft void
+.Ft int
+.Fn pause_sig "const char *wmesg" "int timo"
+.Ft int
 .Fn pause_sbt "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" \
  "int flags"
 .Ft int
@@ -73,6 +76,8 @@ The functions
 .Fn msleep ,
 .Fn msleep_spin ,
 .Fn pause ,
+.Fn pause_sig ,
+.Fn pause_sbt ,
 .Fn wakeup ,
 and
 .Fn wakeup_one
@@ -82,8 +87,10 @@ external event, it is put to sleep by
 .Fn tsleep ,
 .Fn msleep ,
 .Fn msleep_spin ,
+.Fn pause ,
+.Fn pause_sig ,
 or
-.Fn pause .
+.Fn pause_sbt .
 Threads may also wait using one of the locking primitive sleep routines
 .Xr mtx_sleep 9 ,
 .Xr rw_sleep 9 ,
@@ -261,6 +268,11 @@ The thread can not be awakened early by signals or cal
 .Fn wakeup
 or
 .Fn wakeup_one .
+The
+.Fn pause_sig
+function is a variant of
+.Fn pause
+which can be awakened early by signals.
 .Pp
 The
 .Fn wakeup_one
@@ -380,6 +392,10 @@ The
 .Fn pause
 function appeared in
 .Fx 7.0 .
+The
+.Fn pause_sig
+function appeared in
+.Fx 12.0 .
 .Sh AUTHORS
 .An -nosplit
 This manual page was written by

Modified: stable/10/sys/kern/kern_synch.c
==============================================================================
--- stable/10/sys/kern/kern_synch.c	Wed Aug  1 08:24:34 2018	(r337033)
+++ stable/10/sys/kern/kern_synch.c	Wed Aug  1 10:34:53 2018	(r337034)
@@ -334,16 +334,16 @@ msleep_spin_sbt(void *ident, struct mtx *mtx, const ch
 }
 
 /*
- * pause() delays the calling thread by the given number of system ticks.
- * During cold bootup, pause() uses the DELAY() function instead of
- * the tsleep() function to do the waiting. The "timo" argument must be
- * greater than or equal to zero. A "timo" value of zero is equivalent
- * to a "timo" value of one.
+ * pause_sbt() delays the calling thread by the given signed binary
+ * time. During cold bootup, pause_sbt() uses the DELAY() function
+ * instead of the _sleep() function to do the waiting. The "sbt"
+ * argument must be greater than or equal to zero. A "sbt" value of
+ * zero is equivalent to a "sbt" value of one tick.
  */
 int
 pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
 {
-	KASSERT(sbt >= 0, ("pause: timeout must be >= 0"));
+	KASSERT(sbt >= 0, ("pause_sbt: timeout must be >= 0"));
 
 	/* silently convert invalid timeouts */
 	if (sbt == 0)
@@ -364,7 +364,8 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_
 			DELAY(sbt);
 		return (0);
 	}
-	return (_sleep(&pause_wchan[curcpu], NULL, 0, wmesg, sbt, pr, flags));
+	return (_sleep(&pause_wchan[curcpu], NULL,
+	    (flags & C_CATCH) ? PCATCH : 0, wmesg, sbt, pr, flags));
 }
 
 /*

Modified: stable/10/sys/sys/callout.h
==============================================================================
--- stable/10/sys/sys/callout.h	Wed Aug  1 08:24:34 2018	(r337033)
+++ stable/10/sys/sys/callout.h	Wed Aug  1 10:34:53 2018	(r337034)
@@ -58,6 +58,7 @@
 #define	C_HARDCLOCK		0x0100 /* align to hardclock() calls */
 #define	C_ABSOLUTE		0x0200 /* event time is absolute. */
 #define	C_PRECALC		0x0400 /* event time is pre-calculated. */
+#define	C_CATCH			0x0800 /* catch signals, used by pause_sbt(9) */
 
 struct callout_handle {
 	struct callout *callout;

Modified: stable/10/sys/sys/systm.h
==============================================================================
--- stable/10/sys/sys/systm.h	Wed Aug  1 08:24:34 2018	(r337033)
+++ stable/10/sys/sys/systm.h	Wed Aug  1 10:34:53 2018	(r337034)
@@ -386,6 +386,8 @@ int	pause_sbt(const char *wmesg, sbintime_t sbt, sbint
 	    int flags);
 #define	pause(wmesg, timo)						\
 	pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK)
+#define	pause_sig(wmesg, timo)						\
+	pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK | C_CATCH)
 #define	tsleep(chan, pri, wmesg, timo)					\
 	_sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo),		\
 	    0, C_HARDCLOCK)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808011034.w71AYrVX069341>