GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.kernel.org — refcount_t API compared to atomic_t — The Linux Kernel documentation
English
refcount_t API compared to atomic_t¶Introduction¶The 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 The terms used through this document try to follow the formal LKMM defined in tools/memory-model/Documentation/explanation.txt. memory-barriers.txt and atomic_t.txt provide more background to the memory ordering in general and for atomic operations specifically. Relevant types of memory ordering¶Note The 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. In 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 A 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 A 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
An 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
A 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. Comparison of functions¶case 1) - non-“Read/Modify/Write” (RMW) ops¶Function changes: Memory ordering guarantee changes:
case 2) - non-“Read/Modify/Write” (RMW) ops with release ordering¶Function changes: Memory ordering guarantee changes:
case 3) - increment-based ops that return no value¶Function changes: Memory ordering guarantee changes:
case 4) - decrement-based RMW ops that return no value¶Function changes: Memory ordering guarantee changes:
case 5) - increment-based RMW ops that return a value¶Function changes:
Memory ordering guarantees changes:
Note We really assume here that necessary ordering is provided as a result of obtaining pointer to the object! case 6) - increment-based RMW ops with acquire ordering that return a value¶Function changes:
Memory ordering guarantees changes:
case 7) - generic dec/sub decrement-based RMW ops that return a value¶Function changes: Memory ordering guarantees changes:
case 8) other decrement-based RMW ops that return a value¶Function changes:
Memory ordering guarantees changes:
Note
case 9) - lock-based RMW¶Function changes:
Memory ordering guarantees changes:
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |