sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget//translations/zh_CN/core-api/refcount-vs-atomicmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/zh_TW/core-api/refcount-vs-atomicmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/it_IT/core-api/refcount-vs-atomicmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/ja_JP/core-api/refcount-vs-atomicmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/ko_KR/core-api/refcount-vs-atomicmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/sp_SP/core-api/refcount-vs-atomicmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h#refcount_t API compared to atomic_th]h#refcount_t API compared to atomic_t}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhI/var/lib/git/docbuild/linux/Documentation/core-api/refcount-vs-atomic.rsthKubhtopic)}(hhh]h bullet_list)}(hhh](h list_item)}(hhh]h paragraph)}(hhh]h reference)}(hhh]h Introduction}(hhhhhNhNubah}(h]id1ah ]h"]h$]h&]refid introductionuh1hhhubah}(h]h ]h"]h$]h&]uh1hhhubah}(h]h ]h"]h$]h&]uh1hhhubh)}(hhh]h)}(hhh]h)}(hhh]h!Relevant types of memory ordering}(hhhhhNhNubah}(h]id2ah ]h"]h$]h&]refid!relevant-types-of-memory-orderinguh1hhhubah}(h]h ]h"]h$]h&]uh1hhhubah}(h]h ]h"]h$]h&]uh1hhhubh)}(hhh](h)}(hhh]h)}(hhh]hComparison of functions}(hjhhhNhNubah}(h]id3ah ]h"]h$]h&]refidcomparison-of-functionsuh1hhjubah}(h]h ]h"]h$]h&]uh1hhj ubh)}(hhh](h)}(hhh]h)}(hhh]h)}(hhh]h/case 1) - non-“Read/Modify/Write” (RMW) ops}(hj0hhhNhNubah}(h]id4ah ]h"]h$]h&]refid$case-1-non-read-modify-write-rmw-opsuh1hhj-ubah}(h]h ]h"]h$]h&]uh1hhj*ubah}(h]h ]h"]h$]h&]uh1hhj'ubh)}(hhh]h)}(hhh]h)}(hhh]hEcase 2) - non-“Read/Modify/Write” (RMW) ops with release ordering}(hjRhhhNhNubah}(h]id5ah ]h"]h$]h&]refid:case-2-non-read-modify-write-rmw-ops-with-release-orderinguh1hhjOubah}(h]h ]h"]h$]h&]uh1hhjLubah}(h]h ]h"]h$]h&]uh1hhj'ubh)}(hhh]h)}(hhh]h)}(hhh]h2case 3) - increment-based ops that return no value}(hjthhhNhNubah}(h]id6ah ]h"]h$]h&]refid/case-3-increment-based-ops-that-return-no-valueuh1hhjqubah}(h]h ]h"]h$]h&]uh1hhjnubah}(h]h ]h"]h$]h&]uh1hhj'ubh)}(hhh]h)}(hhh]h)}(hhh]h6case 4) - decrement-based RMW ops that return no value}(hjhhhNhNubah}(h]id7ah ]h"]h$]h&]refid3case-4-decrement-based-rmw-ops-that-return-no-valueuh1hhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1hhj'ubh)}(hhh]h)}(hhh]h)}(hhh]h5case 5) - increment-based RMW ops that return a value}(hjhhhNhNubah}(h]id8ah ]h"]h$]h&]refid2case-5-increment-based-rmw-ops-that-return-a-valueuh1hhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1hhj'ubh)}(hhh]h)}(hhh]h)}(hhh]hKcase 6) - increment-based RMW ops with acquire ordering that return a value}(hjhhhNhNubah}(h]id9ah ]h"]h$]h&]refidHcase-6-increment-based-rmw-ops-with-acquire-ordering-that-return-a-valueuh1hhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1hhj'ubh)}(hhh]h)}(hhh]h)}(hhh]hEcase 7) - generic dec/sub decrement-based RMW ops that return a value}(hjhhhNhNubah}(h]id10ah ]h"]h$]h&]refidBcase-7-generic-dec-sub-decrement-based-rmw-ops-that-return-a-valueuh1hhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1hhj'ubh)}(hhh]h)}(hhh]h)}(hhh]h9case 8) other decrement-based RMW ops that return a value}(hjhhhNhNubah}(h]id11ah ]h"]h$]h&]refid8case-8-other-decrement-based-rmw-ops-that-return-a-valueuh1hhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1hhj'ubh)}(hhh]h)}(hhh]h)}(hhh]hcase 9) - lock-based RMW}(hj@hhhNhNubah}(h]id12ah ]h"]h$]h&]refidcase-9-lock-based-rmwuh1hhj=ubah}(h]h ]h"]h$]h&]uh1hhj:ubah}(h]h ]h"]h$]h&]uh1hhj'ubeh}(h]h ]h"]h$]h&]uh1hhj ubeh}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhhhhNhNubah}(h]contentsah ](contentslocaleh"]contentsah$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(h Introductionh]h Introduction}(hj{hhhNhNubah}(h]h ]h"]h$]h&]refidhuh1hhjxhhhhhKubh)}(hXThe goal of refcount_t API is to provide a minimal API for implementing an object's reference counters. While a generic architecture-independent implementation from lib/refcount.c uses atomic operations underneath, there are a number of differences between some of the ``refcount_*()`` and ``atomic_*()`` functions with regards to the memory ordering guarantees. This document outlines the differences and provides respective examples in order to help maintainers validate their code against the change in these memory ordering guarantees.h](hXThe goal of refcount_t API is to provide a minimal API for implementing an object’s reference counters. While a generic architecture-independent implementation from lib/refcount.c uses atomic operations underneath, there are a number of differences between some of the }(hjhhhNhNubhliteral)}(h``refcount_*()``h]h refcount_*()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh and }(hjhhhNhNubj)}(h``atomic_*()``h]h atomic_*()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh functions with regards to the memory ordering guarantees. This document outlines the differences and provides respective examples in order to help maintainers validate their code against the change in these memory ordering guarantees.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK hjxhhubh)}(hThe terms used through this document try to follow the formal LKMM defined in tools/memory-model/Documentation/explanation.txt.h]hThe terms used through this document try to follow the formal LKMM defined in tools/memory-model/Documentation/explanation.txt.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjxhhubh)}(hmemory-barriers.txt and atomic_t.txt provide more background to the memory ordering in general and for atomic operations specifically.h]hmemory-barriers.txt and atomic_t.txt provide more background to the memory ordering in general and for atomic operations specifically.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjxhhubeh}(h]hah ]h"] introductionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h!Relevant types of memory orderingh]h!Relevant types of memory ordering}(hjhhhNhNubah}(h]h ]h"]h$]h&]jhuh1hhjhhhhhKubhnote)}(hThe following section only covers some of the memory ordering types that are relevant for the atomics and reference counters and used through this document. For a much broader picture please consult memory-barriers.txt document.h]h)}(hThe following section only covers some of the memory ordering types that are relevant for the atomics and reference counters and used through this document. For a much broader picture please consult memory-barriers.txt document.h]hThe following section only covers some of the memory ordering types that are relevant for the atomics and reference counters and used through this document. For a much broader picture please consult memory-barriers.txt document.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubh)}(hXIn the absence of any memory ordering guarantees (i.e. fully unordered) atomics & refcounters only provide atomicity and program order (po) relation (on the same CPU). It guarantees that each ``atomic_*()`` and ``refcount_*()`` operation is atomic and instructions are executed in program order on a single CPU. This is implemented using READ_ONCE()/WRITE_ONCE() and compare-and-swap primitives.h](hIn the absence of any memory ordering guarantees (i.e. fully unordered) atomics & refcounters only provide atomicity and program order (po) relation (on the same CPU). It guarantees that each }(hj hhhNhNubj)}(h``atomic_*()``h]h atomic_*()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh and }(hj hhhNhNubj)}(h``refcount_*()``h]h refcount_*()}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh operation is atomic and instructions are executed in program order on a single CPU. This is implemented using READ_ONCE()/WRITE_ONCE() and compare-and-swap primitives.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK!hjhhubh)}(hXA strong (full) memory ordering guarantees that all prior loads and stores (all po-earlier instructions) on the same CPU are completed before any po-later instruction is executed on the same CPU. It also guarantees that all po-earlier stores on the same CPU and all propagated stores from other CPUs must propagate to all other CPUs before any po-later instruction is executed on the original CPU (A-cumulative property). This is implemented using smp_mb().h]hXA strong (full) memory ordering guarantees that all prior loads and stores (all po-earlier instructions) on the same CPU are completed before any po-later instruction is executed on the same CPU. It also guarantees that all po-earlier stores on the same CPU and all propagated stores from other CPUs must propagate to all other CPUs before any po-later instruction is executed on the original CPU (A-cumulative property). This is implemented using smp_mb().}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK)hjhhubh)}(hXA RELEASE memory ordering guarantees that all prior loads and stores (all po-earlier instructions) on the same CPU are completed before the operation. It also guarantees that all po-earlier stores on the same CPU and all propagated stores from other CPUs must propagate to all other CPUs before the release operation (A-cumulative property). This is implemented using smp_store_release().h]hXA RELEASE memory ordering guarantees that all prior loads and stores (all po-earlier instructions) on the same CPU are completed before the operation. It also guarantees that all po-earlier stores on the same CPU and all propagated stores from other CPUs must propagate to all other CPUs before the release operation (A-cumulative property). This is implemented using smp_store_release().}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hjhhubh)}(hXWAn ACQUIRE memory ordering guarantees that all post loads and stores (all po-later instructions) on the same CPU are completed after the acquire operation. It also guarantees that all po-later stores on the same CPU must propagate to all other CPUs after the acquire operation executes. This is implemented using smp_acquire__after_ctrl_dep().h]hXWAn ACQUIRE memory ordering guarantees that all post loads and stores (all po-later instructions) on the same CPU are completed after the acquire operation. It also guarantees that all po-later stores on the same CPU must propagate to all other CPUs after the acquire operation executes. This is implemented using smp_acquire__after_ctrl_dep().}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hjhhubh)}(hXA control dependency (on success) for refcounters guarantees that if a reference for an object was successfully obtained (reference counter increment or addition happened, function returned true), then further stores are ordered against this operation. Control dependency on stores are not implemented using any explicit barriers, but rely on CPU not to speculate on stores. This is only a single CPU relation and provides no guarantees for other CPUs.h]hXA control dependency (on success) for refcounters guarantees that if a reference for an object was successfully obtained (reference counter increment or addition happened, function returned true), then further stores are ordered against this operation. Control dependency on stores are not implemented using any explicit barriers, but rely on CPU not to speculate on stores. This is only a single CPU relation and provides no guarantees for other CPUs.}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK@hjhhubeh}(h]hah ]h"]!relevant types of memory orderingah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hComparison of functionsh]hComparison of functions}(hjhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj}hhhhhKJubh)}(hhh](h)}(h+case 1) - non-"Read/Modify/Write" (RMW) opsh]h/case 1) - non-“Read/Modify/Write” (RMW) ops}(hjhhhNhNubah}(h]h ]h"]h$]h&]jj9uh1hhjhhhhhKMubh)}(hFunction changes:h]hFunction changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjhhubh block_quote)}(hF* atomic_set() --> refcount_set() * atomic_read() --> refcount_read() h]h)}(hhh](h)}(hatomic_set() --> refcount_set()h]h)}(hjh]hatomic_set() --> refcount_set()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjubah}(h]h ]h"]h$]h&]uh1hhjubh)}(h"atomic_read() --> refcount_read() h]h)}(h!atomic_read() --> refcount_read()h]h!atomic_read() --> refcount_read()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKRhjubah}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]bullet*uh1hhhhKQhjubah}(h]h ]h"]h$]h&]uh1jhhhKQhjhhubh)}(h"Memory ordering guarantee changes:h]h"Memory ordering guarantee changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKThjhhubj)}(h* none (both fully unordered) h]h)}(hhh]h)}(hnone (both fully unordered) h]h)}(hnone (both fully unordered)h]hnone (both fully unordered)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKVhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]jjuh1hhhhKVhjubah}(h]h ]h"]h$]h&]uh1jhhhKVhjhhubeh}(h]j?ah ]h"]+case 1) - non-"read/modify/write" (rmw) opsah$]h&]uh1hhj}hhhhhKMubh)}(hhh](h)}(hAcase 2) - non-"Read/Modify/Write" (RMW) ops with release orderingh]hEcase 2) - non-“Read/Modify/Write” (RMW) ops with release ordering}(hj6hhhNhNubah}(h]h ]h"]h$]h&]jj[uh1hhj3hhhhhKZubh)}(hFunction changes:h]hFunction changes:}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hj3hhubj)}(h2* atomic_set_release() --> refcount_set_release() h]h)}(hhh]h)}(h0atomic_set_release() --> refcount_set_release() h]h)}(h/atomic_set_release() --> refcount_set_release()h]h/atomic_set_release() --> refcount_set_release()}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK^hjYubah}(h]h ]h"]h$]h&]uh1hhjVubah}(h]h ]h"]h$]h&]jjuh1hhhhK^hjRubah}(h]h ]h"]h$]h&]uh1jhhhK^hj3hhubh)}(h"Memory ordering guarantee changes:h]h"Memory ordering guarantee changes:}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK`hj3hhubj)}(h(* none (both provide RELEASE ordering) h]h)}(hhh]h)}(h&none (both provide RELEASE ordering) h]h)}(h$none (both provide RELEASE ordering)h]h$none (both provide RELEASE ordering)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]jjuh1hhhhKbhjubah}(h]h ]h"]h$]h&]uh1jhhhKbhj3hhubeh}(h]jaah ]h"]Acase 2) - non-"read/modify/write" (rmw) ops with release orderingah$]h&]uh1hhj}hhhhhKZubh)}(hhh](h)}(h2case 3) - increment-based ops that return no valueh]h2case 3) - increment-based ops that return no value}(hjhhhNhNubah}(h]h ]h"]h$]h&]jj}uh1hhjhhhhhKfubh)}(hFunction changes:h]hFunction changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhjhhubj)}(hD* atomic_inc() --> refcount_inc() * atomic_add() --> refcount_add() h]h)}(hhh](h)}(hatomic_inc() --> refcount_inc()h]h)}(hjh]hatomic_inc() --> refcount_inc()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKjhjubah}(h]h ]h"]h$]h&]uh1hhjubh)}(h atomic_add() --> refcount_add() h]h)}(hatomic_add() --> refcount_add()h]hatomic_add() --> refcount_add()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhjubah}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]jjuh1hhhhKjhjubah}(h]h ]h"]h$]h&]uh1jhhhKjhjhhubh)}(h"Memory ordering guarantee changes:h]h"Memory ordering guarantee changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKmhjhhubj)}(h* none (both fully unordered) h]h)}(hhh]h)}(hnone (both fully unordered) h]h)}(hnone (both fully unordered)h]hnone (both fully unordered)}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKohj3ubah}(h]h ]h"]h$]h&]uh1hhj0ubah}(h]h ]h"]h$]h&]jjuh1hhhhKohj,ubah}(h]h ]h"]h$]h&]uh1jhhhKohjhhubeh}(h]jah ]h"]2case 3) - increment-based ops that return no valueah$]h&]uh1hhj}hhhhhKfubh)}(hhh](h)}(h6case 4) - decrement-based RMW ops that return no valueh]h6case 4) - decrement-based RMW ops that return no value}(hjahhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj^hhhhhKrubh)}(hFunction changes:h]hFunction changes:}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKthj^hhubj)}(h"* atomic_dec() --> refcount_dec() h]h)}(hhh]h)}(h atomic_dec() --> refcount_dec() h]h)}(hatomic_dec() --> refcount_dec()h]hatomic_dec() --> refcount_dec()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKvhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]jjuh1hhhhKvhj}ubah}(h]h ]h"]h$]h&]uh1jhhhKvhj^hhubh)}(h"Memory ordering guarantee changes:h]h"Memory ordering guarantee changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKxhj^hhubj)}(h(* fully unordered --> RELEASE ordering h]h)}(hhh]h)}(h&fully unordered --> RELEASE ordering h]h)}(h$fully unordered --> RELEASE orderingh]h$fully unordered --> RELEASE ordering}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]jjuh1hhhhKzhjubah}(h]h ]h"]h$]h&]uh1jhhhKzhj^hhubeh}(h]jah ]h"]6case 4) - decrement-based rmw ops that return no valueah$]h&]uh1hhj}hhhhhKrubh)}(hhh](h)}(h5case 5) - increment-based RMW ops that return a valueh]h5case 5) - increment-based RMW ops that return a value}(hjhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjhhhhhK~ubh)}(hFunction changes:h]hFunction changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hh* atomic_inc_not_zero() --> refcount_inc_not_zero() * no atomic counterpart --> refcount_add_not_zero() h]h)}(hhh](h)}(h1atomic_inc_not_zero() --> refcount_inc_not_zero()h]h)}(hjh]h1atomic_inc_not_zero() --> refcount_inc_not_zero()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhj ubh)}(h2no atomic counterpart --> refcount_add_not_zero() h]h)}(h1no atomic counterpart --> refcount_add_not_zero()h]h1no atomic counterpart --> refcount_add_not_zero()}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj%ubah}(h]h ]h"]h$]h&]uh1hhj ubeh}(h]h ]h"]h$]h&]jjuh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh)}(h#Memory ordering guarantees changes:h]h#Memory ordering guarantees changes:}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h=* fully ordered --> control dependency on success for stores h]h)}(hhh]h)}(h;fully ordered --> control dependency on success for stores h]h)}(h:fully ordered --> control dependency on success for storesh]h:fully ordered --> control dependency on success for stores}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj^ubah}(h]h ]h"]h$]h&]uh1hhj[ubah}(h]h ]h"]h$]h&]jjuh1hhhhKhjWubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hiWe really assume here that necessary ordering is provided as a result of obtaining pointer to the object!h]h)}(hiWe really assume here that necessary ordering is provided as a result of obtaining pointer to the object!h]hiWe really assume here that necessary ordering is provided as a result of obtaining pointer to the object!}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]jah ]h"]5case 5) - increment-based rmw ops that return a valueah$]h&]uh1hhj}hhhhhK~ubh)}(hhh](h)}(hKcase 6) - increment-based RMW ops with acquire ordering that return a valueh]hKcase 6) - increment-based RMW ops with acquire ordering that return a value}(hjhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjhhhhhKubh)}(hFunction changes:h]hFunction changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hx* atomic_inc_not_zero() --> refcount_inc_not_zero_acquire() * no atomic counterpart --> refcount_add_not_zero_acquire() h]h)}(hhh](h)}(h9atomic_inc_not_zero() --> refcount_inc_not_zero_acquire()h]h)}(hjh]h9atomic_inc_not_zero() --> refcount_inc_not_zero_acquire()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjubh)}(h:no atomic counterpart --> refcount_add_not_zero_acquire() h]h)}(h9no atomic counterpart --> refcount_add_not_zero_acquire()h]h9no atomic counterpart --> refcount_add_not_zero_acquire()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]jjuh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh)}(h#Memory ordering guarantees changes:h]h#Memory ordering guarantees changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h1* fully ordered --> ACQUIRE ordering on success h]h)}(hhh]h)}(h/fully ordered --> ACQUIRE ordering on success h]h)}(h-fully ordered --> ACQUIRE ordering on successh]h-fully ordered --> ACQUIRE ordering on success}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]jjuh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubeh}(h]jah ]h"]Kcase 6) - increment-based rmw ops with acquire ordering that return a valueah$]h&]uh1hhj}hhhhhKubh)}(hhh](h)}(hEcase 7) - generic dec/sub decrement-based RMW ops that return a valueh]hEcase 7) - generic dec/sub decrement-based RMW ops that return a value}(hjEhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjBhhhhhKubh)}(hFunction changes:h]hFunction changes:}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjBhhubj)}(hh* atomic_dec_and_test() --> refcount_dec_and_test() * atomic_sub_and_test() --> refcount_sub_and_test() h]h)}(hhh](h)}(h1atomic_dec_and_test() --> refcount_dec_and_test()h]h)}(hjjh]h1atomic_dec_and_test() --> refcount_dec_and_test()}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhubah}(h]h ]h"]h$]h&]uh1hhjeubh)}(h2atomic_sub_and_test() --> refcount_sub_and_test() h]h)}(h1atomic_sub_and_test() --> refcount_sub_and_test()h]h1atomic_sub_and_test() --> refcount_sub_and_test()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjeubeh}(h]h ]h"]h$]h&]jjuh1hhhhKhjaubah}(h]h ]h"]h$]h&]uh1jhhhKhjBhhubh)}(h#Memory ordering guarantees changes:h]h#Memory ordering guarantees changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjBhhubj)}(hD* fully ordered --> RELEASE ordering + ACQUIRE ordering on success h]h)}(hhh]h)}(hBfully ordered --> RELEASE ordering + ACQUIRE ordering on success h]h)}(h@fully ordered --> RELEASE ordering + ACQUIRE ordering on successh]h@fully ordered --> RELEASE ordering + ACQUIRE ordering on success}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]jjuh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjBhhubeh}(h]j ah ]h"]Ecase 7) - generic dec/sub decrement-based rmw ops that return a valueah$]h&]uh1hhj}hhhhhKubh)}(hhh](h)}(h9case 8) other decrement-based RMW ops that return a valueh]h9case 8) other decrement-based RMW ops that return a value}(hjhhhNhNubah}(h]h ]h"]h$]h&]jj'uh1hhjhhhhhKubh)}(hFunction changes:h]hFunction changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hz* no atomic counterpart --> refcount_dec_if_one() * ``atomic_add_unless(&var, -1, 1)`` --> ``refcount_dec_not_one(&var)`` h]h)}(hhh](h)}(h/no atomic counterpart --> refcount_dec_if_one()h]h)}(hj h]h/no atomic counterpart --> refcount_dec_if_one()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1hhjubh)}(hF``atomic_add_unless(&var, -1, 1)`` --> ``refcount_dec_not_one(&var)`` h]h)}(hE``atomic_add_unless(&var, -1, 1)`` --> ``refcount_dec_not_one(&var)``h](j)}(h"``atomic_add_unless(&var, -1, 1)``h]hatomic_add_unless(&var, -1, 1)}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubh --> }(hj$hhhNhNubj)}(h``refcount_dec_not_one(&var)``h]hrefcount_dec_not_one(&var)}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]jjuh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh)}(h#Memory ordering guarantees changes:h]h#Memory ordering guarantees changes:}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h:* fully ordered --> RELEASE ordering + control dependency h]h)}(hhh]h)}(h8fully ordered --> RELEASE ordering + control dependency h]h)}(h7fully ordered --> RELEASE ordering + control dependencyh]h7fully ordered --> RELEASE ordering + control dependency}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjuubah}(h]h ]h"]h$]h&]uh1hhjrubah}(h]h ]h"]h$]h&]jjuh1hhhhKhjnubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(h8atomic_add_unless() only provides full order on success.h]h)}(hjh]h8atomic_add_unless() only provides full order on success.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]j-ah ]h"]9case 8) other decrement-based rmw ops that return a valueah$]h&]uh1hhj}hhhhhKubh)}(hhh](h)}(hcase 9) - lock-based RMWh]hcase 9) - lock-based RMW}(hjhhhNhNubah}(h]h ]h"]h$]h&]jjIuh1hhjhhhhhKubh)}(hFunction changes:h]hFunction changes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(ht* atomic_dec_and_lock() --> refcount_dec_and_lock() * atomic_dec_and_mutex_lock() --> refcount_dec_and_mutex_lock() h]h)}(hhh](h)}(h1atomic_dec_and_lock() --> refcount_dec_and_lock()h]h)}(hjh]h1atomic_dec_and_lock() --> refcount_dec_and_lock()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjubh)}(h>atomic_dec_and_mutex_lock() --> refcount_dec_and_mutex_lock() h]h)}(h=atomic_dec_and_mutex_lock() --> refcount_dec_and_mutex_lock()h]h=atomic_dec_and_mutex_lock() --> refcount_dec_and_mutex_lock()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]jjuh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh)}(h#Memory ordering guarantees changes:h]h#Memory ordering guarantees changes:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hY* fully ordered --> RELEASE ordering + control dependency + hold spin_lock() on successh]h)}(hhh]h)}(hUfully ordered --> RELEASE ordering + control dependency + hold spin_lock() on successh]h)}(hUfully ordered --> RELEASE ordering + control dependency + hold spin_lock() on successh]hUfully ordered --> RELEASE ordering + control dependency + hold spin_lock() on success}(hj1 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj- ubah}(h]h ]h"]h$]h&]uh1hhj* ubah}(h]h ]h"]h$]h&]jjuh1hhhhKhj& ubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubeh}(h]jOah ]h"]case 9) - lock-based rmwah$]h&]uh1hhj}hhhhhKubeh}(h]j ah ]h"]comparison of functionsah$]h&]uh1hhhhhhhhKJubeh}(h]#refcount-t-api-compared-to-atomic-tah ]h"]#refcount_t api compared to atomic_tah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_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_handlerj error_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}(jd ja jujpjhjzhj\ j j0j?jjaj[jjjjjj?jjj jj-jU jOu nametypes}(jd jujjzj\ j0jj[jjj?jjjU uh}(ja hjphhjxhjj j}j?jjaj3jjjj^jjjjj jBj-jjOjhhhhjjj9j0j[jRj}jtjjjjjjjjj'jjIj@u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}j K sRparse_messages]transform_messages] transformerN include_log] decorationNhhub.