Skip to content

Commit 75a3f11

Browse files
KAGA-KOKOgregkh
authored andcommitted
RDMA/rxe: Fix rxe_qp_cleanup()
commit bb3ffb7 upstream. rxe_qp_cleanup() can sleep so it must be run in thread context and not in atomic context. This patch avoids that the following bug is triggered: Kernel BUG at 00000000560033f3 [verbose debug info unavailable] BUG: sleeping function called from invalid context at net/core/sock.c:2761 in_atomic(): 1, irqs_disabled(): 0, pid: 7, name: ksoftirqd/0 INFO: lockdep is turned off. Preemption disabled at: [<00000000b6e69628>] __do_softirq+0x4e/0x540 CPU: 0 PID: 7 Comm: ksoftirqd/0 Not tainted 4.15.0-rc7-dbg+ raspberrypi#4 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 Call Trace: dump_stack+0x85/0xbf ___might_sleep+0x177/0x260 lock_sock_nested+0x1d/0x90 inet_shutdown+0x2e/0xd0 rxe_qp_cleanup+0x107/0x140 [rdma_rxe] rxe_elem_release+0x18/0x80 [rdma_rxe] rxe_requester+0x1cf/0x11b0 [rdma_rxe] rxe_do_task+0x78/0xf0 [rdma_rxe] tasklet_action+0x99/0x270 __do_softirq+0xc0/0x540 run_ksoftirqd+0x1c/0x70 smpboot_thread_fn+0x1be/0x270 kthread+0x117/0x130 ret_from_fork+0x24/0x30 Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Cc: Moni Shoua <monis@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 571cb36 commit 75a3f11

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎drivers/infiniband/sw/rxe/rxe_qp.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,9 @@ void rxe_qp_destroy(struct rxe_qp *qp)
824824
}
825825

826826
/* called when the last reference to the qp is dropped */
827-
void rxe_qp_cleanup(struct rxe_pool_entry *arg)
827+
static void rxe_qp_do_cleanup(struct work_struct *work)
828828
{
829-
struct rxe_qp *qp = container_of(arg, typeof(*qp), pelem);
829+
struct rxe_qp *qp = container_of(work, typeof(*qp), cleanup_work.work);
830830

831831
rxe_drop_all_mcast_groups(qp);
832832

@@ -859,3 +859,11 @@ void rxe_qp_cleanup(struct rxe_pool_entry *arg)
859859
kernel_sock_shutdown(qp->sk, SHUT_RDWR);
860860
sock_release(qp->sk);
861861
}
862+
863+
/* called when the last reference to the qp is dropped */
864+
void rxe_qp_cleanup(struct rxe_pool_entry *arg)
865+
{
866+
struct rxe_qp *qp = container_of(arg, typeof(*qp), pelem);
867+
868+
execute_in_process_context(rxe_qp_do_cleanup, &qp->cleanup_work);
869+
}

‎drivers/infiniband/sw/rxe/rxe_verbs.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define RXE_VERBS_H
3636

3737
#include <linux/interrupt.h>
38+
#include <linux/workqueue.h>
3839
#include <rdma/rdma_user_rxe.h>
3940
#include "rxe_pool.h"
4041
#include "rxe_task.h"
@@ -281,6 +282,8 @@ struct rxe_qp {
281282
struct timer_list rnr_nak_timer;
282283

283284
spinlock_t state_lock; /* guard requester and completer */
285+
286+
struct execute_work cleanup_work;
284287
};
285288

286289
enum rxe_mem_state {

0 commit comments

Comments
 (0)