RDS: Fix panic on unload
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/5 RDS: Fix potential race around rds_i[bw]_allocation
Quoted 1 line
From Shin Hong:
"At rds_ib_recv_refill_one(), it first executes atomic_read(&rds_ib_allocation) for if-condition checking,
and then executes atomic_inc(&rds_ib_allocation) if the condition was not satisfied.
However, if any other code which updates rds_ib_allocation executes between these two atomic operation executions,
it seems that it may result race condition. (especially when rds_ib_allocation + 1 == rds_ib_sysctl_max_recv_allocation)"
This patch fixes this by using atomic_inc_unless to eliminate the possibility of allocating more than rds_ib_sysctl_max_recv_allocation and then decrementing the count if the allocation fails. It also makes an identical change to the iwarp transport.
--- net/rds/ib_recv.c | 7 ++++--- net/rds/iw_recv.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-)
net/rds/ib_recv.c +4 -3
@@ -143,15 +143,16 @@ static int rds_ib_recv_refill_one(struct rds_connection *conn,int ret = -ENOMEM ;if (recv->r_ibinc ==NULL ) { -if (atomic_read (&rds_ib_allocation) >= rds_ib_sysctl_max_recv_allocation) { +if (!atomic_add_unless (&rds_ib_allocation,1 , rds_ib_sysctl_max_recv_allocation)) {rds_ib_stats_inc (s_ib_rx_alloc_limit); goto out; } recv->r_ibinc =kmem_cache_alloc (rds_ib_incoming_slab, kptr_gfp); -if (recv->r_ibinc ==NULL ) +if (recv->r_ibinc ==NULL ) { +atomic_dec (&rds_ib_allocation); goto out; -atomic_inc (&rds_ib_allocation); + }INIT_LIST_HEAD (&recv->r_ibinc->ii_frags);rds_inc_init (&recv->r_ibinc->ii_inc, conn, conn->c_faddr); }
net/rds/iw_recv.c +4 -3
@@ -143,15 +143,16 @@ static int rds_iw_recv_refill_one(struct rds_connection *conn,int ret = -ENOMEM ;if (recv->r_iwinc ==NULL ) { -if (atomic_read (&rds_iw_allocation) >= rds_iw_sysctl_max_recv_allocation) { +if (!atomic_add_unless (&rds_iw_allocation,1 , rds_iw_sysctl_max_recv_allocation)) {rds_iw_stats_inc (s_iw_rx_alloc_limit); goto out; } recv->r_iwinc =kmem_cache_alloc (rds_iw_incoming_slab, kptr_gfp); -if (recv->r_iwinc ==NULL ) +if (recv->r_iwinc ==NULL ) { +atomic_dec (&rds_iw_allocation); goto out; -atomic_inc (&rds_iw_allocation); + }INIT_LIST_HEAD (&recv->r_iwinc->ii_frags);rds_inc_init (&recv->r_iwinc->ii_inc, conn, conn->c_faddr); }
Signature · 1 line
1.6.3.3
PATCH 3/5 RDS: Fix panic on unload
In reply to a message not in the archiveRemove explicit destruction of passive connection when destroying active end of the connection. The passive end is also on the device's connection list, and will thus be cleaned up properly. Panic was caused by trying to clean it up twice.
--- net/rds/ib_rdma.c | 5 +---- net/rds/iw_rdma.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-)
net/rds/ib_rdma.c +1 -4
@@ -187,11 +187,8 @@ void __rds_ib_destroy_conns(struct list_head *list, spinlock_t *list_lock)INIT_LIST_HEAD (list);spin_unlock_irq (list_lock); -list_for_each_entry_safe (ic, _ic, &tmp_list, ib_node) { -if (ic->conn->c_passive) -rds_conn_destroy (ic->conn->c_passive); +list_for_each_entry_safe (ic, _ic, &tmp_list, ib_node)rds_conn_destroy (ic->conn); - } }struct rds_ib_mr_pool *rds_ib_create_mr_pool (struct rds_ib_device *rds_ibdev)
net/rds/iw_rdma.c +1 -4
@@ -245,11 +245,8 @@ void __rds_iw_destroy_conns(struct list_head *list, spinlock_t *list_lock)INIT_LIST_HEAD (list);spin_unlock_irq (list_lock); -list_for_each_entry_safe (ic, _ic, &tmp_list, iw_node) { -if (ic->conn->c_passive) -rds_conn_destroy (ic->conn->c_passive); +list_for_each_entry_safe (ic, _ic, &tmp_list, iw_node)rds_conn_destroy (ic->conn); - } } static void rds_iw_set_scatterlist(struct rds_iw_scatterlist *sg,
Signature · 1 line
1.6.3.3
PATCH 4/5 RDS: Do not send congestion updates to loopback connections
In reply to a message not in the archiveThis issue was discovered by HP's Pradeep and fixed in OFED 1.3, but not fixed in later versions, since the fix's implementation was not immediately applyable to the later code. This patch should do the trick for 1.4+ codebases.
--- net/rds/cong.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
net/rds/cong.c +2 -0
@@ -218,6 +218,8 @@ void rds_cong_queue_updates(struct rds_cong_map *map)spin_lock_irqsave (&rds_cong_lock, flags);list_for_each_entry (conn, &map->m_conn_list, c_map_item) { +if (conn->c_loopback) +continue ;if (!test_and_set_bit (0 , &conn->c_map_queued)) {rds_stats_inc (s_cong_update_queued);queue_delayed_work (rds_wq, &conn->c_send_w,0 );
Signature · 1 line
1.6.3.3
PATCH 5/5 RDS/IB+IW: Move recv processing to a tasklet
In reply to a message not in the archiveMove receive processing from event handler to a tasklet. This should help prevent hangcheck timer from going off when RDS is under heavy load.
--- net/rds/ib.h | 2 ++ net/rds/ib_cm.c | 2 ++ net/rds/ib_recv.c | 28 ++++++++++++++++++++++------ net/rds/iw.h | 2 ++ net/rds/iw_cm.c | 2 ++ net/rds/iw_recv.c | 28 ++++++++++++++++++++++------ 6 files changed, 52 insertions(+), 12 deletions(-)
net/rds/ib.h +2 -0
@@ -98,6 +98,7 @@ struct rds_ib_connection {struct rds_ib_send_work *i_sends;/* rx */ +struct tasklet_struct i_recv_tasklet;struct mutex i_recv_mutex;struct rds_ib_work_ring i_recv_ring;struct rds_ib_incoming *i_ibinc;
@@ -303,6 +304,7 @@ void rds_ib_inc_free(struct rds_incoming *inc);int rds_ib_inc_copy_to_user (struct rds_incoming *inc,struct iovec *iov,size_t size);void rds_ib_recv_cq_comp_handler (struct ib_cq *cq,void *context); +void rds_ib_recv_tasklet_fn (unsigned long data);void rds_ib_recv_init_ring (struct rds_ib_connection *ic);void rds_ib_recv_clear_ring (struct rds_ib_connection *ic);void rds_ib_recv_init_ack (struct rds_ib_connection *ic);
net/rds/ib_cm.c +2 -0
@@ -694,6 +694,8 @@ int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp)return -ENOMEM ;INIT_LIST_HEAD (&ic->ib_node); +tasklet_init (&ic->i_recv_tasklet, rds_ib_recv_tasklet_fn, + (unsigned long ) ic);mutex_init (&ic->i_recv_mutex);#ifndef KERNEL_HAS_ATOMIC64 spin_lock_init (&ic->i_ack_lock);
net/rds/ib_recv.c +22 -6
@@ -825,17 +825,22 @@ void rds_ib_recv_cq_comp_handler(struct ib_cq *cq, void *context) {struct rds_connection *conn = context;struct rds_ib_connection *ic = conn->c_transport_data; -struct ib_wc wc; -struct rds_ib_ack_state state = {0 , }; -struct rds_ib_recv_work *recv;rdsdebug ("conn %p cq %p\n" , conn, cq);rds_ib_stats_inc (s_ib_rx_cq_call); -ib_req_notify_cq (cq,IB_CQ_SOLICITED ); +tasklet_schedule (&ic->i_recv_tasklet); +} -while (ib_poll_cq (cq,1 , &wc) >0 ) { +static inline void rds_poll_cq (struct rds_ib_connection *ic, +struct rds_ib_ack_state *state) +{ +struct rds_connection *conn = ic->conn; +struct ib_wc wc; +struct rds_ib_recv_work *recv; + +while (ib_poll_cq (ic->i_recv_cq,1 , &wc) >0 ) {rdsdebug ("wc wr_id 0x%llx status %u byte_len %u imm_data %u\n" , (unsigned long long )wc.wr_id, wc.status, wc.byte_len,be32_to_cpu (wc.ex.imm_data));
@@ -853,7 +858,7 @@ void rds_ib_recv_cq_comp_handler(struct ib_cq *cq, void *context)if (rds_conn_up (conn) ||rds_conn_connecting (conn)) {/* We expect errors as the qp is drained during shutdown */ if (wc.status ==IB_WC_SUCCESS ) { -rds_ib_process_recv (conn, recv, wc.byte_len, &state); +rds_ib_process_recv (conn, recv, wc.byte_len, state); }else {rds_ib_conn_error (conn,"recv completion on " "%pI4 had status %u, disconnecting and "
@@ -864,6 +869,17 @@ void rds_ib_recv_cq_comp_handler(struct ib_cq *cq, void *context)rds_ib_ring_free (&ic->i_recv_ring,1 ); } +} + +void rds_ib_recv_tasklet_fn (unsigned long data) +{ +struct rds_ib_connection *ic = (struct rds_ib_connection *) data; +struct rds_connection *conn = ic->conn; +struct rds_ib_ack_state state = {0 , }; + +rds_poll_cq (ic, &state); +ib_req_notify_cq (ic->i_recv_cq,IB_CQ_SOLICITED ); +rds_poll_cq (ic, &state);if (state.ack_next_valid)rds_ib_set_ack (ic, state.ack_next, state.ack_required);
net/rds/iw.h +2 -0
@@ -119,6 +119,7 @@ struct rds_iw_connection {struct rds_iw_send_work *i_sends;/* rx */ +struct tasklet_struct i_recv_tasklet;struct mutex i_recv_mutex;struct rds_iw_work_ring i_recv_ring;struct rds_iw_incoming *i_iwinc;
@@ -330,6 +331,7 @@ void rds_iw_inc_free(struct rds_incoming *inc);int rds_iw_inc_copy_to_user (struct rds_incoming *inc,struct iovec *iov,size_t size);void rds_iw_recv_cq_comp_handler (struct ib_cq *cq,void *context); +void rds_iw_recv_tasklet_fn (unsigned long data);void rds_iw_recv_init_ring (struct rds_iw_connection *ic);void rds_iw_recv_clear_ring (struct rds_iw_connection *ic);void rds_iw_recv_init_ack (struct rds_iw_connection *ic);
net/rds/iw_cm.c +2 -0
@@ -696,6 +696,8 @@ int rds_iw_conn_alloc(struct rds_connection *conn, gfp_t gfp)return -ENOMEM ;INIT_LIST_HEAD (&ic->iw_node); +tasklet_init (&ic->i_recv_tasklet, rds_iw_recv_tasklet_fn, + (unsigned long ) ic);mutex_init (&ic->i_recv_mutex);#ifndef KERNEL_HAS_ATOMIC64 spin_lock_init (&ic->i_ack_lock);
net/rds/iw_recv.c +22 -6
@@ -784,17 +784,22 @@ void rds_iw_recv_cq_comp_handler(struct ib_cq *cq, void *context) {struct rds_connection *conn = context;struct rds_iw_connection *ic = conn->c_transport_data; -struct ib_wc wc; -struct rds_iw_ack_state state = {0 , }; -struct rds_iw_recv_work *recv;rdsdebug ("conn %p cq %p\n" , conn, cq);rds_iw_stats_inc (s_iw_rx_cq_call); -ib_req_notify_cq (cq,IB_CQ_SOLICITED ); +tasklet_schedule (&ic->i_recv_tasklet); +} -while (ib_poll_cq (cq,1 , &wc) >0 ) { +static inline void rds_poll_cq (struct rds_iw_connection *ic, +struct rds_iw_ack_state *state) +{ +struct rds_connection *conn = ic->conn; +struct ib_wc wc; +struct rds_iw_recv_work *recv; + +while (ib_poll_cq (ic->i_recv_cq,1 , &wc) >0 ) {rdsdebug ("wc wr_id 0x%llx status %u byte_len %u imm_data %u\n" , (unsigned long long )wc.wr_id, wc.status, wc.byte_len,be32_to_cpu (wc.ex.imm_data));
@@ -812,7 +817,7 @@ void rds_iw_recv_cq_comp_handler(struct ib_cq *cq, void *context)if (rds_conn_up (conn) ||rds_conn_connecting (conn)) {/* We expect errors as the qp is drained during shutdown */ if (wc.status ==IB_WC_SUCCESS ) { -rds_iw_process_recv (conn, recv, wc.byte_len, &state); +rds_iw_process_recv (conn, recv, wc.byte_len, state); }else {rds_iw_conn_error (conn,"recv completion on " "%pI4 had status %u, disconnecting and "
@@ -823,6 +828,17 @@ void rds_iw_recv_cq_comp_handler(struct ib_cq *cq, void *context)rds_iw_ring_free (&ic->i_recv_ring,1 ); } +} + +void rds_iw_recv_tasklet_fn (unsigned long data) +{ +struct rds_iw_connection *ic = (struct rds_iw_connection *) data; +struct rds_connection *conn = ic->conn; +struct rds_iw_ack_state state = {0 , }; + +rds_poll_cq (ic, &state); +ib_req_notify_cq (ic->i_recv_cq,IB_CQ_SOLICITED ); +rds_poll_cq (ic, &state);if (state.ack_next_valid)rds_iw_set_ack (ic, state.ack_next, state.ack_required);
Signature · 1 line
1.6.3.3