aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2023-02-20 17:28:36 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2023-02-20 17:28:36 +0000
commit24a7d13928234ff989bdbf8a5f1397b94f086bdd (patch)
tree7f03f97778bb9f252a5386055f1e2c6860e72d59
parent5a33e9990b6745b5b659229ab33661b4811f8ddb (diff)
downloadsrc-24a7d13928234ff989bdbf8a5f1397b94f086bdd.tar.gz
src-24a7d13928234ff989bdbf8a5f1397b94f086bdd.zip
cpuset: Adapt sched_affinity compat shims to the stable/13
Use compat shims to run the stable/13 world on a kernels which does not support CPU_WHICH_TIDPID. This is direct commit to the stable/13. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D38677
-rw-r--r--lib/libc/gen/sched_getaffinity.c6
-rw-r--r--lib/libc/gen/sched_setaffinity.c6
-rw-r--r--sys/sys/param.h1
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/libc/gen/sched_getaffinity.c b/lib/libc/gen/sched_getaffinity.c
index fce47fbfc0d2..0275a2190afa 100644
--- a/lib/libc/gen/sched_getaffinity.c
+++ b/lib/libc/gen/sched_getaffinity.c
@@ -38,9 +38,11 @@ int
sched_getaffinity(pid_t pid, size_t cpusetsz, cpuset_t *cpuset)
{
cpuwhich_t which;
- int error;
+ int error, osrel;
- if (__getosreldate() < P_OSREL_TIDPID) {
+ osrel = __getosreldate();
+ if (osrel < P_OSREL_TIDPID_13 || (osrel < P_OSREL_TIDPID &&
+ P_OSREL_MAJOR(osrel) == P_OSREL_MAJOR(P_OSREL_TIDPID))) {
if (pid == 0 || pid > _PID_MAX)
which = CPU_WHICH_TID;
else
diff --git a/lib/libc/gen/sched_setaffinity.c b/lib/libc/gen/sched_setaffinity.c
index b878e1affc41..7fbebbfe6b6e 100644
--- a/lib/libc/gen/sched_setaffinity.c
+++ b/lib/libc/gen/sched_setaffinity.c
@@ -41,10 +41,12 @@ sched_setaffinity(pid_t pid, size_t cpusetsz, const cpuset_t *cpuset)
static int mp_maxid;
cpuwhich_t which;
cpuset_t c;
- int error, lbs, cpu;
+ int error, lbs, cpu, osrel;
size_t len, sz;
- if (__getosreldate() < P_OSREL_TIDPID) {
+ osrel = __getosreldate();
+ if (osrel < P_OSREL_TIDPID_13 || (osrel < P_OSREL_TIDPID &&
+ P_OSREL_MAJOR(osrel) == P_OSREL_MAJOR(P_OSREL_TIDPID))) {
if (pid == 0 || pid > _PID_MAX)
which = CPU_WHICH_TID;
else
diff --git a/sys/sys/param.h b/sys/sys/param.h
index d2fbad6c127b..6c95088e783d 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -92,6 +92,7 @@
#define P_OSREL_CK_INODE 1300005
#define P_OSREL_POWERPC_NEW_AUX_ARGS 1300070
#define P_OSREL_TIDPID 1400079
+#define P_OSREL_TIDPID_13 1302501
#define P_OSREL_MAJOR(x) ((x) / 100000)
#endif