$sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget5/translations/zh_CN/arch/powerpc/transactional_memorymodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget5/translations/zh_TW/arch/powerpc/transactional_memorymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget5/translations/it_IT/arch/powerpc/transactional_memorymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget5/translations/ja_JP/arch/powerpc/transactional_memorymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget5/translations/ko_KR/arch/powerpc/transactional_memorymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget5/translations/sp_SP/arch/powerpc/transactional_memorymodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hTransactional Memory supporth]hTransactional Memory support}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhO/var/lib/git/docbuild/linux/Documentation/arch/powerpc/transactional_memory.rsthKubh paragraph)}(hPOWER kernel support for this feature is currently limited to supporting its use by user programs. It is not currently used by the kernel itself.h]hPOWER kernel support for this feature is currently limited to supporting its use by user programs. It is not currently used by the kernel itself.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hpThis file aims to sum up how it is supported by Linux and what behaviour you can expect from your user programs.h]hpThis file aims to sum up how it is supported by Linux and what behaviour you can expect from your user programs.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hBasic overviewh]hBasic overview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh)}(hX.Hardware Transactional Memory is supported on POWER8 processors, and is a feature that enables a different form of atomic memory access. Several new instructions are presented to delimit transactions; transactions are guaranteed to either complete atomically or roll back and undo any partial changes.h]hX.Hardware Transactional Memory is supported on POWER8 processors, and is a feature that enables a different form of atomic memory access. Several new instructions are presented to delimit transactions; transactions are guaranteed to either complete atomically or roll back and undo any partial changes.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h&A simple transaction looks like this::h]h%A simple transaction looks like this:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh literal_block)}(hXbegin_move_money: tbegin beq abort_handler ld r4, SAVINGS_ACCT(r3) ld r5, CURRENT_ACCT(r3) subi r5, r5, 1 addi r4, r4, 1 std r4, SAVINGS_ACCT(r3) std r5, CURRENT_ACCT(r3) tend b continue abort_handler: ... test for odd failures ... /* Retry the transaction if it failed because it conflicted with * someone else: */ b begin_move_moneyh]hXbegin_move_money: tbegin beq abort_handler ld r4, SAVINGS_ACCT(r3) ld r5, CURRENT_ACCT(r3) subi r5, r5, 1 addi r4, r4, 1 std r4, SAVINGS_ACCT(r3) std r5, CURRENT_ACCT(r3) tend b continue abort_handler: ... test for odd failures ... /* Retry the transaction if it failed because it conflicted with * someone else: */ b begin_move_money}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKhhhhubh)}(hXThe 'tbegin' instruction denotes the start point, and 'tend' the end point. Between these points the processor is in 'Transactional' state; any memory references will complete in one go if there are no conflicts with other transactional or non-transactional accesses within the system. In this example, the transaction completes as though it were normal straight-line code IF no other processor has touched SAVINGS_ACCT(r3) or CURRENT_ACCT(r3); an atomic move of money from the current account to the savings account has been performed. Even though the normal ld/std instructions are used (note no lwarx/stwcx), either *both* SAVINGS_ACCT(r3) and CURRENT_ACCT(r3) will be updated, or neither will be updated.h](hXyThe ‘tbegin’ instruction denotes the start point, and ‘tend’ the end point. Between these points the processor is in ‘Transactional’ state; any memory references will complete in one go if there are no conflicts with other transactional or non-transactional accesses within the system. In this example, the transaction completes as though it were normal straight-line code IF no other processor has touched SAVINGS_ACCT(r3) or CURRENT_ACCT(r3); an atomic move of money from the current account to the savings account has been performed. Even though the normal ld/std instructions are used (note no lwarx/stwcx), either }(hjhhhNhNubhemphasis)}(h*both*h]hboth}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhS SAVINGS_ACCT(r3) and CURRENT_ACCT(r3) will be updated, or neither will be updated.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK.hhhhubh)}(hXpIf, in the meantime, there is a conflict with the locations accessed by the transaction, the transaction will be aborted by the CPU. Register and memory state will roll back to that at the 'tbegin', and control will continue from 'tbegin+4'. The branch to abort_handler will be taken this second time; the abort handler can check the cause of the failure, and retry.h]hXxIf, in the meantime, there is a conflict with the locations accessed by the transaction, the transaction will be aborted by the CPU. Register and memory state will roll back to that at the ‘tbegin’, and control will continue from ‘tbegin+4’. The branch to abort_handler will be taken this second time; the abort handler can check the cause of the failure, and retry.}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hhhhubh)}(hCheckpointed registers include all GPRs, FPRs, VRs/VSRs, LR, CCR/CR, CTR, FPCSR and a few other status/flag regs; see the ISA for details.h]hCheckpointed registers include all GPRs, FPRs, VRs/VSRs, LR, CCR/CR, CTR, FPCSR and a few other status/flag regs; see the ISA for details.}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK?hhhhubeh}(h]basic-overviewah ]h"]basic overviewah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(hCauses of transaction abortsh]hCauses of transaction aborts}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjZhhhhhKCubh bullet_list)}(hhh](h list_item)}(h3Conflicts with cache lines used by other processorsh]h)}(hjth]h3Conflicts with cache lines used by other processors}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKEhjrubah}(h]h ]h"]h$]h&]uh1jphjmhhhhhNubjq)}(hSignalsh]h)}(hjh]hSignals}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKFhjubah}(h]h ]h"]h$]h&]uh1jphjmhhhhhNubjq)}(hContext switchesh]h)}(hjh]hContext switches}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhjubah}(h]h ]h"]h$]h&]uh1jphjmhhhhhNubjq)}(hPSee the ISA for full documentation of everything that will abort transactions. h]h)}(hNSee the ISA for full documentation of everything that will abort transactions.h]hNSee the ISA for full documentation of everything that will abort transactions.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKHhjubah}(h]h ]h"]h$]h&]uh1jphjmhhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1jkhhhKEhjZhhubeh}(h]causes-of-transaction-abortsah ]h"]causes of transaction abortsah$]h&]uh1hhhhhhhhKCubh)}(hhh](h)}(hSyscallsh]hSyscalls}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKLubh)}(hSyscalls made from within an active transaction will not be performed and the transaction will be doomed by the kernel with the failure code TM_CAUSE_SYSCALL | TM_CAUSE_PERSISTENT.h]hSyscalls made from within an active transaction will not be performed and the transaction will be doomed by the kernel with the failure code TM_CAUSE_SYSCALL | TM_CAUSE_PERSISTENT.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKNhjhhubh)}(hXSyscalls made from within a suspended transaction are performed as normal and the transaction is not explicitly doomed by the kernel. However, what the kernel does to perform the syscall may result in the transaction being doomed by the hardware. The syscall is performed in suspended mode so any side effects will be persistent, independent of transaction success or failure. No guarantees are provided by the kernel about which syscalls will affect transaction success.h]hXSyscalls made from within a suspended transaction are performed as normal and the transaction is not explicitly doomed by the kernel. However, what the kernel does to perform the syscall may result in the transaction being doomed by the hardware. The syscall is performed in suspended mode so any side effects will be persistent, independent of transaction success or failure. No guarantees are provided by the kernel about which syscalls will affect transaction success.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKRhjhhubh)}(hXrCare must be taken when relying on syscalls to abort during active transactions if the calls are made via a library. Libraries may cache values (which may give the appearance of success) or perform operations that cause transaction failure before entering the kernel (which may produce different failure codes). Examples are glibc's getpid() and lazy symbol resolution.h]hXtCare must be taken when relying on syscalls to abort during active transactions if the calls are made via a library. Libraries may cache values (which may give the appearance of success) or perform operations that cause transaction failure before entering the kernel (which may produce different failure codes). Examples are glibc’s getpid() and lazy symbol resolution.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKZhjhhubeh}(h]syscallsah ]h"]syscallsah$]h&]uh1hhhhhhhhKLubh)}(hhh](h)}(hSignalsh]hSignals}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj"hhhhhKbubh)}(hXDelivery of signals (both sync and async) during transactions provides a second thread state (ucontext/mcontext) to represent the second transactional register state. Signal delivery 'treclaim's to capture both register states, so signals abort transactions. The usual ucontext_t passed to the signal handler represents the checkpointed/original register state; the signal appears to have arisen at 'tbegin+4'.h]hXDelivery of signals (both sync and async) during transactions provides a second thread state (ucontext/mcontext) to represent the second transactional register state. Signal delivery ‘treclaim’s to capture both register states, so signals abort transactions. The usual ucontext_t passed to the signal handler represents the checkpointed/original register state; the signal appears to have arisen at ‘tbegin+4’.}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhj"hhubh)}(hX*If the sighandler ucontext has uc_link set, a second ucontext has been delivered. For future compatibility the MSR.TS field should be checked to determine the transactional state -- if so, the second ucontext in uc->uc_link represents the active transactional registers at the point of the signal.h]hX*If the sighandler ucontext has uc_link set, a second ucontext has been delivered. For future compatibility the MSR.TS field should be checked to determine the transactional state -- if so, the second ucontext in uc->uc_link represents the active transactional registers at the point of the signal.}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhj"hhubh)}(hsFor 64-bit processes, uc->uc_mcontext.regs->msr is a full 64-bit MSR and its TS field shows the transactional mode.h]hsFor 64-bit processes, uc->uc_mcontext.regs->msr is a full 64-bit MSR and its TS field shows the transactional mode.}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphj"hhubh)}(hFor 32-bit processes, the mcontext's MSR register is only 32 bits; the top 32 bits are stored in the MSR of the second ucontext, i.e. in uc->uc_link->uc_mcontext.regs->msr. The top word contains the transactional state TS.h]hFor 32-bit processes, the mcontext’s MSR register is only 32 bits; the top 32 bits are stored in the MSR of the second ucontext, i.e. in uc->uc_link->uc_mcontext.regs->msr. The top word contains the transactional state TS.}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKshj"hhubh)}(hHowever, basic signal handlers don't need to be aware of transactions and simply returning from the handler will deal with things correctly:h]hHowever, basic signal handlers don’t need to be aware of transactions and simply returning from the handler will deal with things correctly:}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKxhj"hhubh)}(hTransaction-aware signal handlers can read the transactional register state from the second ucontext. This will be necessary for crash handlers to determine, for example, the address of the instruction causing the SIGSEGV.h]hTransaction-aware signal handlers can read the transactional register state from the second ucontext. This will be necessary for crash handlers to determine, for example, the address of the instruction causing the SIGSEGV.}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK{hj"hhubh)}(hExample signal handler::h]hExample signal handler:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj"hhubj)}(hX void crash_handler(int sig, siginfo_t *si, void *uc) { ucontext_t *ucp = uc; ucontext_t *transactional_ucp = ucp->uc_link; if (ucp_link) { u64 msr = ucp->uc_mcontext.regs->msr; /* May have transactional ucontext! */ #ifndef __powerpc64__ msr |= ((u64)transactional_ucp->uc_mcontext.regs->msr) << 32; #endif if (MSR_TM_ACTIVE(msr)) { /* Yes, we crashed during a transaction. Oops. */ fprintf(stderr, "Transaction to be restarted at 0x%llx, but " "crashy instruction was at 0x%llx\n", ucp->uc_mcontext.regs->nip, transactional_ucp->uc_mcontext.regs->nip); } } fix_the_problem(ucp->dar); }h]hX void crash_handler(int sig, siginfo_t *si, void *uc) { ucontext_t *ucp = uc; ucontext_t *transactional_ucp = ucp->uc_link; if (ucp_link) { u64 msr = ucp->uc_mcontext.regs->msr; /* May have transactional ucontext! */ #ifndef __powerpc64__ msr |= ((u64)transactional_ucp->uc_mcontext.regs->msr) << 32; #endif if (MSR_TM_ACTIVE(msr)) { /* Yes, we crashed during a transaction. Oops. */ fprintf(stderr, "Transaction to be restarted at 0x%llx, but " "crashy instruction was at 0x%llx\n", ucp->uc_mcontext.regs->nip, transactional_ucp->uc_mcontext.regs->nip); } } fix_the_problem(ucp->dar); }}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj"hhubh)}(hX'When in an active transaction that takes a signal, we need to be careful with the stack. It's possible that the stack has moved back up after the tbegin. The obvious case here is when the tbegin is called inside a function that returns before a tend. In this case, the stack is part of the checkpointed transactional memory state. If we write over this non transactionally or in suspend, we are in trouble because if we get a tm abort, the program counter and stack pointer will be back at the tbegin but our in memory stack won't be valid anymore.h]hX+When in an active transaction that takes a signal, we need to be careful with the stack. It’s possible that the stack has moved back up after the tbegin. The obvious case here is when the tbegin is called inside a function that returns before a tend. In this case, the stack is part of the checkpointed transactional memory state. If we write over this non transactionally or in suspend, we are in trouble because if we get a tm abort, the program counter and stack pointer will be back at the tbegin but our in memory stack won’t be valid anymore.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj"hhubh)}(hXTo avoid this, when taking a signal in an active transaction, we need to use the stack pointer from the checkpointed state, rather than the speculated state. This ensures that the signal context (written tm suspended) will be written below the stack required for the rollback. The transaction is aborted because of the treclaim, so any memory written between the tbegin and the signal will be rolled back anyway.h]hXTo avoid this, when taking a signal in an active transaction, we need to use the stack pointer from the checkpointed state, rather than the speculated state. This ensures that the signal context (written tm suspended) will be written below the stack required for the rollback. The transaction is aborted because of the treclaim, so any memory written between the tbegin and the signal will be rolled back anyway.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj"hhubh)}(h`For signals taken in non-TM or suspended mode, we use the normal/non-checkpointed stack pointer.h]h`For signals taken in non-TM or suspended mode, we use the normal/non-checkpointed stack pointer.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj"hhubh)}(hAny transaction initiated inside a sighandler and suspended on return from the sighandler to the kernel will get reclaimed and discarded.h]hAny transaction initiated inside a sighandler and suspended on return from the sighandler to the kernel will get reclaimed and discarded.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj"hhubeh}(h]signalsah ]h"]signalsah$]h&]uh1hhhhhhhhKbubh)}(hhh](h)}(h"Failure cause codes used by kernelh]h"Failure cause codes used by kernel}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hiThese are defined in , and distinguish different reasons why the kernel aborted a transaction:h]hiThese are defined in , and distinguish different reasons why the kernel aborted a transaction:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh block_quote)}(hX====================== ================================ TM_CAUSE_RESCHED Thread was rescheduled. TM_CAUSE_TLBI Software TLB invalid. TM_CAUSE_FAC_UNAV FP/VEC/VSX unavailable trap. TM_CAUSE_SYSCALL Syscall from active transaction. TM_CAUSE_SIGNAL Signal delivered. TM_CAUSE_MISC Currently unused. TM_CAUSE_ALIGNMENT Alignment fault. TM_CAUSE_EMULATE Emulation that touched memory. ====================== ================================ h]htable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK uh1jhjubhtbody)}(hhh](hrow)}(hhh](hentry)}(hhh]h)}(hTM_CAUSE_RESCHEDh]hTM_CAUSE_RESCHED}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj4ubah}(h]h ]h"]h$]h&]uh1j2hj/ubj3)}(hhh]h)}(hThread was rescheduled.h]hThread was rescheduled.}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjKubah}(h]h ]h"]h$]h&]uh1j2hj/ubeh}(h]h ]h"]h$]h&]uh1j-hj*ubj.)}(hhh](j3)}(hhh]h)}(h TM_CAUSE_TLBIh]h TM_CAUSE_TLBI}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjkubah}(h]h ]h"]h$]h&]uh1j2hjhubj3)}(hhh]h)}(hSoftware TLB invalid.h]hSoftware TLB invalid.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hjhubeh}(h]h ]h"]h$]h&]uh1j-hj*ubj.)}(hhh](j3)}(hhh]h)}(hTM_CAUSE_FAC_UNAVh]hTM_CAUSE_FAC_UNAV}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hjubj3)}(hhh]h)}(hFP/VEC/VSX unavailable trap.h]hFP/VEC/VSX unavailable trap.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hjubeh}(h]h ]h"]h$]h&]uh1j-hj*ubj.)}(hhh](j3)}(hhh]h)}(hTM_CAUSE_SYSCALLh]hTM_CAUSE_SYSCALL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hjubj3)}(hhh]h)}(h Syscall from active transaction.h]h Syscall from active transaction.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hjubeh}(h]h ]h"]h$]h&]uh1j-hj*ubj.)}(hhh](j3)}(hhh]h)}(hTM_CAUSE_SIGNALh]hTM_CAUSE_SIGNAL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hj ubj3)}(hhh]h)}(hSignal delivered.h]hSignal delivered.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj'ubah}(h]h ]h"]h$]h&]uh1j2hj ubeh}(h]h ]h"]h$]h&]uh1j-hj*ubj.)}(hhh](j3)}(hhh]h)}(h TM_CAUSE_MISCh]h TM_CAUSE_MISC}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjGubah}(h]h ]h"]h$]h&]uh1j2hjDubj3)}(hhh]h)}(hCurrently unused.h]hCurrently unused.}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj^ubah}(h]h ]h"]h$]h&]uh1j2hjDubeh}(h]h ]h"]h$]h&]uh1j-hj*ubj.)}(hhh](j3)}(hhh]h)}(hTM_CAUSE_ALIGNMENTh]hTM_CAUSE_ALIGNMENT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj~ubah}(h]h ]h"]h$]h&]uh1j2hj{ubj3)}(hhh]h)}(hAlignment fault.h]hAlignment fault.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hj{ubeh}(h]h ]h"]h$]h&]uh1j-hj*ubj.)}(hhh](j3)}(hhh]h)}(hTM_CAUSE_EMULATEh]hTM_CAUSE_EMULATE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hjubj3)}(hhh]h)}(hEmulation that touched memory.h]hEmulation that touched memory.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j2hjubeh}(h]h ]h"]h$]h&]uh1j-hj*ubeh}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]colsKuh1j hj ubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh)}(hThese can be checked by the user program's abort handler as TEXASR[0:7]. If bit 7 is set, it indicates that the error is considered persistent. For example a TM_CAUSE_ALIGNMENT will be persistent while a TM_CAUSE_RESCHED will not.h]hThese can be checked by the user program’s abort handler as TEXASR[0:7]. If bit 7 is set, it indicates that the error is considered persistent. For example a TM_CAUSE_ALIGNMENT will be persistent while a TM_CAUSE_RESCHED will not.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]"failure-cause-codes-used-by-kernelah ]h"]"failure cause codes used by kernelah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hGDBh]hGDB}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXGDB and ptrace are not currently TM-aware. If one stops during a transaction, it looks like the transaction has just started (the checkpointed state is presented). The transaction cannot then be continued and will take the failure handler route. Furthermore, the transactional 2nd register state will be inaccessible. GDB can currently be used on programs using TM, but not sensibly in parts within transactions.h]hXGDB and ptrace are not currently TM-aware. If one stops during a transaction, it looks like the transaction has just started (the checkpointed state is presented). The transaction cannot then be continued and will take the failure handler route. Furthermore, the transactional 2nd register state will be inaccessible. GDB can currently be used on programs using TM, but not sensibly in parts within transactions.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]gdbah ]h"]gdbah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hPOWER9h]hPOWER9}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj?hhhhhKubh)}(hdTM on POWER9 has issues with storing the complete register state. This is described in this commit::h]hcTM on POWER9 has issues with storing the complete register state. This is described in this commit:}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubj)}(hcommit 4bb3c7a0208fc13ca70598efd109901a7cd45ae7 Author: Paul Mackerras Date: Wed Mar 21 21:32:01 2018 +1100 KVM: PPC: Book3S HV: Work around transactional memory bugs in POWER9h]hcommit 4bb3c7a0208fc13ca70598efd109901a7cd45ae7 Author: Paul Mackerras Date: Wed Mar 21 21:32:01 2018 +1100 KVM: PPC: Book3S HV: Work around transactional memory bugs in POWER9}hj^sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj?hhubh)}(hMTo account for this different POWER9 chips have TM enabled in different ways.h]hMTo account for this different POWER9 chips have TM enabled in different ways.}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubh)}(hTOn POWER9N DD2.01 and below, TM is disabled. ie HWCAP2[PPC_FEATURE2_HTM] is not set.h]hTOn POWER9N DD2.01 and below, TM is disabled. ie HWCAP2[PPC_FEATURE2_HTM] is not set.}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubh)}(hXOn POWER9N DD2.1 TM is configured by firmware to always abort a transaction when tm suspend occurs. So tsuspend will cause a transaction to be aborted and rolled back. Kernel exceptions will also cause the transaction to be aborted and rolled back and the exception will not occur. If userspace constructs a sigcontext that enables TM suspend, the sigcontext will be rejected by the kernel. This mode is advertised to users with HWCAP2[PPC_FEATURE2_HTM_NO_SUSPEND] set. HWCAP2[PPC_FEATURE2_HTM] is not set in this mode.h]hXOn POWER9N DD2.1 TM is configured by firmware to always abort a transaction when tm suspend occurs. So tsuspend will cause a transaction to be aborted and rolled back. Kernel exceptions will also cause the transaction to be aborted and rolled back and the exception will not occur. If userspace constructs a sigcontext that enables TM suspend, the sigcontext will be rejected by the kernel. This mode is advertised to users with HWCAP2[PPC_FEATURE2_HTM_NO_SUSPEND] set. HWCAP2[PPC_FEATURE2_HTM] is not set in this mode.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubh)}(hX#On POWER9N DD2.2 and above, KVM and POWERVM emulate TM for guests (as described in commit 4bb3c7a0208f), hence TM is enabled for guests ie. HWCAP2[PPC_FEATURE2_HTM] is set for guest userspace. Guests that makes heavy use of TM suspend (tsuspend or kernel suspend) will result in traps into the hypervisor and hence will suffer a performance degradation. Host userspace has TM disabled ie. HWCAP2[PPC_FEATURE2_HTM] is not set. (although we make enable it at some point in the future if we bring the emulation into host userspace context switching).h]hX#On POWER9N DD2.2 and above, KVM and POWERVM emulate TM for guests (as described in commit 4bb3c7a0208f), hence TM is enabled for guests ie. HWCAP2[PPC_FEATURE2_HTM] is set for guest userspace. Guests that makes heavy use of TM suspend (tsuspend or kernel suspend) will result in traps into the hypervisor and hence will suffer a performance degradation. Host userspace has TM disabled ie. HWCAP2[PPC_FEATURE2_HTM] is not set. (although we make enable it at some point in the future if we bring the emulation into host userspace context switching).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubh)}(hPOWER9C DD1.2 and above are only available with POWERVM and hence Linux only runs as a guest. On these systems TM is emulated like on POWER9N DD2.2.h]hPOWER9C DD1.2 and above are only available with POWERVM and hence Linux only runs as a guest. On these systems TM is emulated like on POWER9N DD2.2.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubh)}(hGuest migration from POWER8 to POWER9 will work with POWER9N DD2.2 and POWER9C DD1.2. Since earlier POWER9 processors don't support TM emulation, migration from POWER8 to POWER9 is not supported there.h]hGuest migration from POWER8 to POWER9 will work with POWER9N DD2.2 and POWER9C DD1.2. Since earlier POWER9 processors don’t support TM emulation, migration from POWER8 to POWER9 is not supported there.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubeh}(h]power9ah ]h"]power9ah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hKernel implementationh]hKernel implementation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hh/rfid mtmsrd quirkh]hh/rfid mtmsrd quirk}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXAs defined in the ISA, rfid has a quirk which is useful in early exception handling. When in a userspace transaction and we enter the kernel via some exception, MSR will end up as TM=0 and TS=01 (ie. TM off but TM suspended). Regularly the kernel will want change bits in the MSR and will perform an rfid to do this. In this case rfid can have SRR0 TM = 0 and TS = 00 (ie. TM off and non transaction) and the resulting MSR will retain TM = 0 and TS=01 from before (ie. stay in suspend). This is a quirk in the architecture as this would normally be a transition from TS=01 to TS=00 (ie. suspend -> non transactional) which is an illegal transition.h]hXAs defined in the ISA, rfid has a quirk which is useful in early exception handling. When in a userspace transaction and we enter the kernel via some exception, MSR will end up as TM=0 and TS=01 (ie. TM off but TM suspended). Regularly the kernel will want change bits in the MSR and will perform an rfid to do this. In this case rfid can have SRR0 TM = 0 and TS = 00 (ie. TM off and non transaction) and the resulting MSR will retain TM = 0 and TS=01 from before (ie. stay in suspend). This is a quirk in the architecture as this would normally be a transition from TS=01 to TS=00 (ie. suspend -> non transactional) which is an illegal transition.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hTThis quirk is described the architecture in the definition of rfid with these lines:h]hTThis quirk is described the architecture in the definition of rfid with these lines:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubj)}(hRif (MSR 29:31 ¬ = 0b010 | SRR1 29:31 ¬ = 0b000) then MSR 29:31 <- SRR1 29:31 h]hdefinition_list)}(hhh]hdefinition_list_item)}(hOif (MSR 29:31 ¬ = 0b010 | SRR1 29:31 ¬ = 0b000) then MSR 29:31 <- SRR1 29:31 h](hterm)}(h6if (MSR 29:31 ¬ = 0b010 | SRR1 29:31 ¬ = 0b000) thenh]h6if (MSR 29:31 ¬ = 0b010 | SRR1 29:31 ¬ = 0b000) then}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubh definition)}(hhh]h)}(hMSR 29:31 <- SRR1 29:31h]hMSR 29:31 <- SRR1 29:31}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj'ubah}(h]h ]h"]h$]h&]uh1j%hjubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubah}(h]h ]h"]h$]h&]uh1j hjubah}(h]h ]h"]h$]h&]uh1jhhhM hjhhubh)}(h%hrfid and mtmsrd have the same quirk.h]h%hrfid and mtmsrd have the same quirk.}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hAThe Linux kernel uses this quirk in its early exception handling.h]hAThe Linux kernel uses this quirk in its early exception handling.}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]h-rfid-mtmsrd-quirkah ]h"]h/rfid mtmsrd quirkah$]h&]uh1hhjhhhhhKubeh}(h]kernel-implementationah ]h"]kernel implementationah$]h&]uh1hhhhhhhhKubeh}(h]transactional-memory-supportah ]h"]transactional memory supportah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksj2footnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jj~jWjTjjjjjjjjj<j9jjjyjvjqjnu nametypes}(jjWjjjjj<jjyjquh}(j~hjThjjZjjjj"jjj9jjj?jvjjnju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.