From patchwork Tue Feb 7 00:16:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 64388 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 9425D382E6A5 for ; Tue, 7 Feb 2023 00:18:39 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 36D8F3858C66 for ; Tue, 7 Feb 2023 00:16:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 36D8F3858C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-wr1-x42c.google.com with SMTP id g6so4068929wrv.1 for ; Mon, 06 Feb 2023 16:16:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YJYMF8Hd3zoU/fHdlx9uwPS6z7TdUxv0RapDL83AFlw=; b=glP8ZqkuGdEwUAtPEM0nyEcXOlMM22uONiQrXV8Fq/OXD7JIs2IC7b56GyaR3aV9WQ 42nSGKU3ORv/LTrDh3UZhpjvhTL1JD2FBs078xgBgVziITtgQvOKg6a46yT9f9vCFBeE leqvlLeUxJNCtW5SlWlFrY92A0BZV3Za2mTMmDhMa9PDwisaP9QFuzoDgFONaw5eIA5O MbxNIulfpWDHA/nRUHn6GnDgvcKA/P8hlpX77/nMvVabfQwNBNywiEyNCKCib+SxU2Ia QwnjTPbNU0qnWbwUpT+D80DzbWrXAyLYq/bI4L1qXTdRzbXcLrBfwcOpnyqFW21hW8Oo sCNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YJYMF8Hd3zoU/fHdlx9uwPS6z7TdUxv0RapDL83AFlw=; b=MsVpaYFHBOyxUTBmOn8ohKynArSjJ26R+q+YjN1/t6rRIf4WIiJWEV95f43U+PyCOP pOXrm44XxJBPm7000eRH1ijlrKi7iL2vsh5fWVcNv0g9XVEYaiKwKeAFo9xB6TM/QwBr q2ge3ViQD82ZTiloecIsTBIlh1d+Q0kqeOfetKm+a2RKB4WILtyb2RyEXPsbBHoIdSp/ ZxNFTHQQ80WQKaHAEE35MrOCsRFkz4aBsnfKFJRSdPIU0tat74DLqYjnolerXY1bHFXP m39cUcI6BYYCfhckWyZ1W3LkV05GG5hDcs4eS+akhPvXNp0rE4HLxQ2P0IeWw0olnKMx VrKw== X-Gm-Message-State: AO0yUKXLm7AzCzIGmBVYrH3PFjjzf6/fN51fun8InrwLNxD2kzAcH47c 232m31buOxGkDywopaarDWVxFmIysZBtK0zq X-Google-Smtp-Source: AK7set8E+JEmcWcPBbyz+HGe9LgnMqb50GnkrzEFpwOKS9+r8KeMQf6MyVZk6xhbRnLIUTUAWgugkQ== X-Received: by 2002:a05:6000:110:b0:2c3:ea52:7d0e with SMTP id o16-20020a056000011000b002c3ea527d0emr557164wrx.69.1675729000598; Mon, 06 Feb 2023 16:16:40 -0800 (PST) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id f1-20020a1cc901000000b003df14531724sm16862050wmb.21.2023.02.06.16.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 16:16:40 -0800 (PST) From: Christoph Muellner To: libc-alpha@sourceware.org, Palmer Dabbelt , Darius Rad , Andrew Waterman , DJ Delorie , Vineet Gupta , Kito Cheng , Jeff Law , Philipp Tomsich , Heiko Stuebner Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [RFC PATCH 07/19] riscv: hart-features: Add fast_unaligned property Date: Tue, 7 Feb 2023 01:16:06 +0100 Message-Id: <20230207001618.458947-8-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207001618.458947-1-christoph.muellner@vrull.eu> References: <20230207001618.458947-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_MANYTO, 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" From: Christoph Müllner Having fast unaligned accesses opens the door for a performance optimizations. Let's add this property to the hart-features so that this property can be queried using the environment variable RISCV_RT_FAST_UNALIGNED (e.g. by setting it to "1"). Signed-off-by: Christoph Müllner --- sysdeps/unix/sysv/linux/riscv/hart-features.c | 19 +++++++++++++++++++ sysdeps/unix/sysv/linux/riscv/hart-features.h | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/sysdeps/unix/sysv/linux/riscv/hart-features.c b/sysdeps/unix/sysv/linux/riscv/hart-features.c index 6de41a26cc..b3b7955534 100644 --- a/sysdeps/unix/sysv/linux/riscv/hart-features.c +++ b/sysdeps/unix/sysv/linux/riscv/hart-features.c @@ -326,6 +326,22 @@ parse_rt_cboz_blocksize (struct hart_features *hart_features) hart_features->cboz_blocksize = v; } +/* Parse RISCV_RT_FAST_UNALIGNED and store value. */ +static inline void +parse_rt_fast_unaligned (struct hart_features *hart_features) +{ + hart_features->rt_fast_unaligned = NULL; + hart_features->fast_unaligned = 0; + + const char *s = simple_getenv ("RISCV_RT_FAST_UNALIGNED"); + if (s == NULL) + return; + + uint64_t v = _dl_strtoul (s, NULL); + hart_features->rt_fast_unaligned = s; + hart_features->fast_unaligned = v; +} + /* Discover hart features and store them. */ static inline void init_hart_features (struct hart_features *hart_features) @@ -334,4 +350,7 @@ init_hart_features (struct hart_features *hart_features) parse_rt_march (hart_features); parse_rt_cbom_blocksize (hart_features); parse_rt_cboz_blocksize (hart_features); + + /* Parse tuning properties. */ + parse_rt_fast_unaligned (hart_features); } diff --git a/sysdeps/unix/sysv/linux/riscv/hart-features.h b/sysdeps/unix/sysv/linux/riscv/hart-features.h index dd94685676..b2cefd5748 100644 --- a/sysdeps/unix/sysv/linux/riscv/hart-features.h +++ b/sysdeps/unix/sysv/linux/riscv/hart-features.h @@ -34,6 +34,9 @@ #define HAVE_CBOZ_BLOCKSIZE(n) \ (GLRO (dl_riscv_hart_features).cboz_blocksize == n) +#define HAVE_FAST_UNALIGNED() \ + (GLRO (dl_riscv_hart_features).fast_unaligned != 0) + struct hart_features { const char* rt_march; @@ -48,6 +51,8 @@ struct hart_features unsigned cbom_blocksize; const char* rt_cboz_blocksize; unsigned cboz_blocksize; + const char* rt_fast_unaligned; + unsigned fast_unaligned; }; #endif /* _CPU_FEATURES_RISCV_H */