From owner-dev-commits-src-main@freebsd.org Sun Jun 6 14:21:30 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B54265F4C2; Sun, 6 Jun 2021 14:21:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FydwV0FyGz4rJ4; Sun, 6 Jun 2021 14:21:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E5CA62502F; Sun, 6 Jun 2021 14:21:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 156ELTs7045193; Sun, 6 Jun 2021 14:21:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 156ELTuv045192; Sun, 6 Jun 2021 14:21:29 GMT (envelope-from git) Date: Sun, 6 Jun 2021 14:21:29 GMT Message-Id: <202106061421.156ELTuv045192@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 187715a42023 - main - linux(4): Implement clock_getres_time64 system call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 187715a420237e1ed94dd5aef158eada7dcdc559 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jun 2021 14:21:30 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=187715a420237e1ed94dd5aef158eada7dcdc559 commit 187715a420237e1ed94dd5aef158eada7dcdc559 Author: Dmitry Chagin AuthorDate: 2021-06-07 02:21:32 +0000 Commit: Dmitry Chagin CommitDate: 2021-06-07 02:21:32 +0000 linux(4): Implement clock_getres_time64 system call. MFC after: 2 weeks --- sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/amd64/linux32/syscalls.master | 5 +- sys/compat/linux/linux_time.c | 92 +++++++++++++++++++++++-------- sys/i386/linux/linux_dummy_machdep.c | 1 - sys/i386/linux/syscalls.master | 5 +- 5 files changed, 76 insertions(+), 28 deletions(-) diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index 022fbcbdd0c6..3f8dfe711dba 100644 --- a/sys/amd64/linux32/linux32_dummy_machdep.c +++ b/sys/amd64/linux32/linux32_dummy_machdep.c @@ -68,7 +68,6 @@ DUMMY(mq_getsetattr); DUMMY(arch_prctl); /* Linux 5.0: */ DUMMY(clock_adjtime64); -DUMMY(clock_getres_time64); DUMMY(clock_nanosleep_time64); DUMMY(timer_gettime64); DUMMY(timer_settime64); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index 924fbce9eac7..27034c0216ff 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2356,7 +2356,10 @@ int linux_clock_adjtime64(void); } 406 AUE_NULL STD { - int linux_clock_getres_time64(void); + int linux_clock_getres_time64( + clockid_t which, + struct l_timespec64 *tp + ); } 407 AUE_NULL STD { int linux_clock_nanosleep_time64(void); diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index 65bb4e9b754f..43db8871a0d8 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -94,10 +94,13 @@ LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime, copyin_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime64, conversion_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime64, copyin_error, "int"); #endif -LIN_SDT_PROBE_DEFINE0(time, linux_clock_getres, nullcall); -LIN_SDT_PROBE_DEFINE1(time, linux_clock_getres, conversion_error, "int"); -LIN_SDT_PROBE_DEFINE1(time, linux_clock_getres, getres_error, "int"); +LIN_SDT_PROBE_DEFINE0(time, linux_common_clock_getres, nullcall); +LIN_SDT_PROBE_DEFINE1(time, linux_common_clock_getres, conversion_error, "int"); +LIN_SDT_PROBE_DEFINE1(time, linux_common_clock_getres, getres_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_getres, copyout_error, "int"); +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +LIN_SDT_PROBE_DEFINE1(time, linux_clock_getres_time64, copyout_error, "int"); +#endif LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, conversion_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, copyout_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, copyin_error, "int"); @@ -111,6 +114,8 @@ static int linux_common_clock_gettime(struct thread *, clockid_t, struct timespec *); static int linux_common_clock_settime(struct thread *, clockid_t, struct timespec *); +static int linux_common_clock_getres(struct thread *, clockid_t, + struct timespec *); int native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp) @@ -486,23 +491,22 @@ linux_clock_settime64(struct thread *td, struct linux_clock_settime64_args *args } #endif -int -linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) +static int +linux_common_clock_getres(struct thread *td, clockid_t which, + struct timespec *ts) { struct proc *p; - struct timespec ts; - struct l_timespec lts; int error, clockwhich; clockid_t nwhich; pid_t pid; lwpid_t tid; - error = linux_to_native_clockid(&nwhich, args->which); + error = linux_to_native_clockid(&nwhich, which); if (error != 0) { linux_msg(curthread, - "unsupported clock_getres clockid %d", args->which); - LIN_SDT_PROBE1(time, linux_clock_getres, conversion_error, - error); + "unsupported clock_getres clockid %d", which); + LIN_SDT_PROBE1(time, linux_common_clock_getres, + conversion_error, error); return (error); } @@ -510,10 +514,10 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) * Check user supplied clock id in case of per-process * or thread-specific cpu-time clock. */ - if (args->which < 0) { + if (which < 0) { switch (nwhich) { case CLOCK_THREAD_CPUTIME_ID: - tid = LINUX_CPUCLOCK_ID(args->which); + tid = LINUX_CPUCLOCK_ID(which); if (tid != 0) { p = td->td_proc; if (linux_tdfind(td, tid, p->p_pid) == NULL) @@ -522,7 +526,7 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) } break; case CLOCK_PROCESS_CPUTIME_ID: - pid = LINUX_CPUCLOCK_ID(args->which); + pid = LINUX_CPUCLOCK_ID(which); if (pid != 0) { error = pget(pid, PGET_CANSEE, &p); if (error != 0) @@ -533,15 +537,15 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) } } - if (args->tp == NULL) { - LIN_SDT_PROBE0(time, linux_clock_getres, nullcall); + if (ts == NULL) { + LIN_SDT_PROBE0(time, linux_common_clock_getres, nullcall); return (0); } switch (nwhich) { case CLOCK_THREAD_CPUTIME_ID: case CLOCK_PROCESS_CPUTIME_ID: - clockwhich = LINUX_CPUCLOCK_WHICH(args->which); + clockwhich = LINUX_CPUCLOCK_WHICH(which); /* * In both cases (when the clock id obtained by a call to * clock_getcpuclockid() or using the clock @@ -550,9 +554,9 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) * * See Linux posix_cpu_clock_getres() implementation. */ - if (args->which > 0 || clockwhich == LINUX_CPUCLOCK_SCHED) { - ts.tv_sec = 0; - ts.tv_nsec = 1; + if (which > 0 || clockwhich == LINUX_CPUCLOCK_SCHED) { + ts->tv_sec = 0; + ts->tv_nsec = 1; goto out; } @@ -571,22 +575,62 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) default: break; } - error = kern_clock_getres(td, nwhich, &ts); + error = kern_clock_getres(td, nwhich, ts); if (error != 0) { - LIN_SDT_PROBE1(time, linux_clock_getres, getres_error, error); + LIN_SDT_PROBE1(time, linux_common_clock_getres, + getres_error, error); return (error); } out: + return (error); +} + +int +linux_clock_getres(struct thread *td, + struct linux_clock_getres_args *args) +{ + struct timespec ts; + struct l_timespec lts; + int error; + + error = linux_common_clock_getres(td, args->which, &ts); + if (error != 0 || args->tp == NULL) + return (error); + error = native_to_linux_timespec(<s, &ts); if (error != 0) return (error); - error = copyout(<s, args->tp, sizeof lts); + error = copyout(<s, args->tp, sizeof(lts)); if (error != 0) - LIN_SDT_PROBE1(time, linux_clock_getres, copyout_error, error); + LIN_SDT_PROBE1(time, linux_clock_getres, + copyout_error, error); + return (error); +} + +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_clock_getres_time64(struct thread *td, + struct linux_clock_getres_time64_args *args) +{ + struct timespec ts; + struct l_timespec64 lts; + int error; + + error = linux_common_clock_getres(td, args->which, &ts); + if (error != 0 || args->tp == NULL) + return (error); + error = native_to_linux_timespec64(<s, &ts); + if (error != 0) + return (error); + error = copyout(<s, args->tp, sizeof(lts)); + if (error != 0) + LIN_SDT_PROBE1(time, linux_clock_getres_time64, + copyout_error, error); return (error); } +#endif int linux_nanosleep(struct thread *td, struct linux_nanosleep_args *args) diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index 762dc177b1b0..6e4c9c66edcb 100644 --- a/sys/i386/linux/linux_dummy_machdep.c +++ b/sys/i386/linux/linux_dummy_machdep.c @@ -70,7 +70,6 @@ DUMMY(vm86old); DUMMY(arch_prctl); /* Linux 5.0: */ DUMMY(clock_adjtime64); -DUMMY(clock_getres_time64); DUMMY(clock_nanosleep_time64); DUMMY(timer_gettime64); DUMMY(timer_settime64); diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index a8b41605b743..0876a039ea05 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2374,7 +2374,10 @@ int linux_clock_adjtime64(void); } 406 AUE_NULL STD { - int linux_clock_getres_time64(void); + int linux_clock_getres_time64( + clockid_t which, + struct l_timespec64 *tp + ); } 407 AUE_NULL STD { int linux_clock_nanosleep_time64(void);