Lines Matching refs:the
28 This associative array implementation is an object container with the following
34 [!] NOTE: Pointers to objects _must_ be zero in the least significant bit.
36 (2) Objects do not need to contain linkage blocks for use by the array. This
38 Rather, the array is made up of metadata blocks that point to objects.
40 (3) Objects require index keys to locate them within the array.
42 (4) Index keys must be unique. Inserting an object with the same key as one
43 already in the array will replace the old object.
47 (6) Index keys should encode the length early on, before any variation due to
50 (7) Index keys can include a hash to scatter objects throughout the array.
55 (9) The array can be iterated over whilst it is being modified, provided the
56 RCU readlock is being held by the iterator. Note, however, under these
58 problem, the iterator should lock against modification. Objects will not
61 (10) Objects in the array can be looked up by means of their index key.
63 (11) Objects can be looked up whilst the array is being modified, provided the
64 RCU readlock is being held by the thread doing the look up.
67 on each level by nibbles from the index key in the same manner as in a radix
70 pack leaf object pointers into spare space in the node rather than making an
79 rooted on the following structure:
92 applied to effect the changes without risking ENOMEM. This retains the
93 preallocated metadata blocks that will be installed in the internal tree and
94 keeps track of the metadata blocks that will be removed from the tree when the
97 This is also used to keep track of dead blocks and dead objects after the
100 proceed under the RCU read lock.
102 The script appears as outside of the API as a pointer of the type:
106 There are two functions for dealing with the script:
112 This will perform the edit functions, interpolating various write barriers
113 to permit accesses under the RCU read lock to continue. The edit script
121 This frees the edit script and all preallocated memory immediately. If
122 this was for insertion, the new object is _not_ released by this function,
123 but must rather be released by the caller.
143 This should return a chunk of caller-supplied index key starting at the
144 *bit* position given by the level argument. The level argument will be a
145 multiple of ASSOC_ARRAY_KEY_CHUNK_SIZE and the function should return
153 As the previous function, but gets its data from an object in the array
157 (3) See if this is the object we're looking for.
161 Compare the object against an index key and return true if it matches and
165 (4) Diff the index keys of two objects.
169 Return the bit position at which the index key of the specified object
170 differs from the given index key or -1 if they are the same.
177 Free the specified object. Note that this may be called an RCU grace
191 This initialises the base structure for an associative array. It can't
203 This inserts the given object into the array. Note that the least
204 significant bit of the pointer must be zero as it's used to type-mark
207 If an object already exists for that key then it will be replaced with the
208 new object and the old one will be freed automatically.
211 passed to the methods in the ops table when they are called.
213 This function makes no alteration to the array itself, but rather returns
214 an edit script that must be applied. -ENOMEM is returned in the case of
217 The caller should lock exclusively against other modifiers of the array.
227 This deletes an object that matches the specified data from the array.
230 passed to the methods in the ops table when they are called.
232 This function makes no alteration to the array itself, but rather returns
233 an edit script that must be applied. -ENOMEM is returned in the case of
234 an out-of-memory error. NULL will be returned if the specified object is
235 not found within the array.
237 The caller should lock exclusively against other modifiers of the array.
246 This deletes all the objects from an associative array and leaves it
249 This function makes no alteration to the array itself, but rather returns
250 an edit script that must be applied. -ENOMEM is returned in the case of
253 The caller should lock exclusively against other modifiers of the array.
261 This destroys the contents of the associative array and leaves it
263 the array under the RCU read lock at the same time as this function is
268 of the array.
278 This iterates over the objects in an associative array and passes each one
279 to iterator(). If iterator() returns true, the object is kept. If it
280 returns false, the object will be freed. If the iterator() function
281 returns true, it must perform any appropriate refcount incrementing on the
284 The internal tree will be packed down if possible as part of the iteration
285 to reduce the number of nodes in it.
288 ignored by the function.
293 It is possible for other threads to iterate over or search the array under
294 the RCU read lock whilst this function is in progress. The caller should
295 lock exclusively against other modifiers of the array.
303 (1) Iterate over all the objects in an associative array.
310 This passes each object in the array to the iterator callback function.
313 This may be used on an array at the same time as the array is being
314 modified, provided the RCU read lock is held. Under such circumstances,
315 it is possible for the iteration function to see some objects twice. If
319 The function will return 0 if no objects were in the array or else it will
320 return the result of the last iterator function called. Iteration stops
321 immediately if any call to the iteration function results in a non-zero
331 This walks through the array's internal tree directly to the object
332 specified by the index key..
334 This may be used on an array at the same time as the array is being
335 modified, provided the RCU read lock is held.
337 The function will return the object if found (and set *_type to the object
338 type) or will return NULL if the object was not found.
344 The index key can be of any form, but since the algorithms aren't told how long
345 the key is, it is strongly recommended that the index key includes its length
346 very early on before any variation due to the length would have an effect on
350 other - and those with the same length keys to cluster together.
352 It is also recommended that the index key begin with a hash of the rest of the
355 The better the scattering, the wider and lower the internal tree will be.
362 on a 64-bit CPU, 16 levels. Unless the scattering is really poor, it is
376 (*) A NULL pointer, indicating that the slot is empty.
380 (*) A pointer to a node at the next level.
388 Ignoring shortcuts for the moment, the nodes form a multilevel tree. The index
389 key space is strictly subdivided by the nodes in the tree and nodes occur on
422 In the above example, there are 7 nodes (A-G), each with 16 slots (0-f).
423 Assuming no other meta data nodes in the tree, the key space is divided thusly:
435 So, for instance, keys with the following example index keys will be found in
436 the appropriate nodes:
453 To save memory, if a node can hold all the leaves in its portion of keyspace,
454 then the node will have all those leaves in it and will not have any metadata
455 pointers - even if some of those leaves would like to be in the same slot.
458 Metadata pointers must be in the slots that match their subdivisions of key
460 is guaranteed that none of the leaves in a node will match a slot occupied by a
461 metadata pointer. If the metadata pointer is there, any leaf whose key matches
462 the metadata key prefix must be in the subtree that the metadata pointer points
465 In the above example list of index keys, node A will contain:
485 is a replacement for a series of single-occupancy nodes ascending through the
488 It is possible for the root of the tree to be a shortcut - say, for example,
489 the tree contains at least 17 nodes all with key prefix '1111'. The insertion
490 algorithm will insert a shortcut to skip over the '1111' keyspace in a single
491 bound and get to the fourth level where these actually become different.
497 Each node has a maximum capacity of 16 leaves and metadata pointers. If the
503 If the leaves in a full node and the leaf that is being inserted are
504 sufficiently similar, then a shortcut will be inserted into the tree.
506 When the number of objects in the subtree rooted at a node falls to 16 or
507 fewer, then the subtree will be collapsed down to a single node - and this will
508 ripple towards the root if possible.
514 Each node and shortcut contains a back pointer to its parent and the number of
516 proceed rootwards through the tree, going to the parent node, slot N + 1 to
517 make sure progress is made without the need for a stack.
528 matching leaf pointer with the pointer to the new leaf after a barrier.
530 until after the RCU grace period.
534 after the RCU grace period.
538 the iteration as we won't have reached the pointer to it yet and the
539 ancestry blocks are not replaced (the layout of those does not change).
542 problem as we've passed the anchoring pointer and won't switch onto the
543 new layout until we follow the back pointers - at which point we've
544 already examined the leaves in the replaced node (we iterate over all the
551 This won't affect us until we follow the back pointers. Similar to (4).
553 (6) Deletion collapsing a branch under us. This doesn't affect us because the
554 back pointers will get us back to the parent of the new node before we
555 could see the new node. The entire collapsed subtree is thrown away
556 unchanged - and will still be rooted on the same slot, so we shouldn't
561 (*) Under some circumstances, we need to simultaneously change the parent
562 pointer and the parent slot pointer on a node (say, for example, we
567 as shortcuts only have one slot and so the parent slot number isn't used
569 the slot number first - provided suitable barriers are used to make sure
570 the parent slot number is read after the back pointer.
573 so as long as anyone doing walking or iteration holds the RCU read lock, the