From nobody Tue Jul 23 20:11:13 2024 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WT7Zb0n3qz5QKj0; Tue, 23 Jul 2024 20:11:19 +0000 (UTC) (envelope-from jfc@mit.edu) Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazlp170110009.outbound.protection.outlook.com [IPv6:2a01:111:f403:c111::9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.protection.outlook.com", Issuer "DigiCert Cloud Services CA-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WT7ZZ3FM0z4CW4; Tue, 23 Jul 2024 20:11:18 +0000 (UTC) (envelope-from jfc@mit.edu) Authentication-Results: mx1.freebsd.org; none ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pkXZ5p9F9qagekLy0OaY75GEgYHvhWs7LraeNLbCqHJtsFen0ozn5KHn+gctV/CaPLqA4yXV75kr3bOSByKpROhk1xdgK8OPGRv9jcs28pXd358Wldh1z512AbvJMRuL3k0gZMhDTXQdQpMiiRHcrmaF8+tBU8LrrN+y0/rCPDlb8ImW8a38gH0b2trhvMDO08rlX5QNgDRaxAwE1zdtF/D5WmXKl+6b+D8aWr+F7rtUB5zr8ISD/9084W96cxrX2hl9vebC9kYdF1jRsDWc6DcdC6KG6BsDnM/VWKcw8xfMYuqfbzgEKiQ6gYWiIKbH634AMuEVr/pdQFy4jt9t2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=+plYhsLWINIA4XeQ8sxA6k8eBrmXrWwzZjHPndbm9I8=; b=WARfIAWOUabRsUXSAOhlVCQrQpJIMfsRrtTefTzVJbWZ+8U6fBaeY+n/JaEEN6PYhQXKr+1tSfhd51iocJkwAj2c0IbVlZSC9l8R3XfIhKGQ+wIHTZfidu1c1IycqbgvV+t9Qht8DXxfKO2PpkJpvLL3kXM+p14X7wi+UbKG+2J0AewwRaz3vMm+ClokWn4YanQmM9lO5NRojbNbOMeGejOWQXjQ9ZUhWCCjFHDRiIaAZqrOGrp6HLnPeuekvEHdmmCXLpU6hKQ9/mmoPBwtbOkzXTNlPSJAD4EkiRdvgkYLZYhNBlaxYaL/VlfRGNxsw6EXWHT3gqvkO1QY5zPtCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mit.edu; dmarc=pass action=none header.from=mit.edu; dkim=pass header.d=mit.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+plYhsLWINIA4XeQ8sxA6k8eBrmXrWwzZjHPndbm9I8=; b=dRYze598b4FG3pnbgOTpcJeWvwoBCTfuhxcST6qBAOxCTo/afaKOT0GsEjIUQk0sr792mitCbs6r79rJFNR40XnQzCoCn3/+26tqWoc08ZaeiXw6h+zz6ahEXHec+3E8mX2tGdCkx56SV7SeoGfIYLpNm2zEcpL4Fm0SvcOSX38= Received: from SA3PR01MB8450.prod.exchangelabs.com (2603:10b6:806:382::17) by SJ0PR01MB6301.prod.exchangelabs.com (2603:10b6:a03:29e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Tue, 23 Jul 2024 20:11:14 +0000 Received: from SA3PR01MB8450.prod.exchangelabs.com ([fe80::bb39:d8c:f575:6b9d]) by SA3PR01MB8450.prod.exchangelabs.com ([fe80::bb39:d8c:f575:6b9d%6]) with mapi id 15.20.7762.027; Tue, 23 Jul 2024 20:11:13 +0000 From: John F Carr To: "mmel@freebsd.org" CC: Konstantin Belousov , Mark Millard , FreeBSD Current , "freebsd-arm@freebsd.org" Subject: Re: armv7-on-aarch64 stuck at urdlck Thread-Topic: armv7-on-aarch64 stuck at urdlck Thread-Index: AQHa2/xL/eBpVtdzuUaKV+38IPbVfLICobiAgAAf4ACAAC4tAIAABE8AgAAMwwCAACPzAIAAiccAgABEVICAABzIAIAAiPOAgAAoSAA= Date: Tue, 23 Jul 2024 20:11:13 +0000 Message-ID: References: <724db42b-5550-4381-8277-2971e6b3e8f1@freebsd.org> <86185657-e521-466b-89e2-f291aaac10a6@freebsd.org> <0EF18174-8735-46A4-BD71-FFA3472B319F@yahoo.com> <33251aa3-681f-4d17-afe9-953490afeaf0@gmail.com> <0DD19771-3AAB-469E-981B-1203F1C28233@yahoo.com> <6a969609-fa0e-419d-83d5-e4fcf0f6ec35@freebsd.org> In-Reply-To: <6a969609-fa0e-419d-83d5-e4fcf0f6ec35@freebsd.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA3PR01MB8450:EE_|SJ0PR01MB6301:EE_ x-ms-office365-filtering-correlation-id: af333be8-0f0f-48ea-1088-08dcab539a2b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|366016|376014|1800799024|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?mpAqdbqvPJwIffV9FJ7GUjwycV2R1ntgGz8qf1/rTxeBNVfqbCjn/Ru0Y0E0?= =?us-ascii?Q?NIk4XpLhfgdo9CfhKbIhnyC55V34Tiwzsb3VGrYLkoFlgFKBupGj/LPnPyJH?= =?us-ascii?Q?RyoJ1lEIjzE6Kmh4Ct+kNo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=?us-ascii?Q?hlE1WOTXY0M1KSsRuLPGZEcVNfk44sJMWtC0W5cAo86k4EDub89NONTT4/iS?= =?us-ascii?Q?Y2etkV0Lgw8w0f+kBuqKlYxwLdRPrMqdrAVau1veifgX4NGkZ7U4WurFq52h?= =?us-ascii?Q?5hD/csGSLus1aVn0SRiwSDLyehmLAz4rV5blI9j0QCQZaG0wESnBzxfloC7X?= =?us-ascii?Q?7B8/mgRAa9bepmqzh8PWdcakuJHf4ZFeo0Is/wJEAnO+c1RrDyqNRqvx7NHj?= =?us-ascii?Q?Z1r2ErQ+TdyMRinpJIwnOhkau+hpjf1UZ8HPrejR8uf6R39CFADVVIhj77HO?= =?us-ascii?Q?9bLJqPZhpDpwNN/8I86ICi2rvq0HRtDnz+EVHnigM8ZzAc/Nk2/cFPsbuMZ0?= =?us-ascii?Q?ksELpEA=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA3PR01MB8450.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024)(38070700018);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?5EUEuPftSqRC0Z6qVzQVTCcJH89Mk+cjH9l8JCJ+Jx9dFJPtjDCFKyfLN2Im?= =?us-ascii?Q?c/qG4eNQKaaYlVm3a0di6OuUXNCUKpQ45mVFyydPSUEETA8C0UKVaHw+9+fr?= =?us-ascii?Q?n3bLIKGRkrGUfx6nLrZOGLMQjx6yqIK9D7qtBmpSrIhzpm9ap61dy8nGUpRE?= =?us-ascii?Q?nGsrOj0+MGki87o7Ak35vk8FwUQIuNlhoA4GQoXnf7kjUpzQH/FhrTIzjaht?= =?us-ascii?Q?olMrqKjlUtQTBshqvzb0U6frUjK4FHHjkPsludrtkq33tZksZI5q09yxOv7W?= =?us-ascii?Q?bKZDZKSA8qskPVA5KP+WP3QjC5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K6jmh7kmPf2gWNXDenDmyp5JTTXcvWkCxlndwq6YnUTJtUxFAoqQ8KKaBT?= =?us-ascii?Q?htS121MV0lAqenyF/ssR2EwP0A+9jRWd44ry2mfenmhPfjTFn9XUdzrRrpCJ?= =?us-ascii?Q?5feCV6Hxnqlgs96xyYix0R34nKWX0vXGirigkNnVExJpNDRKvrxHVMyvwz7f?= =?us-ascii?Q?eoCSXQi4cXLjhyrrQoOSK6PLjljFj69bCOB3Y/2tm4sJqFrioCsJ08aJbzwp?= =?us-ascii?Q?fmrkMXqFl5XyqQqh2DEUAM6EVAwnUlYsg/ijXyEtUZMAz5d12UYkBLzOoyHz?= =?us-ascii?Q?gIhXIVWASmdBlrGzuhAnXD1Qc5ZeECDa2oH2vHc9WuL0Yo3soNOr1BLtDzNj?= =?us-ascii?Q?kPYTEp5bZzuiPDhGkldDhK/NllFYdGFEskUdijg5xpy086PzlUN0VPpHC2fZ?= =?us-ascii?Q?MBe23r2gYKJZYVKm87rinb5N1DL+k7ygE7yGEm8gNNdi?= Content-Type: text/plain; charset="us-ascii" Content-ID: <3C1289ACC911024FA23CCA9F8DC63333@prod.exchangelabs.com> Content-Transfer-Encoding: quoted-printable List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@FreeBSD.org MIME-Version: 1.0 X-OriginatorOrg: mit.edu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA3PR01MB8450.prod.exchangelabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: af333be8-0f0f-48ea-1088-08dcab539a2b X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jul 2024 20:11:13.6466 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: QLj36hS/OJQpxOXWIkulHPASiK//m0GjKq5VaXaXYzpQ2GmbXtdIrLySH2+0Debe X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6301 X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:8075, ipnet:2a01:111:f000::/36, country:US] X-Rspamd-Queue-Id: 4WT7ZZ3FM0z4CW4 On Jul 23, 2024, at 13:46, Michal Meloun wrote: >=20 > On 23.07.2024 11:36, Konstantin Belousov wrote: >> On Tue, Jul 23, 2024 at 09:53:41AM +0200, Michal Meloun wrote: >>> The good news is that I'm finally able to generate a working/locking >>> test case. The culprit (at least for me) is if "-mcpu" is used when >>> compiling libthr (e.g. indirectly injected via CPUTYPE in /etc/make.con= f). >>> If it is not used, libthr is broken (regardless of -O level or debug/no= rmal >>> build), but -mcpu=3Dcortex-a15 will always produce a working libthr. >> I think this is very significant progress. >> Do you plan to drill down more to see what is going on? >=20 > So the problem is now clear, and I fear it may apply to other architectur= es as well. > dlopen_object() (from rtld_elf), > https://cgit.freebsd.org/src/tree/libexec/rtld-elf/rtld.c#n3766, > holds the rtld_bind_lock write lock for almost the entire time a new libr= ary is loaded. > If the code uses a yet unresolved symbol to load the library, the rtl_bin= d() function attempts to get read lock of rtld_bind_lock and a deadlock oc= curs. >=20 > In this case, it round_up() in _thr_stack_fix_protection, > https://cgit.freebsd.org/src/tree/lib/libthr/thread/thr_stack.c#n136. > Issued by __aeabi_uidiv (since not all armv7 processors support HW divide= ). >=20 > Unfortunately, I'm not sure how to fix it. The compiler can emit __aeabi= _<> in any place, and I'm not sure if it can resolve all the symbols used b= y rtld_eld and libthr beforehand. >=20 >=20 > Michal >=20 In this case (but not for all _aeabi_ functions) we can avoid division as long as page size is a power of 2. The function is static inline size_t round_up(size_t size) { if (size % _thr_page_size !=3D 0) size =3D ((size / _thr_page_size) + 1) * _thr_page_size; return size; } The body can be condensed to return (size + _thr_page_size - 1) & ~(_thr_page_size - 1); This is shorter in both lines of code and instruction bytes. John Carr