From 0f21952d6c81b19447210e4ab8f6f208bcec4955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Thu, 23 Jan 2025 14:11:34 +0100 Subject: [PATCH 1/2] a-st-ext: mark examples as a note MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Examples are usually in note blocks already. Make these consistent. The text about compare-and-swap example should probably be improved and moved above the example. Signed-off-by: Radim Krčmář --- src/a-st-ext.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/a-st-ext.adoc b/src/a-st-ext.adoc index abc9ec38c..c17d5dcb4 100644 --- a/src/a-st-ext.adoc +++ b/src/a-st-ext.adoc @@ -229,6 +229,8 @@ those with both bits clear, but may result in lower performance. <<< +[NOTE] +==== [[cas]] [source,asm] .Sample code for compare-and-swap function using LR/SC. @@ -250,6 +252,7 @@ those with both bits clear, but may result in lower performance. LR/SC can be used to construct lock-free data structures. An example using LR/SC to implement a compare-and-swap function is shown in <>. If inlined, compare-and-swap functionality need only take four instructions. +==== [[sec:lrscseq]] === Eventual Success of Store-Conditional Instructions @@ -434,6 +437,8 @@ both imply additional unnecessary ordering as compared to AMOs with the corresponding _aq_ or _rl_ bit set. ==== +[NOTE] +==== An example code sequence for a critical section guarded by a test-and-test-and-set spinlock is shown in Example <>. Note the first AMO is marked _aq_ to @@ -457,8 +462,6 @@ relinquishment. # ... amoswap.w.rl x0, x0, (a0) # Release lock by storing 0. -[NOTE] -==== We recommend the use of the AMO Swap idiom shown above for both lock acquire and release to simplify the implementation of speculative lock elision. cite:[Rajwar:2001:SLE] From eccfc4f60d1c9c7941eedb34f2a07dd863c91019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Thu, 23 Jan 2025 15:26:08 +0100 Subject: [PATCH 2/2] a-st-ext: remove manual page breaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should improve the tooling instead of adding manual page breaks. Also replace "above" with a reference, because "above" is not correct anymore and most importantly, it's not acceptable for a spec. This does not imply any acceptability of the the rest of the sentence, I just didn't want to leave the spec in a worse shape. Signed-off-by: Radim Krčmář --- src/a-st-ext.adoc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/a-st-ext.adoc b/src/a-st-ext.adoc index c17d5dcb4..adea186b0 100644 --- a/src/a-st-ext.adoc +++ b/src/a-st-ext.adoc @@ -227,8 +227,6 @@ instruction unless the _rl_ bit is also set. LR._rl_ and SC._aq_ instructions are not guaranteed to provide any stronger ordering than those with both bits clear, but may result in lower performance. -<<< - [NOTE] ==== [[cas]] @@ -446,8 +444,6 @@ order the lock acquisition before the critical section, and the second AMO is marked _rl_ to order the critical section before the lock relinquishment. -<<< - [[critical]] [source,asm] .Sample code for mutual exclusion. `a0` contains the address of the lock. @@ -462,7 +458,7 @@ relinquishment. # ... amoswap.w.rl x0, x0, (a0) # Release lock by storing 0. -We recommend the use of the AMO Swap idiom shown above for both lock +We recommend the use of the AMO Swap idiom shown in <> for both lock acquire and release to simplify the implementation of speculative lock elision. cite:[Rajwar:2001:SLE] ====