aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-20 16:23:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-20 16:23:30 -0500
commit42e1b14b6e1455ece2ccbe474c25388d0230a590 (patch)
tree7f62d95f795a2ac5c183248dce39e75340ccfb76 /net
parent828cad8ea05d194d8a9452e0793261c2024c23a2 (diff)
parent95cb64c1fe61e70685a95f6260c8e9cd219fe08c (diff)
Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking updates from Ingo Molnar: "The main changes in this cycle were: - Implement wraparound-safe refcount_t and kref_t types based on generic atomic primitives (Peter Zijlstra) - Improve and fix the ww_mutex code (Nicolai Hähnle) - Add self-tests to the ww_mutex code (Chris Wilson) - Optimize percpu-rwsems with the 'rcuwait' mechanism (Davidlohr Bueso) - Micro-optimize the current-task logic all around the core kernel (Davidlohr Bueso) - Tidy up after recent optimizations: remove stale code and APIs, clean up the code (Waiman Long) - ... plus misc fixes, updates and cleanups" * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (50 commits) fork: Fix task_struct alignment locking/spinlock/debug: Remove spinlock lockup detection code lockdep: Fix incorrect condition to print bug msgs for MAX_LOCKDEP_CHAIN_HLOCKS lkdtm: Convert to refcount_t testing kref: Implement 'struct kref' using refcount_t refcount_t: Introduce a special purpose refcount type sched/wake_q: Clarify queue reinit comment sched/wait, rcuwait: Fix typo in comment locking/mutex: Fix lockdep_assert_held() fail locking/rtmutex: Flip unlikely() branch to likely() in __rt_mutex_slowlock() locking/rwsem: Reinit wake_q after use locking/rwsem: Remove unnecessary atomic_long_t casts jump_labels: Move header guard #endif down where it belongs locking/atomic, kref: Implement kref_put_lock() locking/ww_mutex: Turn off __must_check for now locking/atomic, kref: Avoid more abuse locking/atomic, kref: Use kref_get_unless_zero() more locking/atomic, kref: Kill kref_sub() locking/atomic, kref: Add kref_read() locking/atomic, kref: Add KREF_INIT() ...
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/6lowpan.c2
-rw-r--r--net/bluetooth/a2mp.c4
-rw-r--r--net/bluetooth/amp.c4
-rw-r--r--net/bluetooth/l2cap_core.c4
-rw-r--r--net/ceph/messenger.c4
-rw-r--r--net/ceph/osd_client.c10
-rw-r--r--net/sunrpc/cache.c2
-rw-r--r--net/sunrpc/svc_xprt.c6
-rw-r--r--net/sunrpc/svcauth.c15
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_transport.c4
10 files changed, 30 insertions, 25 deletions
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 1904a93f47d5..d491529332f4 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -920,7 +920,7 @@ static void chan_close_cb(struct l2cap_chan *chan)
920 BT_DBG("dev %p removing %speer %p", dev, 920 BT_DBG("dev %p removing %speer %p", dev,
921 last ? "last " : "1 ", peer); 921 last ? "last " : "1 ", peer);
922 BT_DBG("chan %p orig refcnt %d", chan, 922 BT_DBG("chan %p orig refcnt %d", chan,
923 atomic_read(&chan->kref.refcount)); 923 kref_read(&chan->kref));
924 924
925 l2cap_chan_put(chan); 925 l2cap_chan_put(chan);
926 break; 926 break;
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 5f123c3320a7..f0095fd79818 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -810,7 +810,7 @@ static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
810/* AMP Manager functions */ 810/* AMP Manager functions */
811struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr) 811struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr)
812{ 812{
813 BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); 813 BT_DBG("mgr %p orig refcnt %d", mgr, kref_read(&mgr->kref));
814 814
815 kref_get(&mgr->kref); 815 kref_get(&mgr->kref);
816 816
@@ -833,7 +833,7 @@ static void amp_mgr_destroy(struct kref *kref)
833 833
834int amp_mgr_put(struct amp_mgr *mgr) 834int amp_mgr_put(struct amp_mgr *mgr)
835{ 835{
836 BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); 836 BT_DBG("mgr %p orig refcnt %d", mgr, kref_read(&mgr->kref));
837 837
838 return kref_put(&mgr->kref, &amp_mgr_destroy); 838 return kref_put(&mgr->kref, &amp_mgr_destroy);
839} 839}
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index e32f34189007..02a4ccc04e1e 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -24,7 +24,7 @@
24void amp_ctrl_get(struct amp_ctrl *ctrl) 24void amp_ctrl_get(struct amp_ctrl *ctrl)
25{ 25{
26 BT_DBG("ctrl %p orig refcnt %d", ctrl, 26 BT_DBG("ctrl %p orig refcnt %d", ctrl,
27 atomic_read(&ctrl->kref.refcount)); 27 kref_read(&ctrl->kref));
28 28
29 kref_get(&ctrl->kref); 29 kref_get(&ctrl->kref);
30} 30}
@@ -42,7 +42,7 @@ static void amp_ctrl_destroy(struct kref *kref)
42int amp_ctrl_put(struct amp_ctrl *ctrl) 42int amp_ctrl_put(struct amp_ctrl *ctrl)
43{ 43{
44 BT_DBG("ctrl %p orig refcnt %d", ctrl, 44 BT_DBG("ctrl %p orig refcnt %d", ctrl,
45 atomic_read(&ctrl->kref.refcount)); 45 kref_read(&ctrl->kref));
46 46
47 return kref_put(&ctrl->kref, &amp_ctrl_destroy); 47 return kref_put(&ctrl->kref, &amp_ctrl_destroy);
48} 48}
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ce0b5dd01953..fc7f321a3823 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -481,14 +481,14 @@ static void l2cap_chan_destroy(struct kref *kref)
481 481
482void l2cap_chan_hold(struct l2cap_chan *c) 482void l2cap_chan_hold(struct l2cap_chan *c)
483{ 483{
484 BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount)); 484 BT_DBG("chan %p orig refcnt %d", c, kref_read(&c->kref));
485 485
486 kref_get(&c->kref); 486 kref_get(&c->kref);
487} 487}
488 488
489void l2cap_chan_put(struct l2cap_chan *c) 489void l2cap_chan_put(struct l2cap_chan *c)
490{ 490{
491 BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount)); 491 BT_DBG("chan %p orig refcnt %d", c, kref_read(&c->kref));
492 492
493 kref_put(&c->kref, l2cap_chan_destroy); 493 kref_put(&c->kref, l2cap_chan_destroy);
494} 494}
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 770c52701efa..bad3d4ae43f6 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -3425,7 +3425,7 @@ static void ceph_msg_release(struct kref *kref)
3425struct ceph_msg *ceph_msg_get(struct ceph_msg *msg) 3425struct ceph_msg *ceph_msg_get(struct ceph_msg *msg)
3426{ 3426{
3427 dout("%s %p (was %d)\n", __func__, msg, 3427 dout("%s %p (was %d)\n", __func__, msg,
3428 atomic_read(&msg->kref.refcount)); 3428 kref_read(&msg->kref));
3429 kref_get(&msg->kref); 3429 kref_get(&msg->kref);
3430 return msg; 3430 return msg;
3431} 3431}
@@ -3434,7 +3434,7 @@ EXPORT_SYMBOL(ceph_msg_get);
3434void ceph_msg_put(struct ceph_msg *msg) 3434void ceph_msg_put(struct ceph_msg *msg)
3435{ 3435{
3436 dout("%s %p (was %d)\n", __func__, msg, 3436 dout("%s %p (was %d)\n", __func__, msg,
3437 atomic_read(&msg->kref.refcount)); 3437 kref_read(&msg->kref));
3438 kref_put(&msg->kref, ceph_msg_release); 3438 kref_put(&msg->kref, ceph_msg_release);
3439} 3439}
3440EXPORT_SYMBOL(ceph_msg_put); 3440EXPORT_SYMBOL(ceph_msg_put);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 842f049abb86..f3378ba1a828 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -438,7 +438,7 @@ static void ceph_osdc_release_request(struct kref *kref)
438void ceph_osdc_get_request(struct ceph_osd_request *req) 438void ceph_osdc_get_request(struct ceph_osd_request *req)
439{ 439{
440 dout("%s %p (was %d)\n", __func__, req, 440 dout("%s %p (was %d)\n", __func__, req,
441 atomic_read(&req->r_kref.refcount)); 441 kref_read(&req->r_kref));
442 kref_get(&req->r_kref); 442 kref_get(&req->r_kref);
443} 443}
444EXPORT_SYMBOL(ceph_osdc_get_request); 444EXPORT_SYMBOL(ceph_osdc_get_request);
@@ -447,7 +447,7 @@ void ceph_osdc_put_request(struct ceph_osd_request *req)
447{ 447{
448 if (req) { 448 if (req) {
449 dout("%s %p (was %d)\n", __func__, req, 449 dout("%s %p (was %d)\n", __func__, req,
450 atomic_read(&req->r_kref.refcount)); 450 kref_read(&req->r_kref));
451 kref_put(&req->r_kref, ceph_osdc_release_request); 451 kref_put(&req->r_kref, ceph_osdc_release_request);
452 } 452 }
453} 453}
@@ -487,11 +487,11 @@ static void request_reinit(struct ceph_osd_request *req)
487 struct ceph_msg *reply_msg = req->r_reply; 487 struct ceph_msg *reply_msg = req->r_reply;
488 488
489 dout("%s req %p\n", __func__, req); 489 dout("%s req %p\n", __func__, req);
490 WARN_ON(atomic_read(&req->r_kref.refcount) != 1); 490 WARN_ON(kref_read(&req->r_kref) != 1);
491 request_release_checks(req); 491 request_release_checks(req);
492 492
493 WARN_ON(atomic_read(&request_msg->kref.refcount) != 1); 493 WARN_ON(kref_read(&request_msg->kref) != 1);
494 WARN_ON(atomic_read(&reply_msg->kref.refcount) != 1); 494 WARN_ON(kref_read(&reply_msg->kref) != 1);
495 target_destroy(&req->r_t); 495 target_destroy(&req->r_t);
496 496
497 request_init(req); 497 request_init(req);
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 8147e8d56eb2..f39e3e11f9aa 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1358,7 +1358,7 @@ static int c_show(struct seq_file *m, void *p)
1358 ifdebug(CACHE) 1358 ifdebug(CACHE)
1359 seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n", 1359 seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n",
1360 convert_to_wallclock(cp->expiry_time), 1360 convert_to_wallclock(cp->expiry_time),
1361 atomic_read(&cp->ref.refcount), cp->flags); 1361 kref_read(&cp->ref), cp->flags);
1362 cache_get(cp); 1362 cache_get(cp);
1363 if (cache_check(cd, cp, NULL)) 1363 if (cache_check(cd, cp, NULL))
1364 /* cache_check does a cache_put on failure */ 1364 /* cache_check does a cache_put on failure */
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 9c9db55a0c1e..7bfe1fb42add 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -490,7 +490,7 @@ static struct svc_xprt *svc_xprt_dequeue(struct svc_pool *pool)
490 svc_xprt_get(xprt); 490 svc_xprt_get(xprt);
491 491
492 dprintk("svc: transport %p dequeued, inuse=%d\n", 492 dprintk("svc: transport %p dequeued, inuse=%d\n",
493 xprt, atomic_read(&xprt->xpt_ref.refcount)); 493 xprt, kref_read(&xprt->xpt_ref));
494 } 494 }
495 spin_unlock_bh(&pool->sp_lock); 495 spin_unlock_bh(&pool->sp_lock);
496out: 496out:
@@ -822,7 +822,7 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
822 /* XPT_DATA|XPT_DEFERRED case: */ 822 /* XPT_DATA|XPT_DEFERRED case: */
823 dprintk("svc: server %p, pool %u, transport %p, inuse=%d\n", 823 dprintk("svc: server %p, pool %u, transport %p, inuse=%d\n",
824 rqstp, rqstp->rq_pool->sp_id, xprt, 824 rqstp, rqstp->rq_pool->sp_id, xprt,
825 atomic_read(&xprt->xpt_ref.refcount)); 825 kref_read(&xprt->xpt_ref));
826 rqstp->rq_deferred = svc_deferred_dequeue(xprt); 826 rqstp->rq_deferred = svc_deferred_dequeue(xprt);
827 if (rqstp->rq_deferred) 827 if (rqstp->rq_deferred)
828 len = svc_deferred_recv(rqstp); 828 len = svc_deferred_recv(rqstp);
@@ -980,7 +980,7 @@ static void svc_age_temp_xprts(unsigned long closure)
980 * through, close it. */ 980 * through, close it. */
981 if (!test_and_set_bit(XPT_OLD, &xprt->xpt_flags)) 981 if (!test_and_set_bit(XPT_OLD, &xprt->xpt_flags))
982 continue; 982 continue;
983 if (atomic_read(&xprt->xpt_ref.refcount) > 1 || 983 if (kref_read(&xprt->xpt_ref) > 1 ||
984 test_bit(XPT_BUSY, &xprt->xpt_flags)) 984 test_bit(XPT_BUSY, &xprt->xpt_flags))
985 continue; 985 continue;
986 list_del_init(le); 986 list_del_init(le);
diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c
index e112da8005b5..bb8db3cb8032 100644
--- a/net/sunrpc/svcauth.c
+++ b/net/sunrpc/svcauth.c
@@ -126,13 +126,18 @@ EXPORT_SYMBOL_GPL(svc_auth_unregister);
126static struct hlist_head auth_domain_table[DN_HASHMAX]; 126static struct hlist_head auth_domain_table[DN_HASHMAX];
127static DEFINE_SPINLOCK(auth_domain_lock); 127static DEFINE_SPINLOCK(auth_domain_lock);
128 128
129static void auth_domain_release(struct kref *kref)
130{
131 struct auth_domain *dom = container_of(kref, struct auth_domain, ref);
132
133 hlist_del(&dom->hash);
134 dom->flavour->domain_release(dom);
135 spin_unlock(&auth_domain_lock);
136}
137
129void auth_domain_put(struct auth_domain *dom) 138void auth_domain_put(struct auth_domain *dom)
130{ 139{
131 if (atomic_dec_and_lock(&dom->ref.refcount, &auth_domain_lock)) { 140 kref_put_lock(&dom->ref, auth_domain_release, &auth_domain_lock);
132 hlist_del(&dom->hash);
133 dom->flavour->domain_release(dom);
134 spin_unlock(&auth_domain_lock);
135 }
136} 141}
137EXPORT_SYMBOL_GPL(auth_domain_put); 142EXPORT_SYMBOL_GPL(auth_domain_put);
138 143
diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
index ca2799af05a6..39652d390a9c 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
@@ -1201,9 +1201,9 @@ static void __svc_rdma_free(struct work_struct *work)
1201 ib_drain_qp(rdma->sc_qp); 1201 ib_drain_qp(rdma->sc_qp);
1202 1202
1203 /* We should only be called from kref_put */ 1203 /* We should only be called from kref_put */
1204 if (atomic_read(&xprt->xpt_ref.refcount) != 0) 1204 if (kref_read(&xprt->xpt_ref) != 0)
1205 pr_err("svcrdma: sc_xprt still in use? (%d)\n", 1205 pr_err("svcrdma: sc_xprt still in use? (%d)\n",
1206 atomic_read(&xprt->xpt_ref.refcount)); 1206 kref_read(&xprt->xpt_ref));
1207 1207
1208 /* 1208 /*
1209 * Destroy queued, but not processed read completions. Note 1209 * Destroy queued, but not processed read completions. Note