summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2024-08-11 16:46:05 +0100
committerAndrew Clayton <a.clayton@nginx.com>2024-08-19 23:29:40 +0100
commitf38201c2a144fb28978eabb32a3a080874f92775 (patch)
treefd88edfa2ac3dc0522d00726d6bce1e5f2e2cdf2
parentae4795aa182a27fb1b091670f4831e345614a09c (diff)
downloadunit-f38201c2a144fb28978eabb32a3a080874f92775.tar.gz
unit-f38201c2a144fb28978eabb32a3a080874f92775.tar.bz2
auto: Add a check for Linux's sched_getaffinity(2)
This will help to better determine the number of router threads to create in certain situations. Unlike sysconf(_SC_NPROCESSORS_ONLN) this takes into account per-process cpu allowed masks as set by sched_setaffinity(2)/cpusets etc. So while a system may have 64 on-line cpu's, Unit itself may be limited to using just four of them in which case we should create four extra router threads, not sixty-four! Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
-rw-r--r--auto/sched19
-rwxr-xr-xconfigure1
2 files changed, 20 insertions, 0 deletions
diff --git a/auto/sched b/auto/sched
new file mode 100644
index 00000000..a6a4499b
--- /dev/null
+++ b/auto/sched
@@ -0,0 +1,19 @@
+# Copyright (C) Andrew Clayton
+# Copyright (C) NGINX, Inc.
+
+
+nxt_feature="Linux sched_getaffinity()"
+nxt_feature_name=NXT_HAVE_LINUX_SCHED_GETAFFINITY
+nxt_feature_run=no
+nxt_feature_incs=
+nxt_feature_libs=
+nxt_feature_test="#define _GNU_SOURCE
+ #include <sched.h>
+
+ int main(void) {
+ cpu_set_t set;
+
+ sched_getaffinity(0, sizeof(set), &set);
+ return 0;
+ }"
+. auto/feature
diff --git a/configure b/configure
index 4ad0dcdc..6929d41d 100755
--- a/configure
+++ b/configure
@@ -135,6 +135,7 @@ fi
. auto/cgroup
. auto/isolation
. auto/capability
+. auto/sched
case "$NXT_SYSTEM_PLATFORM" in