요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
============
LITMUS TESTS
============
Each subdirectory contains litmus tests that are typical to describe the
semantics of respective kernel APIs.
For more information about how to "run" a litmus test or how to generate
a kernel test module based on a litmus test, please see
tools/memory-model/README.
atomic (/atomic directory)
--------------------------
Atomic-RMW+mb__after_atomic-is-stronger-than-acquire.litmus
Test that an atomic RMW followed by a smp_mb__after_atomic() is
stronger than a normal acquire: both the read and write parts of
the RMW are ordered before the subsequential memory accesses.
Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus
Test that atomic_set() cannot break the atomicity of atomic RMWs.
NOTE: Require herd7 7.56 or later which supports "(void)expr".
cmpxchg-fail-ordered-1.litmus
Demonstrate that a failing cmpxchg() operation acts as a full barrier
when followed by smp_mb__after_atomic().
cmpxchg-fail-ordered-2.litmus
Demonstrate that a failing cmpxchg() operation acts as an acquire
operation when followed by smp_mb__after_atomic().
cmpxchg-fail-unordered-1.litmus
Demonstrate that a failing cmpxchg() operation does not act as a
full barrier.
cmpxchg-fail-unordered-2.litmus
Demonstrate that a failing cmpxchg() operation does not act as an
acquire operation.
locking (/locking directory)
----------------------------
DCL-broken.litmus
Demonstrates that double-checked locking needs more than just
the obvious lock acquisitions and releases.
DCL-fixed.litmus
Demonstrates corrected double-checked locking that uses
smp_store_release() and smp_load_acquire() in addition to the
obvious lock acquisitions and releases.
RM-broken.litmus
Demonstrates problems with "roach motel" locking, where code is
freely moved into lock-based critical sections. This example also
shows how to use the "filter" clause to discard executions that
would be excluded by other code not modeled in the litmus test.
Note also that this "roach motel" optimization is emulated by
physically moving P1()'s two reads from x under the lock.
What is a roach motel? This is from an old advertisement for
a cockroach trap, much later featured in one of the "Men in
Black" movies. "The roaches check in. They don't check out."
RM-fixed.litmus
The counterpart to RM-broken.litmus, showing P0()'s two loads from
x safely outside of the critical section.
RCU (/rcu directory)
--------------------
MP+onceassign+derefonce.litmus (under tools/memory-model/litmus-tests/)
Demonstrates the use of rcu_assign_pointer() and rcu_dereference() to
ensure that an RCU reader will not see pre-initialization garbage.
RCU+sync+read.litmus
RCU+sync+free.litmus
Both the above litmus tests demonstrate the RCU grace period guarantee
that an RCU read-side critical section can never span a grace period.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Litmus test 모음의 목적
1-9각 하위 directory에는 해당 kernel API의 memory-ordering semantics를 대표적으로 설명하는 litmus test가 들어 있습니다.
Litmus test를 실행하는 방법과 test로부터 kernel test module을 생성하는 방법은 `tools/memory-model/README`를 참조합니다.
API 보장을 작은 concurrent program으로 검증하는 흐름입니다.
============
LITMUS TESTS
============
Each subdirectory contains litmus tests that are typical to describe the
semantics of respective kernel APIs.
For more information about how to "run" a litmus test or how to generate
a kernel test module based on a litmus test, please see
tools/memory-model/README.
Atomic API litmus test
10-38`Atomic-RMW+mb__after_atomic-is-stronger-than-acquire.litmus`는 atomic RMW 뒤의 `smp_mb__after_atomic()`이 일반 acquire보다 강함을 검증합니다. RMW의 read 부분과 write 부분 모두 뒤따르는 memory access보다 먼저 ordering됩니다.
`Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus`는 `atomic_set()`이 atomic RMW의 atomicity를 깨뜨릴 수 없음을 시험합니다. `(void)expr`를 지원하는 herd7 7.56 이상이 필요합니다.
`cmpxchg-fail-ordered-1.litmus`는 실패한 `cmpxchg()` 뒤에 `smp_mb__after_atomic()`이 있으면 full barrier처럼 동작함을 보여주고, `cmpxchg-fail-ordered-2.litmus`는 같은 조합이 acquire operation처럼 동작함을 보여줍니다.
반대로 `cmpxchg-fail-unordered-1.litmus`와 `cmpxchg-fail-unordered-2.litmus`는 실패한 `cmpxchg()` 자체만으로는 각각 full barrier나 acquire operation이 되지 않음을 보여줍니다.
실패한 cmpxchg와 후속 barrier 유무의 차이를 포함합니다.
atomic (/atomic directory)
--------------------------
Atomic-RMW+mb__after_atomic-is-stronger-than-acquire.litmus
Test that an atomic RMW followed by a smp_mb__after_atomic() is
stronger than a normal acquire: both the read and write parts of
the RMW are ordered before the subsequential memory accesses.
Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus
Test that atomic_set() cannot break the atomicity of atomic RMWs.
NOTE: Require herd7 7.56 or later which supports "(void)expr".
cmpxchg-fail-ordered-1.litmus
Demonstrate that a failing cmpxchg() operation acts as a full barrier
when followed by smp_mb__after_atomic().
cmpxchg-fail-ordered-2.litmus
Demonstrate that a failing cmpxchg() operation acts as an acquire
operation when followed by smp_mb__after_atomic().
cmpxchg-fail-unordered-1.litmus
Demonstrate that a failing cmpxchg() operation does not act as a
full barrier.
cmpxchg-fail-unordered-2.litmus
Demonstrate that a failing cmpxchg() operation does not act as an
acquire operation.
Locking과 RCU litmus test
39-80`DCL-broken.litmus`는 double-checked locking에 겉으로 보이는 lock acquire·release만으로 충분하지 않음을 보여줍니다. `DCL-fixed.litmus`는 여기에 `smp_store_release()`와 `smp_load_acquire()`를 더한 수정 형태를 검증합니다.
`RM-broken.litmus`는 code가 lock-based critical section 안으로 자유롭게 이동하는 `roach motel` locking의 문제를 보여줍니다. Test에 model하지 않은 다른 code가 배제할 execution을 `filter` clause로 제거하는 방법도 설명하며, P1의 x read 두 개를 실제로 lock 안으로 이동해 optimization을 흉내 냅니다.
`roach motel`이라는 이름은 들어갈 수는 있지만 나올 수는 없다는 오래된 해충 trap 광고 표현에서 왔습니다. `RM-fixed.litmus`는 대응 test로서 P0의 x load 두 개를 critical section 밖에 안전하게 두는 형태입니다.
`MP+onceassign+derefonce.litmus`는 `rcu_assign_pointer()`와 `rcu_dereference()`로 RCU reader가 초기화 전 garbage를 보지 않게 하는 방법을 보여줍니다. 이 test는 `tools/memory-model/litmus-tests/` 아래에 있습니다.
`RCU+sync+read.litmus`와 `RCU+sync+free.litmus`는 RCU read-side critical section이 grace period 전체에 걸쳐 존재할 수 없다는 RCU grace-period 보장을 함께 검증합니다.
잘못된 optimization과 수정된 ordering을 대응시킵니다.
Publication과 grace-period 보장을 검증합니다.
locking (/locking directory)
----------------------------
DCL-broken.litmus
Demonstrates that double-checked locking needs more than just
the obvious lock acquisitions and releases.
DCL-fixed.litmus
Demonstrates corrected double-checked locking that uses
smp_store_release() and smp_load_acquire() in addition to the
obvious lock acquisitions and releases.
RM-broken.litmus
Demonstrates problems with "roach motel" locking, where code is
freely moved into lock-based critical sections. This example also
shows how to use the "filter" clause to discard executions that
would be excluded by other code not modeled in the litmus test.
Note also that this "roach motel" optimization is emulated by
physically moving P1()'s two reads from x under the lock.
What is a roach motel? This is from an old advertisement for
a cockroach trap, much later featured in one of the "Men in
Black" movies. "The roaches check in. They don't check out."
RM-fixed.litmus
The counterpart to RM-broken.litmus, showing P0()'s two loads from
x safely outside of the critical section.
RCU (/rcu directory)
--------------------
MP+onceassign+derefonce.litmus (under tools/memory-model/litmus-tests/)
Demonstrates the use of rcu_assign_pointer() and rcu_dereference() to
ensure that an RCU reader will not see pre-initialization garbage.
RCU+sync+read.litmus
RCU+sync+free.litmus
Both the above litmus tests demonstrate the RCU grace period guarantee
that an RCU read-side critical section can never span a grace period.
요약·해설
README:1-80각 test는 kernel API의 보장 또는 허용되지 않아야 할 execution을 작은 concurrent program으로 드러냅니다.
Broken·fixed pair와 barrier 유무를 함께 보면 memory-ordering 차이를 빠르게 비교할 수 있습니다.