From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58911C433EF for ; Thu, 14 Oct 2021 06:51:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3245061040 for ; Thu, 14 Oct 2021 06:51:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbhJNGxu (ORCPT ); Thu, 14 Oct 2021 02:53:50 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:58563 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhJNGxt (ORCPT ); Thu, 14 Oct 2021 02:53:49 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]) by mrelayeu.kundenserver.de (mreue012 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MoeU5-1n7WR43Cht-00p0qS; Thu, 14 Oct 2021 08:51:43 +0200 Received: by mail-wr1-f41.google.com with SMTP id o20so16155263wro.3; Wed, 13 Oct 2021 23:51:43 -0700 (PDT) X-Gm-Message-State: AOAM530xIU2MsIQEIKDOBHGB4hwNCEqNhNMvGoi4lN85TYopVEW40c5q alNuktdfd2aVUw5q/A4otH7A1QOuxxPHwr4jQvU= X-Google-Smtp-Source: ABdhPJyjkQmPWKvwtoJuywMTwdaB2QbiQeIa9CvSMEZ8lo+ku78lzm6zV4NgWZcj6r9FJxHxXDzR/T1V0OVEWXe/2uU= X-Received: by 2002:a1c:2358:: with SMTP id j85mr17404148wmj.1.1634194303392; Wed, 13 Oct 2021 23:51:43 -0700 (PDT) MIME-Version: 1.0 References: <20211014055527.1238645-1-alistair.francis@opensource.wdc.com> <20211014055527.1238645-2-alistair.francis@opensource.wdc.com> In-Reply-To: <20211014055527.1238645-2-alistair.francis@opensource.wdc.com> From: Arnd Bergmann Date: Thu, 14 Oct 2021 08:51:27 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] selftests: futex: Use a 64-bit time_t To: Alistair Francis Cc: linux-riscv , linux-perf-users@vger.kernel.org, Linux Kernel Mailing List , Alistair Francis , Namhyung Kim , Jiri Olsa , Alexander Shishkin , Mark Rutland , Arnaldo Carvalho de Melo , Davidlohr Bueso , Darren Hart , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Atish Patra , Arnd Bergmann , Alistair Francis Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:uaIx0SONLfYOEYGGXqs6wd7mJ4VYpvjZSTe/4OrVu+w78Iu+rLv 3xR1og+W5spFVDC/jx0Hs696hW3pG7CAJE+QwD+t2Z1XE+4med7uDJIacbv8hEbC4uxFO7f fyKDFjBwiT2xLNA4WufKdpEuLuxI3+bZrDBr3plBNsy381ODD/VxH6f6wZlcjB/baGgMj4h goaWOQ2CpqTQTR+KLBQIw== X-UI-Out-Filterresults: notjunk:1;V03:K0:ruxhhwKyz5w=:PS+2KOXKV4ntXskPdAlJp/ q/+g3PgHyk9Vz2AN/W3qggiVyJ1HquvPBevqFioWwt1WX7vIqBJcUy/luuV8l/k/PdP8p5jtv GsQB0uymTDxYrFyC/iVaz5Bd1Ta62DfOSTy7+cNWKaMtU/JPRMI9QgA7Y44VZCL7dW46pNCyp 0LwLtg74EDalw10iwC3WU/WioKYaWFmnw6fzqm8yGIN5g0coryzf+C3JGWi44Ta/TZ6hobGkd EdZK13aNM2+4sSY4D7z21faCaffleVh5u/dkJJNorOF8DCjFLzCzHVGHJOrfQ4hYZFQYeO1kU MxpSGNRhm0Ago+dExTumEjwFetsCMs8piyj130S+zkMzeNVfvKP2Ufk56yFH0e6PRxLU/HoGf Den6MWWLd4lyjpp8M6/sQ/q0sFEUcZJlevle5ZCyPa9WYQEGEq945XEQtom3ymKjwRdaUmGNt hqpP/JQNtImyzxdyDF//d6iYXuF0PYkx9XRrwTnoU9kHlyXyl4LjUltXCDDTlIF8Q2Kz0zonh 2BtuiISuQyjKxpzU6aV4gfXig7+Xw5b/+ZBBF9LTdeI3GDNYReCIg1IhLnEME2/iMZDNgOWRw PbWiglUfZ3DMZv+Z28jp+wa79DXuKmtER7NdD2skexR7D/+/8Bhn9GwjSxnZMy7KLm6m2t8kU 4fJ59xPlRzMspW9BZ3I+neKHHAz9/9FM+HqtgWofstuhWwais6fUC0ITlbSgiolh1CNyWRLqT z2e+jRdKv5SYfJCWGP2oTuMRJIn074else52vP5pZgURPhSODbZX9HRczBLRr962vjrQoU4j0 +eal1jYONDyCIZHPoSjC9OhCoLjcXCQt5Vrooj/Aa41mv8Q01gvc3U3F3VCojRDH740MQpYvC A9ybPaDamyuT7IvwcRFg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 14, 2021 at 7:55 AM Alistair Francis wrote: > > From: Alistair Francis > > Convert the futex selftests to only use a 64-bit time_t. On 64-bit > architectures this isn't a functional change. On 32-bit architectures > we now only perform 64-bit time_t syscalls (__NR_futex_time64) and > use a struct timespec64. > > This won't work on kernels before 5.1, but as perf is tied to the kernel > that's ok. > > This allows the tests to run and pass on RISC-V 32-bit. > > Signed-off-by: Alistair Francis This looks correct to me, two minor comments: > +struct timespec64 { > + long long tv_sec; /* seconds */ > + long long tv_nsec; /* nanoseconds */ > +}; This is a bit different from the normal timespec definition, which has to use a '__kernel_long_t' tv_nsec for POSIX compliance. The difference is harmless, because the bit layout has the lower 32 bits in the same position, and the kernel zeroes the upper 32 bits on the syscall boundary. I would just use #define timespec64 __kernel_timespec for the same effect, since that is what __kernel_timespec is meant for. > +#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__)) > +# define futex(uaddr, op, val, timeout, uaddr2, val3, opflags) \ > + syscall(__NR_futex, uaddr, op | opflags, val, timeout, uaddr2, val3) > +#else > +# define futex(uaddr, op, val, timeout, uaddr2, val3, opflags) \ > + syscall(__NR_futex_time64, uaddr, op | opflags, val, timeout, uaddr2, val3) > +#endif The check for x32 user space looks correct here, but as I commented in the other patch, I would keep it simple and use futex_time64() on all 32-bit ABIs. There are approximately zero users of x32, and they don't benefit from being able to run new perf binaries on pre-5.1 kernels when everyone else can't. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD7D7C433F5 for ; Thu, 14 Oct 2021 06:52:18 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9952060C49 for ; Thu, 14 Oct 2021 06:52:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9952060C49 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cXEEJq94RWE1vPEUD2oYF9F39lk9TGKnO4fLrYh7FI0=; b=b+FKs9e6FHCbjp LYYaKrXK35RH9HSmGoFcTwIrc/FoFKwAW8QZW+Yje8S1WyzdDSIUJzA6OCh3Xx0Edcb19Mum2+JTy H5dBNkW8iUvcA5Pydnyi6BZiA0HMyMFEYCU+tTgE7YbYHMDuJGPBr+ayIn/g69QrJpKPSdGvfaMi8 jHoRP/TGX/e18qlJD7lHZADASEsYOEZence98oDeYxvRxPglybL1CXTSx8/guJ0B5l+n/PhxTOFUt mpALrxNriat0hEPPnYF4DO1cFJCP3XKzqal3ch7VwNZaUhrYqbGYwmDk6Yv4VN9zvhhUbSzzE+eZK IhQsGy0LYMBFliB5z5Kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maual-001lPP-FH; Thu, 14 Oct 2021 06:51:51 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mauai-001lOE-Jn for linux-riscv@lists.infradead.org; Thu, 14 Oct 2021 06:51:50 +0000 Received: from mail-wr1-f52.google.com ([209.85.221.52]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MXY2Z-1mF9A633Ed-00YyQT for ; Thu, 14 Oct 2021 08:51:45 +0200 Received: by mail-wr1-f52.google.com with SMTP id t2so16088019wrb.8 for ; Wed, 13 Oct 2021 23:51:43 -0700 (PDT) X-Gm-Message-State: AOAM530MXwyvBtgqyNzimoneUO3MsuHzF9rnIbY0uEy5mgAbfkOdZPGM mcP8hXHEvglviGz/xE2y9jUvFrKdlsa9ZXSEf1U= X-Google-Smtp-Source: ABdhPJyjkQmPWKvwtoJuywMTwdaB2QbiQeIa9CvSMEZ8lo+ku78lzm6zV4NgWZcj6r9FJxHxXDzR/T1V0OVEWXe/2uU= X-Received: by 2002:a1c:2358:: with SMTP id j85mr17404148wmj.1.1634194303392; Wed, 13 Oct 2021 23:51:43 -0700 (PDT) MIME-Version: 1.0 References: <20211014055527.1238645-1-alistair.francis@opensource.wdc.com> <20211014055527.1238645-2-alistair.francis@opensource.wdc.com> In-Reply-To: <20211014055527.1238645-2-alistair.francis@opensource.wdc.com> From: Arnd Bergmann Date: Thu, 14 Oct 2021 08:51:27 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] selftests: futex: Use a 64-bit time_t To: Alistair Francis Cc: linux-riscv , linux-perf-users@vger.kernel.org, Linux Kernel Mailing List , Alistair Francis , Namhyung Kim , Jiri Olsa , Alexander Shishkin , Mark Rutland , Arnaldo Carvalho de Melo , Davidlohr Bueso , Darren Hart , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Atish Patra , Arnd Bergmann , Alistair Francis X-Provags-ID: V03:K1:2Gh5RtCGAPRqiv+Gbe906vDYh2rrg6zKUfoMXG4ixxuoarbtryS wQ+4zxyJbWJCqlZ+Sa+ep1GDN1rm1vF6nwHtgkrZKwwXsaoEqIgZtz/vvx0F1FFpb5C/maX oMjAKMe1AfJdR/q+nvELSsC11Nz4ggdlqDg+nYdwsKiS7fauemKHSfHVBmo742AXB2+MYiO 2MrpX1tWkRCcgjGpNd5XA== X-UI-Out-Filterresults: notjunk:1;V03:K0:OUC4RpmU9CU=:pogs/JYDXbR4XFP6rWMEVw 7RQ1rUskhIwachX0svvWxNI96ZSWVqaP7gm4+hnKxRTfUV0u3UTbsV5Dh5KXYjfaCF8n0jJZw JljzCpghkb7+LLUbfa9fmW7uGrqKkYno06P69KkxgDGnE0RquxwEPv7yBwGStqaT1bPDDwKCf 3C/o5MgJMtyro7pVJil9KRolM9Js1dlwtZAbM5EMUFPBghCCvtNhKuyB+Id2NyD4aSXrZc56/ azOrsBH1xC/7JYfACEeQur3BNdFLHDPcS/dA05/vuHaShwOWFUzWalyNGVBYpmKVnKCBIA62M VIuwhPcsC02HOsG1lEdDh5btX2ETvRecaRvCWS7MYmzalaKM2BJjoWjgttkld5gA+lbZsA+fX 86Doq7n9ioY0wCjWltNmxT/FEbN53kAtXWu11eY/AgpcWL3evsG/nVyxc8fI7XXIRHLGG2tNN 7IfBCxmdqklFS6sgN222n+mtY5B8fqcjlPijnqPkZQwqfOtPunzVhl3NCxm9/jlso934FR4R+ E0yGmpFUEtBIwury3y9KNIDLOLKRWX7jE3ySJvN13/Wu5HprGs+hWGP34UW5u9lA4dfs5Irxp wWzXPD1Mg6b7+jfJU9fRD7TQRkfG4I8c2Orr4NhX6Xq8alkFyh6M5NoyiGx3U6vBFAv4Ap1nf xrnWGHq/aYsLj6xRqeAg9YXeE9wZkIw9q+obWTb6dLDlR3pSOfI2fI6RB3oRh0W09YbnFuKCF CMQwDlxxMshdpEAPhs3qifRSlk2LEWMEH0vQiIxutCoL2/YRFGYiS5y2fzThfRmMFTOQAph1X PveLgSDPK1HGVoeUItkF9T5bZEqNLaj6N6enXcMTNeFdwxQeW7/+a5/TRdcb9BArlqFYmnCLO 5b3MYkIgs8u8CMv2sBzw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211013_235148_957314_B8634E65 X-CRM114-Status: GOOD ( 20.96 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Thu, Oct 14, 2021 at 7:55 AM Alistair Francis wrote: > > From: Alistair Francis > > Convert the futex selftests to only use a 64-bit time_t. On 64-bit > architectures this isn't a functional change. On 32-bit architectures > we now only perform 64-bit time_t syscalls (__NR_futex_time64) and > use a struct timespec64. > > This won't work on kernels before 5.1, but as perf is tied to the kernel > that's ok. > > This allows the tests to run and pass on RISC-V 32-bit. > > Signed-off-by: Alistair Francis This looks correct to me, two minor comments: > +struct timespec64 { > + long long tv_sec; /* seconds */ > + long long tv_nsec; /* nanoseconds */ > +}; This is a bit different from the normal timespec definition, which has to use a '__kernel_long_t' tv_nsec for POSIX compliance. The difference is harmless, because the bit layout has the lower 32 bits in the same position, and the kernel zeroes the upper 32 bits on the syscall boundary. I would just use #define timespec64 __kernel_timespec for the same effect, since that is what __kernel_timespec is meant for. > +#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__)) > +# define futex(uaddr, op, val, timeout, uaddr2, val3, opflags) \ > + syscall(__NR_futex, uaddr, op | opflags, val, timeout, uaddr2, val3) > +#else > +# define futex(uaddr, op, val, timeout, uaddr2, val3, opflags) \ > + syscall(__NR_futex_time64, uaddr, op | opflags, val, timeout, uaddr2, val3) > +#endif The check for x32 user space looks correct here, but as I commented in the other patch, I would keep it simple and use futex_time64() on all 32-bit ABIs. There are approximately zero users of x32, and they don't benefit from being able to run new perf binaries on pre-5.1 kernels when everyone else can't. Arnd _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv