From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2086.outbound.protection.outlook.com [40.107.20.86]) by sourceware.org (Postfix) with ESMTPS id 682CB385829C for ; Thu, 14 Mar 2024 08:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 682CB385829C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 682CB385829C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.20.86 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1710405346; cv=pass; b=xo81c6GiMaENjg7BHEmGlitBFYv0/cbK13VeOQ60C3L+mTLUb5pEEX9qUutZzDlUJM8ctMLACcQywkpmnTP8k9qCKWgAwfgkxj9wB7M8WqMqVwPYMY31uh1o+QVkc1QfzrH7FjLjjXI/UjfiaUf1CBqy/aekveYoNbcA+4yJhVY= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1710405346; c=relaxed/simple; bh=xSs+ciZka1dFoYjguxWc0gBzkKMcKgSH1NYO36SuiME=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=QsKOuOyeb8M+bqX0lAJBThLau23OBuUrVXodWVTaUthh0CqYPIAbFjZtXz2+PZnIrM/1B2hGDcXXoj6v0EL1SGhoQwMcMC/8OIN75yCMPQJts5y9CipcMaUvb5bM/bZbXlMFCnDBdMWYcNZaDaXmpoqRA2xEt3y3knzENhSM33w= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=BFvEdsxPk3/EyQ9RqQA8TpeYhzLEc8rr8JvBmB35z/+R6auJ0JOIKNsIMrs1AwbfXAa5dSJDMTW1uQwfnsb0ufTsTsCV/Nnq9PsUd/cYzAmOWxo5/Ww2hxjPRzwjGoa8BP5rRq9JV57/LzgP1vvNOGnimoGPCqcQtug7r1wcgW7BnK/5vUB0zir+IaFxRZg/sXOGngk/0ws1ReAamZ7lHjYp5V9rgI61VH3tRGm/PuZQT1zRS34+PE12KMNDj8Bf+YmruWg88XKWp1hOZIZYyICwDATc674133dQCWA+GdhTEk1k+ho3cpFXIHSM1rQ/iwJEtk/Kf92HXY+K7oBh0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QnJd/6i27OG8R6OoWGv6Wi4oCqZ757yMV7rpzlOJfqM=; b=OJVWOaEWM6R4tVpjH1ZpmwQXoxcx0LIBrc7py0vFNuVwxxGqxs7axo4rbw3JpofDuHpFCUWbZtDu3gaZdNaGYND68ZsdjYwT15dORp1WgTc45gPcrbqGhgdImAF7hUXtEuAA3OECpM7T6+iTGyyTvbgK3HRYyOpFtYl9ABKzkSjK/iUxQAXXFAo+wPDtr92ZIMfJn6+Cuyz8KbOzfdliSApyIQLeQOD9F/k+OTUmf1D1H09QE1pO5BvPFU84u4W0ekHyi50YYiQrjUE1tnQnnjgd+N03gqOEKPWjvypN+Tycrgx6oBaMPQS+GFK3ljqkwho1LMOPMbaVKb+KDecKcw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QnJd/6i27OG8R6OoWGv6Wi4oCqZ757yMV7rpzlOJfqM=; b=Q2ExvRX7bTMqwMf9fw5uZOWqYFfrQ6wIfybrPfjr39arMP5f55rXUIKjVx3IcdOpsMMCIUYz4xvxfuGAAU3AqxqqtP2/Fk0E4WWqB0UI3Q/vXe+/lCTCaGaey5c5Bl5YSD0SCjJPCvQxcGvWJkPkDIyya92OB+Ceek0SvaviD5I= Received: from AM6PR0502CA0037.eurprd05.prod.outlook.com (2603:10a6:20b:56::14) by AS8PR08MB9480.eurprd08.prod.outlook.com (2603:10a6:20b:61f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.19; Thu, 14 Mar 2024 08:35:22 +0000 Received: from AMS0EPF000001B3.eurprd05.prod.outlook.com (2603:10a6:20b:56:cafe::f4) by AM6PR0502CA0037.outlook.office365.com (2603:10a6:20b:56::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.19 via Frontend Transport; Thu, 14 Mar 2024 08:35:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS0EPF000001B3.mail.protection.outlook.com (10.167.16.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.12 via Frontend Transport; Thu, 14 Mar 2024 08:35:21 +0000 Received: ("Tessian outbound 598157ceef91:v276"); Thu, 14 Mar 2024 08:35:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9ec9088e70b55d8d X-CR-MTA-TID: 64aa7808 Received: from 2fe885524867.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5CE52A9F-7BE8-4F11-86EF-665B8D7668F0.1; Thu, 14 Mar 2024 08:35:16 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2fe885524867.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 14 Mar 2024 08:35:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IFe9MXwHZ7G6E4xbt9T0Ll/o4/jGJ/QQ2A3qGzgXwBhUx/bcSQa0RM+ZtrpVxWfE7D4McYWoV0Jfc9CmySnD8C6JfmhMiHcaeYsH85jeIQGG/H2HauRpVm+/1/y00h0I0cRop6/XtWvirLGTCnTsrTnQoB2ILjkjJmaBRwsfDXhpNpn8fRXYO785H8PrJsDb1xJBs927wrJYe41G8rv5dIiQnl2gt8B5HjOgjklCZPZ45nSjyAf2Uqg+KTrEDIcQbP1h5pb+ip1qTKg5j4ag70A/mDq/lKEOCaoLV69DKzTia6m1GzsHu8rwr04L9i+ZKFV7jxgJx9+M5ooNbGc/WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QnJd/6i27OG8R6OoWGv6Wi4oCqZ757yMV7rpzlOJfqM=; b=DUgzxIozN4kjxF3Ya8Zi9Z3HfuC7f2isEpF24M+GXLBDlOmzH/GL+uOvNUI4i6lu8wBO+yeMv/XNMW2QWOUQwxNVVGLsZn7K9HJeJH1FjzTmQCrW93fslWCpig627xn7EOyHZvcFWzSqpK8/hiR5NgTmHNtn4SdajUPNDhhSfnLSzyABWE2cMp1kjh6UVz8/i5SK7J6/iZZO/8QZmujhit1op4aotApKwPBHs8Wr30BYj38XE+cpBNUgVO+Tq4RGAnDYMSjkZ0BVimX70IqpG/4Yy6Sfnvps1PVIBrvnzXVIblP2UQgPrH0v96M1lYh3PeBGxZMYUL/0d6YzHw5rmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QnJd/6i27OG8R6OoWGv6Wi4oCqZ757yMV7rpzlOJfqM=; b=Q2ExvRX7bTMqwMf9fw5uZOWqYFfrQ6wIfybrPfjr39arMP5f55rXUIKjVx3IcdOpsMMCIUYz4xvxfuGAAU3AqxqqtP2/Fk0E4WWqB0UI3Q/vXe+/lCTCaGaey5c5Bl5YSD0SCjJPCvQxcGvWJkPkDIyya92OB+Ceek0SvaviD5I= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by VI0PR08MB10629.eurprd08.prod.outlook.com (2603:10a6:800:20b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27; Thu, 14 Mar 2024 08:35:14 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::8c23:46ef:c2c9:ea91]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::8c23:46ef:c2c9:ea91%4]) with mapi id 15.20.7386.020; Thu, 14 Mar 2024 08:35:13 +0000 Date: Thu, 14 Mar 2024 08:35:00 +0000 From: Szabolcs Nagy To: Adhemerval Zanella Netto , Wilco Dijkstra , 'GNU C Library' Subject: Re: [PATCH] AArch64: Check kernel version for SVE ifuncs Message-ID: References: <319a4afc-3841-4532-8350-be16e296c251@linaro.org> <44aeef4b-1044-4be8-9f35-e592a1c26080@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <44aeef4b-1044-4be8-9f35-e592a1c26080@linaro.org> X-ClientProxiedBy: LO2P265CA0292.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::16) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|VI0PR08MB10629:EE_|AMS0EPF000001B3:EE_|AS8PR08MB9480:EE_ X-MS-Office365-Filtering-Correlation-Id: 1813ad3d-f1a6-42d1-17c1-08dc4401b026 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 8zNSOf2czZSFw7DaoMUMn//Vh+sHyepKisO4Fj69IM6Kp9F77V7wnTkUt4JjX8mQV5CFpgBEc2g+Pfih4COEUuCRzXUCeJ+wV7Sk7T6xtgwIsKY0wlAQiBqeWMFa+cpZTlaOcNJjYY6Jkqs6QHkf2W0YLpN0O5CmVeRHOFGPz8gSe3Djdi5mFmVuQM7WA4bYf+2s9ZmMrTupjmBSLe2eYcsWHkGf98B0cNrO3/lWvq3m53jgR6UwdrRpKls3n9Td8l/bWf5WFCLQvYq+gNt63AYSYXu4TtU+YUbGySPkCRbzO0RwXXG4YVZyXxmY/sq8NIfZPaHTh6ieW3+0Eej9Bz0NvHKyaLxi09kyw3Bf1KQBbHj0Q/wiwSFCd0zFG9JRlZYT8c3seN9rG56BZT0f505z1pd8Gr7RQwv5DLyr5MJs7A4xdZ4kN1G+YCFcD/CLFV39O814Zc6sHfPDGV0ny2yEtyoZAn8TJOVl6YnlcJ+LFSu/IUgZ+u7UTfotRmG1iCvps6E55RqEtw8OQz4cWuKDCvaEIPj2qa8wAOZEbZM2mfLyMZIZl8wYCUQZ6o0HYSoF8gaQ7zCJrmOZx6YMYp21Qn8JXz0XtuYXoeXQACP1DStbUcNT+FhIT+ByclSMPvPquSxRlsp0D2vyc8btDuzGeaTDipb49o6SFcqaWK0= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB7179.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR08MB10629 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF000001B3.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6658e831-7e80-4c45-2632-08dc4401aadd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mZWKa4e0J6uqeBaLLBMlXfsamj8RY1dgyUvohyhlddwds9zsgcmnlVirfThWqL/Cd/eaW7h1I8d7hwpwZCKdrhi2aZl13IoZ4EA8vv0gV1NSp+AtRDoo0V/1FB6Yhxkzlgz4v5ROzLoNV7r3VFgsbL0WAAF8cz+WBDTE6M67xsRbsn8fTX3KhpPGcCpKshv5RgaKgTs3xPGrF294cCzniuW17PcfkZRrA1GYBNtcr1A8M2yqC15iyxFqQpNpaqHLWDafyOyjEPNLcQLxRVNPzlLtSwh3f8RnmWvytb1WNPDCZCkZOFEET39+/pgcPj52lRo6MOext9O/kPimgshcduUxdDx2OABrymME6wCi0q8+F3lU5yxYgaAg0v7OrzWAhl9Yh9MqYzNay0tnEf3iE3oRX4VXU5hIvOyVGvhyXJt2OPg2o0td/oATZ0bfyyqxVAFrTtVB09eQY0lPGOWZ1eVBuL3RUlJDD4M8GeEWFlYOjZEE2gzeHUdkaeZ9qR0dxvOZoyUnTXp9W3Q1hI6ZYAI1dfPe95AaS7MpzNJLUAgBYFIJ8D/dJoMzvI6/GMIDgalpxs/2szNRRYueoiGPAMyRlKhu/ywesKBOjO5wokxfuL4GEl5CcPktVfHvUoq2thNM6m2weCJ530xh2T7AbXXFtyxd2ugInZBR5/UrKxzXokXBj74enL4hy0H1foD01gDBxjZMDBziNfj+EdoEhOR+FARb8rzwTNIDGLHiCgKEUB9hEuBnKcYrkpkOLhsv X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230031)(36860700004)(376005)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2024 08:35:21.9929 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1813ad3d-f1a6-42d1-17c1-08dc4401b026 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001B3.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9480 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_LOTSOFHASH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The 03/13/2024 16:55, Adhemerval Zanella Netto wrote: > On 13/03/24 16:25, Szabolcs Nagy wrote: > > The 03/13/2024 15:12, Adhemerval Zanella Netto wrote: > >> On 13/03/24 11:31, Wilco Dijkstra wrote: > >>> > >>> Older Linux kernels may disable SVE after certain syscalls. Calling the > >>> SVE-optimized memcpy afterwards will then cause a trap to reenable SVE. > >>> As a result, applications with a high use of syscalls may run slower with > >>> the SVE memcpy. Avoid this by checking the kernel version and enable the > >>> SVE-optimized memcpy/memmove ifuncs only on Linux kernel 6.2 or newer. > >>> > >>> Passes regress, OK for commit? > >> > >> How does it handle backports? Parsing kernel version is really not ideal > >> (and that's why we removed it on previous version), can't kernel provide > >> this information through any means (as powerpc does for HTM without > >> suspend, PPC_FEATURE2_HTM_NO_SUSPEND) ? > > > > the check is for performance only, not correctness. > > > > if we detect a bad kernel as good, that can cause significant > > slowdown due to the traps depending on the workload. > > (at least this is the claim, i haven't verified, but plausible) > > > > if we detect a good kernel as bad (e.g. because of kernel > > backports), that is acceptable amount of slowdown (the fallback > > memcpy is reasonably fast). > > > > i think the kernel version check is ugly, but in this case it > > makes sense: direct detection of the behaviour is hard, the > > version check should reliably avoid detecting a bad kernel as > > good, and it is better than always assuming a bad kernel. > > Yes, I understand this. My point it won't be possible to backport this > kernel fix to get the performance improvement of SVE routines without > hacking the glibc as well. It is not really a blocker, but I would > expect kernel to do proper advertise for such performance change that > might interfere with ifunc selection. Maybe we can add a tunable to > force SVE selection, but I don't have a strong opinion. right. i can ask linux devs, if they are happy introducing an easy check in future kernels or if the change is easy to backport at all or we don't want to encourage that. > > And I don't think __ASSUME_FAST_SVE would work well here, it means it > would always detect a good kernel even when running on a older one why? if it is set based on min supported kernel version then running on older kernel is a bug. if it can be overriden by a tunable then it is a user error if the tunable is wrong. > (I am not sure how usual this is). The minimum supported kernel > version can work to ensure that this check won't be necessary, but in > this case we won't really need this test anyway. you mean after min version is increased the check can be removed? i expect all __ASSUME* based on min linux version works like that and it's useful to have the __ASSUME exactly to be able to find which code can be removed after a min version increase. i don't know if distros actually adjust the min version in their glibc, i guess that would be risky if it should work in containers, so 6.2 min version is probably far in the future. > > The _dl_discover_osversion (removed by b46d250656794e63a2946c481fda) > used to check the PT_NOTE, and fallback to uname or /proc/sys/kernel/osrelease. > I think we will need at least the osrelease fallback in the case of > uname syscall filtering. i didn't know about the vdso PT_NOTE. we could check osrelease there i guess. fallback is not critical as slightly slower memcpy is not the end of the world, and there is a balance how complicated code we want to maintain here. > > > > >> > >>> > >>> --- > >>> > >>> diff --git a/sysdeps/aarch64/cpu-features.h b/sysdeps/aarch64/cpu-features.h > >>> index 77a782422af1b6e4b2af32bfebfda37874111510..5f2da91ebbd0adafb0d84ec503b0f902f566da5a 100644 > >>> --- a/sysdeps/aarch64/cpu-features.h > >>> +++ b/sysdeps/aarch64/cpu-features.h > >>> @@ -71,6 +71,7 @@ struct cpu_features > >>> /* Currently, the GLIBC memory tagging tunable only defines 8 bits. */ > >>> uint8_t mte_state; > >>> bool sve; > >>> + bool prefer_sve_ifuncs; > >>> bool mops; > >>> }; > >>> > >>> diff --git a/sysdeps/aarch64/multiarch/init-arch.h b/sysdeps/aarch64/multiarch/init-arch.h > >>> index c52860efb22d70eb4bdf356781f51c7de8ec67dc..61dc40088f4d9e5e06b57bdc7d54bde1e2a686a4 100644 > >>> --- a/sysdeps/aarch64/multiarch/init-arch.h > >>> +++ b/sysdeps/aarch64/multiarch/init-arch.h > >>> @@ -36,5 +36,7 @@ > >>> MTE_ENABLED (); \ > >>> bool __attribute__((unused)) sve = \ > >>> GLRO(dl_aarch64_cpu_features).sve; \ > >>> + bool __attribute__((unused)) prefer_sve_ifuncs = \ > >>> + GLRO(dl_aarch64_cpu_features).prefer_sve_ifuncs; \ > >>> bool __attribute__((unused)) mops = \ > >>> GLRO(dl_aarch64_cpu_features).mops; > >>> diff --git a/sysdeps/aarch64/multiarch/memcpy.c b/sysdeps/aarch64/multiarch/memcpy.c > >>> index d12eccfca51f4bcfef6ccf5aa286edb301e361ac..ce53567dab33c2f00b89b4069235abd4651811a6 100644 > >>> --- a/sysdeps/aarch64/multiarch/memcpy.c > >>> +++ b/sysdeps/aarch64/multiarch/memcpy.c > >>> @@ -47,7 +47,7 @@ select_memcpy_ifunc (void) > >>> { > >>> if (IS_A64FX (midr)) > >>> return __memcpy_a64fx; > >>> - return __memcpy_sve; > >>> + return prefer_sve_ifuncs ? __memcpy_sve : __memcpy_generic; > >>> } > >>> > >>> if (IS_THUNDERX (midr)) > >>> diff --git a/sysdeps/aarch64/multiarch/memmove.c b/sysdeps/aarch64/multiarch/memmove.c > >>> index 2081eeb4d40e0240e67a7b26b64576f44eaf18e3..fe95037be391896c7670ef606bf4d3ba7dfb6a00 100644 > >>> --- a/sysdeps/aarch64/multiarch/memmove.c > >>> +++ b/sysdeps/aarch64/multiarch/memmove.c > >>> @@ -47,7 +47,7 @@ select_memmove_ifunc (void) > >>> { > >>> if (IS_A64FX (midr)) > >>> return __memmove_a64fx; > >>> - return __memmove_sve; > >>> + return prefer_sve_ifuncs ? __memmove_sve : __memmove_generic; > >>> } > >>> > >>> if (IS_THUNDERX (midr)) > >>> diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c > >>> index b1a3f673f067280bdacfddd92723a81e418023e5..13b02c45df80b493516b3c9d4acbbbffaa47af92 100644 > >>> --- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c > >>> +++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c > >>> @@ -21,6 +21,7 @@ > >>> #include > >>> #include > >>> #include > >>> +#include > >>> #include > >>> > >>> #define DCZID_DZP_MASK (1 << 4) > >>> @@ -62,6 +63,41 @@ get_midr_from_mcpu (const struct tunable_str_t *mcpu) > >>> return UINT64_MAX; > >>> } > >>> > >>> +/* Parse kernel version without calling any library functions. > >>> + Allow 2 digits for kernel version and 3 digits for major version, > >>> + separated by '.': "kk.mmm.". > >>> + Return kernel version * 1000 + major version, or -1 on failure. */ > >>> + > >>> +static inline int > >>> +kernel_version (void) > >>> +{ > >>> + struct utsname buf; > >>> + const char *p = &buf.release[0]; > >>> + int kernel = 0; > >>> + int major = 0; > >>> + > >>> + if (__uname (&buf) < 0) > >>> + return -1; > >>> + > >>> + if (*p >= '0' && *p <= '9') > >>> + kernel = (kernel * 10) + *p++ - '0'; > >>> + if (*p >= '0' && *p <= '9') > >>> + kernel = (kernel * 10) + *p++ - '0'; > >>> + if (*p != '.') > >>> + return -1; > >>> + p++; > >>> + if (*p >= '0' && *p <= '9') > >>> + major = (major * 10) + *p++ - '0'; > >>> + if (*p >= '0' && *p <= '9') > >>> + major = (major * 10) + *p++ - '0'; > >>> + if (*p >= '0' && *p <= '9') > >>> + major = (major * 10) + *p++ - '0'; > >>> + if (*p != '.' && *p != '\0') > >>> + return -1; > >>> + > >>> + return kernel * 1000 + major; > >>> +} > >>> + > >>> static inline void > >>> init_cpu_features (struct cpu_features *cpu_features) > >>> { > >>> @@ -126,6 +162,10 @@ init_cpu_features (struct cpu_features *cpu_features) > >>> /* Check if SVE is supported. */ > >>> cpu_features->sve = GLRO (dl_hwcap) & HWCAP_SVE; > >>> > >>> + /* Prefer using SVE in string ifuncs from Linux 6.2 onwards. */ > >>> + cpu_features->prefer_sve_ifuncs = > >>> + cpu_features->sve && kernel_version () >= 6002; > >>> + > >>> /* Check if MOPS is supported. */ > >>> cpu_features->mops = GLRO (dl_hwcap2) & HWCAP2_MOPS; > >>> } > >>>