요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
Software emulation of deprecated SWP instruction (CONFIG_SWP_EMULATE)
---------------------------------------------------------------------
ARMv6 architecture deprecates use of the SWP/SWPB instructions, and recommends
moving to the load-locked/store-conditional instructions LDREX and STREX.
ARMv7 multiprocessing extensions introduce the ability to disable these
instructions, triggering an undefined instruction exception when executed.
Trapped instructions are emulated using an LDREX/STREX or LDREXB/STREXB
sequence. If a memory access fault (an abort) occurs, a segmentation fault is
signalled to the triggering process.
/proc/cpu/swp_emulation holds some statistics/information, including the PID of
the last process to trigger the emulation to be invocated. For example::
Emulated SWP: 12
Emulated SWPB: 0
Aborted SWP{B}: 1
Last process: 314
NOTE:
when accessing uncached shared regions, LDREX/STREX rely on an external
transaction monitoring block called a global monitor to maintain update
atomicity. If your system does not implement a global monitor, this option can
cause programs that perform SWP operations to uncached memory to deadlock, as
the STREX operation will always fail.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Software emulation of deprecated SWP instruction
1-3`CONFIG_SWP_EMULATE`가 deprecated `SWP` instruction을 software로 emulate하는 방식을 설명합니다.
SWP에서 LDREX/STREX로 전환
4-12ARMv6 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-27uncached shared region에서 `LDREX`/`STREX`는 update atomicity를 유지하기 위해 global monitor라는 외부 transaction-monitoring block에 의존합니다. system에 global monitor가 없으면 uncached memory에 `SWP`를 수행하는 program은 `STREX`가 항상 실패해 deadlock될 수 있습니다.
요약과 해설
swp_emulation.rst:1-27SWP emulation은 오래된 binary를 계속 실행하기 위한 compatibility path입니다. cached memory에서는 exclusive sequence로 바꿀 수 있지만 uncached shared memory의 atomicity는 hardware global monitor 유무에 달려 있습니다.
instruction trap부터 성공 또는 process fault까지의 분기입니다.