Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1215221pxb; Fri, 10 Sep 2021 00:18:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJ14GEsdEt35a7oTFyIAM5Fww0EN9b4yK2n65DC3PultFKDjD/Wgk28Isp6UF6d2pvNruT X-Received: by 2002:a5e:c807:: with SMTP id y7mr5888072iol.87.1631258332738; Fri, 10 Sep 2021 00:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631258332; cv=none; d=google.com; s=arc-20160816; b=FDIqf/ZsAEu7NhOEQ1dqBK3kgpc/qOVvB76Xu93ATCXrb3GjQronUMstnKsfugqK+X jsYAcjQzr+HywW6kvPqNBMiVh2iXcku8zyQTrtJxPN+lM/YHD2C3Y/pyyCYD4quRVJDb dd++J35Pu5MwwbD2IlJG5Ic0ZCC4Tp3H5iJn/emPmHNXcDpwMYo230ac2gtqgPwPhRbj 9gO0w0B5zbhU+MShXs7Hy+4yWWa+j5EF0RkgM2NWuruIWoZsg/Jihy5dWsBGUS1MY5ey zDeZiLOlk6UpZG91w+KgMfQnvnwfczbeoWvlqNfOaWnInqqDM8nAV3SCnAPzgSSwzDJz hfvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=0E1MIQ4IoJr4tdDFqWVhogv9SyWPvsaypyFSDpw2260=; b=CuKxzsy217M+ENVHQaxD1YslOxf9LghIihoJP24V1v0vM5DBW1Q3MLjA6f9+vmQ9/e duWT966+G1UshMNbSSauMBdKyExnsUcBcT1ZvCFVS/AKoptvV2b06gvMJTDKZnbmTcBo 3a1l7h1zGWnMYsS3LN8bDMgye+kkBFw1xRBlta0WjVCVnWkPhN2ekU5UuEsfuxCEd9PD rohJEhaPJH3O7fu7XNKBjimNNA6tVr4E3XjP+23+cCL7rhLRAYy4G/GFsXFSyXfg4e+f a3pd2LbtUvCsuGkemUNxTxbxRj19QeQNPVXt8LgUWEqtXizV0RFMLxdVeV+8Di1+RKN/ 80vg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o12si4203120iow.40.2021.09.10.00.18.40; Fri, 10 Sep 2021 00:18:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231337AbhIJHTL (ORCPT + 99 others); Fri, 10 Sep 2021 03:19:11 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:32801 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbhIJHTK (ORCPT ); Fri, 10 Sep 2021 03:19:10 -0400 Received: from mail-wr1-f50.google.com ([209.85.221.50]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1Mt6x5-1nD87K0HQv-00tSjk; Fri, 10 Sep 2021 09:17:59 +0200 Received: by mail-wr1-f50.google.com with SMTP id t18so1246551wrb.0; Fri, 10 Sep 2021 00:17:58 -0700 (PDT) X-Gm-Message-State: AOAM530tUllB172YTRMIlok+K9DwPJDzESBRS5jfr291t5TAj24NDZGF +eSNYvoOWWHXFNQzKs7x0s8ftrCu4TyvcPpa/3k= X-Received: by 2002:adf:f884:: with SMTP id u4mr7688308wrp.411.1631258278655; Fri, 10 Sep 2021 00:17:58 -0700 (PDT) MIME-Version: 1.0 References: <20210910043102.3616198-1-alistair.francis@opensource.wdc.com> <20210910043102.3616198-2-alistair.francis@opensource.wdc.com> In-Reply-To: <20210910043102.3616198-2-alistair.francis@opensource.wdc.com> From: Arnd Bergmann Date: Fri, 10 Sep 2021 09:17:42 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] perf bench: Add support for 32-bit systems with 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:yLyEBWzN8orKgC7JoBJLJBeID0xZqkk3Izp6B13iX96VT+NjRGz JiHtrBJIPGdThHoF/rvFsi0PFmToQvYZ7W2N31mzaTNPa0IVn1lc4q4rHGYu/oebXUMIwxL vV6Aqy562+i28WR49fsufcQAI2vdRuEQQJiLVWToR8ZFVEcFQtG643hvNsTH+NoxVlfQjeM 4WVC110/4FvTYyduo6Mlg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:DwjTfUOniio=:RDyjFFbH4Ha44B/h1oPSCY l+i4gK/DLmUN2WopwCVOBWDXeIGokk9g3xTYJoMG3J+NvMNc501NGJ9dzZCfkrhAZ271NRlId cqAyHgMCzKhURYIV9npmg6BFxbr7OJvETq2Ey3PQCG5LcxdujHSnrc+MIYMvRgBFkXRsCZ5Wk 3pkFYDveDBQAV/q/FyM219MKoXEq20klze7hY9waS0mKH5jROdxrKowQLSFF2NLTx7m8/VPuo 6bP1TWoTS6oOuMMyvqZadKwfj3uR3WohoVdZ92vA1gl1aTOlOXs9JKynoUdyY66TI+9cmAdK/ 05+3Ad5Z59epnoihG8m75R7pC5D5+uTTj9q91d05bb2gLnbwzkyundNvg0E+zYbkpucL3Y5Hn GeK6qdqNBx+6ELcSw+/DMIuDyDP8BQsRmfJIZMrIJfAcfxTMmHtRI8C72nWPC8EVUGulSyjTW IwxSTkHW5DnC5rL+RpY3gbqz6eqyhK2F9eEA+6wYL/gV8Z8WgoSNC5s7R/qk+25pfl2bwT1ad dO9LuXhvf8o7wXlhoao0UF2iGhhFKkH3wlAsZkqEL7123M+YbRkef6awjw7wq09eXpBJ3RFoT 1ajYUUMZ9+RZOHKjTG5oAkVDjxgd9wyr9LdR2cMdt6eO5IwJLGZYW2iN6N80Gx35yCz/t4Dxa bJPE+Rw5I/PoftbKwPwttNPm9weqBEJSbfnrK7GkB6yVyGXKx0FImfDl4qNqSkD1P6IWmgiOj da0kaAlFh/POjQ74WBbAIGwjbhMWXv41gC6PtQ== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 10, 2021 at 6:31 AM Alistair Francis wrote: > > 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. > > Signed-off-by: Alistair Francis > --- > tools/perf/bench/futex.h | 43 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 42 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h > index f80a4759ee79b..09c5596726c60 100644 > --- a/tools/perf/bench/futex.h > +++ b/tools/perf/bench/futex.h > @@ -27,6 +27,12 @@ struct bench_futex_parameters { > unsigned int nrequeue; > }; > > +/* A version of 'struct timespec' with 32-bit time_t and nanoseconds. */ > +struct __timespec32 { > + __kernel_long_t tv_sec; > + __kernel_long_t tv_nsec; > +}; Why not use the existing __kernel_old_timespec structure definition from the header? > +#if defined(SYS_futex) > + if (sizeof(*timeout) == sizeof(struct __timespec32)) > + return syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); > + > + if (timeout && timeout->tv_sec == (long)timeout->tv_sec) { > + struct __timespec32 ts32; > + > + ts32.tv_sec = (__kernel_long_t) timeout->tv_sec; > + ts32.tv_nsec = (__kernel_long_t) timeout->tv_nsec; > + > + return syscall(SYS_futex, uaddr, op | opflags, val, ts32, uaddr2, val3); > + } else if (!timeout) { > + return syscall(SYS_futex, uaddr, op | opflags, val, NULL, uaddr2, val3); > + } > +#endif > + > + errno = ENOSYS; > + return -1; Similarly, I think just using the kernel's constants like __NR_futex instead of SYS_futex would be more appropriate here, this way you know if futex_time64 is available and don't have to do the emulation for running the binary on pre-5.1 kernels. Perf already uses __NR_perf_event_open, __NR_getcpu, and __NR_setns instead of the SYS_* versions. Arnd