From patchwork Fri Oct 28 09:56:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13023352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2870ECAAA1 for ; Fri, 28 Oct 2022 10:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=176lBQvaKwhHAYOznZhYsdZlKjdKSoySo3etAK1A3bU=; b=ss2NJuav1LCDuC OaeR6wi1MKH2Cs67XxtBLNEOO8Mr9qp6JOvnTEtqat8+803m5Yx5JjevUwcz29T+sEnNk/peRUHRu qopEeRBRHx3HTZwUARPOx51FvoQjv5qhC8ekH+losVdSG5vnQVnM0qwNkrznACrCCMZebnfSg9DUv Kc8l1LmjvHNGgqRahU9kpvIU82HlewZ6ItbGLPtTKyaznR+NINxDBmi0CdghIXqOOHTQcjdUXZ/lb VuaqME8bNZMDynJSrlSwufNk2xuRqHJBXr6PqrqXRY1rnvfC6zSbwYMVejvBjdBjrf9l5dz1YgB94 vFWglcf7pO4ZP24AdcpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooMDM-00GVz0-3P; Fri, 28 Oct 2022 10:03:48 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooM6j-00GTLq-K1 for linux-riscv@lists.infradead.org; Fri, 28 Oct 2022 09:56:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1666951016; x=1698487016; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cCBe/q5YolyqbHnPs4c9IauGtcofM9sooHtix6H+SW0=; b=ZUv9O+2F1wtTskodRw/MT1nTGV+knOZ3MNGHePrWsz3HN2PFt9jNbk8r k73/8Kn+aTvclGuNZnxdsgrp6FQqSxxhjQaNFPLdul7Sh1pFqKQ6Zp0ij m4oTX/oWcnm6kJF+REJEe8tAoBe10h8s7SkaSKRNek3T53bxrD3x+numJ kOMDgZG5fS90o9DqTQAy4aKqwj1qxwJB4PiRanAcXdgjmAumYpL8JbdcF 7Xvpj3M13K3/Hb14xTQKzV7HusEI+wWwOQlcAKSfbVvrd+gJUomSlxBxN hdny+IYb11cH+fXyuGpdex68kW11aX/ifLZbFC2q3oOiGiT3zl4FnByrd g==; X-IronPort-AV: E=Sophos;i="5.95,220,1661788800"; d="scan'208";a="213258370" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2022 17:56:56 +0800 IronPort-SDR: LRUBrgrpw0WObl21KYL+UXKm1KMSdbkG05Df95k6A6d6JZwRycAoaTlzlkB1ymsQxj+JF2hY9D 8r6Usl2wNa7+JjmaZ1zQe5RhnE6JT583+6jiNQeeNrzRgapGzHMwDXYCWmfgshG6cG/TK54FEV IjOajNI2E+S2tcvxdWkYFDM+r0QAIiVkv7jt3ac8ECuZHTKqypxyaAjwXONtCausGSW52gse9F sh/Bm0kleaNifA6Pa0mrnaOKoYc/ETRcMPHC9pI8k4h4MFmutKDeJ6/GzWukUrLsDLdnZ6DwK/ edUBT0rY7KysEaz301/u0Hqu Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:16:17 -0700 IronPort-SDR: BDz36yemM8SaLmQtxYOL9OXnsZ1hWvLPuqpOBaC+f+u5uuYNCZj31A1TD4/wYhf8RjMNXAvNBk +mJA1rEWjYNZrN8NGxyPnwjoVfLczvPcDtMT2h6xGzrfM3o+z+3kRE8+aGeYUfqKPxpFI7nS4T 3NO68VilYhW8yxLXZdXBtJHQAyPamXWtWpIaONyu7masampM/m10OaDJebsudum/RzzHgdjAZN nTCfXgfsJqHXhKlEIVD9gDQbDdCr1U5NQVRdvCIF5xyhW933w2NfBLw9tzyJqgfaK1vFzI5ZIR OOY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:56:57 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4MzHyJ4ZR7z1SHkR for ; Fri, 28 Oct 2022 02:56:56 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1666951014; x=1669543015; bh=cCBe/q5YolyqbHnPs4 c9IauGtcofM9sooHtix6H+SW0=; b=OAa1FYOtOr8Yv6LLPxBxxoNFUhQW1PLMnJ KFEd1oT/7vn16T4Ox7LgvGBdS+hqd6gPwOQD+nIAb+mY8pOgCRmEUosR2o/YvVo7 wpOApZYhSgJk5YFexLdrCigBcPzlYSH1qa+qFwQ6OpEDnM78Seta0h3nrh40sQme m6PJx/hKkzXwqplYVSPZZP6jZpEbq6RStVjLuI+4SJNkY8C/uphHH0wg2GWucedb K7fTkvTVRg6JfbnLrdL1GltYKVNnAI5+AYitDl/Pdw2Vvy69WKH6rB4ynzmNbF3H kXvPWTYZsbt5AnqAlvR2HFSepDgUBQm5t2SDARtsEN5IOPa9eCSw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UMW_v1A6fuLi for ; Fri, 28 Oct 2022 02:56:54 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.167.50]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4MzHy76NpKz1Rwt8; Fri, 28 Oct 2022 02:56:47 -0700 (PDT) From: Alistair Francis To: linux-kernel@vger.kernel.org Cc: acme@kernel.org, dave@stgolabs.net, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@redhat.com, linux-perf-users@vger.kernel.org, acme@redhat.com, dvhart@infradead.org, mark.rutland@arm.com, peterz@infradead.org, arnd@arndb.de, alistair23@gmail.com, linux-riscv@lists.infradead.org, mingo@redhat.com, alistair.francis@wdc.com, atish.patra@wdc.com Subject: [PATCH 1/6] perf bench futex: Add support for 32-bit systems with 64-bit time_t Date: Fri, 28 Oct 2022 19:56:27 +1000 Message-Id: <20221028095632.1081262-2-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> References: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_025657_788142_ED3845BE X-CRM114-Status: GOOD ( 22.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Alistair Francis Some 32-bit architectures (such are 32-bit RISC-V) only have a 64-bit time_t and as such don't have the SYS_futex syscall. This patch will allow us to use the SYS_futex_time64 syscall on those platforms. This also converts the futex calls to be y2038 safe (when built for a 5.1+ kernel). This is a revert of commit ba4026b09d83acf56c040b6933eac7916c27e728 "Revert "perf bench futex: Add support for 32-bit systems with 64-bit time_t"". The original commit was reverted as including linux/time_types.h would fail to compile on older kernels. This commit doesn't include linux/time_types.h to avoid this issue. Signed-off-by: Alistair Francis Cc: Alexander Shishkin Cc: Alistair Francis Cc: Atish Patra Cc: Darren Hart Cc: Davidlohr Bueso Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-riscv@lists.infradead.org Cc: Arnaldo Carvalho de Melo Reviewed-by: Arnd Bergmann Message-Id: <20211209235857.423773-1-alistair.francis@opensource.wdc.com> --- tools/perf/bench/futex.h | 52 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h index ebdc2b032afc..385d2bdfaa9f 100644 --- a/tools/perf/bench/futex.h +++ b/tools/perf/bench/futex.h @@ -8,6 +8,7 @@ #ifndef _FUTEX_H #define _FUTEX_H +#include #include #include #include @@ -28,7 +29,17 @@ struct bench_futex_parameters { }; /** - * futex_syscall() - SYS_futex syscall wrapper + * This is copied from linux/time_types.h. + * We copy this here to avoid compilation failures when running + * on systems that don't ship with linux/time_types.h. + */ +struct __kernel_old_timespec { + __kernel_old_time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +/** + * futex_syscall() - __NR_futex syscall wrapper * @uaddr: address of first futex * @op: futex op code * @val: typically expected value of uaddr, but varies by op @@ -49,14 +60,49 @@ static inline int futex_syscall(volatile u_int32_t *uaddr, int op, u_int32_t val, struct timespec *timeout, volatile u_int32_t *uaddr2, int val3, int opflags) { - return syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); +#if defined(__NR_futex_time64) + if (sizeof(*timeout) != sizeof(struct __kernel_old_timespec)) { + int ret = syscall(__NR_futex_time64, uaddr, op | opflags, val, timeout, + uaddr2, val3); + if (ret == 0 || errno != ENOSYS) + return ret; + } +#endif + +#if defined(__NR_futex) + if (sizeof(*timeout) == sizeof(struct __kernel_old_timespec)) + return syscall(__NR_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); + + if (timeout && timeout->tv_sec == (long)timeout->tv_sec) { + struct __kernel_old_timespec ts32; + + ts32.tv_sec = (__kernel_long_t) timeout->tv_sec; + ts32.tv_nsec = (__kernel_long_t) timeout->tv_nsec; + + return syscall(__NR_futex, uaddr, op | opflags, val, ts32, uaddr2, val3); + } else if (!timeout) { + return syscall(__NR_futex, uaddr, op | opflags, val, NULL, uaddr2, val3); + } +#endif + + errno = ENOSYS; + return -1; } static inline int futex_syscall_nr_requeue(volatile u_int32_t *uaddr, int op, u_int32_t val, int nr_requeue, volatile u_int32_t *uaddr2, int val3, int opflags) { - return syscall(SYS_futex, uaddr, op | opflags, val, nr_requeue, uaddr2, val3); +#if defined(__NR_futex_time64) + int ret = syscall(__NR_futex_time64, uaddr, op | opflags, val, nr_requeue, + uaddr2, val3); + if (ret == 0 || errno != ENOSYS) + return ret; +#endif + +#if defined(__NR_futex) + return syscall(__NR_futex, uaddr, op | opflags, val, nr_requeue, uaddr2, val3); +#endif } /** From patchwork Fri Oct 28 09:56:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13023353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C18FDECAAA1 for ; Fri, 28 Oct 2022 10:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=td9Dv24kTmtrf2CKDA064tnFVCtNPzAm2mt1Xj6icuA=; b=VopEaY9L6ZZBue 8PvAv8bHUb5spZJti8zfNZ6yXVxBFFkxHKWl4kxpwB+ij8bFwB1itNSemYByjb3RrZPZAxlLgdi6x fgvWwmfdI0BwQ18V1da8ygRSRYpT+AlelNIauB5gTi0/iPZwwjMl+lgWEeqQk6VJyGQRH4Uwe9VBL SUM9QnqlD2CvYttBvgTkKYfrL+DFwN3l6VZNhCTnsefglvqunDM1NSKjsbqyZ5Sb891iXk5RgpgtW XF0KnVLgglL3Fca4SaUUdCGGPkxYdHq4Ocezj3KR+oMXXYHcBpMyKrvcAXndXo5S32JyiWPqmUhHw TLzJwXLRFgYmicL1XsWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooMDb-00GW6O-GY; Fri, 28 Oct 2022 10:04:03 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooM6s-00GTTB-Jn for linux-riscv@lists.infradead.org; Fri, 28 Oct 2022 09:57:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1666951026; x=1698487026; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HDOW4KvVqZm7M+oRwyLLXnE8cnS2CkUYQNAOKUB1qEA=; b=jRqdHqcx/aR/bij84Bzd1HIN5kpKrBVS7bBSC2/+cto/QOMYEPxGiDwz yfusXjdNONcY1dNteLvSg1RNi3XPQg1aJSPq2JUQynfwyMsJDzBFtsfzJ Ws1Jy1muSwkseREWSFoGlkB/5ZLn30cRbRvoGffVn7dJlghIfIXMptYdF HO9VwhV5hvJfzDe8OxWpS28p8ya0vKmblZ2WwUKE9V2nDy9U4mKRVyUV5 2tLFlLnHXIHsNQ1oxmBnbPsUdeeufSQflrmonIv3YdJJ9Yd3vwA4QUsYs HIztAgSpODBzH4aPknySfKAB7+LXt7qSjN+FWR7BC12qxBP4JkOJvZS2q g==; X-IronPort-AV: E=Sophos;i="5.95,220,1661788800"; d="scan'208";a="214962178" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2022 17:57:05 +0800 IronPort-SDR: EpTaSDYiopKLHh6wawg6i/B6e7AzwdvUw68NG8JWCKSikQTe3eSkqfnOfqeTwcoXsFuliXsT4r /o00k0jLhblYZiGvz0uaioyVQVxQogrKy5rj2rBgc90p/SMQZwvZ3l19kos6iLTcVZAcCtQ1DA zznhRzBu80vVVHt4guLotQJ9NYn18NFQnmnMMGf1ElfNqv7fc+OeyiZKnkUlmsYyekJX7lmtGy M95hk++p7/onihKI7cjFP7O5IJb3MVs2fLqdo3rSy3wZHug4BneknkBnWrl3frcmSsv9rxRsH8 qMsTFTdNlHqdRyL1hF0/TUen Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:16:25 -0700 IronPort-SDR: 0/w+qhZizad765dw5jx5c5mxhJVrY4OhmEOfhUvacgVwm2a5lbdNz3AdcXxBzYPGsMFnF82r7F bXFLtckayvvuAbInCTgnoA3Sph8SvPV+HlOFbYUmQiPU/8RaXmJzHu/CqMGKaike8S2fcqcYU4 BfhrMNwmPnlv8w/wS4yoEAqPMPlIc0C3yOu+tDc+PuEfbPKhiMjn5HqyyWxpMvQlbS6Th1Wae3 53yyCX2PD3dVTvYJ7KyYqI8dw5x4aD0NcUDWdWNWAbRHhRBxH/kGso6abz0UIiwrwEAxVs9N/p 4nI= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:57:06 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4MzHyT1WkTz1Rwtm for ; Fri, 28 Oct 2022 02:57:05 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1666951023; x=1669543024; bh=HDOW4KvVqZm7M+oRwy LLXnE8cnS2CkUYQNAOKUB1qEA=; b=sAi49Kz2aJYOKZLKyiB/WlLqbdA/IvI1xK OBN3BMUWU/e1IBbG+n6Ac+ZZqv+G5mMc1Js/804PxVD4y7APryBjKkSh849VHIcc nG0PZChp3RVA8YGzYh0X1Ha/1dDleUur6uepq87pxLK13mEGdf6JAZ9jaNdTnE0i NFUaD83Rux/jF5LDGkHT8Lc1SafrYsu3KuGFpuFooVooLgnLcxnK6S4j7V2l6FFX kAPK8IsQ/ENXLpif3vkLWEudo6NV1JaLzzENYnjyxnnxeQ3cni0F3GER8FPdqS41 NT3LgJcWBh2BCp1vKPVeDaSZgJ+IK92VwpME44nP1sYKxpqe/+MA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id oQZtcP_aH-WB for ; Fri, 28 Oct 2022 02:57:03 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.167.50]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4MzHyH5rjnz1RvLy; Fri, 28 Oct 2022 02:56:55 -0700 (PDT) From: Alistair Francis To: linux-kernel@vger.kernel.org Cc: acme@kernel.org, dave@stgolabs.net, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@redhat.com, linux-perf-users@vger.kernel.org, acme@redhat.com, dvhart@infradead.org, mark.rutland@arm.com, peterz@infradead.org, arnd@arndb.de, alistair23@gmail.com, linux-riscv@lists.infradead.org, mingo@redhat.com, alistair.francis@wdc.com, atish.patra@wdc.com Subject: [PATCH 2/6] selftests: futex: Call the futex syscall from a function Date: Fri, 28 Oct 2022 19:56:28 +1000 Message-Id: <20221028095632.1081262-3-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> References: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_025706_708522_5F51C229 X-CRM114-Status: GOOD ( 16.59 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Alistair Francis Call the futex syscall from a function In preparation for a more complex futex() function let's convert the current macro into two functions. We need two functions to avoid compiler failures as the macro is overloaded. This will allow us to include pre-processor conditionals in the futex syscall functions. Signed-off-by: Alistair Francis Message-Id: <20211209235857.423773-2-alistair.francis@opensource.wdc.com> --- .../selftests/futex/include/futextest.h | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/futex/include/futextest.h b/tools/testing/selftests/futex/include/futextest.h index ddbcfc9b7bac..c786fffecb8a 100644 --- a/tools/testing/selftests/futex/include/futextest.h +++ b/tools/testing/selftests/futex/include/futextest.h @@ -48,7 +48,7 @@ typedef volatile u_int32_t futex_t; #endif /** - * futex() - SYS_futex syscall wrapper + * futex_syscall() - SYS_futex syscall wrapper * @uaddr: address of first futex * @op: futex op code * @val: typically expected value of uaddr, but varies by op @@ -58,17 +58,26 @@ typedef volatile u_int32_t futex_t; * @val3: varies by op * @opflags: flags to be bitwise OR'd with op, such as FUTEX_PRIVATE_FLAG * - * futex() is used by all the following futex op wrappers. It can also be + * futex_syscall() is used by all the following futex op wrappers. It can also be * used for misuse and abuse testing. Generally, the specific op wrappers - * should be used instead. It is a macro instead of an static inline function as - * some of the types over overloaded (timeout is used for nr_requeue for - * example). + * should be used instead. * * These argument descriptions are the defaults for all * like-named arguments in the following wrappers except where noted below. */ -#define futex(uaddr, op, val, timeout, uaddr2, val3, opflags) \ - syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3) +static inline int +futex_syscall(volatile u_int32_t *uaddr, int op, u_int32_t val, struct timespec *timeout, + volatile u_int32_t *uaddr2, int val3, int opflags) +{ + return syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); +} + +static inline int +futex_syscall_nr_requeue(volatile u_int32_t *uaddr, int op, u_int32_t val, int nr_requeue, + volatile u_int32_t *uaddr2, int val3, int opflags) +{ + return syscall(SYS_futex, uaddr, op | opflags, val, nr_requeue, uaddr2, val3); +} /** * futex_wait() - block on uaddr with optional timeout @@ -77,7 +86,7 @@ typedef volatile u_int32_t futex_t; static inline int futex_wait(futex_t *uaddr, futex_t val, struct timespec *timeout, int opflags) { - return futex(uaddr, FUTEX_WAIT, val, timeout, NULL, 0, opflags); + return futex_syscall(uaddr, FUTEX_WAIT, val, timeout, NULL, 0, opflags); } /** @@ -87,7 +96,7 @@ futex_wait(futex_t *uaddr, futex_t val, struct timespec *timeout, int opflags) static inline int futex_wake(futex_t *uaddr, int nr_wake, int opflags) { - return futex(uaddr, FUTEX_WAKE, nr_wake, NULL, NULL, 0, opflags); + return futex_syscall(uaddr, FUTEX_WAKE, nr_wake, NULL, NULL, 0, opflags); } /** @@ -98,8 +107,8 @@ static inline int futex_wait_bitset(futex_t *uaddr, futex_t val, struct timespec *timeout, u_int32_t bitset, int opflags) { - return futex(uaddr, FUTEX_WAIT_BITSET, val, timeout, NULL, bitset, - opflags); + return futex_syscall(uaddr, FUTEX_WAIT_BITSET, val, timeout, NULL, bitset, + opflags); } /** @@ -109,8 +118,8 @@ futex_wait_bitset(futex_t *uaddr, futex_t val, struct timespec *timeout, static inline int futex_wake_bitset(futex_t *uaddr, int nr_wake, u_int32_t bitset, int opflags) { - return futex(uaddr, FUTEX_WAKE_BITSET, nr_wake, NULL, NULL, bitset, - opflags); + return futex_syscall(uaddr, FUTEX_WAKE_BITSET, nr_wake, NULL, NULL, bitset, + opflags); } /** @@ -121,7 +130,7 @@ static inline int futex_lock_pi(futex_t *uaddr, struct timespec *timeout, int detect, int opflags) { - return futex(uaddr, FUTEX_LOCK_PI, detect, timeout, NULL, 0, opflags); + return futex_syscall(uaddr, FUTEX_LOCK_PI, detect, timeout, NULL, 0, opflags); } /** @@ -130,7 +139,7 @@ futex_lock_pi(futex_t *uaddr, struct timespec *timeout, int detect, static inline int futex_unlock_pi(futex_t *uaddr, int opflags) { - return futex(uaddr, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0, opflags); + return futex_syscall(uaddr, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0, opflags); } /** @@ -140,8 +149,8 @@ static inline int futex_wake_op(futex_t *uaddr, futex_t *uaddr2, int nr_wake, int nr_wake2, int wake_op, int opflags) { - return futex(uaddr, FUTEX_WAKE_OP, nr_wake, nr_wake2, uaddr2, wake_op, - opflags); + return futex_syscall_nr_requeue(uaddr, FUTEX_WAKE_OP, nr_wake, nr_wake2, uaddr2, wake_op, + opflags); } /** @@ -156,8 +165,8 @@ static inline int futex_requeue(futex_t *uaddr, futex_t *uaddr2, int nr_wake, int nr_requeue, int opflags) { - return futex(uaddr, FUTEX_REQUEUE, nr_wake, nr_requeue, uaddr2, 0, - opflags); + return futex_syscall_nr_requeue(uaddr, FUTEX_REQUEUE, nr_wake, nr_requeue, uaddr2, 0, + opflags); } /** @@ -169,8 +178,8 @@ static inline int futex_cmp_requeue(futex_t *uaddr, futex_t val, futex_t *uaddr2, int nr_wake, int nr_requeue, int opflags) { - return futex(uaddr, FUTEX_CMP_REQUEUE, nr_wake, nr_requeue, uaddr2, - val, opflags); + return futex_syscall_nr_requeue(uaddr, FUTEX_CMP_REQUEUE, nr_wake, nr_requeue, uaddr2, + val, opflags); } /** @@ -185,8 +194,8 @@ static inline int futex_wait_requeue_pi(futex_t *uaddr, futex_t val, futex_t *uaddr2, struct timespec *timeout, int opflags) { - return futex(uaddr, FUTEX_WAIT_REQUEUE_PI, val, timeout, uaddr2, 0, - opflags); + return futex_syscall(uaddr, FUTEX_WAIT_REQUEUE_PI, val, timeout, uaddr2, 0, + opflags); } /** @@ -200,8 +209,8 @@ static inline int futex_cmp_requeue_pi(futex_t *uaddr, futex_t val, futex_t *uaddr2, int nr_wake, int nr_requeue, int opflags) { - return futex(uaddr, FUTEX_CMP_REQUEUE_PI, nr_wake, nr_requeue, uaddr2, - val, opflags); + return futex_syscall_nr_requeue(uaddr, FUTEX_CMP_REQUEUE_PI, nr_wake, nr_requeue, uaddr2, + val, opflags); } /** From patchwork Fri Oct 28 09:56:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13023354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F23DCECAAA1 for ; Fri, 28 Oct 2022 10:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CAXG1JWXDh55q6k/09m3bMXsjRwL1lG0JexJMOhQZzs=; b=B4h5cLihGM2dJR VrecxlYkVOtwJtF8jO1t1wLIQnJv7+vAIvGQlpXVDgSQ9GXHTWcLWPzS8ItPCtqElUjKnRTaMG6Ah PYLriI/7jDMjv0+hfegRbkDW4UjYxpYA0fHXxYUQmyZkmSF5IZpQtrtC6zouSXSAY4btgKCNx8/Qu Fs0RWki6RP4rsjvbtmXAdClWSRg7B7h8fwK4hhP4YnASUSIS362vIi7WTWQiQcU28CD0b+twqFtxk vLq8OAEk5PNGLRvhMy6KL9VaupuU6ryyP4TGfHGrFS3jaovgX3FHpMAgHLUKy+n1sVqi3+MVbaw0x zPBTDUy4x7PO7GYSWcgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooMFE-00GWwO-Rw; Fri, 28 Oct 2022 10:05:44 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooM72-00GTXU-9G for linux-riscv@lists.infradead.org; Fri, 28 Oct 2022 09:57:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1666951036; x=1698487036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ukg2qTmNSbfxQotuwWTieHEmVg4/tjCtE5mHopxUMgk=; b=YvzNXw/i/lv7iO8qEhP8q94e4XsyKevzTExkY4l7PIYg9tlVNwlcrQOw A1Q/Oae+5/S7tl6Kt0N/YsZ+UVbdFa3xRlWDUl88M7SqG/uw3HqtT2hwk iNUuQwRZhvAaQXs+7rJRep1NfWnS/r7kIPRkQCp3pbWwT0DlTFsDkJ9Up udr2Gmi9vUTJBqMUAtQRJoYQweF8fu23NcVuBHOJAVGZZcz2cbWr2db8t Y6f9Wq1rSkKRmFOZz2nkmVoBNP8a67Ro6ZncvS15WUIcCWoBUs+L6yakw +/kU/sHctNAjGBONS89BDyj4tocujZ3MwpQRADm3WXtybHAyw3xdUFX/a g==; X-IronPort-AV: E=Sophos;i="5.95,220,1661788800"; d="scan'208";a="215317989" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2022 17:57:14 +0800 IronPort-SDR: Xea2NtP8s8A+1tXJ8IjgFabjb45D9wcyJ4+8EyVzxPklfh55FUy2H+Ia9+3o81vVQoDjtjFw7d ue3rqenPZpPzwhsjRT3C6icKHw86zaioJBEMwNDb2Jw/Pkn5RoyM5wMzB4dbd7D4GCT78RqzQm 5o+CxrUJNaWVWzeevrXyWGC4C5cMnCsKBrqzyu7yPBg6brIb2xHKIGpXHYObWAWn9X8o0MuVq4 sIUfgEpFnkYOrzyhSUvIFP4dfzW0D917PDD5fI3AwRKeTK2cPwamTuBAw0pv56GOzAjW+vAI6i qJLguNZeS3xgwxeDrrt6tJS3 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:16:34 -0700 IronPort-SDR: 8FbO6fyTzzBXZdR9XN2GexFHpakj+SyN4QKczgHj1uS8+5VxzorqhS5fpHDIMInQoFTubfDO6f 5QGWe9xaKXFl4tRLiY8wjf09WN9XuYAkN2fSfn0xDr7Y8jRHvJqdDsZZ1aDEOOZvZIGw4VXUvJ hYWRWY5YLQASIDTaFQ5AS9nXmgFh2p2/s2/oh0B1Pn1TLB19SgtS+NnmRskvXiX3OdL+k54FWC VbNnm1/FgDSQWhjBWc/pn5E3eJbotdbwQbjeOR3BXeB0I6tFpmv8cGMxDsgsFd8XT4bQz8rJNZ UjA= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:57:14 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4MzHyd1y2cz1SHkN for ; Fri, 28 Oct 2022 02:57:13 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1666951031; x=1669543032; bh=Ukg2qTmNSbfxQotuwW TieHEmVg4/tjCtE5mHopxUMgk=; b=XoCXBRwRjUVW20Iyiw7Ncz9qA6Y7jOuo8m w/G8osTW19FFlzpKM22INyC6m+ZqsW/n1Ch9ryyHlArDTWw5GB0zrU+ZQfljy2oX c9kEp9TUbpGba2sWPxxEeX04baDMcX8URqB8BANKiB3LEOlMACM6C+z8GOgLLVIa /V6DhcV2n/hnsi6JusbOgc3btLu+n4nNjIEykuu50qKj159tB4KpJoa3tfqyAm3D DqQeycQan6SOtNMyUmwhPpoAp6kasc30qw80a32RT+WEeDcCrXkj2xlvU+VWpoeK inkUSTGoxo1PxL6eKckIQhzvoCrVaSXMkHLfOi24JRTGYzJ3FhXg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 8w7G-d3_pnDX for ; Fri, 28 Oct 2022 02:57:11 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.167.50]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4MzHyS2SsTz1RvTp; Fri, 28 Oct 2022 02:57:03 -0700 (PDT) From: Alistair Francis To: linux-kernel@vger.kernel.org Cc: acme@kernel.org, dave@stgolabs.net, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@redhat.com, linux-perf-users@vger.kernel.org, acme@redhat.com, dvhart@infradead.org, mark.rutland@arm.com, peterz@infradead.org, arnd@arndb.de, alistair23@gmail.com, linux-riscv@lists.infradead.org, mingo@redhat.com, alistair.francis@wdc.com, atish.patra@wdc.com Subject: [PATCH 3/6] uapi: futex: Add a futex syscall Date: Fri, 28 Oct 2022 19:56:29 +1000 Message-Id: <20221028095632.1081262-4-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> References: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_025716_455028_7535FB09 X-CRM114-Status: GOOD ( 19.89 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Alistair Francis This commit adds two futex syscall wrappers that are exposed to userspace. Neither the kernel or glibc currently expose a futex wrapper, so userspace is left performing raw syscalls. This has mostly been because the overloading of one of the arguments makes it impossible to provide a single type safe function. Until recently the single syscall has worked fine. With the introduction of a 64-bit time_t futex call on 32-bit architectures, this has become more complex. The logic of handling the two possible futex syscalls is complex and often implemented incorrectly. This patch adds two futex syscall functions that correctly handle the time_t complexity for userspace. This idea is based on previous discussions: https://lore.kernel.org/lkml/CAK8P3a3x_EyCiPDpMK54y=Rtm-Wb08ym2TNiuAZgXhYrThcWTw@mail.gmail.com/ Signed-off-by: Alistair Francis Message-Id: <20211209235857.423773-3-alistair.francis@opensource.wdc.com> --- include/uapi/linux/futex_syscall.h | 92 ++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 include/uapi/linux/futex_syscall.h diff --git a/include/uapi/linux/futex_syscall.h b/include/uapi/linux/futex_syscall.h new file mode 100644 index 000000000000..bac621eb319c --- /dev/null +++ b/include/uapi/linux/futex_syscall.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Futex syscall helper functions + * + * Copyright (C) 2021 Western Digital. All Rights Reserved. + * + * Author: Alistair Francis + */ +#ifndef _UAPI_LINUX_FUTEX_SYSCALL_H +#define _UAPI_LINUX_FUTEX_SYSCALL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * __kernel_futex_syscall_timeout() - __NR_futex/__NR_futex_time64 syscall wrapper + * @uaddr: address of first futex + * @op: futex op code + * @val: typically expected value of uaddr, but varies by op + * @timeout: an absolute struct timespec + * @uaddr2: address of second futex for some ops + * @val3: varies by op + */ +static inline int +__kernel_futex_syscall_timeout(volatile uint32_t *uaddr, int op, uint32_t val, + struct timespec *timeout, volatile uint32_t *uaddr2, int val3) +{ +#if defined(__NR_futex_time64) + if (sizeof(*timeout) != sizeof(struct __kernel_old_timespec)) { + int ret = syscall(__NR_futex_time64, uaddr, op, val, timeout, uaddr2, val3); + + if (ret == 0 || errno != ENOSYS) + return ret; + } +#endif + +#if defined(__NR_futex) + if (sizeof(*timeout) == sizeof(struct __kernel_old_timespec)) + return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3); + + if (timeout && timeout->tv_sec == (long)timeout->tv_sec) { + struct __kernel_old_timespec ts_old; + + ts_old.tv_sec = (__kernel_long_t) timeout->tv_sec; + ts_old.tv_nsec = (__kernel_long_t) timeout->tv_nsec; + + return syscall(__NR_futex, uaddr, op, val, &ts_old, uaddr2, val3); + } else if (!timeout) { + return syscall(__NR_futex, uaddr, op, val, NULL, uaddr2, val3); + } +#endif + + errno = ENOSYS; + return -1; +} + +/** + * __kernel_futex_syscall_nr_requeue() - __NR_futex/__NR_futex_time64 syscall wrapper + * @uaddr: address of first futex + * @op: futex op code + * @val: typically expected value of uaddr, but varies by op + * @nr_requeue: an op specific meaning + * @uaddr2: address of second futex for some ops + * @val3: varies by op + */ +static inline int +__kernel_futex_syscall_nr_requeue(volatile uint32_t *uaddr, int op, uint32_t val, + uint32_t nr_requeue, volatile uint32_t *uaddr2, int val3) +{ +#if defined(__NR_futex_time64) + int ret = syscall(__NR_futex_time64, uaddr, op, val, nr_requeue, uaddr2, val3); + + if (ret == 0 || errno != ENOSYS) + return ret; +#endif + +#if defined(__NR_futex) + return syscall(__NR_futex, uaddr, op, val, nr_requeue, uaddr2, val3); +#endif + + errno = ENOSYS; + return -1; +} + +#endif /* _UAPI_LINUX_FUTEX_SYSCALL_H */ From patchwork Fri Oct 28 09:56:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13023355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1F6CC38A02 for ; Fri, 28 Oct 2022 10:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5kmjM0PQhwuCjAX8iFC+mC7ShsddeT8QnKV9r444/tE=; b=xAgxvkCVNOHDEQ ULyDQ/1ie6SbO/6zOKG0MBt1r+PgGXa0jfy409ItELfF7DdQfSuX0IqKg3G9LqmA6cNgqIzXv6700 Njfu1RGQOWJU1maTobEGkFP8S2isDcvFgUJGnQ/NkWfxvucms35cFeVqYN5OPTH1aTEQDIykGdJ8k 2VOlAxK7MUwUdbq/l1gipr7ppLq3p3TpWHBHNlNcVGsz47Wrh5zE2Lhdd62yaaZgDR0ehigz7YavQ dv9ouVr7KQWr40ylaby90S+C79d/OMun7c8Iz9yrHGQazzvecft0SX6dXFXjPatm6EF2tNRshL90J Say+kjss41qMiLAMjnzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooMFX-00GX4d-4U; Fri, 28 Oct 2022 10:06:03 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooM78-00GTXU-6o for linux-riscv@lists.infradead.org; Fri, 28 Oct 2022 09:57:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1666951041; x=1698487041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r/Wt8wTrrxLwn/R3qKGQRI/nbpEUQa2isveXNykvGmo=; b=CoWpMyVPk8fXs2aNiALzsvYWBCkIvcyd5no20kZVKGIMIzUZP/JvNctu 8ElK2BUi1VEdZ1r/YphgTmEJHdZ6zZ3UOlmghpaKqM+mn+MYskcc7eTQT w8pC9VxjNXLhHk+YbC/bbG9PcR7tiIgcNaR13RH2cjOEwvkqz4IYJVc5O jIXl6GRuWQY/wU6b1fgYGivWQIyYip7/8b3oZ5rrXU52JWxhJbka8Ee18 wevbXy07KK8c0zNDwnkFnGmMsERo2Y+SMutmZ7k6WyjKxcckx/FCWiDVy +1QWwjFOqHEmfpNMNMo7acrzxl6IxNN1byYZ92NOwfnEI2RV1MT9GBR/l Q==; X-IronPort-AV: E=Sophos;i="5.95,220,1661788800"; d="scan'208";a="215318005" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2022 17:57:21 +0800 IronPort-SDR: N99BV9AujTp/h0Q1rxjxIZB8npOXVZgvuhRrn3GUxkI1ov2sM3WDGN0xUnc9G5vg88C+uphWNR ics1feSXahSCLNs/YP7iz5PI4fN9+7NcFgaw2IW4yuUhWPxw3DPWBg4/RJcIpfMiktxyjfRNOv 3g7fDMemKDNtalozshB+ybxfsTfkSHtCSc4xZi4Ob9GjQTKtcEcv/beXBYyePLKsnUY4A5lsVN fDBbHtVhFM1l5hYpMkahd4COWLWbGetXqWlGHAWYzhLIhaOvuuCE6+KjND89Fzf9fT6mRdt2+z ATXdXb6b1O0HmGMniuFNPSK1 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:10:58 -0700 IronPort-SDR: iIp38ZdPnvLasN84dJzrPyivi1m6YNGD6HnPXro5hXQSrQr2QmECMqLSUo8Ic/ThwjBPZ111Zo 7iJW6qNrjKKiXucAcRYq8AwAGdH7UEl7KXNGA7A9diLDAYQ0gbwAnMvEjU1qizEcwg/0csOxod 5pZJCRF52rqHa9mTILuU+NeXMFJQWtyTvdmt9a1jltBOvpawZQFeVZCQDII2iKyjiiCm4/0Zfj yFT1JeDu87kpinFweYSYwdlEYcCJ2YrmHBESofge6t6T8FATujBiFA1eWE2m8GduoAnoyxBhq8 VVk= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:57:22 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4MzHyn2p54z1SHkR for ; Fri, 28 Oct 2022 02:57:21 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1666951040; x=1669543041; bh=r/Wt8wTrrxLwn/R3qK GQRI/nbpEUQa2isveXNykvGmo=; b=J/XB7nV3s8VIP3A2o68BCRLdofvNTcUQoQ WBFb7oiY2q3ZtHUgU/oyAMv/aTGdkNAeTg4zioNsvN7N0Hvi8camt+2Vqc4Qmkma qD0h9f2TouksOrzl9VGkBu3QSVWJZF96fMvqslYzl6fx0nuuG0EApS6wBlbZT/Ju ylvGiB/zfeLKclZ6F9BQzXJ3tz8BueH6n7jBLDHqU0xCaJBqIduYTbdnPuq9nUUV Ys2p0lfJmr7fykFMktiyg2cVClc1P5j8dlG3k/YHZfjvLL0WFRrE/yew1NptDn2O JaS6AJcDVjHiv/l5rwKPGC4g9b+fPyNrNQTpGA3BdKyqPUbB63JA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id jdcIbtv2LM4b for ; Fri, 28 Oct 2022 02:57:20 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.167.50]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4MzHyc2BBbz1RvLy; Fri, 28 Oct 2022 02:57:11 -0700 (PDT) From: Alistair Francis To: linux-kernel@vger.kernel.org Cc: acme@kernel.org, dave@stgolabs.net, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@redhat.com, linux-perf-users@vger.kernel.org, acme@redhat.com, dvhart@infradead.org, mark.rutland@arm.com, peterz@infradead.org, arnd@arndb.de, alistair23@gmail.com, linux-riscv@lists.infradead.org, mingo@redhat.com, alistair.francis@wdc.com, atish.patra@wdc.com Subject: [PATCH 4/6] selftests: futex: Add support for 32-bit systems with 64-bit time_t Date: Fri, 28 Oct 2022 19:56:30 +1000 Message-Id: <20221028095632.1081262-5-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> References: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_025722_387823_3231B83B X-CRM114-Status: GOOD ( 15.82 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Alistair Francis Using the new __kernel_futex_syscall*() functions let's add support for 32-bit systems with a 64-bit time_t. We can just direclty call the publically exposed __kernel_futex_syscall_timeout() and __kernel_futex_syscall_nr_requeue() functions to do this. Signed-off-by: Alistair Francis Message-Id: <20211209235857.423773-4-alistair.francis@opensource.wdc.com> --- tools/testing/selftests/futex/functional/futex_requeue_pi.c | 2 +- tools/testing/selftests/futex/include/futextest.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_requeue_pi.c b/tools/testing/selftests/futex/functional/futex_requeue_pi.c index 1ee5518ee6b7..556bf3e74755 100644 --- a/tools/testing/selftests/futex/functional/futex_requeue_pi.c +++ b/tools/testing/selftests/futex/functional/futex_requeue_pi.c @@ -294,7 +294,7 @@ int unit_test(int broadcast, long lock, int third_party_owner, long timeout_ns) secs = (ts.tv_nsec + timeout_ns) / 1000000000; ts.tv_nsec = ((int64_t)ts.tv_nsec + timeout_ns) % 1000000000; ts.tv_sec += secs; - info("ts.tv_sec = %ld\n", ts.tv_sec); + info("ts.tv_sec = %lld\n", (long long) ts.tv_sec); info("ts.tv_nsec = %ld\n", ts.tv_nsec); tsp = &ts; } diff --git a/tools/testing/selftests/futex/include/futextest.h b/tools/testing/selftests/futex/include/futextest.h index c786fffecb8a..1686f94667b1 100644 --- a/tools/testing/selftests/futex/include/futextest.h +++ b/tools/testing/selftests/futex/include/futextest.h @@ -21,6 +21,7 @@ #include #include #include +#include typedef volatile u_int32_t futex_t; #define FUTEX_INITIALIZER 0 @@ -69,14 +70,14 @@ static inline int futex_syscall(volatile u_int32_t *uaddr, int op, u_int32_t val, struct timespec *timeout, volatile u_int32_t *uaddr2, int val3, int opflags) { - return syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); + return __kernel_futex_syscall_timeout(uaddr, op | opflags, val, timeout, uaddr2, val3); } static inline int futex_syscall_nr_requeue(volatile u_int32_t *uaddr, int op, u_int32_t val, int nr_requeue, volatile u_int32_t *uaddr2, int val3, int opflags) { - return syscall(SYS_futex, uaddr, op | opflags, val, nr_requeue, uaddr2, val3); + return __kernel_futex_syscall_nr_requeue(uaddr, op | opflags, val, nr_requeue, uaddr2, val3); } /** From patchwork Fri Oct 28 09:56:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13023356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F3D4C38A02 for ; Fri, 28 Oct 2022 10:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JIwEECF207/SDQasfTpqBI4NB67YvceiSEO7Mpgwnk4=; b=TAVmd4DT7AWJzs knmg3cTgcLCQrOshhBUttw2HBIRDmp6ODXc5oY3e5kEtDFe4qHMhLv1qbAskGQ6obiAIeCWkEOuWo Q2/LIVDbbjgSOFDPyG751clpTpd99IV9lWZ7hDEbnST8P8gHgv2DGeclGvhXadMfj4n1d5JX6miVB /dSXPRm/TwVXvLE4zTwFfWm3oDVnnmRdAlSrrSerDZXloqRZYL97IJOIMUf9qCp8woRQdhCo/7ZJk GnAEw2rPCXxtTJE1legcq+qKnetXcUuJUtuNdodbdeRSVY9ds/YJQAXPJqrxbyG/K8KEx/Vnu7DPy kDsL6HjsjfkYq4BMgFYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooMFm-00GXC2-FA; Fri, 28 Oct 2022 10:06:19 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooM7I-00GTfM-Sy for linux-riscv@lists.infradead.org; Fri, 28 Oct 2022 09:57:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1666951052; x=1698487052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5sXdRpXoL8fKMHadmBmTH5z4Y4mbuNPDkZAxHvAj8lU=; b=oXDiouemYkNz3V1T1KwN2AgmAXQyq+B4+Fw8JPNeVVGfErvf1ZQJ/MAV 0pEIJwNts4GepmiZnHY4aMEqrIDezziMmPhYW/yoS7vRnbAsMr1r18/6f TctDLw+JKx4Btu/NQ61ag+wSWAa2kymHS2voXc2K4M9bQpvhiZugiXvYp aToCCjyR5q7WlvjpZrKC5dbz5/DjrRpidHq76Y5BS0U0cXDSyv0BcNzKj b6SFdKJfVz+NGE9EZ53na5PgtMh/4i4FM/AVzzdfddfRGTtKYNauEUTKu IalnWGmk+8NL5/C+ehZbe2E366fQDnFWQJPms+B2YUR/FcYovimIyy224 Q==; X-IronPort-AV: E=Sophos;i="5.95,220,1661788800"; d="scan'208";a="213258417" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2022 17:57:31 +0800 IronPort-SDR: O/ubV0l6WyNKKIR9Df/lwC1IHUnmABtCjVjNsXPcbBXkc/gi0o57DieaIGp8QMsEmPTQS8u9ma El4Vp3UyDcbUIJ/hv+0s2403husl7rDjWfKUaVVWGGKnY3KCC4tEs1F3W3+KgaFxbzLolpnJqd NoNgDCNtyzowPcn5NvG1eYmGBuUuXwZVqi6k2h+TJqi839koMb1AkuG/92hni63Dh9OpGXVLjU Kf2lX5AhkYSwexQy4JBMb9BkYiRMW/OCzBKMqZHeKgAxUE3f6QZ92ZENiD1zEjNy+5zKM/k5Tp 98RI40ziuAM/Tb6d9zQasbLs Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:16:52 -0700 IronPort-SDR: AwpmRz02gecJQlWs/qd/IpcLfsgfyB5fijb1jx5uBO3FSN5xMe3Vj5j1qTNA6uE8lNSN+4jCZq Xr90gDpV3EWVKBDEhkKOXxRIMh63vp/bFY34Qgrsjs3sXP7389HENvFYV2HfxOsVw1Qg4edQw1 jGixq6bnbA4MCn2RQGXY1PNknHRK7TPcipBaOgbJaldQvSYEUao4TAS9BIqDZUojeDSSZx/PMh QDTj1FG0DYYVNL6Bq4AR3btXZNE+KMhFZnJHAxwjZTBWJgKJGdEvApo6wMgsiPSVIlyLQNMvdg Nc4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:57:33 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4MzHyz09Nqz1RWxq for ; Fri, 28 Oct 2022 02:57:30 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1666951049; x=1669543050; bh=5sXdRpXoL8fKMHadmB mTH5z4Y4mbuNPDkZAxHvAj8lU=; b=i4/10uIu5RyP75V/f5ENBFGxGBQsJdPxTT e+kzdLy8o7BJq2hv9WGbJcPNne4tQPPnn2Acj2woZm2Xyp4Jhw3LAI8A/HAIFFwl NNiTQBR4Zf4diFyhwtRhDQRyV4eUz8AhcYUH6bk+kk/ew6Ih3Lw2hZlN3MeFCtWq yg8I5LQk6DPR8peBUxhVIrW2l/B00G4BReNrsIqnEJFmkQSIk0ZyB2BKx8Y9ZjZH HMMi3VYWfIYEbXeJU5BkIuewRNqpBMfAqUzDKolPa5HPPj05XT48eQ9Y3LRbuUoe 1dKOqJ/YCh/NfdcW9YftXy/87Oq4Y/lmphJilXOocMvsDc8RgHXw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id r5G7vh9n7NmV for ; Fri, 28 Oct 2022 02:57:29 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.167.50]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4MzHyn26b8z1RwtC; Fri, 28 Oct 2022 02:57:20 -0700 (PDT) From: Alistair Francis To: linux-kernel@vger.kernel.org Cc: acme@kernel.org, dave@stgolabs.net, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@redhat.com, linux-perf-users@vger.kernel.org, acme@redhat.com, dvhart@infradead.org, mark.rutland@arm.com, peterz@infradead.org, arnd@arndb.de, alistair23@gmail.com, linux-riscv@lists.infradead.org, mingo@redhat.com, alistair.francis@wdc.com, atish.patra@wdc.com Subject: [PATCH 5/6] uapi: futex: Add a futex waitv syscall Date: Fri, 28 Oct 2022 19:56:31 +1000 Message-Id: <20221028095632.1081262-6-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> References: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_025733_055121_90EC571B X-CRM114-Status: GOOD ( 15.64 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Alistair Francis This commit adds a futex waitv syscall wrapper that is exposed to userspace. Neither the kernel or glibc currently expose a futex wrapper, so userspace is left performing raw syscalls. As the futex_waitv syscall always expects a 64-bit time_t this can be tricky for 32-bit systems to get correct. In order to avoid userspace incorrectly passing the wrong timeouts let's expose a public helper function that ensures the kernel is passed the correct timeout struct. Signed-off-by: Alistair Francis Reviewed-by: Arnd Bergmann Message-Id: <20211209235857.423773-5-alistair.francis@opensource.wdc.com> --- include/uapi/linux/futex_syscall.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/uapi/linux/futex_syscall.h b/include/uapi/linux/futex_syscall.h index bac621eb319c..f637f05a3be0 100644 --- a/include/uapi/linux/futex_syscall.h +++ b/include/uapi/linux/futex_syscall.h @@ -89,4 +89,31 @@ __kernel_futex_syscall_nr_requeue(volatile uint32_t *uaddr, int op, uint32_t val return -1; } +/** + * __kernel_futex_syscall_waitv - Wait at multiple futexes, wake on any + * @waiters: Array of waiters + * @nr_waiters: Length of waiters array + * @flags: Operation flags + * @timo: Optional timeout for operation + */ +static inline int +__kernel_futex_syscall_waitv(volatile struct futex_waitv *waiters, unsigned long nr_waiters, + unsigned long flags, struct timespec *timo, clockid_t clockid) +{ + /* futex_waitv expects a 64-bit time_t */ + if (sizeof(*timo) == sizeof(struct __kernel_timespec)) + return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid); + + /* If the caller supplied a 32-bit time_t, convert it to 64-bit */ + if (timo) { + struct __kernel_timespec ts_new; + + ts_new.tv_sec = timo->tv_sec; + ts_new.tv_nsec = timo->tv_nsec; + + return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, &ts_new, clockid); + } else + return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, NULL, clockid); +} + #endif /* _UAPI_LINUX_FUTEX_SYSCALL_H */ From patchwork Fri Oct 28 09:56:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13023357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8DA2ECAAA1 for ; Fri, 28 Oct 2022 10:06:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DVYLak33A1orWztOrN598rby5cfsQOyasSILaAm8B1A=; b=UE+gi1XUHnotWM tm7czvvoSy8/wDYl76wJGTuLOS6Lds84Tk6oOC/tg7bVP64+Wt81IgzxwEqHS0F0OY49jqpjCxQ60 7LSLKqg0840BsTt9gVAaCumTLBtFYMSHCw/RzDVC5qNKAtTWB/xLpc4UhHd4R5Xys9YQXn6mKssNH qxHDHrSGVYUqEfx0UWfAGWHnHJpPqw52Y6HicSuYlG58a77VKzM0or+or16IXSqSnM5W94ex42LrB 8GH54ZB9nbFTwsjwR3jKpROLigzYqWe3laGc/wOb2Jbu6CbvUnsqP8rRAJ9GsByaV+UfCR7l4/5U+ 5JwfaIcAh7fY/adBzW8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooMG2-00GXKc-Ac; Fri, 28 Oct 2022 10:06:34 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooM7N-00GTfM-DM for linux-riscv@lists.infradead.org; Fri, 28 Oct 2022 09:57:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1666951056; x=1698487056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JydiMbJm91qt7Dzdbzqgf9FuIhgVG9u78TP21lC8mbE=; b=BVnrFIl1Ebc1HRak6ydpe0JHAntexjYW5PDLD8sIe74JZ6c4QW6e43Sg GKe8Z6Y/eP7bP/sVitVOcqh5Pq6L1oi/n6DochRkaeKzURESHVimESWzM I7a3gGynvN/L6U0YrCqvaWCoihK+GuXLu/5R1gH4+JOvOijbx6J9lhxQU ltrcwADgJ1NNuSTCx6SdHm9VHj5heK3syGjZPhqe7JU/UVdwq7E4zc9Eq R+BkWh6KxUw4wBY8NkgEbfOHy0WKldY7bejVinKiCLRh4bNMxVqdIhOSj XWwiazNQnFhqOWjvPVcsBLLwwRIHpFARKW5bf1bJNSlB97El6hWIN8pTa A==; X-IronPort-AV: E=Sophos;i="5.95,220,1661788800"; d="scan'208";a="213258419" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2022 17:57:36 +0800 IronPort-SDR: av+dagjkY6EkFnwBppv4ckRXe6zZOONdwBq1darThD3XBg7Lcq+XyZxdS/1MTL8816ggqZ872+ n6PfJ3M4/iQR8/Cu7V+pdj2F1OtiguB54oVUnbBcYDeFnTV66wVKNwPUVMlEDvpmhD2VTDaAjk af/MsRJh9pA3wWuUtEI6r5kMD8T4eAiJ1LZGfVFoVas7BwdepEvZxqFrnGAg8DyTW8FQ6KhW4m hxKQ3opH8dNYK1p43v66gTEXFlJFquTGeOjqQmkebCwV7BbyfH5WF4ZnxH3qDKsyyt666QPG09 ZiQ5J621PYMJ6Tj4QtAoa0fy Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:16:56 -0700 IronPort-SDR: Ufi+IF736FoO6ZywYMfrwn/UnA7ZubsCn5rgVU928LkfO/hRRLP6WN7rMXeTZ7cEIAZncoha2M cKaZdEBeB5QsxCjv7Aj9DDD38NNeWtvnHAMlaoHuGhBLKxiw6aDORaKlNqH1vPpAOO7yc1Ktxs 17LqHdyYDtRhAZdy6dhVb+aMZVeQCssJZafe3p4urrh5ahHURzNQrUco2EK8iNFqhNV0OqX8Aw jX79hs6nrxSfX5OeraaoBQeisS3yfHgRpOqsiERBjHNmmAbYhZ7LBImFOts7em/fsPTX4Q6rwk VDs= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Oct 2022 02:57:37 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4MzHz45N2Nz1Rx15 for ; Fri, 28 Oct 2022 02:57:36 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1666951055; x=1669543056; bh=JydiMbJm91qt7Dzdbz qgf9FuIhgVG9u78TP21lC8mbE=; b=j4RPkeDxD2OMqX5Kxa/3L32kWsZVpnmHr6 BX+yIlhNHMvGj8A/k3T1hWRpUdDmrQWD7bum2uaSPmy7PgQtfwWQh9jsrpx9aLai twJ3Qb4KRS3qMqAY5VyHySyh/tP8wknTEYHCs061Qq7tKyih2RzCagzYSo+nsAQH dvvF8wU4J247DKqVq+cPiysOHuqw5sByri8/ct5ZjmjXPD6smYx/xm7TL4i5AZvh i539ZC1YkSepuErIJctkmpHBUR4i5HAeJgJKBBDQ/doWP8SbVzFX+EErBI3DA9hF vGgkNwGT29RTkowIHP/Zy/Wu4zNaPL+MlyFdv2ud1IqiEU2U1i/g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Cfz6XwZHgA2X for ; Fri, 28 Oct 2022 02:57:35 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.167.50]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4MzHyy43gyz1RvLy; Fri, 28 Oct 2022 02:57:30 -0700 (PDT) From: Alistair Francis To: linux-kernel@vger.kernel.org Cc: acme@kernel.org, dave@stgolabs.net, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@redhat.com, linux-perf-users@vger.kernel.org, acme@redhat.com, dvhart@infradead.org, mark.rutland@arm.com, peterz@infradead.org, arnd@arndb.de, alistair23@gmail.com, linux-riscv@lists.infradead.org, mingo@redhat.com, alistair.francis@wdc.com, atish.patra@wdc.com Subject: [PATCH 6/6] selftests: futex: Use futex_waitv helper function Date: Fri, 28 Oct 2022 19:56:32 +1000 Message-Id: <20221028095632.1081262-7-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> References: <20221028095632.1081262-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_025737_589644_2D39308D X-CRM114-Status: GOOD ( 11.25 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Alistair Francis Use the publically exposed __kernel_futex_syscall_waitv() helper function for the futex_waitv tests. Signed-off-by: Alistair Francis Message-Id: <20211209235857.423773-6-alistair.francis@opensource.wdc.com> --- tools/testing/selftests/futex/include/futex2test.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/futex/include/futex2test.h b/tools/testing/selftests/futex/include/futex2test.h index 9d305520e849..fdc0a0a270cd 100644 --- a/tools/testing/selftests/futex/include/futex2test.h +++ b/tools/testing/selftests/futex/include/futex2test.h @@ -5,6 +5,7 @@ * Copyright 2021 Collabora Ltd. */ #include +#include #define u64_to_ptr(x) ((void *)(uintptr_t)(x)) @@ -18,5 +19,5 @@ static inline int futex_waitv(volatile struct futex_waitv *waiters, unsigned long nr_waiters, unsigned long flags, struct timespec *timo, clockid_t clockid) { - return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid); + return __kernel_futex_syscall_waitv(waiters, nr_waiters, flags, timo, clockid); }