From 53a9829a45d4939829a0719eaa10a3fa46ea8e06 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 01:40:41 +0000 Subject: [PATCH] ib_srpt: Fix a runtime warning Avoid that the following warning is reported: WARNING: CPU: 7 PID: 32692 at kernel/sched/core.c:7533 __might_sleep+0x82/0x90() do not call blocking ops when !TASK_RUNNING; state=1 set at [] srpt_compl_thread+0xab/0x1c0 [ib_srpt] Call Trace: [] dump_stack+0x4f/0x74 [] warn_slowpath_common+0x8b/0xd0 [] warn_slowpath_fmt+0x41/0x70 [] __might_sleep+0x82/0x90 [] mempool_alloc+0x94/0x180 [] scst_alloc_mgmt_cmd+0x4c/0x120 [scst] [] scst_pre_rx_mgmt_cmd+0x84/0x1e0 [scst] [] scst_rx_mgmt_fn+0x8a/0x3e0 [scst] [] scst_rx_mgmt_fn_lun+0x6e/0x90 [ib_srpt] [] srpt_handle_tsk_mgmt+0x1c1/0x2f0 [ib_srpt] [] srpt_handle_new_iu+0x1c0/0x230 [ib_srpt] [] srpt_process_rcv_completion+0x89/0xd0 [ib_srpt] [] srpt_process_one_compl+0x54/0x70 [ib_srpt] [] srpt_poll+0x69/0x90 [ib_srpt] [] srpt_process_completion+0x1e/0x40 [ib_srpt] [] srpt_compl_thread+0xdc/0x1c0 [ib_srpt] git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6727 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 2d2895335..115175845 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2068,13 +2068,18 @@ static int srpt_poll(struct srpt_rdma_ch *ch, int budget) return processed; } -static int srpt_process_completion(struct srpt_rdma_ch *ch, int budget) +static int srpt_process_completion(struct srpt_rdma_ch *ch, int budget, + bool thread_context) { struct ib_cq *const cq = ch->cq; int processed = 0, n = budget; do { + if (thread_context) + set_current_state(TASK_RUNNING); processed += srpt_poll(ch, n); + if (thread_context) + set_current_state(TASK_INTERRUPTIBLE); n = ib_req_notify_cq(cq, IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS); } while (n > 0); @@ -2143,6 +2148,7 @@ static int srpt_compl_thread(void *arg) { enum { poll_budget = 65536 }; struct srpt_rdma_ch *ch; + int n; /* Hibernation / freezing of the SRPT kernel thread is not supported. */ current->flags |= PF_NOFREEZE; @@ -2151,8 +2157,10 @@ static int srpt_compl_thread(void *arg) BUG_ON(!ch); while (ch->state < CH_LIVE) { - set_current_state(TASK_INTERRUPTIBLE); - if (srpt_process_completion(ch, poll_budget) >= poll_budget) + n = srpt_process_completion(ch, poll_budget, true); + if (ch->state >= CH_LIVE) + break; + if (n >= poll_budget) cond_resched(); else schedule(); @@ -2161,8 +2169,10 @@ static int srpt_compl_thread(void *arg) srpt_process_wait_list(ch); while (ch->state < CH_DISCONNECTED) { - set_current_state(TASK_INTERRUPTIBLE); - if (srpt_process_completion(ch, poll_budget) >= poll_budget) + n = srpt_process_completion(ch, poll_budget, true); + if (ch->state >= CH_DISCONNECTED) + break; + if (n >= poll_budget) cond_resched(); else schedule();