← Documents Documentation/arch/arm/swp_emulation.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

Software emulation of deprecated SWP instruction

ARMv6 이후 deprecated SWP/SWPB를 LDREX/STREX로 emulate하는 경로와 통계, global monitor 부재 시 deadlock 위험을 설명합니다.

Source pathDocumentation/arch/arm/swp_emulation.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약과 해설

swp_emulation.rst:1-27

SWP emulation은 오래된 binary를 계속 실행하기 위한 compatibility path입니다. cached memory에서는 exclusive sequence로 바꿀 수 있지만 uncached shared memory의 atomicity는 hardware global monitor 유무에 달려 있습니다.

SWP emulation 경로
SWP / SWPBundefined instruction trapLDREX/STREX sequenceatomic update
memory abortsegmentation fault/proc/cpu/swp_emulation stats

instruction trap부터 성공 또는 process fault까지의 분기입니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 Software emulation of deprecated SWP instruction (CONFIG_SWP_EMULATE)
2 ---------------------------------------------------------------------
3
4 ARMv6 architecture deprecates use of the SWP/SWPB instructions, and recommends
5 moving to the load-locked/store-conditional instructions LDREX and STREX.
6
7 ARMv7 multiprocessing extensions introduce the ability to disable these
8 instructions, triggering an undefined instruction exception when executed.
9 Trapped instructions are emulated using an LDREX/STREX or LDREXB/STREXB
10 sequence. If a memory access fault (an abort) occurs, a segmentation fault is
11 signalled to the triggering process.
12
13 /proc/cpu/swp_emulation holds some statistics/information, including the PID of
14 the last process to trigger the emulation to be invocated. For example::
15
16 Emulated SWP: 12
17 Emulated SWPB: 0
18 Aborted SWP{B}: 1
19 Last process: 314
20
21
22 NOTE:
23 when accessing uncached shared regions, LDREX/STREX rely on an external
24 transaction monitoring block called a global monitor to maintain update
25 atomicity. If your system does not implement a global monitor, this option can
26 cause programs that perform SWP operations to uncached memory to deadlock, as
27 the STREX operation will always fail.
28

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Software emulation of deprecated SWP instruction

1-3

`CONFIG_SWP_EMULATE`가 deprecated `SWP` instruction을 software로 emulate하는 방식을 설명합니다.

SWP에서 LDREX/STREX로 전환

4-12

ARMv6 architecture는 `SWP`/`SWPB` instruction 사용을 deprecated로 정하고 load-locked/store-conditional 방식인 `LDREX`와 `STREX`로 옮기도록 권장합니다.

ARMv7 multiprocessing extension에서는 `SWP` instruction을 disable할 수 있습니다. disable된 instruction을 실행하면 undefined-instruction exception이 발생하고, trap된 instruction은 `LDREX`/`STREX` 또는 `LDREXB`/`STREXB` sequence로 emulate됩니다. memory access fault, 즉 abort가 나면 실행 process에 segmentation fault를 보냅니다.

/proc/cpu/swp_emulation

13-21

`/proc/cpu/swp_emulation`에는 emulation을 마지막으로 일으킨 process의 PID를 포함한 통계와 정보가 있습니다. 출력 예는 다음과 같습니다.

Emulated SWP:                12
Emulated SWPB:                0
Aborted SWP{B}:                1
Last process:                314

Global monitor 주의사항

22-27

uncached shared region에서 `LDREX`/`STREX`는 update atomicity를 유지하기 위해 global monitor라는 외부 transaction-monitoring block에 의존합니다. system에 global monitor가 없으면 uncached memory에 `SWP`를 수행하는 program은 `STREX`가 항상 실패해 deadlock될 수 있습니다.