Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp1067679rwl; Thu, 10 Aug 2023 06:06:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5X0H12wWnVFuIIg8XThBAqbx4o5v3QeS1d5JjneT20A2F9YOcvIYV9XOZtvSNODiWHQEW X-Received: by 2002:a05:6a00:1594:b0:64f:7a9c:cb15 with SMTP id u20-20020a056a00159400b0064f7a9ccb15mr2580511pfk.11.1691672807164; Thu, 10 Aug 2023 06:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691672807; cv=none; d=google.com; s=arc-20160816; b=sDmeW7h4bwMZFO1x/0SlkAG0Lumv4iBeGoVLkN9+rooDftGDuGgh0fdpuYaQqIVeaZ V0H2yz9p+eqwm9xjisrvERWYI/t46QtrWdMWtq/ltEWcrJALILLYjxozl7oNFc08yJXd ikfSI5NvBKIEOiEPOKQSCSdSzVF/YOY2wbsPUJp10kVT0XYTF2N7yNnbX/srbXiKlSx5 e00T/QnP6FHbtXP99CPKEFI62ZBeGnGeuttzNuioX9t3VAcTk7fesDMc4Jac+7PdzkC4 AIY5915Ms8+eNP9/Z3xok7L418BcAvQHGQ/5r3GIEPoxi79AvD5/7YelcVRyeCrkrOvr WHnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=iU7RcUotLxvCaIn+eDZQPBdo1ZsgBKspczf6WXiyguk=; fh=+8VV2q0AQ/kcznuOwW1/nUS8/s6O7CvicwzHt/E1qQk=; b=PmCWLd1AyqPcf7LMju5DWbcwMq9B555f8AcflDba+s6X+JIx6tpbEbk5kMF7jcyhYB MXfFzYS1vH5vnAcJ/iUVXnvAPRVxjlBf5YuN4ou0MxE6Hg3g2lU5nex/fnykHAJ9/Rt+ juCK2L7tXEbvXbvWbiYtMO6cHhOEGlh5u4Y9iw2IGEtm6j5s+en7slz8thVEK2Zlgwvc Nx4yJetbSAjSobzxI5M49v6x2xgFGkxLCHnMRshxFRNMQnylAlUWk9T9VbiDsaXGjy9r jazP3Urg3Wf/GvJcz3Xj4nr2BuIfg67oE0icJBazGZwypFi9WHF8jdcLY4k/UsP9ne94 pQuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ycec3jI+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m123-20020a632681000000b005641bbe7841si1494399pgm.524.2023.08.10.06.06.34; Thu, 10 Aug 2023 06:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ycec3jI+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235412AbjHJLjf (ORCPT + 99 others); Thu, 10 Aug 2023 07:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235421AbjHJLjd (ORCPT ); Thu, 10 Aug 2023 07:39:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83489120; Thu, 10 Aug 2023 04:39:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 14CFF65A3A; Thu, 10 Aug 2023 11:39:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC500C43391; Thu, 10 Aug 2023 11:39:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691667569; bh=TWailZRjY0e+eZNG0KbVuBj7vwCo8+irTvS4gJ/TsSo=; h=From:Date:Subject:To:Cc:From; b=Ycec3jI++B2DemmO0X24rmDGt5uP/+g1lYJa9Hyfi6d7UELoLZXB2Z5ejbmN3GcDv EwUHHtrZ1gwmF3reOs3j0i8eihpBloUT0ls1xGLxo7AoC+9i3v2zRTYJBaiE2Aqrna SEIhk49XQm6fWl5yW1NHtYQ3SVJwn/+nG8Tz06hHyNJFv+bY7yudAOsGJ8lN/PsBJj hNUZVVGhKtExtD13jG4RganXxBb2d5fq568W7HS7B6fjT350Ndae6rFjw7jUDoIQIl EBhgGSTQpuxChF7NBVcTrXtGe/7l15wJAuslGWJAD+OPADnJiRzgz+if6YOL6FwM9v 7ePKJCEaliyqw== From: Mark Brown Date: Thu, 10 Aug 2023 12:39:19 +0100 Subject: [PATCH] kselftest/arm64: Size sycall-abi buffers for the actual maximum VL MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230810-arm64-syscall-abi-perf-v1-1-6a0d7656359c@kernel.org> X-B4-Tracking: v=1; b=H4sIAGbM1GQC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDI2MDCwNL3cSiXDMT3eLK4uTEnBzdxKRM3YLUojRdw1RTC3OzFEMzwyQjJaD mgqLUtMwKsMHRsbW1AHmPd99oAAAA To: Catalin Marinas , Will Deacon , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-034f2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4518; i=broonie@kernel.org; h=from:subject:message-id; bh=TWailZRjY0e+eZNG0KbVuBj7vwCo8+irTvS4gJ/TsSo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBk1Mxui0TdliWUY4lyyzPw0Wk8Ox8X4CucUB4Yx3uP ksqc6rmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZNTMbgAKCRAk1otyXVSH0P6AB/ 9Pmv5jV7G7opPlIhRunsboaHBuLcjYK2tKjRx7V2lXPOa6FG/2vE309Uw9blivEmaaSMRnGeT3lQMP MvMBa4SWHtxc9gti0FdbitmV28cTVcn093jkUGITx6LjrMDp35HKZj3Nxxvg1ggIPfPijzm/U7m8ze bf6eHIzYh2SxWR6J3qz2N/utG3AxuR1j4sxl/FdynAbgXi5kF/dwelXg4PpDP7YHV7Fuwemng2lJSs MZ4fir0mayRVS2dfwTD+7MdeV9ISUgqi0WBNOoMdFJjIvppsTioRgi7x8NApwT1hwEoQFVwsfL0l5u R8W763tA9dyG9X9tzVbuYCr68YeHHj X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Our ABI opts to provide future proofing by defining a much larger SVE_VQ_MAX than the architecture actually supports. Since we use this define to control the size of our vector data buffers this results in a lot of overhead when we initialise which can be a very noticable problem in emulation, we fill buffers that are orders of magnitude larger than we will ever actually use even with virtual platforms that provide the full range of architecturally supported vector lengths. Define and use the actual architecture maximum to mitigate this. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/abi/syscall-abi.c | 38 +++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/arm64/abi/syscall-abi.c b/tools/testing/selftests/arm64/abi/syscall-abi.c index 18cc123e2347..d704511a0955 100644 --- a/tools/testing/selftests/arm64/abi/syscall-abi.c +++ b/tools/testing/selftests/arm64/abi/syscall-abi.c @@ -20,12 +20,20 @@ #include "syscall-abi.h" +/* + * The kernel defines a much larger SVE_VQ_MAX than is expressable in + * the architecture, this creates a *lot* of overhead filling the + * buffers (especially ZA) on emulated platforms so use the actual + * architectural maximum instead. + */ +#define ARCH_SVE_VQ_MAX 16 + static int default_sme_vl; static int sve_vl_count; -static unsigned int sve_vls[SVE_VQ_MAX]; +static unsigned int sve_vls[ARCH_SVE_VQ_MAX]; static int sme_vl_count; -static unsigned int sme_vls[SVE_VQ_MAX]; +static unsigned int sme_vls[ARCH_SVE_VQ_MAX]; extern void do_syscall(int sve_vl, int sme_vl); @@ -130,9 +138,9 @@ static int check_fpr(struct syscall_cfg *cfg, int sve_vl, int sme_vl, #define SVE_Z_SHARED_BYTES (128 / 8) -static uint8_t z_zero[__SVE_ZREG_SIZE(SVE_VQ_MAX)]; -uint8_t z_in[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)]; -uint8_t z_out[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)]; +static uint8_t z_zero[__SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)]; +uint8_t z_in[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)]; +uint8_t z_out[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)]; static void setup_z(struct syscall_cfg *cfg, int sve_vl, int sme_vl, uint64_t svcr) @@ -190,8 +198,8 @@ static int check_z(struct syscall_cfg *cfg, int sve_vl, int sme_vl, return errors; } -uint8_t p_in[SVE_NUM_PREGS * __SVE_PREG_SIZE(SVE_VQ_MAX)]; -uint8_t p_out[SVE_NUM_PREGS * __SVE_PREG_SIZE(SVE_VQ_MAX)]; +uint8_t p_in[SVE_NUM_PREGS * __SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)]; +uint8_t p_out[SVE_NUM_PREGS * __SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)]; static void setup_p(struct syscall_cfg *cfg, int sve_vl, int sme_vl, uint64_t svcr) @@ -222,8 +230,8 @@ static int check_p(struct syscall_cfg *cfg, int sve_vl, int sme_vl, return errors; } -uint8_t ffr_in[__SVE_PREG_SIZE(SVE_VQ_MAX)]; -uint8_t ffr_out[__SVE_PREG_SIZE(SVE_VQ_MAX)]; +uint8_t ffr_in[__SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)]; +uint8_t ffr_out[__SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)]; static void setup_ffr(struct syscall_cfg *cfg, int sve_vl, int sme_vl, uint64_t svcr) @@ -300,8 +308,8 @@ static int check_svcr(struct syscall_cfg *cfg, int sve_vl, int sme_vl, return errors; } -uint8_t za_in[ZA_SIG_REGS_SIZE(SVE_VQ_MAX)]; -uint8_t za_out[ZA_SIG_REGS_SIZE(SVE_VQ_MAX)]; +uint8_t za_in[ZA_SIG_REGS_SIZE(ARCH_SVE_VQ_MAX)]; +uint8_t za_out[ZA_SIG_REGS_SIZE(ARCH_SVE_VQ_MAX)]; static void setup_za(struct syscall_cfg *cfg, int sve_vl, int sme_vl, uint64_t svcr) @@ -470,9 +478,9 @@ void sve_count_vls(void) return; /* - * Enumerate up to SVE_VQ_MAX vector lengths + * Enumerate up to ARCH_SVE_VQ_MAX vector lengths */ - for (vq = SVE_VQ_MAX; vq > 0; vq /= 2) { + for (vq = ARCH_SVE_VQ_MAX; vq > 0; vq /= 2) { vl = prctl(PR_SVE_SET_VL, vq * 16); if (vl == -1) ksft_exit_fail_msg("PR_SVE_SET_VL failed: %s (%d)\n", @@ -496,9 +504,9 @@ void sme_count_vls(void) return; /* - * Enumerate up to SVE_VQ_MAX vector lengths + * Enumerate up to ARCH_SVE_VQ_MAX vector lengths */ - for (vq = SVE_VQ_MAX; vq > 0; vq /= 2) { + for (vq = ARCH_SVE_VQ_MAX; vq > 0; vq /= 2) { vl = prctl(PR_SME_SET_VL, vq * 16); if (vl == -1) ksft_exit_fail_msg("PR_SME_SET_VL failed: %s (%d)\n", --- base-commit: 52a93d39b17dc7eb98b6aa3edb93943248e03b2f change-id: 20230809-arm64-syscall-abi-perf-1e5876d161b2 Best regards, -- Mark Brown