public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Evan Green <evan@rivosinc.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: Florian Weimer <fweimer@redhat.com>,
	libc-alpha@sourceware.org, slewis@rivosinc.com,
	 palmer@rivosinc.com, vineetg@rivosinc.com
Subject: Re: [PATCH v6 5/5] riscv: Add and use alignment-ignorant memcpy
Date: Thu, 3 Aug 2023 11:42:31 -0700	[thread overview]
Message-ID: <CALs-HssWPZoMpuqxfEg3+bVdRgvm03ZYBPrAAjKXx=ojsoemYw@mail.gmail.com> (raw)
In-Reply-To: <6f0911c6-b24b-444c-4b4b-a62e49a51734@linaro.org>

On Thu, Aug 3, 2023 at 10:50 AM Richard Henderson
<richard.henderson@linaro.org> 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_func)
> >> +{
> >> +  INIT_ARCH ();
> >> +
> >> +  struct riscv_hwprobe pair;
> >> +
> >> +  pair.key = RISCV_HWPROBE_KEY_CPUPERF_0;
> >> +  if (!hwprobe_func || hwprobe_func(&pair, 1, 0, NULL, 0) != 0)
> >> +    return __memcpy_generic;
> >> +
> >> +  if ((pair.key > 0) &&
> >> +      (pair.value & RISCV_HWPROBE_MISALIGNED_MASK) ==
> >> +       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 per the extra
> hoops above.  I would hope for something with hidden visibility in libc_nonshared.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

  reply	other threads:[~2023-08-03 18:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02 15:58 [PATCH v6 0/5] RISC-V: ifunced memcpy using new kernel hwprobe interface Evan Green
2023-08-02 15:58 ` [PATCH v6 1/5] riscv: Add Linux hwprobe syscall support Evan Green
2023-08-02 16:52   ` Joseph Myers
2023-08-03  7:24   ` Florian Weimer
2023-08-02 15:59 ` [PATCH v6 2/5] riscv: Add hwprobe vdso call support Evan Green
2023-08-02 15:59 ` [PATCH v6 3/5] riscv: Add __riscv_hwprobe pointer to ifunc calls Evan Green
2023-08-02 15:59 ` [PATCH v6 4/5] riscv: Enable multi-arg ifunc resolvers Evan Green
2023-08-02 15:59 ` [PATCH v6 5/5] riscv: Add and use alignment-ignorant memcpy Evan Green
2023-08-03  7:25   ` Florian Weimer
2023-08-03 17:50     ` Richard Henderson
2023-08-03 18:42       ` Evan Green [this message]
2023-08-03 22:30         ` Richard Henderson
2023-08-07 22:10           ` Evan Green
2023-08-07 22:21             ` Florian Weimer
2023-08-07 22:30               ` Evan Green
2023-08-07 22:48             ` enh
2023-08-08  0:01               ` Evan Green
2023-08-12  0:01                 ` enh
2023-08-15 16:40                   ` Evan Green
2023-08-15 21:53                     ` enh
2023-08-15 23:01                       ` Evan Green
2023-08-16 23:18                         ` enh
2023-08-17 16:27                           ` Evan Green
2023-08-17 16:37                             ` enh
2023-08-17 17:40                               ` Evan Green
2023-08-22 15:06                                 ` enh
2023-08-02 16:03 ` [PATCH v6 0/5] RISC-V: ifunced memcpy using new kernel hwprobe interface Evan Green

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALs-HssWPZoMpuqxfEg3+bVdRgvm03ZYBPrAAjKXx=ojsoemYw@mail.gmail.com' \
    --to=evan@rivosinc.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=palmer@rivosinc.com \
    --cc=richard.henderson@linaro.org \
    --cc=slewis@rivosinc.com \
    --cc=vineetg@rivosinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).