git: b2f336bb7395 - stable/13 - linux(4): Implement sched_rr_get_interval_time64 syscall.

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Fri, 17 Jun 2022 19:39:34 UTC
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=b2f336bb7395106e65e15957cab1aa7cceb40c02

commit b2f336bb7395106e65e15957cab1aa7cceb40c02
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-05-04 10:06:47 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:34:15 +0000

    linux(4): Implement sched_rr_get_interval_time64 syscall.
    
    MFC after:              2 weeks
    
    (cherry picked from commit 8c84ca657bb343b73f315520ac3cabc43c5a67ec)
---
 sys/amd64/linux32/linux32_dummy_machdep.c |  1 -
 sys/compat/linux/linux_misc.c             | 45 +++++++++++++++++++++++++------
 sys/i386/linux/linux_dummy_machdep.c      |  1 -
 3 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c
index fb7c88629af7..e14da5b74733 100644
--- a/sys/amd64/linux32/linux32_dummy_machdep.c
+++ b/sys/amd64/linux32/linux32_dummy_machdep.c
@@ -77,4 +77,3 @@ DUMMY(recvmmsg_time64);
 DUMMY(mq_timedsend_time64);
 DUMMY(mq_timedreceive_time64);
 DUMMY(semtimedop_time64);
-DUMMY(sched_rr_get_interval_time64);
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index ff8c1b26d1d8..cdc68d64fc5b 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -2665,12 +2665,10 @@ linux_pollout(struct thread *td, struct pollfd *fds, struct pollfd *ufds, u_int
 	return (0);
 }
 
-int
-linux_sched_rr_get_interval(struct thread *td,
-    struct linux_sched_rr_get_interval_args *uap)
+static int
+linux_sched_rr_get_interval_common(struct thread *td, pid_t pid,
+    struct timespec *ts)
 {
-	struct timespec ts;
-	struct l_timespec lts;
 	struct thread *tdt;
 	int error;
 
@@ -2678,15 +2676,27 @@ linux_sched_rr_get_interval(struct thread *td,
 	 * According to man in case the invalid pid specified
 	 * EINVAL should be returned.
 	 */
-	if (uap->pid < 0)
+	if (pid < 0)
 		return (EINVAL);
 
-	tdt = linux_tdfind(td, uap->pid, -1);
+	tdt = linux_tdfind(td, pid, -1);
 	if (tdt == NULL)
 		return (ESRCH);
 
-	error = kern_sched_rr_get_interval_td(td, tdt, &ts);
+	error = kern_sched_rr_get_interval_td(td, tdt, ts);
 	PROC_UNLOCK(tdt->td_proc);
+	return (error);
+}
+
+int
+linux_sched_rr_get_interval(struct thread *td,
+    struct linux_sched_rr_get_interval_args *uap)
+{
+	struct timespec ts;
+	struct l_timespec lts;
+	int error;
+
+	error = linux_sched_rr_get_interval_common(td, uap->pid, &ts);
 	if (error != 0)
 		return (error);
 	error = native_to_linux_timespec(&lts, &ts);
@@ -2695,6 +2705,25 @@ linux_sched_rr_get_interval(struct thread *td,
 	return (copyout(&lts, uap->interval, sizeof(lts)));
 }
 
+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
+int
+linux_sched_rr_get_interval_time64(struct thread *td,
+    struct linux_sched_rr_get_interval_time64_args *uap)
+{
+	struct timespec ts;
+	struct l_timespec64 lts;
+	int error;
+
+	error = linux_sched_rr_get_interval_common(td, uap->pid, &ts);
+	if (error != 0)
+		return (error);
+	error = native_to_linux_timespec64(&lts, &ts);
+	if (error != 0)
+		return (error);
+	return (copyout(&lts, uap->interval, sizeof(lts)));
+}
+#endif
+
 /*
  * In case when the Linux thread is the initial thread in
  * the thread group thread id is equal to the process id.
diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c
index 071f5fff6f47..cbe945e00635 100644
--- a/sys/i386/linux/linux_dummy_machdep.c
+++ b/sys/i386/linux/linux_dummy_machdep.c
@@ -79,4 +79,3 @@ DUMMY(recvmmsg_time64);
 DUMMY(mq_timedsend_time64);
 DUMMY(mq_timedreceive_time64);
 DUMMY(semtimedop_time64);
-DUMMY(sched_rr_get_interval_time64);