From nobody Fri Jun 17 19:37:05 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 4F8CC85A54D; Fri, 17 Jun 2022 19:37:06 +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 4LPq753JDnz3PNQ; Fri, 17 Jun 2022 19:37:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494626; 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=yGml7fkaukBqgRL8He/YhqyhiAPBGxSfWfbZB99N3ZY=; b=Qirz/oO9C/QSQv8FL6JDMuucwZj8gn7CXfRGEnwKS6TbGVQyUc45nxqhZAefGU90juwUl0 w2ORnu0RX8qAfho67bJleqNTxiMWO4vUycKdZgwto6knml1Av1qnPO23ri5vfj3Zc8qJib i7MhMjswOJXMuYqHzywvKzCRM0FZO0RYIO3qkN/P9YvcDKkwKhu0EQN3ULce4m8/d6CMg2 3d8kSJSeHB3KJCf9BBE0EeWiKakePJUK7y+mzPCuJjzokhhgp8yHk5eLWzbakNDTqukbdt ZRHuaCqYi+9argDlTlzMZxAsaaDvb+eTht9AXOUYwwTKO2I7FCHry/+kDshFiA== 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 2035025AB2; Fri, 17 Jun 2022 19:37:05 +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 25HJb5Qj012883; Fri, 17 Jun 2022 19:37:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJb50t012882; Fri, 17 Jun 2022 19:37:05 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:37:05 GMT Message-Id: <202206171937.25HJb50t012882@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 6e449c51a907 - stable/13 - linux(4): Factor out the FUTEX_WAIT op into linux_futex_wait(). 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: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6e449c51a90791c76cc473151b275a9a508dc81f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494626; 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=yGml7fkaukBqgRL8He/YhqyhiAPBGxSfWfbZB99N3ZY=; b=pgy8rP6hXSbAf2StyKFU+AxDwCcuj2JXOtIqmeuz7eMot9F+0UtvWq3A7CqWsHv7PCyF91 5tZD6ZRmLEFjICyKAr5RsykZTc3mS/pts384yoH5hW5KvVP6W1mODV41iIDYt8pF/VumOa aoj8iY/zTRkfXDwzhuLtJts64Waqc81qTLWdQm1fD7FAdr9OSKNaahHcL4x9iSJ2KjjJW8 DrRJtJCJlnFgdoUf4sfxTM/fQMpE0nbfhPCgX3Njq2ywHYLuy2q0MSJfHcPHLirgJVra5G 58mzXiE0JJuOOP01nI2UUMElNGjghTvW9v6KiKpdgLt/N4YvLRs22kPVwc/lPQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494626; a=rsa-sha256; cv=none; b=bqLXAABh5q7zxmlPGdxeM5JqFqTdp/8SwUIn7OyHiZTjIg22BPjzkbcd7xEUaA+M9SK5TL 8kYD4Lgm3eDW064COWFtQFLLucVyT7DFvaMMuXJHw2yRfK5a+429B7FkKtxS8mMrEuPBh6 M+V3ktAaEdKQwn7MYJtZhJX9LSHZXUFULMgahNpFUdZRPINIkS5r/C7GZ/uPXerpRZ5ti8 7/U+8nSsQXULk0VI2AEakq1dTTlkGyeMEVE9LtKis1f2FHVfnfQsUbcxc8csHao//84uCF 5/gggqE9b9UwkwlucOHHLCckgfeJ30f7MCEQdfWFTUAzi/+YR2d7Ep6Wx0JG2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6e449c51a90791c76cc473151b275a9a508dc81f commit 6e449c51a90791c76cc473151b275a9a508dc81f Author: Dmitry Chagin AuthorDate: 2021-07-20 11:37:51 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:33:10 +0000 linux(4): Factor out the FUTEX_WAIT op into linux_futex_wait(). MFC after: 2 weeks (cherry picked from commit f6b0d275eb9eb89b9719ca835b34116257f6a236) --- sys/compat/linux/linux_futex.c | 94 +++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index d89b9fd89f3b..15357e75c8af 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -238,6 +238,7 @@ struct linux_futex_args { }; static int linux_futex(struct thread *, struct linux_futex_args *); +static int linux_futex_wait(struct thread *, struct linux_futex_args *); static void futex_put(struct futex *f, struct waiting_proc *wp) @@ -645,9 +646,7 @@ linux_futex(struct thread *td, struct linux_futex_args *args) { int nrwake, nrrequeue, op_ret, ret; struct linux_pemuldata *pem; - struct waiting_proc *wp; struct futex *f, *f2; - struct timespec kts; int error, save; uint32_t val; @@ -686,47 +685,7 @@ linux_futex(struct thread *td, struct linux_futex_args *args) LINUX_CTR3(sys_futex, "WAIT uaddr %p val 0x%x bitset 0x%x", args->uaddr, args->val, args->val3); - if (args->ts != NULL) { - if (args->clockrt) { - nanotime(&kts); - timespecsub(args->ts, &kts, args->ts); - } else if (args->op == LINUX_FUTEX_WAIT_BITSET) { - nanouptime(&kts); - timespecsub(args->ts, &kts, args->ts); - } - } - -retry0: - error = futex_get(args->uaddr, &wp, &f, - args->flags | FUTEX_CREATE_WP); - if (error) - return (error); - - error = copyin_nofault(args->uaddr, &val, sizeof(val)); - if (error) { - futex_put(f, wp); - error = copyin(args->uaddr, &val, sizeof(val)); - if (error == 0) - goto retry0; - LIN_SDT_PROBE1(futex, linux_futex, copyin_error, - error); - LINUX_CTR1(sys_futex, "WAIT copyin failed %d", - error); - return (error); - } - if (val != args->val) { - LIN_SDT_PROBE4(futex, linux_futex, - debug_wait_value_neq, args->uaddr, args->val, val, - args->val3); - LINUX_CTR3(sys_futex, - "WAIT uaddr %p val 0x%x != uval 0x%x", - args->uaddr, args->val, val); - futex_put(f, wp); - return (EWOULDBLOCK); - } - - error = futex_wait(f, wp, args->ts, args->val3); - break; + return (linux_futex_wait(td, args)); case LINUX_FUTEX_WAKE: args->val3 = FUTEX_BITSET_MATCH_ANY; @@ -974,6 +933,55 @@ retry2: return (error); } +static int +linux_futex_wait(struct thread *td, struct linux_futex_args *args) +{ + struct waiting_proc *wp; + struct timespec kts; + struct futex *f; + int error; + uint32_t val; + + if (args->ts != NULL) { + if (args->clockrt) { + nanotime(&kts); + timespecsub(args->ts, &kts, args->ts); + } else if (args->op == LINUX_FUTEX_WAIT_BITSET) { + nanouptime(&kts); + timespecsub(args->ts, &kts, args->ts); + } + } + +retry: + f = NULL; + error = futex_get(args->uaddr, &wp, &f, args->flags | FUTEX_CREATE_WP); + if (error != 0) + return (error); + + error = copyin_nofault(args->uaddr, &val, sizeof(val)); + if (error != 0) { + futex_put(f, wp); + error = copyin(args->uaddr, &val, sizeof(val)); + if (error == 0) + goto retry; + LIN_SDT_PROBE1(futex, linux_futex, copyin_error, error); + LINUX_CTR1(sys_futex, "WAIT copyin failed %d", error); + return (error); + } + if (val != args->val) { + LIN_SDT_PROBE4(futex, linux_futex, + debug_wait_value_neq, args->uaddr, args->val, val, + args->val3); + LINUX_CTR3(sys_futex, + "WAIT uaddr %p val 0x%x != uval 0x%x", + args->uaddr, args->val, val); + futex_put(f, wp); + return (EWOULDBLOCK); + } + + return (futex_wait(f, wp, args->ts, args->val3)); +} + int linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args) {