From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by sourceware.org (Postfix) with ESMTPS id 147843858D3C for ; Wed, 29 Mar 2023 18:39:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 147843858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-17aaa51a911so17195558fac.5 for ; Wed, 29 Mar 2023 11:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680115175; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=Riw9WgK+n4y2Fx4rZVXIJ8Ph8bOYR43oKXoiSyTjYyY=; b=Kerb5Jf1hWW3M0rShPAF/kx2gQiPokurfpPLUb1GbuMTPf5fqGFmsd12waLypH/L0Z 7InNbUjHWoMRpsKhiow7gxVxd4m+MM/29mgJyXrzqdbQlSUsgtv1Qc/lwzx5rFX7Xs9h D0VJBwV6atH67k4BzdFZrpQ4fIr8/y9/TCt0teAyPkgXiHMTzz6l4CLuSJhMCkqALQJ6 vVBYS2QGz9P+boT29wLU7Kv5cSIByTHQNZFnjct2g8UOVebox9YLkXHesPnvOjdoPqDp Xzvyr8txlK+aHFugMznwzHJDwVmuXQPa/+aZkCsBL1Tktd31El31v70ILzRAmms9tIu0 jsYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680115175; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Riw9WgK+n4y2Fx4rZVXIJ8Ph8bOYR43oKXoiSyTjYyY=; b=fZnykWNMatGXV8bWEcfTgEOtIE5nXIE9xyaZgNp/Jjl4346t1dVxXh3DJgv29phS0N wHkuCtsprEaiJApLmHV3vKNFHA0S4HKl0QwT91suSf24EGYnTyMIE/9TPn60gfzxRK7W x7/GwuWJ95t8Qimnt4cVp8/PHqzprimANy7ypO09Bk8Gb/bRb6Dy1w0pYyTYemFL5irG epq6/iNHRlUPQ5iwAUtwq6zK9IDZWsqfrFH9IKYMkgxnCqRt5ae7N7fPKypDacwRlDHq i+8Th7WC5TCX9+gW4PTnQLDZf8CVsM6qhSaD0UKBvvwDQVqho+cwqy+TeYxM4h/cVvE/ 6qYg== X-Gm-Message-State: AAQBX9cUCf+rdAi8a9EUvP4CadAT/J35s3pWvLXHlosrmriuy2fh3elH m5g07BW+eJe6GI03KCl91a+XQA== X-Google-Smtp-Source: AKy350b7jmiaIuBJAazZAlgUffbtBTU6t/f5ZhgT4oBFKuFrfaVpVXcih9rFmVGeh5KkwTyjBwmqqQ== X-Received: by 2002:a05:6870:15c5:b0:17e:b399:4f41 with SMTP id k5-20020a05687015c500b0017eb3994f41mr1631595oad.26.1680115175048; Wed, 29 Mar 2023 11:39:35 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:60f9:1426:1d2d:d6b:1761? ([2804:1b3:a7c1:60f9:1426:1d2d:d6b:1761]) by smtp.gmail.com with ESMTPSA id yt10-20020a05687c220a00b001726cfeea97sm11988473oab.29.2023.03.29.11.39.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 11:39:34 -0700 (PDT) Message-ID: <4c4b73eb-7cdc-bc91-857a-c1451210ce1d@linaro.org> Date: Wed, 29 Mar 2023 15:39:31 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v2 2/3] riscv: Add hwprobe vdso call support Content-Language: en-US To: Evan Green , libc-alpha@sourceware.org Cc: palmer@rivosinc.com, slewis@rivosinc.com, vineetg@rivosinc.com References: <20230221191537.3159966-1-evan@rivosinc.com> <20230221191537.3159966-3-evan@rivosinc.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20230221191537.3159966-3-evan@rivosinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 21/02/23 16:15, Evan Green wrote: > The new riscv_hwprobe syscall also comes with a vDSO for faster answers > to your most common questions. Call in today to speak with a kernel > representative near you! > > Signed-off-by: Evan Green > --- > > Changes in v2: > - Add vDSO interface > > sysdeps/unix/sysv/linux/dl-vdso-setup.c | 10 ++++++++++ > sysdeps/unix/sysv/linux/dl-vdso-setup.h | 3 +++ > sysdeps/unix/sysv/linux/riscv/hwprobe.c | 6 ++++++ > sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + > 4 files changed, 20 insertions(+) > > diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.c b/sysdeps/unix/sysv/linux/dl-vdso-setup.c > index 68fa8de641..3fe304a0c7 100644 > --- a/sysdeps/unix/sysv/linux/dl-vdso-setup.c > +++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.c > @@ -71,6 +71,16 @@ PROCINFO_CLASS int (*_dl_vdso_clock_getres_time64) (clockid_t, > # ifdef HAVE_GET_TBFREQ > PROCINFO_CLASS uint64_t (*_dl_vdso_get_tbfreq)(void) RELRO; > # endif > + > +/* RISC-V specific ones. */ > +# ifdef HAVE_RISCV_HWPROBE > +PROCINFO_CLASS int (*_dl_vdso_riscv_hwprobe)(void *, > + long, > + long, > + unsigned long *, > + long) RELRO; > +# endif > + > #endif > > #undef RELRO > diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.h b/sysdeps/unix/sysv/linux/dl-vdso-setup.h > index 867072b897..39eafd5316 100644 > --- a/sysdeps/unix/sysv/linux/dl-vdso-setup.h > +++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.h > @@ -47,6 +47,9 @@ setup_vdso_pointers (void) > #ifdef HAVE_GET_TBFREQ > GLRO(dl_vdso_get_tbfreq) = dl_vdso_vsym (HAVE_GET_TBFREQ); > #endif > +#ifdef HAVE_RISCV_HWPROBE > + GLRO(dl_vdso_riscv_hwprobe) = dl_vdso_vsym (HAVE_RISCV_HWPROBE); > +#endif > } > > #endif > diff --git a/sysdeps/unix/sysv/linux/riscv/hwprobe.c b/sysdeps/unix/sysv/linux/riscv/hwprobe.c > index 74f68889ca..2c61a67db7 100644 > --- a/sysdeps/unix/sysv/linux/riscv/hwprobe.c > +++ b/sysdeps/unix/sysv/linux/riscv/hwprobe.c > @@ -20,11 +20,17 @@ > #include > #include > #include > +#include > > int > __riscv_hwprobe (struct riscv_hwprobe *pairs, long pair_count, > long cpu_count, unsigned long *cpus, unsigned long flags) > { > + /* The vDSO may be able to provide the answer without a syscall. */ > +#ifdef HAVE_RISCV_HWPROBE > + INLINE_VSYSCALL(riscv_hwprobe, 5, pairs, pair_count, cpu_count, cpus, flags); > +#else > return INLINE_SYSCALL_CALL (riscv_hwprobe, pairs, pair_count, > cpu_count, cpus, flags); > +#endif > } The HAVE_RISCV_HWPROBE is always defined for RISCV, so there is no need to use the fallback (INLINE_VSYSCALL already issues the syscall if the dl_vdso_get_tbfreq is NULL). > diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h > index 4af5fe5dbc..ba17aaaff2 100644 > --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h > +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h > @@ -155,6 +155,7 @@ > /* List of system calls which are supported as vsyscalls (for RV32 and > RV64). */ > # define HAVE_GETCPU_VSYSCALL "__vdso_getcpu" > +# define HAVE_RISCV_HWPROBE "__vdso_riscv_hwprobe" > > # undef HAVE_INTERNAL_BRK_ADDR_SYMBOL > # define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1