Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2213126rwi; Fri, 28 Oct 2022 04:34:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4W/RDZmUgytALkb5aYvl8vGzP6Gwqqtz1OKmFr2c3zfjAjdOAkKxZXNvspOOQszSHz8WSX X-Received: by 2002:a17:907:2bf9:b0:7a4:bbce:dd98 with SMTP id gv57-20020a1709072bf900b007a4bbcedd98mr26943435ejc.669.1666956855222; Fri, 28 Oct 2022 04:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666956855; cv=none; d=google.com; s=arc-20160816; b=fg8pqi+UkB5swxiPggREaZMQO01/1xY3wJKFDa1paKxsHTb9mM2VaTaTQpBxAxt6Au eg39Yhh4+4bPTt8XweufiU02ivEfTVk6CZFC3m49JMiYL83TZ2ngFUSUJZa76LgSci1Z 26OYc1LA4ivTMvVRik/yJKfpQs2Obwo/fMVaO7mxyRnf1GziG3sO+d+cYi2Hm+UjaDnm IZBSzor9Ii95ziF71eqISFCJAjrpHc2PqmJpJbeH59AZxlmDoxXD+Ei8EuG/KbLdv+Xx 5o7BewD5Fa/dZXrd5UDDRyfHCEggeI2zF4yU6b48jxEgCiSF4AempQfnkbWOAT7Oxxos YFoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=4vMPaezZBRCIUQ3U47C32B8j6nKTaOtSDpcJ04CdoS0=; b=GDLIutD8AhsncNn2gETT2u5mAGF+SSk4CgucAVt5xl5poUmjnPmg1sssGw+azvgx+N X2itkcdMnLKw/vnr4fC6jc2WzHDbb++cgsEsXPW0acFXQZj/bHaK/m7f2rnPiWeDBedO XLndWIIsjuWGbkwQN6j4Ajo9MKW7YWS2GSjmjdjgOATsyctuQtZnzktaDRbYpYgjPTm1 YELhWMLF7XzvMsA+6dEBJd2Ezpxz71Ug/j4DFTNp+jN1kPVJrY2at2aXplqBisJPLTzw FXoRKkHfyazRHnI2fWYjnDjwTkPEDsZaeM4Itpr+4vyd+iYmvjrD3qWt7VOSbxQ3DL6J uA+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=MryUVIOx; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=sAi49Kz2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wi13-20020a170906fd4d00b0077ed84da316si3328607ejb.217.2022.10.28.04.33.48; Fri, 28 Oct 2022 04:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=MryUVIOx; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=sAi49Kz2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbiJ1J6Y (ORCPT + 99 others); Fri, 28 Oct 2022 05:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230362AbiJ1J5w (ORCPT ); Fri, 28 Oct 2022 05:57:52 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCE6B78BF9 for ; Fri, 28 Oct 2022 02:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1666951027; x=1698487027; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HDOW4KvVqZm7M+oRwyLLXnE8cnS2CkUYQNAOKUB1qEA=; b=MryUVIOxX5idiKMr1s9eTK0X6QPeDaz/soHe+0Zd73tuen9z+6Ok+/IX llEzY4UfkL9+b/iQ4CQmI9BBSbdzphjJnkoag8YE4BWbn7jkHRfqisT3M FDO++5zOtfgD3hWtl0Qjsvc7yypQk1bH8Iux+Lr70EbppARdhrgbodvfO CAQqZDs5apx9XKX17ukEP+2shDRz95cK4PafIDP0Ok8bno35NjbIzXFRQ GCGGtoFTvFHpDs1NbmHvs/UuSZEYwhWPOsfj9JF2WR68Z3xmiDC/gK6gr PRX+bJ7QyJpEXc9anonNbR1e0c3bk9XdGAuX1jX13eQ5wTSGKzsPlrkYl w==; X-IronPort-AV: E=Sophos;i="5.95,220,1661788800"; d="scan'208";a="214962182" 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:06 +0800 IronPort-SDR: LBpz6MBox9ISVsLvntTKLeeLVan0qiu7RRwb+g2a33sTew4zKHc0b/n71TbykJSBcdsDlx8HfM fIo0YtXlH61zjj//a4X7km73jgTKSyYdiBGNBBazIdY3F77E6VEdmIzlj6YOLV87LEk4p4l0ir 84klRH4xtCQA84vKTNWjv3l7lxm2WG4KRPzQz0PB8scTu8fpWobcayQTHXEV9GuTToisuhc5fc Qyu6vO9CcC28VZ2Gq8qBAbvsouthRSRlLBt9A51GGZ+Dd7Ehhej3VBO1S+DGm9bTpHJAZ49vjX 93oAv9rR5+oWjiZXydGEChG0 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:43 -0700 IronPort-SDR: Cav5Y8AqmC8okMtSDSjHTGImmia9jmTzGbvovhVNqWFMGf4W5IT4yviJCuh+GJo/P7ouKJhg19 N1sCL+nR3XGPFfYkKEQ+httw6AH1s5F0fCkhhQyphoZFysxKt15FkBebHwSciOUisclPSEnid2 3zlR3mfHqx7PRwlVLk3ldVuHEAQpDg9hOtWtr5f34G6HgDBNgtUUZp3VQDQk4nxQXaChYHUCfQ maPOO7kiBZ8RTmrJfZosLdavKYB+X5VdCw4FZdSAWQavpWV3S8g+SvNyc4tRMd6LpWNCClLiWc O7g= 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 4MzHyT2KYCz1SHkX 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 meVjp_qOu_uk 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 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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/te= sting/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 =20 /** - * 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_FLA= G * - * futex() is used by all the following futex op wrappers. It can also b= e + * futex_syscall() is used by all the following futex op wrappers. It ca= n also be * used for misuse and abuse testing. Generally, the specific op wrapper= s - * should be used instead. It is a macro instead of an static inline fun= ction 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 bel= ow. */ -#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 t= imespec *timeout, + volatile u_int32_t *uaddr2, int val3, int opflags) +{ + return syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, va= l3); +} + +static inline int +futex_syscall_nr_requeue(volatile u_int32_t *uaddr, int op, u_int32_t va= l, int nr_requeue, + volatile u_int32_t *uaddr2, int val3, int opflags) +{ + return syscall(SYS_futex, uaddr, op | opflags, val, nr_requeue, uaddr2,= val3); +} =20 /** * 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 op= flags) { - return futex(uaddr, FUTEX_WAIT, val, timeout, NULL, 0, opflags); + return futex_syscall(uaddr, FUTEX_WAIT, val, timeout, NULL, 0, opflags)= ; } =20 /** @@ -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= ); } =20 /** @@ -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, bits= et, + opflags); } =20 /** @@ -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 opf= lags) { - return futex(uaddr, FUTEX_WAKE_BITSET, nr_wake, NULL, NULL, bitset, - opflags); + return futex_syscall(uaddr, FUTEX_WAKE_BITSET, nr_wake, NULL, NULL, bit= set, + opflags); } =20 /** @@ -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, op= flags); } =20 /** @@ -130,7 +139,7 @@ futex_lock_pi(futex_t *uaddr, struct timespec *timeou= t, 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)= ; } =20 /** @@ -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); } =20 /** @@ -156,8 +165,8 @@ static inline int futex_requeue(futex_t *uaddr, futex_t *uaddr2, int nr_wake, int nr_reque= ue, 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_reque= ue, uaddr2, 0, + opflags); } =20 /** @@ -169,8 +178,8 @@ static inline int futex_cmp_requeue(futex_t *uaddr, futex_t val, futex_t *uaddr2, int nr_w= ake, 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_r= equeue, uaddr2, + val, opflags); } =20 /** @@ -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); } =20 /** @@ -200,8 +209,8 @@ static inline int futex_cmp_requeue_pi(futex_t *uaddr, futex_t val, futex_t *uaddr2, int n= r_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, n= r_requeue, uaddr2, + val, opflags); } =20 /** --=20 2.37.3