sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}(hhparenthuba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget(/translations/zh_CN/core-api/assoc_arraymodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}(hhhh2ubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/zh_TW/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}(hhhhFubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/it_IT/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}(hhhhZubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/ja_JP/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}(hhhhnubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/ko_KR/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}(hhhhubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/sp_SP/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h(Generic Associative Array Implementationh]h(Generic Associative Array Implementation}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhB/var/lib/git/docbuild/linux/Documentation/core-api/assoc_array.rsthKubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(h[This associative array implementation is an object container with the following properties:h]h[This associative array implementation is an object container with the following properties:}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhenumerated_list)}(hhh](h list_item)}(hObjects are opaque pointers. The implementation does not care where they point (if anywhere) or what they point to (if anything). .. note:: Pointers to objects _must_ be zero in the least significant bit. h](h)}(hObjects are opaque pointers. The implementation does not care where they point (if anywhere) or what they point to (if anything).h]hObjects are opaque pointers. The implementation does not care where they point (if anywhere) or what they point to (if anything).}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhubhnote)}(h@Pointers to objects _must_ be zero in the least significant bit.h]h)}(hhh]h@Pointers to objects _must_ be zero in the least significant bit.}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhhhhNhNubh)}(hObjects do not need to contain linkage blocks for use by the array. This permits an object to be located in multiple arrays simultaneously. Rather, the array is made up of metadata blocks that point to objects. h]h)}(hObjects do not need to contain linkage blocks for use by the array. This permits an object to be located in multiple arrays simultaneously. Rather, the array is made up of metadata blocks that point to objects.h]hObjects do not need to contain linkage blocks for use by the array. This permits an object to be located in multiple arrays simultaneously. Rather, the array is made up of metadata blocks that point to objects.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(h``. The associative array is rooted on the following structure::h](hThe public API can be found in }(hThe public API can be found in hj2hhhNhNubhliteral)}(h````h]h}(hhhj=hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj2ubh>. The associative array is rooted on the following structure:}(h>. The associative array is rooted on the following structure:hj2hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK;hj!hhubh literal_block)}(h#struct assoc_array { ... };h]h#struct assoc_array { ... };}(hhhjXubah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jVhhhK>hj!hhubh)}(hDThe code is selected by enabling ``CONFIG_ASSOCIATIVE_ARRAY`` with::h](h!The code is selected by enabling }(h!The code is selected by enabling hjhhhhNhNubj<)}(h``CONFIG_ASSOCIATIVE_ARRAY``h]hCONFIG_ASSOCIATIVE_ARRAY}(hhhjqhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjhubh with:}(h with:hjhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKBhj!hhubjW)}(h$./script/config -e ASSOCIATIVE_ARRAYh]h$./script/config -e ASSOCIATIVE_ARRAY}(hhhjubah}(h]h ]h"]h$]h&]jfjguh1jVhhhKDhj!hhubh)}(hhh](h)}(h Edit Scripth]h Edit Script}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKHubh)}(hXIThe insertion and deletion functions produce an 'edit script' that can later be applied to effect the changes without risking ``ENOMEM``. This retains the preallocated metadata blocks that will be installed in the internal tree and keeps track of the metadata blocks that will be removed from the tree when the script is applied.h](hThe insertion and deletion functions produce an ‘edit script’ that can later be applied to effect the changes without risking }(h~The insertion and deletion functions produce an 'edit script' that can later be applied to effect the changes without risking hjhhhNhNubj<)}(h ``ENOMEM``h]hENOMEM}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjubh. This retains the preallocated metadata blocks that will be installed in the internal tree and keeps track of the metadata blocks that will be removed from the tree when the script is applied.}(h. This retains the preallocated metadata blocks that will be installed in the internal tree and keeps track of the metadata blocks that will be removed from the tree when the script is applied.hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKJhjhhubh)}(hXThis is also used to keep track of dead blocks and dead objects after the script has been applied so that they can be freed later. The freeing is done after an RCU grace period has passed - thus allowing access functions to proceed under the RCU read lock.h]hXThis is also used to keep track of dead blocks and dead objects after the script has been applied so that they can be freed later. The freeing is done after an RCU grace period has passed - thus allowing access functions to proceed under the RCU read lock.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKPhjhhubh)}(hCThe script appears as outside of the API as a pointer of the type::h]hBThe script appears as outside of the API as a pointer of the type:}(hBThe script appears as outside of the API as a pointer of the type:hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKUhjhhubjW)}(hstruct assoc_array_edit;h]hstruct assoc_array_edit;}(hhhjubah}(h]h ]h"]h$]h&]jfjguh1jVhhhKWhjhhubh)}(h4There are two functions for dealing with the script:h]h4There are two functions for dealing with the script:}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjhhubh)}(hhh]h)}(hUApply an edit script:: void assoc_array_apply_edit(struct assoc_array_edit *edit); h](h)}(hApply an edit script::h]hApply an edit script:}(hApply an edit script:hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjubjW)}(h;void assoc_array_apply_edit(struct assoc_array_edit *edit);h]h;void assoc_array_apply_edit(struct assoc_array_edit *edit);}(hhhjubah}(h]h ]h"]h$]h&]jfjguh1jVhhhK]hjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubah}(h]h ]h"]h$]h&]jjjhj j uh1hhjhhhhhK[ubh)}(hThis will perform the edit functions, interpolating various write barriers to permit accesses under the RCU read lock to continue. The edit script will then be passed to ``call_rcu()`` to free it and any dead stuff it points to.h](hThis will perform the edit functions, interpolating various write barriers to permit accesses under the RCU read lock to continue. The edit script will then be passed to }(hThis will perform the edit functions, interpolating various write barriers to permit accesses under the RCU read lock to continue. The edit script will then be passed to hj4hhhNhNubj<)}(h``call_rcu()``h]h call_rcu()}(hhhj=hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj4ubh, to free it and any dead stuff it points to.}(h, to free it and any dead stuff it points to.hj4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK_hjhhubh)}(hhh]h)}(hWCancel an edit script:: void assoc_array_cancel_edit(struct assoc_array_edit *edit); h](h)}(hCancel an edit script::h]hCancel an edit script:}(hCancel an edit script:hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhjYubjW)}(hhj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hIf an object already exists for that key then it will be replaced with the new object and the old one will be freed automatically.h]hIf an object already exists for that key then it will be replaced with the new object and the old one will be freed automatically.}(hjLhjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe ``index_key`` argument should hold index key information and is passed to the methods in the ops table when they are called.h](hThe }(hThe hjXhhhNhNubj<)}(h ``index_key``h]h index_key}(hhhjahhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjXubho argument should hold index key information and is passed to the methods in the ops table when they are called.}(ho argument should hold index key information and is passed to the methods in the ops table when they are called.hjXhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. ``-ENOMEM`` is returned in the case of an out-of-memory error.h](hpThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. }(hpThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. hjzhhhNhNubj<)}(h ``-ENOMEM``h]h-ENOMEM}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjzubh3 is returned in the case of an out-of-memory error.}(h3 is returned in the case of an out-of-memory error.hjzhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hHThe caller should lock exclusively against other modifiers of the array.h]hHThe caller should lock exclusively against other modifiers of the array.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hhh]h)}(hDelete an object from an associative array:: struct assoc_array_edit * assoc_array_delete(struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key); h](h)}(h,Delete an object from an associative array::h]h+Delete an object from an associative array:}(h+Delete an object from an associative array:hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubjW)}(hstruct assoc_array_edit * assoc_array_delete(struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key);h]hstruct assoc_array_edit * assoc_array_delete(struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key);}(hhhjubah}(h]h ]h"]h$]h&]jfjguh1jVhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubah}(h]h ]h"]h$]h&]jjjhj j jKuh1hhjhhhhhKubh)}(hFThis deletes an object that matches the specified data from the array.h]hFThis deletes an object that matches the specified data from the array.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe ``index_key`` argument should hold index key information and is passed to the methods in the ops table when they are called.h](hThe }(hThe hjhhhNhNubj<)}(h ``index_key``h]h index_key}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjubho argument should hold index key information and is passed to the methods in the ops table when they are called.}(ho argument should hold index key information and is passed to the methods in the ops table when they are called.hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. ``-ENOMEM`` is returned in the case of an out-of-memory error. ``NULL`` will be returned if the specified object is not found within the array.h](hpThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. }(hpThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. hj hhhNhNubj<)}(h ``-ENOMEM``h]h-ENOMEM}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj ubh5 is returned in the case of an out-of-memory error. }(h5 is returned in the case of an out-of-memory error. hj hhhNhNubj<)}(h``NULL``h]hNULL}(hhhj&hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj ubhH will be returned if the specified object is not found within the array.}(hH will be returned if the specified object is not found within the array.hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hHThe caller should lock exclusively against other modifiers of the array.h]hHThe caller should lock exclusively against other modifiers of the array.}(hjAhj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hhh]h)}(hDelete all objects from an associative array:: struct assoc_array_edit * assoc_array_clear(struct assoc_array *array, const struct assoc_array_ops *ops); h](h)}(h.Delete all objects from an associative array::h]h-Delete all objects from an associative array:}(h-Delete all objects from an associative array:hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjPubjW)}(h|struct assoc_array_edit * assoc_array_clear(struct assoc_array *array, const struct assoc_array_ops *ops);h]h|struct assoc_array_edit * assoc_array_clear(struct assoc_array *array, const struct assoc_array_ops *ops);}(hhhjcubah}(h]h ]h"]h$]h&]jfjguh1jVhhhKhjPubeh}(h]h ]h"]h$]h&]uh1hhjMhhhhhNubah}(h]h ]h"]h$]h&]jjjhj j jKuh1hhjhhhhhKubh)}(hVThis deletes all the objects from an associative array and leaves it completely empty.h]hVThis deletes all the objects from an associative array and leaves it completely empty.}(hjhj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. ``-ENOMEM`` is returned in the case of an out-of-memory error.h](hpThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. }(hpThis function makes no alteration to the array itself, but rather returns an edit script that must be applied. hjhhhNhNubj<)}(h ``-ENOMEM``h]h-ENOMEM}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjubh3 is returned in the case of an out-of-memory error.}(h3 is returned in the case of an out-of-memory error.hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hHThe caller should lock exclusively against other modifiers of the array.h]hHThe caller should lock exclusively against other modifiers of the array.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hhh]h)}(hDestroy an associative array, deleting all objects:: void assoc_array_destroy(struct assoc_array *array, const struct assoc_array_ops *ops); h](h)}(h4Destroy an associative array, deleting all objects::h]h3Destroy an associative array, deleting all objects:}(h3Destroy an associative array, deleting all objects:hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubjW)}(hpvoid assoc_array_destroy(struct assoc_array *array, const struct assoc_array_ops *ops);h]hpvoid assoc_array_destroy(struct assoc_array *array, const struct assoc_array_ops *ops);}(hhhjubah}(h]h ]h"]h$]h&]jfjguh1jVhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubah}(h]h ]h"]h$]h&]jjjhj j jKuh1hhjhhhhhKubh)}(hXJThis destroys the contents of the associative array and leaves it completely empty. It is not permitted for another thread to be traversing the array under the RCU read lock at the same time as this function is destroying it as no RCU deferral is performed on memory release - something that would require memory to be allocated.h]hXJThis destroys the contents of the associative array and leaves it completely empty. It is not permitted for another thread to be traversing the array under the RCU read lock at the same time as this function is destroying it as no RCU deferral is performed on memory release - something that would require memory to be allocated.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hVThe caller should lock exclusively against other modifiers and accessors of the array.h]hVThe caller should lock exclusively against other modifiers and accessors of the array.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hhh]h)}(hXGarbage collect an associative array:: int assoc_array_gc(struct assoc_array *array, const struct assoc_array_ops *ops, bool (*iterator)(void *object, void *iterator_data), void *iterator_data); h](h)}(h&Garbage collect an associative array::h]h%Garbage collect an associative array:}(h%Garbage collect an associative array:hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubjW)}(hint assoc_array_gc(struct assoc_array *array, const struct assoc_array_ops *ops, bool (*iterator)(void *object, void *iterator_data), void *iterator_data);h]hint assoc_array_gc(struct assoc_array *array, const struct assoc_array_ops *ops, bool (*iterator)(void *object, void *iterator_data), void *iterator_data);}(hhhjubah}(h]h ]h"]h$]h&]jfjguh1jVhhhKhj ubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubah}(h]h ]h"]h$]h&]jjjhj j jKuh1hhjhhhhhKubh)}(hXRThis iterates over the objects in an associative array and passes each one to ``iterator()``. If ``iterator()`` returns ``true``, the object is kept. If it returns ``false``, the object will be freed. If the ``iterator()`` function returns ``true``, it must perform any appropriate refcount incrementing on the object before returning.h](hNThis iterates over the objects in an associative array and passes each one to }(hNThis iterates over the objects in an associative array and passes each one to hj7hhhNhNubj<)}(h``iterator()``h]h iterator()}(hhhj@hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj7ubh. If }(h. If hj7hhhNhNubj<)}(h``iterator()``h]h iterator()}(hhhjShhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj7ubh returns }(h returns hj7hhhNhNubj<)}(h``true``h]htrue}(hhhjfhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj7ubh%, the object is kept. If it returns }(h%, the object is kept. If it returns hj7hhhNhNubj<)}(h ``false``h]hfalse}(hhhjyhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj7ubh$, the object will be freed. If the }(h$, the object will be freed. If the hj7hhhNhNubj<)}(h``iterator()``h]h iterator()}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj7ubh function returns }(h function returns hj7hhhNhNubj<)}(h``true``h]htrue}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj7ubhW, it must perform any appropriate refcount incrementing on the object before returning.}(hW, it must perform any appropriate refcount incrementing on the object before returning.hj7hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hoThe internal tree will be packed down if possible as part of the iteration to reduce the number of nodes in it.h]hoThe internal tree will be packed down if possible as part of the iteration to reduce the number of nodes in it.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubh)}(hdThe ``iterator_data`` is passed directly to ``iterator()`` and is otherwise ignored by the function.h](hThe }(hThe hjhhhNhNubj<)}(h``iterator_data``h]h iterator_data}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjubh is passed directly to }(h is passed directly to hjhhhNhNubj<)}(h``iterator()``h]h iterator()}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjubh* and is otherwise ignored by the function.}(h* and is otherwise ignored by the function.hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM hjhhubh)}(h[The function will return ``0`` if successful and ``-ENOMEM`` if there wasn't enough memory.h](hThe function will return }(hThe function will return hjhhhNhNubj<)}(h``0``h]h0}(hhhj hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjubh if successful and }(h if successful and hjhhhNhNubj<)}(h ``-ENOMEM``h]h-ENOMEM}(hhhj hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hjubh! if there wasn’t enough memory.}(h if there wasn't enough memory.hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hIt is possible for other threads to iterate over or search the array under the RCU read lock while this function is in progress. The caller should lock exclusively against other modifiers of the array.h]hIt is possible for other threads to iterate over or search the array under the RCU read lock while this function is in progress. The caller should lock exclusively against other modifiers of the array.}(hj2 hj0 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]manipulation-functionsah ]h"]manipulation functionsah$]h&]uh1hhj!hhhhhKubh)}(hhh](h)}(hAccess Functionsh]hAccess Functions}(hjK hjI hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjF hhhhhMubh)}(h;There are two functions for accessing an associative array:h]h;There are two functions for accessing an associative array:}(hjY hjW hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjF hhubh)}(hhh]h)}(hXIterate over all the objects in an associative array:: int assoc_array_iterate(const struct assoc_array *array, int (*iterator)(const void *object, void *iterator_data), void *iterator_data); h](h)}(h6Iterate over all the objects in an associative array::h]h5Iterate over all the objects in an associative array:}(h5Iterate over all the objects in an associative array:hjl hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjh ubjW)}(hint assoc_array_iterate(const struct assoc_array *array, int (*iterator)(const void *object, void *iterator_data), void *iterator_data);h]hint assoc_array_iterate(const struct assoc_array *array, int (*iterator)(const void *object, void *iterator_data), void *iterator_data);}(hhhj{ ubah}(h]h ]h"]h$]h&]jfjguh1jVhhhMhjh ubeh}(h]h ]h"]h$]h&]uh1hhje hhhhhNubah}(h]h ]h"]h$]h&]jjjhj j uh1hhjF hhhhhMubh)}(h|This passes each object in the array to the iterator callback function. ``iterator_data`` is private data for that function.h](hHThis passes each object in the array to the iterator callback function. }(hHThis passes each object in the array to the iterator callback function. hj hhhNhNubj<)}(h``iterator_data``h]h iterator_data}(hhhj hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj ubh# is private data for that function.}(h# is private data for that function.hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM$hjF hhubh)}(hXTThis may be used on an array at the same time as the array is being modified, provided the RCU read lock is held. Under such circumstances, it is possible for the iteration function to see some objects twice. If this is a problem, then modification should be locked against. The iteration algorithm should not, however, miss any objects.h]hXTThis may be used on an array at the same time as the array is being modified, provided the RCU read lock is held. Under such circumstances, it is possible for the iteration function to see some objects twice. If this is a problem, then modification should be locked against. The iteration algorithm should not, however, miss any objects.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM'hjF hhubh)}(hThe function will return ``0`` if no objects were in the array or else it will return the result of the last iterator function called. Iteration stops immediately if any call to the iteration function results in a non-zero return.h](hThe function will return }(hThe function will return hj hhhNhNubj<)}(h``0``h]h0}(hhhj hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj ubh if no objects were in the array or else it will return the result of the last iterator function called. Iteration stops immediately if any call to the iteration function results in a non-zero return.}(h if no objects were in the array or else it will return the result of the last iterator function called. Iteration stops immediately if any call to the iteration function results in a non-zero return.hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM-hjF hhubh)}(hhh]h)}(hFind an object in an associative array:: void *assoc_array_find(const struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key); h](h)}(h(Find an object in an associative array::h]h'Find an object in an associative array:}(h'Find an object in an associative array:hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM3hj ubjW)}(hvoid *assoc_array_find(const struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key);h]hvoid *assoc_array_find(const struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key);}(hhhj ubah}(h]h ]h"]h$]h&]jfjguh1jVhhhM5hj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubah}(h]h ]h"]h$]h&]jjjhj j jKuh1hhjF hhhhhM3ubh)}(h`This walks through the array's internal tree directly to the object specified by the index key..h]hbThis walks through the array’s internal tree directly to the object specified by the index key..}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hjF hhubh)}(hqThis may be used on an array at the same time as the array is being modified, provided the RCU read lock is held.h]hqThis may be used on an array at the same time as the array is being modified, provided the RCU read lock is held.}(hj' hj% hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM<hjF hhubh)}(hThe function will return the object if found (and set ``*_type`` to the object type) or will return ``NULL`` if the object was not found.h](h6The function will return the object if found (and set }(h6The function will return the object if found (and set hj3 hhhNhNubj<)}(h ``*_type``h]h*_type}(hhhj< hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj3 ubh$ to the object type) or will return }(h$ to the object type) or will return hj3 hhhNhNubj<)}(h``NULL``h]hNULL}(hhhjO hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hj3 ubh if the object was not found.}(h if the object was not found.hj3 hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM?hjF hhubeh}(h]access-functionsah ]h"]access functionsah$]h&]uh1hhj!hhhhhMubh)}(hhh](h)}(hIndex Key Formh]hIndex Key Form}(hju hjs hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjp hhhhhMDubh)}(hThe index key can be of any form, but since the algorithms aren't told how long the key is, it is strongly recommended that the index key includes its length very early on before any variation due to the length would have an effect on comparisons.h]hThe index key can be of any form, but since the algorithms aren’t told how long the key is, it is strongly recommended that the index key includes its length very early on before any variation due to the length would have an effect on comparisons.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMFhjp hhubh)}(hThis will cause leaves with different length keys to scatter away from each other - and those with the same length keys to cluster together.h]hThis will cause leaves with different length keys to scatter away from each other - and those with the same length keys to cluster together.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMKhjp hhubh)}(h~It is also recommended that the index key begin with a hash of the rest of the key to maximise scattering throughout keyspace.h]h~It is also recommended that the index key begin with a hash of the rest of the key to maximise scattering throughout keyspace.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMNhjp hhubh)}(hIThe better the scattering, the wider and lower the internal tree will be.h]hIThe better the scattering, the wider and lower the internal tree will be.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMQhjp hhubh)}(hPoor scattering isn't too much of a problem as there are shortcuts and nodes can contain mixtures of leaves and metadata pointers.h]hPoor scattering isn’t too much of a problem as there are shortcuts and nodes can contain mixtures of leaves and metadata pointers.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShjp hhubh)}(hX;The index key is read in chunks of machine word. Each chunk is subdivided into one nibble (4 bits) per level, so on a 32-bit CPU this is good for 8 levels and on a 64-bit CPU, 16 levels. Unless the scattering is really poor, it is unlikely that more than one word of any particular index key will have to be used.h]hX;The index key is read in chunks of machine word. Each chunk is subdivided into one nibble (4 bits) per level, so on a 32-bit CPU this is good for 8 levels and on a 64-bit CPU, 16 levels. Unless the scattering is really poor, it is unlikely that more than one word of any particular index key will have to be used.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMVhjp hhubeh}(h]index-key-formah ]h"]index key formah$]h&]uh1hhj!hhhhhMDubeh}(h]the-public-apiah ]h"]the public apiah$]h&]uh1hhhhhhhhK9ubh)}(hhh](h)}(hInternal Workingsh]hInternal Workings}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhM^ubh)}(hThe associative array data structure has an internal tree. This tree is constructed of two types of metadata blocks: nodes and shortcuts.h]hThe associative array data structure has an internal tree. This tree is constructed of two types of metadata blocks: nodes and shortcuts.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM`hj hhubh)}(hGA node is an array of slots. Each slot can contain one of four things:h]hGA node is an array of slots. Each slot can contain one of four things:}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMchj hhubh bullet_list)}(hhh](h)}(h2A NULL pointer, indicating that the slot is empty.h]h)}(hj h]h2A NULL pointer, indicating that the slot is empty.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMehj ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(h A pointer to an object (a leaf).h]h)}(hj0 h]h A pointer to an object (a leaf).}(hj0 hj2 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMfhj. ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(h&A pointer to a node at the next level.h]h)}(hjG h]h&A pointer to a node at the next level.}(hjG hjI hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghjE ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(hA pointer to a shortcut. h]h)}(hA pointer to a shortcut.h]hA pointer to a shortcut.}(hjb hj` hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhhj\ ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubeh}(h]h ]h"]h$]h&]bullet*uh1j hhhMehj hhubh)}(hhh](h)}(hBasic Internal Tree Layouth]hBasic Internal Tree Layout}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj| hhhhhMlubh)}(hIgnoring shortcuts for the moment, the nodes form a multilevel tree. The index key space is strictly subdivided by the nodes in the tree and nodes occur on fixed levels. For example::h]hIgnoring shortcuts for the moment, the nodes form a multilevel tree. The index key space is strictly subdivided by the nodes in the tree and nodes occur on fixed levels. For example:}(hIgnoring shortcuts for the moment, the nodes form a multilevel tree. The index key space is strictly subdivided by the nodes in the tree and nodes occur on fixed levels. For example:hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMnhj| hhubjW)}(hX$Level: 0 1 2 3 =============== =============== =============== =============== NODE D NODE B NODE C +------>+---+ +------>+---+ +------>+---+ | | 0 | NODE A | | 0 | | | 0 | | +---+ +---+ | +---+ | +---+ | : : | 0 | | : : | : : | +---+ +---+ | +---+ | +---+ | | f | | 1 |---+ | 3 |---+ | 7 |---+ +---+ +---+ +---+ +---+ : : : : | 8 |---+ +---+ +---+ +---+ | NODE E | e |---+ | f | : : +------>+---+ +---+ | +---+ +---+ | 0 | | f | | | f | +---+ +---+ | +---+ : : | NODE F +---+ +------>+---+ | f | | 0 | NODE G +---+ +---+ +------>+---+ : : | | 0 | +---+ | +---+ | 6 |---+ : : +---+ +---+ : : | f | +---+ +---+ | f | +---+h]hX$Level: 0 1 2 3 =============== =============== =============== =============== NODE D NODE B NODE C +------>+---+ +------>+---+ +------>+---+ | | 0 | NODE A | | 0 | | | 0 | | +---+ +---+ | +---+ | +---+ | : : | 0 | | : : | : : | +---+ +---+ | +---+ | +---+ | | f | | 1 |---+ | 3 |---+ | 7 |---+ +---+ +---+ +---+ +---+ : : : : | 8 |---+ +---+ +---+ +---+ | NODE E | e |---+ | f | : : +------>+---+ +---+ | +---+ +---+ | 0 | | f | | | f | +---+ +---+ | +---+ : : | NODE F +---+ +------>+---+ | f | | 0 | NODE G +---+ +---+ +------>+---+ : : | | 0 | +---+ | +---+ | 6 |---+ : : +---+ +---+ : : | f | +---+ +---+ | f | +---+}(hhhj ubah}(h]h ]h"]h$]h&]jfjguh1jVhhhMrhj| hhubh)}(hIn the above example, there are 7 nodes (A-G), each with 16 slots (0-f). Assuming no other meta data nodes in the tree, the key space is divided thusly::h]hIn the above example, there are 7 nodes (A-G), each with 16 slots (0-f). Assuming no other meta data nodes in the tree, the key space is divided thusly:}(hIn the above example, there are 7 nodes (A-G), each with 16 slots (0-f). Assuming no other meta data nodes in the tree, the key space is divided thusly:hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj| hhubjW)}(hKEY PREFIX NODE ========== ==== 137* D 138* E 13[0-69-f]* C 1[0-24-f]* B e6* G e[0-57-f]* F [02-df]* Ah]hKEY PREFIX NODE ========== ==== 137* D 138* E 13[0-69-f]* C 1[0-24-f]* B e6* G e[0-57-f]* F [02-df]* A}(hhhj ubah}(h]h ]h"]h$]h&]jfjguh1jVhhhMhj| hhubh)}(heSo, for instance, keys with the following example index keys will be found in the appropriate nodes::h]hdSo, for instance, keys with the following example index keys will be found in the appropriate nodes:}(hdSo, for instance, keys with the following example index keys will be found in the appropriate nodes:hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj| hhubjW)}(hXqINDEX KEY PREFIX NODE =============== ======= ==== 13694892892489 13 C 13795289025897 137 D 13889dde88793 138 E 138bbb89003093 138 E 1394879524789 12 C 1458952489 1 B 9431809de993ba - A b4542910809cd - A e5284310def98 e F e68428974237 e6 G e7fffcbd443 e F f3842239082 - Ah]hXqINDEX KEY PREFIX NODE =============== ======= ==== 13694892892489 13 C 13795289025897 137 D 13889dde88793 138 E 138bbb89003093 138 E 1394879524789 12 C 1458952489 1 B 9431809de993ba - A b4542910809cd - A e5284310def98 e F e68428974237 e6 G e7fffcbd443 e F f3842239082 - A}(hhhj ubah}(h]h ]h"]h$]h&]jfjguh1jVhhhMhj| hhubh)}(hTo save memory, if a node can hold all the leaves in its portion of keyspace, then the node will have all those leaves in it and will not have any metadata pointers - even if some of those leaves would like to be in the same slot.h]hTo save memory, if a node can hold all the leaves in its portion of keyspace, then the node will have all those leaves in it and will not have any metadata pointers - even if some of those leaves would like to be in the same slot.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj| hhubh)}(hXA node can contain a heterogeneous mix of leaves and metadata pointers. Metadata pointers must be in the slots that match their subdivisions of key space. The leaves can be in any slot not occupied by a metadata pointer. It is guaranteed that none of the leaves in a node will match a slot occupied by a metadata pointer. If the metadata pointer is there, any leaf whose key matches the metadata key prefix must be in the subtree that the metadata pointer points to.h]hXA node can contain a heterogeneous mix of leaves and metadata pointers. Metadata pointers must be in the slots that match their subdivisions of key space. The leaves can be in any slot not occupied by a metadata pointer. It is guaranteed that none of the leaves in a node will match a slot occupied by a metadata pointer. If the metadata pointer is there, any leaf whose key matches the metadata key prefix must be in the subtree that the metadata pointer points to.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj| hhubh)}(h>In the above example list of index keys, node A will contain::h]h=In the above example list of index keys, node A will contain:}(h=In the above example list of index keys, node A will contain:hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj| hhubjW)}(hSLOT CONTENT INDEX KEY (PREFIX) ==== =============== ================== 1 PTR TO NODE B 1* any LEAF 9431809de993ba any LEAF b4542910809cd e PTR TO NODE F e* any LEAF f3842239082h]hSLOT CONTENT INDEX KEY (PREFIX) ==== =============== ================== 1 PTR TO NODE B 1* any LEAF 9431809de993ba any LEAF b4542910809cd e PTR TO NODE F e* any LEAF f3842239082}(hhhj ubah}(h]h ]h"]h$]h&]jfjguh1jVhhhMhj| hhubh)}(h and node B::h]h and node B:}(h and node B:hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj| hhubjW)}(h63 PTR TO NODE C 13* any LEAF 1458952489h]h63 PTR TO NODE C 13* any LEAF 1458952489}(hhhj, ubah}(h]h ]h"]h$]h&]jfjguh1jVhhhMhj| hhubeh}(h]basic-internal-tree-layoutah ]h"]basic internal tree layoutah$]h&]uh1hhj hhhhhMlubh)}(hhh](h)}(h Shortcutsh]h Shortcuts}(hjG hjE hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjB hhhhhMubh)}(hShortcuts are metadata records that jump over a piece of keyspace. A shortcut is a replacement for a series of single-occupancy nodes ascending through the levels. Shortcuts exist to save memory and to speed up traversal.h]hShortcuts are metadata records that jump over a piece of keyspace. A shortcut is a replacement for a series of single-occupancy nodes ascending through the levels. Shortcuts exist to save memory and to speed up traversal.}(hjU hjS hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjB hhubh)}(hX6It is possible for the root of the tree to be a shortcut - say, for example, the tree contains at least 17 nodes all with key prefix ``1111``. The insertion algorithm will insert a shortcut to skip over the ``1111`` keyspace in a single bound and get to the fourth level where these actually become different.h](hIt is possible for the root of the tree to be a shortcut - say, for example, the tree contains at least 17 nodes all with key prefix }(hIt is possible for the root of the tree to be a shortcut - say, for example, the tree contains at least 17 nodes all with key prefix hja hhhNhNubj<)}(h``1111``h]h1111}(hhhjj hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hja ubhC. The insertion algorithm will insert a shortcut to skip over the }(hC. The insertion algorithm will insert a shortcut to skip over the hja hhhNhNubj<)}(h``1111``h]h1111}(hhhj} hhhNhNubah}(h]h ]h"]h$]h&]uh1j;hja ubh^ keyspace in a single bound and get to the fourth level where these actually become different.J}(h^ keyspace in a single bound and get to the fourth level where these actually become different.hja hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjB hhubeh}(h] shortcutsah ]h"] shortcutsah$]h&]uh1hhj hhhhhMubh)}(hhh](h)}(hSplitting And Collapsing Nodesh]hSplitting And Collapsing Nodes}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hXKEach node has a maximum capacity of 16 leaves and metadata pointers. If the insertion algorithm finds that it is trying to insert a 17th object into a node, that node will be split such that at least two leaves that have a common key segment at that level end up in a separate node rooted on that slot for that common key segment.h]hXKEach node has a maximum capacity of 16 leaves and metadata pointers. If the insertion algorithm finds that it is trying to insert a 17th object into a node, that node will be split such that at least two leaves that have a common key segment at that level end up in a separate node rooted on that slot for that common key segment.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hIf the leaves in a full node and the leaf that is being inserted are sufficiently similar, then a shortcut will be inserted into the tree.h]hIf the leaves in a full node and the leaf that is being inserted are sufficiently similar, then a shortcut will be inserted into the tree.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hWhen the number of objects in the subtree rooted at a node falls to 16 or fewer, then the subtree will be collapsed down to a single node - and this will ripple towards the root if possible.h]hWhen the number of objects in the subtree rooted at a node falls to 16 or fewer, then the subtree will be collapsed down to a single node - and this will ripple towards the root if possible.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]splitting-and-collapsing-nodesah ]h"]splitting and collapsing nodesah$]h&]uh1hhj hhhhhMubh)}(hhh](h)}(hNon-Recursive Iterationh]hNon-Recursive Iteration}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hX"Each node and shortcut contains a back pointer to its parent and the number of slot in that parent that points to it. None-recursive iteration uses these to proceed rootwards through the tree, going to the parent node, slot N + 1 to make sure progress is made without the need for a stack.h]hX"Each node and shortcut contains a back pointer to its parent and the number of slot in that parent that points to it. None-recursive iteration uses these to proceed rootwards through the tree, going to the parent node, slot N + 1 to make sure progress is made without the need for a stack.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hMThe backpointers, however, make simultaneous alteration and iteration tricky.h]hMThe backpointers, however, make simultaneous alteration and iteration tricky.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]non-recursive-iterationah ]h"]non-recursive iterationah$]h&]uh1hhj hhhhhMubh)}(hhh](h)}(h%Simultaneous Alteration And Iterationh]h%Simultaneous Alteration And Iteration}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(h(There are a number of cases to consider:h]h(There are a number of cases to consider:}(hj) hj' hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hhh](h)}(hSimple insert/replace. This involves simply replacing a NULL or old matching leaf pointer with the pointer to the new leaf after a barrier. The metadata blocks don't change otherwise. An old leaf won't be freed until after the RCU grace period. h]h)}(hSimple insert/replace. This involves simply replacing a NULL or old matching leaf pointer with the pointer to the new leaf after a barrier. The metadata blocks don't change otherwise. An old leaf won't be freed until after the RCU grace period.h]hSimple insert/replace. This involves simply replacing a NULL or old matching leaf pointer with the pointer to the new leaf after a barrier. The metadata blocks don’t change otherwise. An old leaf won’t be freed until after the RCU grace period.}(hj> hj< hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj8 ubah}(h]h ]h"]h$]h&]uh1hhj5 hhhhhNubh)}(hSimple delete. This involves just clearing an old matching leaf. The metadata blocks don't change otherwise. The old leaf won't be freed until after the RCU grace period. h]h)}(hSimple delete. This involves just clearing an old matching leaf. The metadata blocks don't change otherwise. The old leaf won't be freed until after the RCU grace period.h]hSimple delete. This involves just clearing an old matching leaf. The metadata blocks don’t change otherwise. The old leaf won’t be freed until after the RCU grace period.}(hjV hjT hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjP ubah}(h]h ]h"]h$]h&]uh1hhj5 hhhhhNubh)}(hXInsertion replacing part of a subtree that we haven't yet entered. This may involve replacement of part of that subtree - but that won't affect the iteration as we won't have reached the pointer to it yet and the ancestry blocks are not replaced (the layout of those does not change). h]h)}(hXInsertion replacing part of a subtree that we haven't yet entered. This may involve replacement of part of that subtree - but that won't affect the iteration as we won't have reached the pointer to it yet and the ancestry blocks are not replaced (the layout of those does not change).h]hX#Insertion replacing part of a subtree that we haven’t yet entered. This may involve replacement of part of that subtree - but that won’t affect the iteration as we won’t have reached the pointer to it yet and the ancestry blocks are not replaced (the layout of those does not change).}(hjn hjl hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjh ubah}(h]h ]h"]h$]h&]uh1hhj5 hhhhhNubh)}(hXInsertion replacing nodes that we're actively processing. This isn't a problem as we've passed the anchoring pointer and won't switch onto the new layout until we follow the back pointers - at which point we've already examined the leaves in the replaced node (we iterate over all the leaves in a node before following any of its metadata pointers). We might, however, re-see some leaves that have been split out into a new branch that's in a slot further along than we were at. h](h)}(hX^Insertion replacing nodes that we're actively processing. This isn't a problem as we've passed the anchoring pointer and won't switch onto the new layout until we follow the back pointers - at which point we've already examined the leaves in the replaced node (we iterate over all the leaves in a node before following any of its metadata pointers).h]hXhInsertion replacing nodes that we’re actively processing. This isn’t a problem as we’ve passed the anchoring pointer and won’t switch onto the new layout until we follow the back pointers - at which point we’ve already examined the leaves in the replaced node (we iterate over all the leaves in a node before following any of its metadata pointers).}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj ubh)}(hWe might, however, re-see some leaves that have been split out into a new branch that's in a slot further along than we were at.h]hWe might, however, re-see some leaves that have been split out into a new branch that’s in a slot further along than we were at.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubeh}(h]h ]h"]h$]h&]uh1hhj5 hhhhhNubh)}(hInsertion replacing nodes that we're processing a dependent branch of. This won't affect us until we follow the back pointers. Similar to (4). h]h)}(hInsertion replacing nodes that we're processing a dependent branch of. This won't affect us until we follow the back pointers. Similar to (4).h]hInsertion replacing nodes that we’re processing a dependent branch of. This won’t affect us until we follow the back pointers. Similar to (4).}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1hhj5 hhhhhNubh)}(hXUDeletion collapsing a branch under us. This doesn't affect us because the back pointers will get us back to the parent of the new node before we could see the new node. The entire collapsed subtree is thrown away unchanged - and will still be rooted on the same slot, so we shouldn't process it a second time as we'll go back to slot + 1. h]h)}(hXTDeletion collapsing a branch under us. This doesn't affect us because the back pointers will get us back to the parent of the new node before we could see the new node. The entire collapsed subtree is thrown away unchanged - and will still be rooted on the same slot, so we shouldn't process it a second time as we'll go back to slot + 1.h]hXZDeletion collapsing a branch under us. This doesn’t affect us because the back pointers will get us back to the parent of the new node before we could see the new node. The entire collapsed subtree is thrown away unchanged - and will still be rooted on the same slot, so we shouldn’t process it a second time as we’ll go back to slot + 1.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1hhj5 hhhhhNubeh}(h]h ]h"]h$]h&]jjjhj j uh1hhj hhhhhMubh)}(hXxUnder some circumstances, we need to simultaneously change the parent pointer and the parent slot pointer on a node (say, for example, we inserted another node before it and moved it up a level). We cannot do this without locking against a read - so we have to replace that node too. However, when we're changing a shortcut into a node this isn't a problem as shortcuts only have one slot and so the parent slot number isn't used when traversing backwards over one. This means that it's okay to change the slot number first - provided suitable barriers are used to make sure the parent slot number is read after the back pointer.h](h)}(hXUnder some circumstances, we need to simultaneously change the parent pointer and the parent slot pointer on a node (say, for example, we inserted another node before it and moved it up a level). We cannot do this without locking against a read - so we have to replace that node too.h]hXUnder some circumstances, we need to simultaneously change the parent pointer and the parent slot pointer on a node (say, for example, we inserted another node before it and moved it up a level). We cannot do this without locking against a read - so we have to replace that node too.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hXZHowever, when we're changing a shortcut into a node this isn't a problem as shortcuts only have one slot and so the parent slot number isn't used when traversing backwards over one. This means that it's okay to change the slot number first - provided suitable barriers are used to make sure the parent slot number is read after the back pointer.h]hXbHowever, when we’re changing a shortcut into a node this isn’t a problem as shortcuts only have one slot and so the parent slot number isn’t used when traversing backwards over one. This means that it’s okay to change the slot number first - provided suitable barriers are used to make sure the parent slot number is read after the back pointer.}(hj hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM"hj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(hObsolete blocks and leaves are freed up after an RCU grace period has passed, so as long as anyone doing walking or iteration holds the RCU read lock, the old superstructure should not go away on them.h]hObsolete blocks and leaves are freed up after an RCU grace period has passed, so as long as anyone doing walking or iteration holds the RCU read lock, the old superstructure should not go away on them.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM(hj hhubeh}(h]%simultaneous-alteration-and-iterationah ]h"]%simultaneous alteration and iterationah$]h&]uh1hhj hhhhhMubeh}(h]internal-workingsah ]h"]internal workingsah$]h&]uh1hhhhhhhhM^ubeh}(h](generic-associative-array-implementationah ]h"](generic associative array implementationah$]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_handlerjKerror_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.confapep_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_spacefile_insertion_enabled raw_enabledKline_length_limitM'syntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_link embed_imagesenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j%j"jjj j jjjjjC j@ jm jj j j jjj? j< j j j j j j jju nametypes}(j%NjNj NjNjNjC Njm Nj NjNj? Nj Nj Nj NjNuh}(j"hjhj j!jjjjj@ jjj jF j jp jj j< j| j jB j j j j jj u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages](hsystem_message)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "2" (ordinal 2)h]h>Enumerated list start value not ordinal-1: “2” (ordinal 2)}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehlineKuh1jhjhhhhhKdubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "2" (ordinal 2)h]h>Enumerated list start value not ordinal-1: “2” (ordinal 2)}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "3" (ordinal 3)h]h>Enumerated list start value not ordinal-1: “3” (ordinal 3)}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "4" (ordinal 4)h]h>Enumerated list start value not ordinal-1: “4” (ordinal 4)}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "5" (ordinal 5)h]h>Enumerated list start value not ordinal-1: “5” (ordinal 5)}(hhhj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "2" (ordinal 2)h]h>Enumerated list start value not ordinal-1: “2” (ordinal 2)}(hhhj;hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj8ubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "3" (ordinal 3)h]h>Enumerated list start value not ordinal-1: “3” (ordinal 3)}(hhhjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjSubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "4" (ordinal 4)h]h>Enumerated list start value not ordinal-1: “4” (ordinal 4)}(hhhjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjnubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "5" (ordinal 5)h]h>Enumerated list start value not ordinal-1: “5” (ordinal 5)}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "6" (ordinal 6)h]h>Enumerated list start value not ordinal-1: “6” (ordinal 6)}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjhhhhhKubj)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "2" (ordinal 2)h]h>Enumerated list start value not ordinal-1: “2” (ordinal 2)}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jhjF hhhhhM3ubetransform_messages] transformerN include_log] decorationNhhub.