From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 14A9B3858C5E for ; Thu, 3 Aug 2023 18:43:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 14A9B3858C5E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4fe457ec6e7so2286656e87.3 for ; Thu, 03 Aug 2023 11:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1691088188; x=1691692988; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yOmj08BlrjMSTRwwmUIv8L0k8TbidOI6GDwwjB1ymok=; b=PpDs5BRXl/uNaHMD6hPmrZ++RNMnwvnuPiY687xnFDLzhHlwTw9i6VhIh4JwoRx/1+ BG2LI0TZRjM8OlioyaC6ktlQrltau2jdk39KQaIa0hK3YDx83aT3ZEnQO+zNjmwlFvgv ahlK1eaR/b88l0q3e4xqaonrpCrqwZSwWL9b+7/yClnStAgzwlmOEoU6XyVDQ6j+gHDm 8MsbaWox+zo7iCJvj5UQAnKCyVBLin+rrioQFA8VigEKuzSpJvk5oY40uxcd3jbWK3Qi QDFcWeR8tsC0kptQTgHwNHXGRGdae1CnglFHwsDzqbLn5K2rQacO55m1XL2AzEEIDA26 s5TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691088188; x=1691692988; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yOmj08BlrjMSTRwwmUIv8L0k8TbidOI6GDwwjB1ymok=; b=I4yAAB6weh8giPJyGbDbwiwRWigZ/lvExeJ7d0hAmCZLvlkJ0jVaORedHa8b7Yt1qp 9NDJfrn1W+NL7cjszjJaxSRmbXyi3sFVjSGHNyBZY48ohKUMI1CsSKiTgHwCIJ2g1LGD e26d9tav3ZuK3ZIYtpo4uDQRAu514wkvfEvNSmta2essflLqqbGoEFguzuAKs7+GGif2 9XK6k5Vvd578H/Y4801E0lzDxJog+niBW1DyewVAxRTIdwnu5Px4pxhZ5nbxyyxGvDtA TlhDmYqwEvB/A+Cqc8cpkrqRAtlZOtEO4NYXBISd+MmsnGDxOwWN2HZL01hTFiIyeQQJ YPhw== X-Gm-Message-State: ABy/qLYRyHEbmUM/yntqpHzI+D7IcuN39LnjbBMaMjAulpdzo7zhD9wA K8/n9gKlxGmg3gMV+j/4RURSAbm0KILKtbJvaCKX0A== X-Google-Smtp-Source: APBJJlFxvviNjz+lo2j1l9SFKZlL8YcBDDLfhKjieC0ZH43cYLdA70s49ft1ba8cIZuBO6yCBXzWQjhWiBUORFMNOMc= X-Received: by 2002:ac2:4d97:0:b0:4fb:829b:197c with SMTP id g23-20020ac24d97000000b004fb829b197cmr7229675lfe.52.1691088188488; Thu, 03 Aug 2023 11:43:08 -0700 (PDT) MIME-Version: 1.0 References: <20230802155903.2552780-1-evan@rivosinc.com> <20230802155903.2552780-6-evan@rivosinc.com> <87il9w37vi.fsf@oldenburg.str.redhat.com> <6f0911c6-b24b-444c-4b4b-a62e49a51734@linaro.org> In-Reply-To: <6f0911c6-b24b-444c-4b4b-a62e49a51734@linaro.org> From: Evan Green Date: Thu, 3 Aug 2023 11:42:31 -0700 Message-ID: Subject: Re: [PATCH v6 5/5] riscv: Add and use alignment-ignorant memcpy To: Richard Henderson Cc: Florian Weimer , libc-alpha@sourceware.org, slewis@rivosinc.com, palmer@rivosinc.com, vineetg@rivosinc.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 Thu, Aug 3, 2023 at 10:50=E2=80=AFAM Richard Henderson wrote: > > On 8/3/23 00:25, Florian Weimer via Libc-alpha wrote: > > * Evan Green: > > > >> +static inline __typeof (__redirect_memcpy) * > >> +select_memcpy_ifunc (uint64_t dl_hwcap, __riscv_hwprobe_t hwprobe_fun= c) > >> +{ > >> + INIT_ARCH (); > >> + > >> + struct riscv_hwprobe pair; > >> + > >> + pair.key =3D RISCV_HWPROBE_KEY_CPUPERF_0; > >> + if (!hwprobe_func || hwprobe_func(&pair, 1, 0, NULL, 0) !=3D 0) > >> + return __memcpy_generic; > >> + > >> + if ((pair.key > 0) && > >> + (pair.value & RISCV_HWPROBE_MISALIGNED_MASK) =3D=3D > >> + RISCV_HWPROBE_MISALIGNED_FAST) > >> + return __memcpy_noalignment; > >> + > >> + return __memcpy_generic; > >> +} > > > > In libc, you could call __riscv_hwprobe directly, so the additional > > argument isn't needed after all. So you think I should drop the libc-symbols.h change and call __riscv_hwprobe directly here? Sure, I can do that. > > Outside libc something is required. > > An extra parameter to ifunc is surprising though, and clearly not ideal p= er the extra > hoops above. I would hope for something with hidden visibility in libc_n= onshared.a that > could always be called directly. My previous spin took that approach, defining a __riscv_hwprobe_early() in libc_nonshared that could route to the real function if available, or make the syscall directly if not. But that approach had the drawback that ifunc users couldn't take advantage of the vDSO, and then all users had to comprehend the difference between __riscv_hwprobe() and __riscv_hwprobe_early(). In contrast, IMO this approach is much nicer. Ifunc writers are already used to getting hwcap info via a parameter. Adding this second parameter, which also provides hwcap-like things, seems like a natural extension. I didn't quite follow what you meant by the "extra hoops above". If you meant the previous patch to libc-symbols.h, that's all glibc-internal-isms, and shouldn't affect external callers. As per Florian's comment above I can drop that patch for now since I don't strictly need it. -Evan