← Documents Documentation/litmus-tests/README GitHub 원문 ↗

Linux 6.18.37 · Litmus Tests

Kernel Litmus Tests

Atomic·locking·RCU API의 memory-ordering semantics를 검증하는 litmus test 목록입니다.

Source pathDocumentation/litmus-tests/README
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

README:1-80

각 test는 kernel API의 보장 또는 허용되지 않아야 할 execution을 작은 concurrent program으로 드러냅니다.

Broken·fixed pair와 barrier 유무를 함께 보면 memory-ordering 차이를 빠르게 비교할 수 있습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ============
2 LITMUS TESTS
3 ============
4
5 Each subdirectory contains litmus tests that are typical to describe the
6 semantics of respective kernel APIs.
7 For more information about how to "run" a litmus test or how to generate
8 a kernel test module based on a litmus test, please see
9 tools/memory-model/README.
10
11
12 atomic (/atomic directory)
13 --------------------------
14
15 Atomic-RMW+mb__after_atomic-is-stronger-than-acquire.litmus
16 Test that an atomic RMW followed by a smp_mb__after_atomic() is
17 stronger than a normal acquire: both the read and write parts of
18 the RMW are ordered before the subsequential memory accesses.
19
20 Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus
21 Test that atomic_set() cannot break the atomicity of atomic RMWs.
22 NOTE: Require herd7 7.56 or later which supports "(void)expr".
23
24 cmpxchg-fail-ordered-1.litmus
25 Demonstrate that a failing cmpxchg() operation acts as a full barrier
26 when followed by smp_mb__after_atomic().
27
28 cmpxchg-fail-ordered-2.litmus
29 Demonstrate that a failing cmpxchg() operation acts as an acquire
30 operation when followed by smp_mb__after_atomic().
31
32 cmpxchg-fail-unordered-1.litmus
33 Demonstrate that a failing cmpxchg() operation does not act as a
34 full barrier.
35
36 cmpxchg-fail-unordered-2.litmus
37 Demonstrate that a failing cmpxchg() operation does not act as an
38 acquire operation.
39
40
41 locking (/locking directory)
42 ----------------------------
43
44 DCL-broken.litmus
45 Demonstrates that double-checked locking needs more than just
46 the obvious lock acquisitions and releases.
47
48 DCL-fixed.litmus
49 Demonstrates corrected double-checked locking that uses
50 smp_store_release() and smp_load_acquire() in addition to the
51 obvious lock acquisitions and releases.
52
53 RM-broken.litmus
54 Demonstrates problems with "roach motel" locking, where code is
55 freely moved into lock-based critical sections. This example also
56 shows how to use the "filter" clause to discard executions that
57 would be excluded by other code not modeled in the litmus test.
58 Note also that this "roach motel" optimization is emulated by
59 physically moving P1()'s two reads from x under the lock.
60
61 What is a roach motel? This is from an old advertisement for
62 a cockroach trap, much later featured in one of the "Men in
63 Black" movies. "The roaches check in. They don't check out."
64
65 RM-fixed.litmus
66 The counterpart to RM-broken.litmus, showing P0()'s two loads from
67 x safely outside of the critical section.
68
69
70 RCU (/rcu directory)
71 --------------------
72
73 MP+onceassign+derefonce.litmus (under tools/memory-model/litmus-tests/)
74 Demonstrates the use of rcu_assign_pointer() and rcu_dereference() to
75 ensure that an RCU reader will not see pre-initialization garbage.
76
77 RCU+sync+read.litmus
78 RCU+sync+free.litmus
79 Both the above litmus tests demonstrate the RCU grace period guarantee
80 that an RCU read-side critical section can never span a grace period.
81

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`를 참조합니다.

Litmus test 활용 경로
검증할 kernel API와 memory-ordering 보장 선택해당 하위 directory의 `.litmus` test 확인`tools/memory-model/README` 절차로 test 실행필요하면 litmus test에서 kernel test module 생성

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이 되지 않음을 보여줍니다.

Atomic litmus test
Test검증 내용조건
`Atomic-RMW+mb__after_atomic-is-stronger-than-acquire`RMW read·write 모두 후속 access보다 앞섬`smp_mb__after_atomic()`
`Atomic-RMW-ops-are-atomic-WRT-atomic_set``atomic_set()`이 RMW atomicity를 깨지 않음herd7 7.56+
`cmpxchg-fail-ordered-1`실패 cmpxchg가 full barrier처럼 ordering후속 `smp_mb__after_atomic()`
`cmpxchg-fail-ordered-2`실패 cmpxchg가 acquire처럼 ordering후속 `smp_mb__after_atomic()`
`cmpxchg-fail-unordered-1`실패 cmpxchg만으로 full barrier 아님후속 barrier 없음
`cmpxchg-fail-unordered-2`실패 cmpxchg만으로 acquire 아님후속 barrier 없음

실패한 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 보장을 함께 검증합니다.

Locking litmus test
Test핵심
`DCL-broken`Lock acquire·release만으로 double-check 불충분
`DCL-fixed`Store-release와 load-acquire 추가
`RM-broken`Read를 critical section 안으로 옮긴 optimization의 문제
`RM-fixed`두 load를 critical section 밖에 안전하게 유지

잘못된 optimization과 수정된 ordering을 대응시킵니다.

RCU litmus test
Test핵심
`MP+onceassign+derefonce`Reader가 초기화 전 garbage를 보지 않음
`RCU+sync+read`Read-side critical section은 grace period를 가로지를 수 없음
`RCU+sync+free`Grace period 뒤 free와 reader의 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.