From patchwork Fri Feb 9 16:53:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13551600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E3CEC48297 for ; Fri, 9 Feb 2024 16:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version:Subject: Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=8m1EA+rIMkyNl2f7R+8QtlFHx6b9O84ohDmNQHoPQ4M=; b=gJkUV4qbSc518I gFz0CsEYGPv5LIWNDe0Abj+CVO+PVLyfIx6/AP1gTv29HdX2hCClvBc8ZJrzDJ7XaB7gug2bw4DcP AvK5qlI8fJ3dmlXIBuY2KValfVd6hpecvtcu15VplBu9cQ0LM4twiYSmwf0DLDmWEZisrtzUkP8MV M08JKb9nvjiFHLtUy6AnCFOS+sHzmdJ8yx7xTWxy7U7/E2LoQv4u1Iex/I+MC/K7sNlpZq3x9xvLS Yhr1o5NZAEpR1VhI0YvccA+wNMvOij2xTF/U3NtBnalW5RbPbTO29QM6PIVKKv/yrRIz58iVt/e5R OB37TGNmCY4aBHtsrDIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYU8K-000000000rL-069C; Fri, 09 Feb 2024 16:53:48 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYU8G-000000000q4-3mXq for linux-arm-kernel@lists.infradead.org; Fri, 09 Feb 2024 16:53:46 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2CA36CE182F; Fri, 9 Feb 2024 16:53:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2758C433F1; Fri, 9 Feb 2024 16:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707497622; bh=LPmWvu0/qYz7qCac8LkiBOl/gSdLmPufqHJzTjBvvM4=; h=From:Date:Subject:To:Cc:From; b=Gp3HUt2rqPqLr4EMOCQJj5WycB+cykYdg+NQQwt2ATnp+Pm9/U1C444psESIa6glw Ynf76roOpbKW5Gr93ed7GQR1e9YL8A+KpLyyRECYnhr0USMxWELDmuzYrodh25ifrz BnAwnj89onLl5FU1ZV7qLV1c9GDoKfUhcqqdQtGxZR/0xaUIuIOxVC/YvrVasGi+qA 5hSPCbgwGGllkEGRxPRU47hXGlO3wCIh5IkkiPhiI33BR3zmQ/X8k0VBR7+OsT3P3A wEesH6ZlkJUPdI4REe5xCLoLT/pfnxV8F2tE+jTwJDCme5IvMeZW2uOL6b+1nOHOzz ld3iFECIdQ1UQ== From: Mark Brown Date: Fri, 09 Feb 2024 16:53:36 +0000 Subject: [PATCH v2] arm64/sve: Document that __SVE_VQ_MAX is much larger than needed MIME-Version: 1.0 Message-Id: <20240209-arm64-sve-vl-max-comment-v2-1-111b283469ee@kernel.org> X-B4-Tracking: v=1; b=H4sIAI9YxmUC/42NQQ7CIBBFr9LM2jFAkYUr72G6IGVoiQXM0JCap ncXewKX7yX//R0KcaAC924HphpKyKmBunQwzjZNhME1BiWUFkoYtByNxlIJ64LRbjjmGCmtaDR 523vRG3WDNn8z+bCd6efQeA5lzfw5n6r82T+iVaJE55yXRkutpXq8iBMt18wTDMdxfAFTjwwzw QAAAA== To: Catalin Marinas , Will Deacon Cc: Dave Martin , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1943; i=broonie@kernel.org; h=from:subject:message-id; bh=LPmWvu0/qYz7qCac8LkiBOl/gSdLmPufqHJzTjBvvM4=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlxliTT4K6oUVqMYwdqskmUbVXtesPvccvCYH0x PiAa2UdVxSJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZcZYkwAKCRAk1otyXVSH 0K+tB/40gNlnhJ/eFz4vBSvLpUHQ40bd5sRJGwfngnD7yqxirWxxPBg9Aqi1XhM5xxV0AMoHRSo c9KtV1OaZvigEjTrMLGeVSagQ7U2+DT+0pdPkcice/rGFb4PhfA4qzWqyLEyyfDsF4rpwXxWR9/ L5RH/uqktwzlspDwgrJ8LVwLyScRd7IGhWOm5ZNqWo+y+RZQ1dNPcRE3o0iXy1EGwG/ccJpBfc0 J2tlTPXb6+9DG/5xYq5CrwH4PKqpoOfS6gQ9qe9xmH/vilegBXuldWlypDSbU4Xl5OnITEpDPHp GnzETzf994WWCNwCDGzQM8BlmVGqG7p2G96utjT1DyfqiCjC X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_085345_338483_0597C8B8 X-CRM114-Status: GOOD ( 11.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org __SVE_VQ_MAX is defined without comment as 512 but the actual architectural maximum is 16, a substantial difference which might not be obvious to readers especially given the several different units used for specifying vector sizes in various contexts and the fact that it's often used via macros. In an effort to minimise surprises for users who might assume the value is the architectural maximum and use it to do things like size allocations add a comment noting the difference, and add a note for SVE_VQ_MAX to aid discoverability. Signed-off-by: Mark Brown Acked-by: Dave Martin --- Changes in v2: - Use new wording mostly provided by Dave Martin. - Reference __SVE_VQ_MAX comment near SVE_VQ_MAX define. - Link to v1: https://lore.kernel.org/r/20240206-arm64-sve-vl-max-comment-v1-1-dddf16414412@kernel.org --- arch/arm64/include/uapi/asm/sve_context.h | 11 +++++++++++ 1 file changed, 11 insertions(+) --- base-commit: 54be6c6c5ae8e0d93a6c4641cb7528eb0b6ba478 change-id: 20240206-arm64-sve-vl-max-comment-64efa3f03625 Best regards, diff --git a/arch/arm64/include/uapi/asm/sve_context.h b/arch/arm64/include/uapi/asm/sve_context.h index 754ab751b523..72aefc081061 100644 --- a/arch/arm64/include/uapi/asm/sve_context.h +++ b/arch/arm64/include/uapi/asm/sve_context.h @@ -13,6 +13,17 @@ #define __SVE_VQ_BYTES 16 /* number of bytes per quadword */ +/* + * Yes, __SVE_VQ_MAX is 512 QUADWORDS. + * + * To help ensure forward portability, this is much larger than the + * current maximum value defined by the SVE architecture. While arrays + * or static allocations can be sized based on this value, watch out! + * It will waste a surprisingly large amount of memory. + * + * Dynamic sizing based on the actual runtime vector length is likely to + * be preferable for most purposes. + */ #define __SVE_VQ_MIN 1 #define __SVE_VQ_MAX 512