From patchwork Tue Feb 21 19:15:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 55511 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACC4738493CD for ; Tue, 21 Feb 2023 19:16:04 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 6FDBC385782B for ; Tue, 21 Feb 2023 19:15:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6FDBC385782B 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-pl1-x62c.google.com with SMTP id z2so6335891plf.12 for ; Tue, 21 Feb 2023 11:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PhDgI1k+5Fcz3j/dwjkYeJiAr1X3RFVH8X1aSg6frv0=; b=jno7LiTQkrB7SnL2ZFvhgZpIz0b6fsP/aVw0zO+ffJUQ8/kS3azvidSwIVrzKrh8mg 5jRQopeBE0HY4zSUum3kEyhR5tADvNmX9aHOq2wPM8WM8ML/2qQdh5YdX8wVEeUNxMul DHeFseG8HAxGSz6kPQaMXwTzgy09UT0uzTye3ELIiFLTS6H12LM+ikb32T/BQ2fJka5U yMs3WFgBklgDhv0fUUniwAHhyLhoKORXhnPsoCW8IesnDBlxPWriO9ohUlcryHFOQvK7 tflSGtkDkdUaJfZGWSqQZRPVrHeD2ibKI/P1VU3tu2UJMWW6LgSOgLc5Ky87gDu4mcSs lD0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PhDgI1k+5Fcz3j/dwjkYeJiAr1X3RFVH8X1aSg6frv0=; b=R778OWfjeAETysWYFSMgot1S1XOYzDCz+aS3YdG6THV7hT61+GrcnYCS72CEfWZjnn E3o1vW8Gz7oweW5AAb7mYK3HnCTFAJGxLYRwTixkih8wiohofWW+oJetejrWraw2GcQd acESBzQfIw0ddtLWf4AYuTN7/cF7UxOfNJICMU8x1hOncoIgGcF7wV7eQ98XE1uM4tVV PhtVwYx3kBbrLEHVzjW1Bu68ec36vpckMpCcszrKA9re9BR6nHeJaQS7nPtL4aprkcK/ g64Dg3gQB+t3S9H27QsqNZ8EiJn6lPW7esYvccsFofgqH0LpDaIzMxjZ+k99nnRDGXRp amyg== X-Gm-Message-State: AO0yUKWME8qmR3c4y+2+PvC+J5FsWT9N2uAtFyMA+Gf7jX2VUp0cch43 3WP5rVsGsJvLR3gFPFy8pEe3I8jFH5d/truO X-Google-Smtp-Source: AK7set/SQBd9Lo+Sjcl7l02oKuLEkYkXRXFXalaeKokDPVpUL3tTSWn8e7IRI7I/mlItvUoegELdvg== X-Received: by 2002:a17:903:7cc:b0:19a:b343:d9ac with SMTP id ko12-20020a17090307cc00b0019ab343d9acmr5589680plb.65.1677006943914; Tue, 21 Feb 2023 11:15:43 -0800 (PST) Received: from evan.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id iy17-20020a170903131100b00198fb25d09bsm3007283plb.237.2023.02.21.11.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 11:15:43 -0800 (PST) From: Evan Green To: libc-alpha@sourceware.org Cc: palmer@rivosinc.com, slewis@rivosinc.com, vineetg@rivosinc.com, Evan Green Subject: [PATCH v2 0/3] RISC-V: ifunced memcpy using new kernel hwprobe interface Date: Tue, 21 Feb 2023 11:15:34 -0800 Message-Id: <20230221191537.3159966-1-evan@rivosinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This series illustrates the use of a proposed Linux syscall that enumerates architectural information about the RISC-V cores the system is running on. In this series we expose a small wrapper function around the syscall. An ifunc selector for memcpy queries it to see if unaligned access is "fast" on this hardware. If it is, it selects a newly provided implementation of memcpy that doesn't work hard at aligning the src and destination buffers. This is somewhat of a proof of concept for the syscall itself, but I do find that in my goofy memcpy test [1], the unaligned memcpy performed at least as well as the generic C version. This is however on Qemu on an M1 mac, so not a test of any real hardware (more a smoke test that the implementation isn't silly). v3 of the Linux series can be found at [2]. [1] https://pastebin.com/Nj8ixpkX [2] https://lore.kernel.org/lkml/20230221190858.3159617-1-evan@rivosinc.com/T/#t Changes in v2: - hwprobe.h: Use __has_include and duplicate Linux content to make compilation work when Linux headers are absent (Adhemerval) - hwprobe.h: Put declaration under __USE_GNU (Adhemerval) - Use INLINE_SYSCALL_CALL (Adhemerval) - Update versions - Update UNALIGNED_MASK to match kernel v3 series. - Add vDSO interface - Used _MASK instead of _FAST value itself. Evan Green (3): riscv: Add Linux hwprobe syscall support riscv: Add hwprobe vdso call support riscv: Add and use alignment-ignorant memcpy sysdeps/riscv/memcopy.h | 28 +++++ sysdeps/riscv/memcpy.c | 65 +++++++++++ sysdeps/riscv/memcpy_noalignment.S | 103 ++++++++++++++++++ sysdeps/unix/sysv/linux/dl-vdso-setup.c | 10 ++ sysdeps/unix/sysv/linux/dl-vdso-setup.h | 3 + sysdeps/unix/sysv/linux/riscv/Makefile | 8 +- sysdeps/unix/sysv/linux/riscv/Versions | 3 + sysdeps/unix/sysv/linux/riscv/hwprobe.c | 36 ++++++ .../unix/sysv/linux/riscv/memcpy-generic.c | 24 ++++ .../unix/sysv/linux/riscv/rv32/arch-syscall.h | 1 + .../unix/sysv/linux/riscv/rv32/libc.abilist | 1 + .../unix/sysv/linux/riscv/rv64/arch-syscall.h | 1 + .../unix/sysv/linux/riscv/rv64/libc.abilist | 1 + sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h | 67 ++++++++++++ sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + sysdeps/unix/sysv/linux/syscall-names.list | 1 + 16 files changed, 351 insertions(+), 2 deletions(-) create mode 100644 sysdeps/riscv/memcopy.h create mode 100644 sysdeps/riscv/memcpy.c create mode 100644 sysdeps/riscv/memcpy_noalignment.S create mode 100644 sysdeps/unix/sysv/linux/riscv/hwprobe.c create mode 100644 sysdeps/unix/sysv/linux/riscv/memcpy-generic.c create mode 100644 sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h Reviewed-by: Palmer Dabbelt