Commit d8bf4ca9ca9576548628344c9725edd3786e90b1
Committed by
Jiri Kosina
1 parent
eb032b9837
Exists in
master
and in
20 other branches
rcu: treewide: Do not use rcu_read_lock_held when calling rcu_dereference_check
Since ca5ecddf (rcu: define __rcu address space modifier for sparse) rcu_dereference_check use rcu_read_lock_held as a part of condition automatically so callers do not have to do that as well. Signed-off-by: Michal Hocko <mhocko@suse.cz> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Showing 14 changed files with 6 additions and 27 deletions Side-by-side Diff
- include/linux/cgroup.h
- include/linux/cred.h
- include/linux/fdtable.h
- include/linux/rtnetlink.h
- include/net/sock.h
- kernel/cgroup.c
- kernel/exit.c
- kernel/pid.c
- kernel/rcutorture.c
- kernel/sched.c
- net/mac80211/sta_info.c
- net/netlabel/netlabel_domainhash.c
- net/netlabel/netlabel_unlabeled.c
- security/keys/keyring.c
include/linux/cgroup.h
include/linux/cred.h
include/linux/fdtable.h
include/linux/rtnetlink.h
... | ... | @@ -758,8 +758,7 @@ |
758 | 758 | * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference() |
759 | 759 | */ |
760 | 760 | #define rcu_dereference_rtnl(p) \ |
761 | - rcu_dereference_check(p, rcu_read_lock_held() || \ | |
762 | - lockdep_rtnl_is_held()) | |
761 | + rcu_dereference_check(p, lockdep_rtnl_is_held()) | |
763 | 762 | |
764 | 763 | /** |
765 | 764 | * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL |
include/net/sock.h
... | ... | @@ -1301,8 +1301,7 @@ |
1301 | 1301 | static inline struct dst_entry * |
1302 | 1302 | __sk_dst_get(struct sock *sk) |
1303 | 1303 | { |
1304 | - return rcu_dereference_check(sk->sk_dst_cache, rcu_read_lock_held() || | |
1305 | - sock_owned_by_user(sk) || | |
1304 | + return rcu_dereference_check(sk->sk_dst_cache, sock_owned_by_user(sk) || | |
1306 | 1305 | lockdep_is_held(&sk->sk_lock.slock)); |
1307 | 1306 | } |
1308 | 1307 |
kernel/cgroup.c
... | ... | @@ -1697,7 +1697,6 @@ |
1697 | 1697 | { |
1698 | 1698 | char *start; |
1699 | 1699 | struct dentry *dentry = rcu_dereference_check(cgrp->dentry, |
1700 | - rcu_read_lock_held() || | |
1701 | 1700 | cgroup_lock_is_held()); |
1702 | 1701 | |
1703 | 1702 | if (!dentry || cgrp == dummytop) { |
... | ... | @@ -1723,7 +1722,6 @@ |
1723 | 1722 | break; |
1724 | 1723 | |
1725 | 1724 | dentry = rcu_dereference_check(cgrp->dentry, |
1726 | - rcu_read_lock_held() || | |
1727 | 1725 | cgroup_lock_is_held()); |
1728 | 1726 | if (!cgrp->parent) |
1729 | 1727 | continue; |
... | ... | @@ -4813,8 +4811,7 @@ |
4813 | 4811 | * on this or this is under rcu_read_lock(). Once css->id is allocated, |
4814 | 4812 | * it's unchanged until freed. |
4815 | 4813 | */ |
4816 | - cssid = rcu_dereference_check(css->id, | |
4817 | - rcu_read_lock_held() || atomic_read(&css->refcnt)); | |
4814 | + cssid = rcu_dereference_check(css->id, atomic_read(&css->refcnt)); | |
4818 | 4815 | |
4819 | 4816 | if (cssid) |
4820 | 4817 | return cssid->id; |
... | ... | @@ -4826,8 +4823,7 @@ |
4826 | 4823 | { |
4827 | 4824 | struct css_id *cssid; |
4828 | 4825 | |
4829 | - cssid = rcu_dereference_check(css->id, | |
4830 | - rcu_read_lock_held() || atomic_read(&css->refcnt)); | |
4826 | + cssid = rcu_dereference_check(css->id, atomic_read(&css->refcnt)); | |
4831 | 4827 | |
4832 | 4828 | if (cssid) |
4833 | 4829 | return cssid->depth; |
kernel/exit.c
kernel/pid.c
... | ... | @@ -405,7 +405,6 @@ |
405 | 405 | if (pid) { |
406 | 406 | struct hlist_node *first; |
407 | 407 | first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]), |
408 | - rcu_read_lock_held() || | |
409 | 408 | lockdep_tasklist_lock_is_held()); |
410 | 409 | if (first) |
411 | 410 | result = hlist_entry(first, struct task_struct, pids[(type)].node); |
kernel/rcutorture.c
... | ... | @@ -941,7 +941,6 @@ |
941 | 941 | idx = cur_ops->readlock(); |
942 | 942 | completed = cur_ops->completed(); |
943 | 943 | p = rcu_dereference_check(rcu_torture_current, |
944 | - rcu_read_lock_held() || | |
945 | 944 | rcu_read_lock_bh_held() || |
946 | 945 | rcu_read_lock_sched_held() || |
947 | 946 | srcu_read_lock_held(&srcu_ctl)); |
... | ... | @@ -1002,7 +1001,6 @@ |
1002 | 1001 | idx = cur_ops->readlock(); |
1003 | 1002 | completed = cur_ops->completed(); |
1004 | 1003 | p = rcu_dereference_check(rcu_torture_current, |
1005 | - rcu_read_lock_held() || | |
1006 | 1004 | rcu_read_lock_bh_held() || |
1007 | 1005 | rcu_read_lock_sched_held() || |
1008 | 1006 | srcu_read_lock_held(&srcu_ctl)); |
kernel/sched.c
net/mac80211/sta_info.c
... | ... | @@ -97,7 +97,6 @@ |
97 | 97 | struct sta_info *sta; |
98 | 98 | |
99 | 99 | sta = rcu_dereference_check(local->sta_hash[STA_HASH(addr)], |
100 | - rcu_read_lock_held() || | |
101 | 100 | lockdep_is_held(&local->sta_lock) || |
102 | 101 | lockdep_is_held(&local->sta_mtx)); |
103 | 102 | while (sta) { |
... | ... | @@ -105,7 +104,6 @@ |
105 | 104 | memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) |
106 | 105 | break; |
107 | 106 | sta = rcu_dereference_check(sta->hnext, |
108 | - rcu_read_lock_held() || | |
109 | 107 | lockdep_is_held(&local->sta_lock) || |
110 | 108 | lockdep_is_held(&local->sta_mtx)); |
111 | 109 | } |
... | ... | @@ -123,7 +121,6 @@ |
123 | 121 | struct sta_info *sta; |
124 | 122 | |
125 | 123 | sta = rcu_dereference_check(local->sta_hash[STA_HASH(addr)], |
126 | - rcu_read_lock_held() || | |
127 | 124 | lockdep_is_held(&local->sta_lock) || |
128 | 125 | lockdep_is_held(&local->sta_mtx)); |
129 | 126 | while (sta) { |
... | ... | @@ -132,7 +129,6 @@ |
132 | 129 | memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) |
133 | 130 | break; |
134 | 131 | sta = rcu_dereference_check(sta->hnext, |
135 | - rcu_read_lock_held() || | |
136 | 132 | lockdep_is_held(&local->sta_lock) || |
137 | 133 | lockdep_is_held(&local->sta_mtx)); |
138 | 134 | } |
net/netlabel/netlabel_domainhash.c
... | ... | @@ -55,8 +55,7 @@ |
55 | 55 | * should be okay */ |
56 | 56 | static DEFINE_SPINLOCK(netlbl_domhsh_lock); |
57 | 57 | #define netlbl_domhsh_rcu_deref(p) \ |
58 | - rcu_dereference_check(p, rcu_read_lock_held() || \ | |
59 | - lockdep_is_held(&netlbl_domhsh_lock)) | |
58 | + rcu_dereference_check(p, lockdep_is_held(&netlbl_domhsh_lock)) | |
60 | 59 | static struct netlbl_domhsh_tbl *netlbl_domhsh = NULL; |
61 | 60 | static struct netlbl_dom_map *netlbl_domhsh_def = NULL; |
62 | 61 |
net/netlabel/netlabel_unlabeled.c
... | ... | @@ -116,8 +116,7 @@ |
116 | 116 | * hash table should be okay */ |
117 | 117 | static DEFINE_SPINLOCK(netlbl_unlhsh_lock); |
118 | 118 | #define netlbl_unlhsh_rcu_deref(p) \ |
119 | - rcu_dereference_check(p, rcu_read_lock_held() || \ | |
120 | - lockdep_is_held(&netlbl_unlhsh_lock)) | |
119 | + rcu_dereference_check(p, lockdep_is_held(&netlbl_unlhsh_lock)) | |
121 | 120 | static struct netlbl_unlhsh_tbl *netlbl_unlhsh = NULL; |
122 | 121 | static struct netlbl_unlhsh_iface *netlbl_unlhsh_def = NULL; |
123 | 122 |
security/keys/keyring.c