Intel® Transactional Synchronization Extensions (Intel® TSX) Programming Considerations
Typical programmer-identified regions are expected to transactionally execute and commit successfully. However, Intel® Transactional Synchronization Extensions (Intel® TSX) does not provide any such guarantee. A transactional execution may abort for many reasons. To take full advantage of the transactional capabilities, programmers should take into account programming considerations to increase the probability of their transactional execution committing successfully.
This section discusses various events that may cause transactional aborts. The architecture ensures that updates performed within a transaction that subsequently aborts execution will not become visible: Only a committed transactional execution updates architectural state. Transactional aborts never cause functional failures and only affect performance.
Instruction Based Considerations
Programmers can use any instruction safely inside a transaction, Hardware Lock Elision (HLE) or Restricted Transactional Memory (RTM) and can use transactions at any privilege level. Some instructions will always abort the transactional execution and cause execution to seamlessly and safely transition to a non-transactional path.
Intel® TSX allows for most common instructions to be used inside transactions without causing aborts. The following operations inside a transaction do not typically cause an abort:
- Operations on the instruction pointer register.
- Operations on general purpose registers (s).GPR
- Operations on the status flags (CF,OF,SF,PF,AF, andZF).
- Operations onXMMandYMMregisters.
- Operations on theMXCSRregister.
Programmers must be careful when intermixing Intel® Supplemental Streaming Extensions (Intel® SSE) and Intel® Advanced Vector Extensions (Intel® AVX) operations inside a transactional region. Intermixing Intel® SSE instructions accessing
XMMregisters and Intel® AVX instructions accessing
YMMregisters may cause transactions to abort.
Programmers may use
REPNEprefixed string operations inside transactions. However, long strings may cause aborts. Further, the use of
STDinstructions may cause aborts if they change the value of the
STDinstruction will not cause an abort. Similarly, if
CLDinstruction will not cause an abort.
Instructions not enumerated here as causing abort when used inside a transaction will typically not cause a transaction to abort (examples include but are not limited to
The following instructions will abort transactional execution on any implementation:
In some implementations, the following instructions may always cause transactional aborts. These instructions are not expected to be commonly used inside typical transactional regions. Programmers must not rely on these instructions to force a transactional abort, since whether they cause transactional aborts is implementation dependent.
- Operations on X87 and MMX™ architecture state. This includes all MMX™ and X87 instructions, including theFXRSTORandFXSAVEinstructions.
- Update to non-status portion of EFLAGS:CLI,STI,POPFD,POPFQ,CLTS.
- Instructions that update segment registers, debug registers and/or control registers:MOVtoDS/ES/FS/GS/SS,POPDS/ES/FS/GS/SS,LDS,LES,LFS,LGS,LSS,SWAPGS,WRFSBASE,WRGSBASE,LGDT,SGDT,LIDT,SIDT,LLDT,SLDT,LTR,STR,Far CALL,Far JMP,Far RET,IRET,MOVto DRx,MOVtoCR0/CR2/CR3/CR4/CR8, andLMSW.
- Ring transitions:SYSENTER,SYSCALL,SYSEXIT, andSYSRET.
- TLB and Cacheability control:CLFLUSH,INVD,WBINVD,INVLPG,INVPCID, and memory instructions with a non-temporal hint (MOVNTDQA,MOVNTDQ,MOVNTI,MOVNTPD,MOVNTPS, andMOVNTQ).
- Processor state save:XSAVE,XSAVEOPT, andXRSTOR.
- IO:IN,INS,REP INS,OUT,OUTS,REP OUTSand their variants.
- VMX:VMPTRLD,VMPTRST,VMCLEAR,VMREAD,VMWRITE,VMCALL,VMLAUNCH,VMRESUME,VMXOFF,VMXON,INVEPT, andINVVPID.