diff options
author | Richard Braun <rbraun@sceen.net> | 2018-02-23 09:45:18 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-02-23 09:45:18 +0100 |
commit | 5df0aba1129b292f41f83ac679fd46a52bc9af3e (patch) | |
tree | f7214958e52b1833f0e7a35c0050ad5020ce9106 /src | |
parent | 5fd332d8fbda137909c777929aebfd69b2a35fa4 (diff) |
Replace "llsync" with "rcu"
Diffstat (limited to 'src')
-rw-r--r-- | src/hlist.h | 52 | ||||
-rw-r--r-- | src/list.h | 60 | ||||
-rw-r--r-- | src/rdxtree.c | 30 | ||||
-rw-r--r-- | src/rdxtree.h | 6 | ||||
-rw-r--r-- | src/slist.h | 56 |
5 files changed, 102 insertions, 102 deletions
diff --git a/src/hlist.h b/src/hlist.h index 1fb4324..09f281c 100644 --- a/src/hlist.h +++ b/src/hlist.h @@ -287,32 +287,32 @@ for (entry = hlist_first_entry(list, typeof(*entry), member), \ * These macros can be replaced by actual functions in an environment * that provides lockless synchronization such as RCU. */ -#define llsync_store_ptr(ptr, value) ((ptr) = (value)) -#define llsync_load_ptr(ptr) (ptr) +#define rcu_store_ptr(ptr, value) ((ptr) = (value)) +#define rcu_load_ptr(ptr) (ptr) /* * Return the first node of a list. */ static inline struct hlist_node * -hlist_llsync_first(const struct hlist *list) +hlist_rcu_first(const struct hlist *list) { - return llsync_load_ptr(list->first); + return rcu_load_ptr(list->first); } /* * Return the node next to the given node. */ static inline struct hlist_node * -hlist_llsync_next(const struct hlist_node *node) +hlist_rcu_next(const struct hlist_node *node) { - return llsync_load_ptr(node->next); + return rcu_load_ptr(node->next); } /* * Insert a node at the head of a list. */ static inline void -hlist_llsync_insert_head(struct hlist *list, struct hlist_node *node) +hlist_rcu_insert_head(struct hlist *list, struct hlist_node *node) { struct hlist_node *first; @@ -324,26 +324,26 @@ hlist_llsync_insert_head(struct hlist *list, struct hlist_node *node) first->pprev = &node->next; } - llsync_store_ptr(list->first, node); + rcu_store_ptr(list->first, node); } /* * Insert a node before another node. */ static inline void -hlist_llsync_insert_before(struct hlist_node *node, struct hlist_node *next) +hlist_rcu_insert_before(struct hlist_node *node, struct hlist_node *next) { node->next = next; node->pprev = next->pprev; next->pprev = &node->next; - llsync_store_ptr(*node->pprev, node); + rcu_store_ptr(*node->pprev, node); } /* * Insert a node after another node. */ static inline void -hlist_llsync_insert_after(struct hlist_node *node, struct hlist_node *prev) +hlist_rcu_insert_after(struct hlist_node *node, struct hlist_node *prev) { node->next = prev->next; node->pprev = &prev->next; @@ -352,48 +352,48 @@ hlist_llsync_insert_after(struct hlist_node *node, struct hlist_node *prev) node->next->pprev = &node->next; } - llsync_store_ptr(prev->next, node); + rcu_store_ptr(prev->next, node); } /* * Remove a node from a list. */ static inline void -hlist_llsync_remove(struct hlist_node *node) +hlist_rcu_remove(struct hlist_node *node) { if (node->next != NULL) { node->next->pprev = node->pprev; } - llsync_store_ptr(*node->pprev, node->next); + rcu_store_ptr(*node->pprev, node->next); } /* * Macro that evaluates to the address of the structure containing the * given node based on the given type and member. */ -#define hlist_llsync_entry(node, type, member) \ - structof(llsync_load_ptr(node), type, member) +#define hlist_rcu_entry(node, type, member) \ + structof(rcu_load_ptr(node), type, member) /* * Get the first entry of a list. */ -#define hlist_llsync_first_entry(list, type, member) \ +#define hlist_rcu_first_entry(list, type, member) \ MACRO_BEGIN \ struct hlist_node *first___; \ \ - first___ = hlist_llsync_first(list); \ + first___ = hlist_rcu_first(list); \ hlist_end(first___) ? NULL : hlist_entry(first___, type, member); \ MACRO_END /* * Get the entry next to the given entry. */ -#define hlist_llsync_next_entry(entry, member) \ +#define hlist_rcu_next_entry(entry, member) \ MACRO_BEGIN \ struct hlist_node *next___; \ \ - next___ = hlist_llsync_next(&entry->member); \ + next___ = hlist_rcu_next(&entry->member); \ hlist_end(next___) \ ? NULL \ : hlist_entry(next___, typeof(*entry), member); \ @@ -402,17 +402,17 @@ MACRO_END /* * Forge a loop to process all nodes of a list. */ -#define hlist_llsync_for_each(list, node) \ -for (node = hlist_llsync_first(list); \ +#define hlist_rcu_for_each(list, node) \ +for (node = hlist_rcu_first(list); \ !hlist_end(node); \ - node = hlist_llsync_next(node)) + node = hlist_rcu_next(node)) /* * Forge a loop to process all entries of a list. */ -#define hlist_llsync_for_each_entry(list, entry, member) \ -for (entry = hlist_llsync_first_entry(list, typeof(*entry), member); \ +#define hlist_rcu_for_each_entry(list, entry, member) \ +for (entry = hlist_rcu_first_entry(list, typeof(*entry), member); \ entry != NULL; \ - entry = hlist_llsync_next_entry(entry, member)) + entry = hlist_rcu_next_entry(entry, member)) #endif /* HLIST_H */ @@ -406,25 +406,25 @@ for (entry = list_last_entry(list, typeof(*entry), member), \ * These macros can be replaced by actual functions in an environment * that provides lockless synchronization such as RCU. */ -#define llsync_store_ptr(ptr, value) ((ptr) = (value)) -#define llsync_load_ptr(ptr) (ptr) +#define rcu_store_ptr(ptr, value) ((ptr) = (value)) +#define rcu_load_ptr(ptr) (ptr) /* * Return the first node of a list. */ static inline struct list * -list_llsync_first(const struct list *list) +list_rcu_first(const struct list *list) { - return llsync_load_ptr(list->next); + return rcu_load_ptr(list->next); } /* * Return the node next to the given node. */ static inline struct list * -list_llsync_next(const struct list *node) +list_rcu_next(const struct list *node) { - return llsync_load_ptr(node->next); + return rcu_load_ptr(node->next); } /* @@ -433,11 +433,11 @@ list_llsync_next(const struct list *node) * This function is private. */ static inline void -list_llsync_add(struct list *prev, struct list *next, struct list *node) +list_rcu_add(struct list *prev, struct list *next, struct list *node) { node->next = next; node->prev = prev; - llsync_store_ptr(prev->next, node); + rcu_store_ptr(prev->next, node); next->prev = node; } @@ -445,36 +445,36 @@ list_llsync_add(struct list *prev, struct list *next, struct list *node) * Insert a node at the head of a list. */ static inline void -list_llsync_insert_head(struct list *list, struct list *node) +list_rcu_insert_head(struct list *list, struct list *node) { - list_llsync_add(list, list->next, node); + list_rcu_add(list, list->next, node); } /* * Insert a node at the tail of a list. */ static inline void -list_llsync_insert_tail(struct list *list, struct list *node) +list_rcu_insert_tail(struct list *list, struct list *node) { - list_llsync_add(list->prev, list, node); + list_rcu_add(list->prev, list, node); } /* * Insert a node before another node. */ static inline void -list_llsync_insert_before(struct list *node, struct list *next) +list_rcu_insert_before(struct list *node, struct list *next) { - list_llsync_add(next->prev, next, node); + list_rcu_add(next->prev, next, node); } /* * Insert a node after another node. */ static inline void -list_llsync_insert_after(struct list *node, struct list *prev) +list_rcu_insert_after(struct list *node, struct list *prev) { - list_llsync_add(prev, prev->next, node); + list_rcu_add(prev, prev->next, node); } /* @@ -483,18 +483,18 @@ list_llsync_insert_after(struct list *node, struct list *prev) * After completion, the node is stale. */ static inline void -list_llsync_remove(struct list *node) +list_rcu_remove(struct list *node) { node->next->prev = node->prev; - llsync_store_ptr(node->prev->next, node->next); + rcu_store_ptr(node->prev->next, node->next); } /* * Macro that evaluates to the address of the structure containing the * given node based on the given type and member. */ -#define list_llsync_entry(node, type, member) \ - structof(llsync_load_ptr(node), type, member) +#define list_rcu_entry(node, type, member) \ + structof(rcu_load_ptr(node), type, member) /* * Get the first entry of a list. @@ -503,13 +503,13 @@ list_llsync_remove(struct list *node) * the node pointer can only be read once, preventing the combination * of lockless list_empty()/list_first_entry() variants. */ -#define list_llsync_first_entry(list, type, member) \ +#define list_rcu_first_entry(list, type, member) \ MACRO_BEGIN \ struct list *list___; \ struct list *first___; \ \ list___ = (list); \ - first___ = list_llsync_first(list___); \ + first___ = list_rcu_first(list___); \ list_end(list___, first___) \ ? NULL \ : list_entry(first___, type, member); \ @@ -522,29 +522,29 @@ MACRO_END * the node pointer can only be read once, preventing the combination * of lockless list_empty()/list_next_entry() variants. */ -#define list_llsync_next_entry(entry, member) \ - list_llsync_first_entry(&entry->member, typeof(*entry), member) +#define list_rcu_next_entry(entry, member) \ + list_rcu_first_entry(&entry->member, typeof(*entry), member) /* * Forge a loop to process all nodes of a list. * * The node must not be altered during the loop. */ -#define list_llsync_for_each(list, node) \ -for (node = list_llsync_first(list); \ +#define list_rcu_for_each(list, node) \ +for (node = list_rcu_first(list); \ !list_end(list, node); \ - node = list_llsync_next(node)) + node = list_rcu_next(node)) /* * Forge a loop to process all entries of a list. * * The entry node must not be altered during the loop. */ -#define list_llsync_for_each_entry(list, entry, member) \ -for (entry = list_llsync_entry(list_first(list), \ +#define list_rcu_for_each_entry(list, entry, member) \ +for (entry = list_rcu_entry(list_first(list), \ typeof(*entry), member); \ !list_end(list, &entry->member); \ - entry = list_llsync_entry(list_next(&entry->member), \ + entry = list_rcu_entry(list_next(&entry->member), \ typeof(*entry), member)) /* diff --git a/src/rdxtree.c b/src/rdxtree.c index 3df6ccb..d5fc7ee 100644 --- a/src/rdxtree.c +++ b/src/rdxtree.c @@ -211,7 +211,7 @@ rdxtree_node_insert(struct rdxtree_node *node, unsigned short index, assert(node->entries[index] == NULL); node->nr_entries++; - llsync_store_ptr(node->entries[index], entry); + rcu_store_ptr(node->entries[index], entry); } static inline void @@ -228,7 +228,7 @@ rdxtree_node_remove(struct rdxtree_node *node, unsigned short index) assert(node->entries[index] != NULL); node->nr_entries--; - llsync_store_ptr(node->entries[index], NULL); + rcu_store_ptr(node->entries[index], NULL); } static inline void * @@ -240,7 +240,7 @@ rdxtree_node_find(struct rdxtree_node *node, unsigned short *indexp) index = *indexp; while (index < ARRAY_SIZE(node->entries)) { - ptr = rdxtree_entry_addr(llsync_load_ptr(node->entries[index])); + ptr = rdxtree_entry_addr(rcu_load_ptr(node->entries[index])); if (ptr != NULL) { *indexp = index; @@ -328,7 +328,7 @@ rdxtree_shrink(struct rdxtree *tree) rdxtree_node_unlink(rdxtree_entry_addr(entry)); } - llsync_store_ptr(tree->root, entry); + rcu_store_ptr(tree->root, entry); rdxtree_node_schedule_destruction(node); } } @@ -376,7 +376,7 @@ rdxtree_grow(struct rdxtree *tree, rdxtree_key_t key) rdxtree_node_insert(node, 0, tree->root); tree->height++; - llsync_store_ptr(tree->root, rdxtree_node_to_entry(node)); + rcu_store_ptr(tree->root, rdxtree_node_to_entry(node)); root = node; } while (new_height > tree->height); @@ -399,7 +399,7 @@ rdxtree_cleanup(struct rdxtree *tree, struct rdxtree_node *node) if (node->parent == NULL) { tree->height = 0; - llsync_store_ptr(tree->root, NULL); + rcu_store_ptr(tree->root, NULL); rdxtree_node_schedule_destruction(node); break; } @@ -454,7 +454,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, return EBUSY; } - llsync_store_ptr(tree->root, ptr); + rcu_store_ptr(tree->root, ptr); if (slotp != NULL) { *slotp = &tree->root; @@ -482,7 +482,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, } if (prev == NULL) { - llsync_store_ptr(tree->root, rdxtree_node_to_entry(node)); + rcu_store_ptr(tree->root, rdxtree_node_to_entry(node)); } else { rdxtree_node_link(node, prev, index); rdxtree_node_insert_node(prev, index, node); @@ -531,7 +531,7 @@ rdxtree_insert_alloc_common(struct rdxtree *tree, void *ptr, if (unlikely(height == 0)) { if (tree->root == NULL) { - llsync_store_ptr(tree->root, ptr); + rcu_store_ptr(tree->root, ptr); *keyp = 0; if (slotp != NULL) { @@ -627,7 +627,7 @@ rdxtree_remove(struct rdxtree *tree, rdxtree_key_t key) node = rdxtree_entry_addr(tree->root); if (unlikely(height == 0)) { - llsync_store_ptr(tree->root, NULL); + rcu_store_ptr(tree->root, NULL); return node; } @@ -666,7 +666,7 @@ rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key, unsigned short height, shift, index; void *entry; - entry = llsync_load_ptr(tree->root); + entry = rcu_load_ptr(tree->root); if (entry == NULL) { node = NULL; @@ -697,7 +697,7 @@ rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key, prev = node; index = (unsigned short)(key >> shift) & RDXTREE_RADIX_MASK; - entry = llsync_load_ptr(node->entries[index]); + entry = rcu_load_ptr(node->entries[index]); node = rdxtree_entry_addr(entry); shift -= RDXTREE_RADIX; height--; @@ -721,7 +721,7 @@ rdxtree_replace_slot(void **slot, void *ptr) old = *slot; assert(old != NULL); rdxtree_assert_alignment(old); - llsync_store_ptr(*slot, ptr); + rcu_store_ptr(*slot, ptr); return old; } @@ -733,7 +733,7 @@ rdxtree_walk_next(struct rdxtree *tree, struct rdxtree_iter *iter) rdxtree_key_t key; void *entry; - entry = llsync_load_ptr(tree->root); + entry = rcu_load_ptr(tree->root); if (entry == NULL) { return NULL; @@ -829,7 +829,7 @@ rdxtree_remove_all(struct rdxtree *tree) if (tree->height == 0) { if (tree->root != NULL) { - llsync_store_ptr(tree->root, NULL); + rcu_store_ptr(tree->root, NULL); } return; diff --git a/src/rdxtree.h b/src/rdxtree.h index 97a96ee..018bb70 100644 --- a/src/rdxtree.h +++ b/src/rdxtree.h @@ -39,8 +39,8 @@ * These macros can be replaced by actual functions in an environment * that provides lockless synchronization such as RCU. */ -#define llsync_store_ptr(ptr, value) ((ptr) = (value)) -#define llsync_load_ptr(ptr) (ptr) +#define rcu_store_ptr(ptr, value) ((ptr) = (value)) +#define rcu_load_ptr(ptr) (ptr) /* * This macro selects between 32 or 64-bits (the default) keys. @@ -181,7 +181,7 @@ rdxtree_lookup_slot(const struct rdxtree *tree, rdxtree_key_t key) static inline void * rdxtree_load_slot(void **slot) { - return llsync_load_ptr(*slot); + return rcu_load_ptr(*slot); } /* diff --git a/src/slist.h b/src/slist.h index a53bbf3..332f0c5 100644 --- a/src/slist.h +++ b/src/slist.h @@ -320,53 +320,53 @@ for (entry = slist_first_entry(list, typeof(*entry), member), \ * These macros can be replaced by actual functions in an environment * that provides lockless synchronization such as RCU. */ -#define llsync_store_ptr(ptr, value) ((ptr) = (value)) -#define llsync_load_ptr(ptr) (ptr) +#define rcu_store_ptr(ptr, value) ((ptr) = (value)) +#define rcu_load_ptr(ptr) (ptr) /* * Return the first node of a list. */ static inline struct slist_node * -slist_llsync_first(const struct slist *list) +slist_rcu_first(const struct slist *list) { - return llsync_load_ptr(list->first); + return rcu_load_ptr(list->first); } /* * Return the node next to the given node. */ static inline struct slist_node * -slist_llsync_next(const struct slist_node *node) +slist_rcu_next(const struct slist_node *node) { - return llsync_load_ptr(node->next); + return rcu_load_ptr(node->next); } /* * Insert a node at the head of a list. */ static inline void -slist_llsync_insert_head(struct slist *list, struct slist_node *node) +slist_rcu_insert_head(struct slist *list, struct slist_node *node) { if (slist_empty(list)) { list->last = node; } node->next = list->first; - llsync_store_ptr(list->first, node); + rcu_store_ptr(list->first, node); } /* * Insert a node at the tail of a list. */ static inline void -slist_llsync_insert_tail(struct slist *list, struct slist_node *node) +slist_rcu_insert_tail(struct slist *list, struct slist_node *node) { node->next = NULL; if (slist_empty(list)) { - llsync_store_ptr(list->first, node); + rcu_store_ptr(list->first, node); } else { - llsync_store_ptr(list->last->next, node); + rcu_store_ptr(list->last->next, node); } list->last = node; @@ -378,11 +378,11 @@ slist_llsync_insert_tail(struct slist *list, struct slist_node *node) * The prev node must be valid. */ static inline void -slist_llsync_insert_after(struct slist *list, struct slist_node *node, +slist_rcu_insert_after(struct slist *list, struct slist_node *node, struct slist_node *prev) { node->next = prev->next; - llsync_store_ptr(prev->next, node); + rcu_store_ptr(prev->next, node); if (list->last == prev) { list->last = node; @@ -397,20 +397,20 @@ slist_llsync_insert_after(struct slist *list, struct slist_node *node, * first node is removed. */ static inline void -slist_llsync_remove(struct slist *list, struct slist_node *prev) +slist_rcu_remove(struct slist *list, struct slist_node *prev) { struct slist_node *node; if (slist_end(prev)) { node = list->first; - llsync_store_ptr(list->first, node->next); + rcu_store_ptr(list->first, node->next); if (list->last == node) { list->last = NULL; } } else { node = prev->next; - llsync_store_ptr(prev->next, node->next); + rcu_store_ptr(prev->next, node->next); if (list->last == node) { list->last = prev; @@ -422,28 +422,28 @@ slist_llsync_remove(struct slist *list, struct slist_node *prev) * Macro that evaluates to the address of the structure containing the * given node based on the given type and member. */ -#define slist_llsync_entry(node, type, member) \ - structof(llsync_load_ptr(node), type, member) +#define slist_rcu_entry(node, type, member) \ + structof(rcu_load_ptr(node), type, member) /* * Get the first entry of a list. */ -#define slist_llsync_first_entry(list, type, member) \ +#define slist_rcu_first_entry(list, type, member) \ MACRO_BEGIN \ struct slist_node *first___; \ \ - first___ = slist_llsync_first(list); \ + first___ = slist_rcu_first(list); \ slist_end(first___) ? NULL : slist_entry(first___, type, member); \ MACRO_END /* * Get the entry next to the given entry. */ -#define slist_llsync_next_entry(entry, member) \ +#define slist_rcu_next_entry(entry, member) \ MACRO_BEGIN \ struct slist_node *next___; \ \ - next___ = slist_llsync_next(&entry->member); \ + next___ = slist_rcu_next(&entry->member); \ slist_end(next___) \ ? NULL \ : slist_entry(next___, typeof(*entry), member); \ @@ -452,17 +452,17 @@ MACRO_END /* * Forge a loop to process all nodes of a list. */ -#define slist_llsync_for_each(list, node) \ -for (node = slist_llsync_first(list); \ +#define slist_rcu_for_each(list, node) \ +for (node = slist_rcu_first(list); \ !slist_end(node); \ - node = slist_llsync_next(node)) + node = slist_rcu_next(node)) /* * Forge a loop to process all entries of a list. */ -#define slist_llsync_for_each_entry(list, entry, member) \ -for (entry = slist_llsync_first_entry(list, typeof(*entry), member); \ +#define slist_rcu_for_each_entry(list, entry, member) \ +for (entry = slist_rcu_first_entry(list, typeof(*entry), member); \ entry != NULL; \ - entry = slist_llsync_next_entry(entry, member)) + entry = slist_rcu_next_entry(entry, member)) #endif /* SLIST_H */ |