From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id E675D4905E for ; Sat, 2 Mar 2024 20:22:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2BCD468D305; Sat, 2 Mar 2024 22:22:02 +0200 (EET) Received: from mail8.parnet.fi (mail8.parnet.fi [77.234.108.134]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 47FE468D28F for ; Sat, 2 Mar 2024 22:21:55 +0200 (EET) Received: from mail9.parnet.fi (mail9.parnet.fi [77.234.108.21]) by mail8.parnet.fi with ESMTP id 422KLrWX018371-422KLrWY018371 for ; Sat, 2 Mar 2024 22:21:53 +0200 Received: from cone.home.martin.st (host-114-191.parnet.fi [77.234.114.191]) by mail9.parnet.fi (Postfix) with ESMTPS id CA706A14A7 for ; Sat, 2 Mar 2024 22:21:53 +0200 (EET) Date: Sat, 2 Mar 2024 22:21:52 +0200 (EET) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: ffmpeg-devel@ffmpeg.org In-Reply-To: <20240227222030.51301-1-martin@martin.st> Message-ID: References: <20240227222030.51301-1-martin@martin.st> MIME-Version: 1.0 X-FEAS-Client-IP: 77.234.108.21 X-FE-Last-Public-Client-IP: 77.234.108.21 X-FE-Policy-ID: 3:14:2:SYSTEM X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH] aarch64: Use regular hwcaps flags instead of HWCAP_CPUID for CPU feature detection on Linux X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-15"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Wed, 28 Feb 2024, Martin Storsj=F6 wrote: > The CPU feature detection was added in > 493fcde50a84cb23854335bcb0e55c6f383d55db, using HWCAP_CPUID. > > The argument for using that, was that HWCAP_CPUID was added much > earlier in the kernel (in Linux v4.11), while the HWCAP flags for > individual features were added much later. And if compiling with > older userland headers that lack the bits for e.g. HWCAP_I8MM, we > wouldn't be able to detect that feature. > > (In practice, e.g. Ubuntu 20.04 lacks HWCAP_I8MM in userland > headers, but the toolchain does support assembling such > instructions). > > However, while the flag HWCAP_I8MM was addded only in Linux v5.10, > any CPU with that feature is most likely running a kernel that is > newer than that as well. So by using HWCAP_CPUID, we could detect > that feature on kernels between v4.11 and v5.10, but that is a > quite unlikely case in practice. > > By using regular hwcaps flags, the code is much simplified, and > doesn't rely on inline assembly to read the cpu id registers. > > And instead of requiring the userland headers to provide the > definitions of the hwcap flags, provide our own definitions of the > constants (they are fixed constants anyway), with names not conflicting > with the ones from system headers. This avoids a number of ifdefs, and > allows detecting these features even if building with userland headers > that don't contain these definitions yet. > > Also, slightly older versions of QEMU, e.g. 6.2 in Ubuntu 22.04, > do expose these features via HWCAP flags, but the emulated cpuid > registers are missing the bits for exposing e.g. I8MM. > --- > libavutil/aarch64/cpu.c | 30 ++++++++---------------------- > 1 file changed, 8 insertions(+), 22 deletions(-) Will apply on Monday, if there's no objections. // Martin _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".