Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109368592
D39584.id120470.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D39584.id120470.diff
View Options
diff --git a/lib/libthr/libthr.3 b/lib/libthr/libthr.3
--- a/lib/libthr/libthr.3
+++ b/lib/libthr/libthr.3
@@ -216,6 +216,12 @@
.Xr _umtx_op
for more details.
The default value is large enough for most useful applications.
+.It Dv kern.ipc.umtx_min_timeout
+The minimal amount of time, in nanoseconds, the thread is required to sleep
+for pthread operations specifying a timeout.
+If the operation requests a timeout less than the value of the MIB,
+it is silently increased to the value.
+The value of zero means no limit.
.It Dv debug.umtx.robust_faults_verbose
A non zero value makes kernel emit some diagnostic when the robust
mutexes unlock was prematurely aborted after detecting some inconsistency,
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -151,6 +151,26 @@
&umtx_max_rb, 0,
"Maximum number of robust mutexes allowed for each thread");
+static sbintime_t umtx_min_timeout;
+static int
+sysctl_umtx_min_timeout(SYSCTL_HANDLER_ARGS)
+{
+ int error, val;
+
+ val = sbttons(umtx_min_timeout);
+ error = sysctl_handle_int(oidp, &val, 0, req);
+ if (error != 0 || req->newptr == NULL)
+ return (error);
+ if (val < 0)
+ return (EINVAL);
+ umtx_min_timeout = nstosbt(val);
+ return (0);
+}
+SYSCTL_PROC(_kern_ipc, OID_AUTO, umtx_min_timeout,
+ CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, NULL, 0,
+ sysctl_umtx_min_timeout, "U",
+ "Minimal timeout for umtx in nanoseconds");
+
static uma_zone_t umtx_pi_zone;
static struct umtxq_chain umtxq_chains[2][UMTX_CHAINS];
static MALLOC_DEFINE(M_UMTX, "umtx", "UMTX queue memory");
@@ -700,6 +720,18 @@
(umtxtime->_flags & UMTX_ABSTIME) != 0, &umtxtime->_timeout);
}
+static void
+umtx_abs_timeout_enforce_min(sbintime_t *sbt)
+{
+ sbintime_t when;
+
+ if (__predict_false(umtx_min_timeout != 0)) {
+ when = sbinuptime() + umtx_min_timeout;
+ if (*sbt < when)
+ *sbt = when;
+ }
+}
+
static int
umtx_abs_timeout_getsbt(struct umtx_abs_timeout *timo, sbintime_t *sbt,
int *flags)
@@ -739,6 +771,7 @@
return (0);
}
*sbt = bttosbt(bt);
+ umtx_abs_timeout_enforce_min(sbt);
/*
* Check if the absolute time should be aligned to
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Feb 5, 4:02 AM (7 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16466692
Default Alt Text
D39584.id120470.diff (2 KB)
Attached To
Mode
D39584: umtx: allow to configure minimal timeout (in nanoseconds)
Attached
Detach File
Event Timeline
Log In to Comment