From nobody Fri Jan 14 18:10:19 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B2CB2194229C; Fri, 14 Jan 2022 18:10:19 +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 4Jb8V337CDz4pD2; Fri, 14 Jan 2022 18:10:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642183819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/+nADXen3p4zeO5Wo23CIieL5cDwHkO0PtnrX9IXGI8=; b=F0f8w8w+StRwrC4AnXnfoS0q6TCfCHXBft3jc1Ou9n5yD7Ub8AOFCYXlAjQDM/hsZ3Dm23 DpYO7h2xb8iIzEpLLswsYs/zJBd83dkao3JQnwU7Q1eyKHhpIkK17thVXwdc5X6Bj2ykxH 5WZ+SEtOzqz+BBtF733fTuI0WPWX0EB6+6vOubI4v4YY1X7yqF4+Cir+wDbukm9J08SqCG 1n9TBN9DopMauBPgYPvSF1ExFzwDDwnuK4lLOGohSC28NrjbFSRWQymS6OCeA1EmQvb3LV pZaoG4cfoJthZ12fQWJH9lKvx7dn4+NNTezUAPUajtqdcSwY5Lvg0fKQrgsO5Q== 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 3E76D18572; Fri, 14 Jan 2022 18:10:19 +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 20EIAJOX093926; Fri, 14 Jan 2022 18:10:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20EIAJE2093917; Fri, 14 Jan 2022 18:10:19 GMT (envelope-from git) Date: Fri, 14 Jan 2022 18:10:19 GMT Message-Id: <202201141810.20EIAJE2093917@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: a48d9f1900d4 - stable/13 - Add sched_getcpu() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a48d9f1900d48eb7222ade05df10df73097b8cca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642183819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/+nADXen3p4zeO5Wo23CIieL5cDwHkO0PtnrX9IXGI8=; b=IQ1gB0onvXqaVASUG6OPlOIM3jl0sAJC7NXsIcQRqCfSBvczGNtbzJy0kQdKLZcyzLi3Pu EkdkozK89Mp4AV9aqo1VPy4PMp31BsbbvCzbQVnP2slPNaL90H0+lSpYGQRWuI6enYXXw0 3+mkzPRPAIk5syWuaqwhZIqv+xwkBb7AYUDlr4T30wZ5AYD5lfUNrdkF7g0KDtsh4w783f AsYq3Ld36z3nZ2nqoiTKSEQSzT0cpvgm3vH9W8MntAtCA4zZZuBWYiMQtH+HzQa0FEfJPi oEQUBWKWMl1xCCzSeCHIJGs1+0UvxoQ5CUErlC8EQLOVuVgKtW3HTa8+oFKpmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642183819; a=rsa-sha256; cv=none; b=OKjNSMNJ2SyDFOAeAnlg8YRvyijbh2gn7leut29ivHxcoY+ZhCJpsx67TRQObrngdjyUwl w8Qeh/nztpb1BUqy2M79IOcGgVKNGp+1iKkMf7U8F0eZhAQ/Nt90Ke81smrdvKNkK9YZZD kI46cNZpGMOoBgOPFIT0DQG2n/NVidRKEoNpTNhXLtP6SPMfmU7TGyOoRXX0l+DpOCZE6w 0flnOi1Cl81r+VAaZ98+YsQoQ1DRepwxW3X7wNX8QX02C4kVelT1jNiu3bmQgdLZeLCH5F fucDz3iTNqm2Kae4zBifaCd2Cmj5XWFSgCPok7/a9BkTLHZidzErIk+/ARhsNw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a48d9f1900d48eb7222ade05df10df73097b8cca commit a48d9f1900d48eb7222ade05df10df73097b8cca Author: Konstantin Belousov AuthorDate: 2021-10-22 15:35:53 +0000 Commit: Konstantin Belousov CommitDate: 2022-01-14 16:17:29 +0000 Add sched_getcpu() (cherry picked from commit 77b2c2f81451db8119e4ea6398fe76813db790de) --- include/sched.h | 1 + lib/libc/aarch64/sys/Makefile.inc | 3 ++- lib/libc/arm/sys/Makefile.inc | 3 ++- lib/libc/gen/Symbol.map | 1 + lib/libc/gen/sched_getcpu_gen.c | 36 ++++++++++++++++++++++++++++++++++++ lib/libc/include/libc_private.h | 1 + lib/libc/mips/sys/Makefile.inc | 3 ++- lib/libc/powerpc/sys/Makefile.inc | 4 +++- lib/libc/powerpc64/sys/Makefile.inc | 4 +++- lib/libc/riscv/sys/Makefile.inc | 3 ++- lib/libc/sys/Makefile.inc | 3 +++ lib/libc/x86/sys/Makefile.inc | 3 ++- sys/compat/freebsd32/syscalls.master | 2 +- sys/kern/capabilities.conf | 1 + sys/kern/kern_synch.c | 7 +++++++ sys/kern/syscalls.master | 4 +++- 16 files changed, 70 insertions(+), 9 deletions(-) diff --git a/include/sched.h b/include/sched.h index 531ecb1bb9a3..1c41cda79046 100644 --- a/include/sched.h +++ b/include/sched.h @@ -47,6 +47,7 @@ __BEGIN_DECLS #if __BSD_VISIBLE int sched_getaffinity(pid_t pid, size_t cpusetsz, cpuset_t *cpuset); int sched_setaffinity(int pid, size_t cpusetsz, const cpuset_t *cpuset); +int sched_getcpu(void); #endif /* __BSD_VISIBLE */ __END_DECLS diff --git a/lib/libc/aarch64/sys/Makefile.inc b/lib/libc/aarch64/sys/Makefile.inc index 623a06b7faf8..97aff8ba92fe 100644 --- a/lib/libc/aarch64/sys/Makefile.inc +++ b/lib/libc/aarch64/sys/Makefile.inc @@ -2,7 +2,8 @@ MIASM:= ${MIASM:Nfreebsd[467]_*} -SRCS+= __vdso_gettc.c +SRCS+= __vdso_gettc.c \ + sched_getcpu_gen.c MDASM= cerror.S \ syscall.S \ diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc index be6a58f8aaf5..c6e854e7954a 100644 --- a/lib/libc/arm/sys/Makefile.inc +++ b/lib/libc/arm/sys/Makefile.inc @@ -1,6 +1,7 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c +SRCS+= __vdso_gettc.c \ + sched_getcpu_gen.c MDASM= Ovfork.S cerror.S syscall.S diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index a52131b34476..5554c32ab4f2 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -441,6 +441,7 @@ FBSD_1.7 { posix_spawn_file_actions_addfchdir_np; sched_getaffinity; sched_setaffinity; + sched_getcpu; }; FBSDprivate_1.0 { diff --git a/lib/libc/gen/sched_getcpu_gen.c b/lib/libc/gen/sched_getcpu_gen.c new file mode 100644 index 000000000000..ef1bebc2915a --- /dev/null +++ b/lib/libc/gen/sched_getcpu_gen.c @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include "libc_private.h" + +int +sched_getcpu(void) +{ + return (__sys_sched_getcpu()); +} diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index 5a524c0211d1..61c1eb438142 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -371,6 +371,7 @@ __ssize_t __sys_recv(int, void *, __size_t, int); __ssize_t __sys_recvfrom(int, void *, __size_t, int, struct sockaddr *, __socklen_t *); __ssize_t __sys_recvmsg(int, struct msghdr *, int); +int __sys_sched_getcpu(void); int __sys_select(int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *); __ssize_t __sys_sendmsg(int, const struct msghdr *, int); diff --git a/lib/libc/mips/sys/Makefile.inc b/lib/libc/mips/sys/Makefile.inc index d7cc70d01b07..fa6d9b32739d 100644 --- a/lib/libc/mips/sys/Makefile.inc +++ b/lib/libc/mips/sys/Makefile.inc @@ -1,6 +1,7 @@ # $FreeBSD$ -SRCS+= trivial-vdso_tc.c +SRCS+= trivial-vdso_tc.c \ + sched_getcpu_gen.c MDASM= Ovfork.S cerror.S syscall.S diff --git a/lib/libc/powerpc/sys/Makefile.inc b/lib/libc/powerpc/sys/Makefile.inc index 99a141b5cb1e..6f07795b8870 100644 --- a/lib/libc/powerpc/sys/Makefile.inc +++ b/lib/libc/powerpc/sys/Makefile.inc @@ -1,4 +1,6 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c +SRCS+= __vdso_gettc.c \ + sched_getcpu_gen.c + MDASM+= cerror.S diff --git a/lib/libc/powerpc64/sys/Makefile.inc b/lib/libc/powerpc64/sys/Makefile.inc index 99a141b5cb1e..6f07795b8870 100644 --- a/lib/libc/powerpc64/sys/Makefile.inc +++ b/lib/libc/powerpc64/sys/Makefile.inc @@ -1,4 +1,6 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c +SRCS+= __vdso_gettc.c \ + sched_getcpu_gen.c + MDASM+= cerror.S diff --git a/lib/libc/riscv/sys/Makefile.inc b/lib/libc/riscv/sys/Makefile.inc index b322cece382c..2eb12bf11cad 100644 --- a/lib/libc/riscv/sys/Makefile.inc +++ b/lib/libc/riscv/sys/Makefile.inc @@ -1,6 +1,7 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c +SRCS+= __vdso_gettc.c \ + sched_getcpu_gen.c MDASM= cerror.S \ syscall.S \ diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 33e87e513b05..5c30f7d6b796 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -36,6 +36,9 @@ SRCS+= \ SRCS+= getdents.c lstat.c mknod.c stat.c +NOASM+= sched_getcpu.o +PSEUDO+= _sched_getcpu.o + SRCS+= fstat.c fstatat.c fstatfs.c getfsstat.c statfs.c NOASM+= fstat.o fstatat.o fstatfs.o getfsstat.o statfs.o PSEUDO+= _fstat.o _fstatat.o _fstatfs.o _getfsstat.o _statfs.o diff --git a/lib/libc/x86/sys/Makefile.inc b/lib/libc/x86/sys/Makefile.inc index 41e0d1a8ad66..8aa4948a3295 100644 --- a/lib/libc/x86/sys/Makefile.inc +++ b/lib/libc/x86/sys/Makefile.inc @@ -4,7 +4,8 @@ SRCS+= \ __vdso_gettc.c \ - pkru.c + pkru.c \ + sched_getcpu_gen.c MAN+= \ pkru.3 diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master index 1a356bf2832e..e5b86c1f066f 100644 --- a/sys/compat/freebsd32/syscalls.master +++ b/sys/compat/freebsd32/syscalls.master @@ -1177,6 +1177,6 @@ 579 AUE_AIO_READV STD { int freebsd32_aio_readv( \ struct aiocb32 *aiocbp); } 580 AUE_NULL UNIMPL fspacectl -581 AUE_NULL UNIMPL sched_getcpu +581 AUE_NULL NOPROTO { int sched_getcpu(void); } 582 AUE_NULL UNIMPL swapoff ; vim: syntax=off diff --git a/sys/kern/capabilities.conf b/sys/kern/capabilities.conf index 602ec7088fc6..7f73ea40b9f7 100644 --- a/sys/kern/capabilities.conf +++ b/sys/kern/capabilities.conf @@ -562,6 +562,7 @@ sbrk ## sched_get_priority_max sched_get_priority_min +sched_getcpu ## ## Allow various thread/process scheduler operations. diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 46d14a35d1ea..88f47ba78601 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -685,3 +685,10 @@ sys_yield(struct thread *td, struct yield_args *uap) td->td_retval[0] = 0; return (0); } + +int +sys_sched_getcpu(struct thread *td, struct sched_getcpu_args *uap) +{ + td->td_retval[0] = td->td_oncpu; + return (0); +} diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 141da7eb7fc5..72e3038ea352 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -3274,7 +3274,9 @@ ); } 580 AUE_NULL UNIMPL fspacectl -581 AUE_NULL UNIMPL sched_getcpu +581 AUE_NULL STD|CAPENABLED { + int sched_getcpu(void); + } 582 AUE_SWAPOFF STD { int swapoff( _In_z_ const char *name,