From nobody Mon Jul 22 22:50:31 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 4WSb8w1TQCz5QMFD; Mon, 22 Jul 2024 22:50:40 +0000 (UTC) (envelope-from kib@freebsd.org) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4WSb8v2nDvz4nxH; Mon, 22 Jul 2024 22:50:39 +0000 (UTC) (envelope-from kib@freebsd.org) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=freebsd.org (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kib@freebsd.org) smtp.mailfrom=kib@freebsd.org Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 46MMoWA2057098; Tue, 23 Jul 2024 01:50:35 +0300 (EEST) (envelope-from kib@freebsd.org) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 46MMoWA2057098 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 46MMoVbi057097; Tue, 23 Jul 2024 01:50:31 +0300 (EEST) (envelope-from kib@freebsd.org) X-Authentication-Warning: tom.home: kostik set sender to kib@freebsd.org using -f Date: Tue, 23 Jul 2024 01:50:31 +0300 From: Konstantin Belousov To: Michal Meloun Cc: Mark Millard , mmel@freebsd.org, FreeBSD Current , "freebsd-arm@freebsd.org" Subject: Re: armv7-on-aarch64 stuck at urdlck 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> 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33251aa3-681f-4d17-afe9-953490afeaf0@gmail.com> X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Spamd-Bar: - X-Spamd-Result: default: False [-1.48 / 15.00]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.98)[-0.980]; MIME_GOOD(-0.10)[text/plain]; DMARC_POLICY_SOFTFAIL(0.10)[freebsd.org : No valid SPF, No valid DKIM,none]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[yahoo.com,freebsd.org]; FREEMAIL_TO(0.00)[gmail.com]; TO_DN_EQ_ADDR_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; TO_DN_SOME(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; FROM_EQ_ENVFROM(0.00)[]; HAS_XAW(0.00)[]; FREEFALL_USER(0.00)[kib]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MLMMJ_DEST(0.00)[freebsd-current@freebsd.org,freebsd-arm@freebsd.org]; RCVD_COUNT_TWO(0.00)[2]; TAGGED_RCPT(0.00)[]; R_DKIM_NA(0.00)[]; RCPT_COUNT_FIVE(0.00)[5] X-Rspamd-Queue-Id: 4WSb8v2nDvz4nxH On Mon, Jul 22, 2024 at 09:36:00PM +0200, Michal Meloun wrote: > IMHO, -O2 shouldn't be able to modify function arguments for public > functions, so this memory corruption fits perfectly with the > observed behavior. > > But , out of curiosity, a quick look at _thr_rwlock_tryrdlock() in > thr_umtx.h:208 makes me wonder: How is the "state" variable inside the loop > guaranteed to be updated? IMHO nothing inside the loop emits a global memory > modification attribute, so the compiler is free to move the assignment to a > "state" variable outside the loop. > I think that you are formally right, because there is only the _acq atomic in the loop body, an evil compiler is allowed to move all loads before the start of the loop iteration. But, since e.g. on arm32 atomic_cmpset_acq implementation contains dmb() which provides the full barrier both for compiler memory accesses, and for hw, it is not the case (for arm32).