Remove unused list_for_each_safe_rcu() API
Subsystems (3)
PATCH 1/2 Remove unused list_for_each_safe_rcu() API
Hello!
This patch removes the unused list_for_each_safe_rcu() API. Any out-of-tree uses of this interface can instead use list_for_each_rcu(), as noted in the documentation updates. Builds, passes kernbench and LTP.
Signed-off-by <[email protected]>
---
Documentation/RCU/checklist.txt | 8 ++++---- Documentation/RCU/whatisRCU.txt | 23 ++++++++++++++++++++++- include/linux/list.h | 16 ---------------- 3 files changed, 26 insertions(+), 21 deletions(-)
Documentation/RCU/checklist.txt +4 -4
@@ -149,10 +149,10 @@ over a rather long period of time, but i should be used in preference to call_rcu(). 9. All RCU list-traversal primitives, which include - list_for_each_rcu(), list_for_each_entry_rcu(), - list_for_each_continue_rcu(), and list_for_each_safe_rcu(), - must be within an RCU read-side critical section. RCU - read-side critical sections are delimited by rcu_read_lock() + list_for_each_rcu(), list_for_each_entry_rcu(), and + list_for_each_continue_rcu() must be within an RCU read-side + critical section (or under the corresponding update-side lock). + RCU read-side critical sections are delimited by rcu_read_lock() and rcu_read_unlock(), or by similar primitives such as rcu_read_lock_bh() and rcu_read_unlock_bh().
Documentation/RCU/whatisRCU.txt +22 -1
@@ -768,7 +768,6 @@ RCU pointer/list traversal: rcu_dereference list_for_each_rcu (to be deprecated in favor of list_for_each_entry_rcu) - list_for_each_safe_rcu (deprecated, not used) list_for_each_entry_rcu list_for_each_continue_rcu (to be deprecated in favor of new list_for_each_entry_continue_rcu)
@@ -798,6 +797,9 @@ RCU grace period: See the comment headers in the source code (or the docbook generated from them) for more information. +Quick Quiz #4: Why isn't there a list_for_each_safe_rcu() and + a list_for_each_entry_safe_rcu()? + 8. ANSWERS TO QUICK QUIZZES
@@ -892,6 +894,25 @@ Answer: Just as PREEMPT_RT permits pree Besides, how does the computer know what pizza parlor the human being went to??? +Quick Quiz #4: Why isn't there a list_for_each_safe_rcu() and + a list_for_each_entry_safe_rcu()? + +Answer: They are not needed. Any place you might be tempted + to use list_for_each_safe_rcu(), you should instead use + list_for_each_rcu(). Similarly, any place you might + want to use list_for_each_entry_safe_rcu() you should + instead use list_for_each_entry_rcu(). + + To see the reason for this substitution, consider that + the whole point of the _safe_ macros is to handle the + case where the body of the loop deletes the list + entry being examined. But RCU takes care of this deletion + case automatically, since any removed list element cannot + be freed until after all RCU read-side critical sections, + including the one containing the list macro, have completed. + Since RCU provides the safety, there is no need for a + special "safe" variant of the list macros. + ACKNOWLEDGEMENTS
include/linux/list.h +0 -16
@@ -452,22 +452,6 @@ static inline void list_splice_init(stru pos = pos->next)/** -* list_for_each_safe_rcu - iterate over an rcu-protected list safe -* against removal of list entry -* @pos: the &struct list_head to use as a loop counter. -* @n: another &struct list_head to use as temporary storage -* @head: the head for your list. -* -* This list-traversal primitive may safely run concurrently with -* the _rcu list-mutation primitives such as list_add_rcu() -* as long as the traversal is guarded by rcu_read_lock(). -*/ -#define list_for_each_safe_rcu (pos, n, head) \ - for (pos = (head)->next; \ - n = rcu_dereference(pos)->next, pos != (head); \ - pos = n) - -/** * list_for_each_entry_rcu - iterate over rcu list of given type * @pos: the type * to use as a loop counter. * @head: the head for your list.
PATCH 2/2 Remove hlist_for_each_rcu() API, convert existing use to hlist_for_each_entry_rcu
Hello!
This patch removes the hlist_for_each_rcu() API, which is used only in one place, and is trivially converted to hlist_for_each_entry_rcu(), making the code shorter and more readable. Any out-of-tree uses may be similarly converted.
Signed-off-by <[email protected]>
---
Documentation/RCU/whatisRCU.txt | 2 -- fs/dcache.c | 10 ++++------ include/linux/list.h | 13 ++++--------- 3 files changed, 8 insertions(+), 17 deletions(-)
Documentation/RCU/whatisRCU.txt +0 -2
@@ -771,8 +771,6 @@ RCU pointer/list traversal: list_for_each_entry_rcu list_for_each_continue_rcu (to be deprecated in favor of new list_for_each_entry_continue_rcu) - hlist_for_each_rcu (to be deprecated in favor of - hlist_for_each_entry_rcu) hlist_for_each_entry_rcu RCU pointer update:
fs/dcache.c +4 -6
@@ -644,7 +644,7 @@ void shrink_dcache_parent(struct dentry* * Prune the dentries that are anonymous * -* parsing d_hash list does not hlist_for_each_rcu() as it +* parsing d_hash list does not hlist_for_each_entry_rcu() as it * done under dcache_lock. * */
@@ -1043,15 +1043,13 @@ struct dentry * __d_lookup(struct dentrystruct hlist_head *head =d_hash (parent,hash);struct dentry *found =NULL ;struct hlist_node *node; +struct dentry *dentry;rcu_read_lock (); -hlist_for_each_rcu (node, head) { -struct dentry *dentry; +hlist_for_each_entry_rcu (dentry, node, head, d_hash) {struct qstr *qstr; - dentry = hlist_entry(node, struct dentry, d_hash); -if (dentry->d_name.hash != hash)continue ;if (dentry->d_parent != parent)
@@ -1123,7 +1121,7 @@ int d_validate(struct dentry *dentry, stspin_lock (&dcache_lock); base =d_hash (dparent, dentry->d_name.hash);hlist_for_each (lhp,base) { -/* hlist_for_each_rcu() not required for d_hash list +/* hlist_for_each_entry_rcu() not required for d_hash list * as it is parsed under dcache_lock */ if (dentry == hlist_entry(lhp, struct dentry, d_hash)) {
include/linux/list.h +4 -9
@@ -585,7 +585,7 @@ static inline void hlist_add_head(struct* or hlist_del_rcu(), running on this same list. * However, it is perfectly legal to run concurrently with * the _rcu list-traversal primitives, such as -* hlist_for_each_rcu(), used to prevent memory-consistency +* hlist_for_each_entry_rcu(), used to prevent memory-consistency * problems on Alpha CPUs. Regardless of the type of CPU, the * list-traversal primitive must be guarded by rcu_read_lock(). */
@@ -634,7 +634,7 @@ static inline void hlist_add_after(struc* or hlist_del_rcu(), running on this same list. * However, it is perfectly legal to run concurrently with * the _rcu list-traversal primitives, such as -* hlist_for_each_rcu(), used to prevent memory-consistency +* hlist_for_each_entry_rcu(), used to prevent memory-consistency * problems on Alpha CPUs. */ static inline void hlist_add_before_rcu(struct hlist_node *n,
@@ -659,7 +659,7 @@ static inline void hlist_add_before_rcu(* or hlist_del_rcu(), running on this same list. * However, it is perfectly legal to run concurrently with * the _rcu list-traversal primitives, such as -* hlist_for_each_rcu(), used to prevent memory-consistency +* hlist_for_each_entry_rcu(), used to prevent memory-consistency * problems on Alpha CPUs. */ static inline void hlist_add_after_rcu(struct hlist_node *prev,
@@ -683,11 +683,6 @@ static inline void hlist_add_after_rcu(sfor (pos = (head)->first; pos && ({ n = pos->next;1 ; }); \ pos = n) -#define hlist_for_each_rcu (pos, head) \ - for ((pos) = (head)->first; \ - rcu_dereference((pos)) && ({ prefetch((pos)->next); 1; }); \ - (pos) = (pos)->next) -/** * hlist_for_each_entry - iterate over list of given type * @tpos: the type * to use as a loop counter.
@@ -740,7 +735,7 @@ static inline void hlist_add_after_rcu(s/** * hlist_for_each_entry_rcu - iterate over rcu list of given type -* @pos: the type * to use as a loop counter. +* @tpos: the type * to use as a loop counter. * @pos: the &struct hlist_node to use as a loop counter. * @head: the head for your list. * @member: the name of the hlist_node within the struct.