Received: by 10.213.65.68 with SMTP id h4csp522453imn; Tue, 13 Mar 2018 11:44:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELtEz4NU767COxta+uMh/Uc5up//B0Y1TniT2kLCthQpfeJSYbw+gx5s49JMFmfbnvcK6h69 X-Received: by 10.101.77.7 with SMTP id i7mr1304365pgt.330.1520966643444; Tue, 13 Mar 2018 11:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520966643; cv=none; d=google.com; s=arc-20160816; b=LSNcKhiJP0v7xtUvTlKNEe1rFNN6ZDkrqwa3jQibEZwZ+XINOEDDUIiBzURMjaa+Uj F0NMEpRwySlP6PAa4bFoqKkXXf4pIOEXJ/xauu4JX8qEcldo3tNmbH2aklJDF6VmfPzx KVh/B8fZNjXZqEJwBbktn6QL3Kwy/IB7JydaJLg/ue6cc9jw071FJjHYOOwO3o2P1ANa dXOZm2XYxhOfa5hxG9WDH684d9Q6Gt9u0NUG25MluB/m6qBAwI4XSGDTWEt55VJuZcKv fRvqntwz2+UDauUjqP6fNvgpq0usDSAyacTCyUTKLkvR+/6pDKbrh3VeQEEx0Jm17trF jmdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Hp8qBkQ57Pnm2W1L7WhZel57FVm+JuSwonpy9dopQ8M=; b=xB8khour/msaGJ+PYofz+ezdUT5IlYbMYh39H4xeIGLwPsZZjMCIdS2PFLU3BeV+si vvoqafMg1TlCkDFLz+uJpmsnew7NxfPwxiDOVoZx7vs5r6WXHe40bWwJj09XoW6apMdr mEt0Aqe0n37jpXqGkaEn9ZSWom9lzWSobH9KPnzbL8d6NaG5E2MRk5AnDwM/DK/dPzoh TNDsDBJdAWAbsxFpvYLq0yqcpDVCd4r51EfkMiBL5P3pdupWx7Wc0UkpIfoDDtGG8WCy lBtduT0lXITBzF/O4RhAA89yv+XYrExHgb6a42fAwUTJg+d/iHjhXPPdkknLqsrGP7EV 27KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10-v6si515975plm.745.2018.03.13.11.43.48; Tue, 13 Mar 2018 11:44:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752226AbeCMSmr (ORCPT + 99 others); Tue, 13 Mar 2018 14:42:47 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:49801 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666AbeCMSmp (ORCPT ); Tue, 13 Mar 2018 14:42:45 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1evosj-0006sa-22; Tue, 13 Mar 2018 19:42:41 +0100 Date: Tue, 13 Mar 2018 19:42:41 +0100 From: Sebastian Andrzej Siewior To: linux-rt-users Cc: Peter Zijlstra , Corey Minyard , Thomas Gleixner , Steven Rostedt , linux-kernel , Tejun Heo Subject: [RT PATCH 2/2] block: blk-mq: move blk_queue_usage_counter_release() into process context Message-ID: <20180313184240.ndq2pw2fmvhkwidc@linutronix.de> References: <20180309110418.lwtennjqwqcxh422@linutronix.de> <20180309174605.GC4064@hirez.programming.kicks-ass.net> <20180309202550.j66qphz3txupt55u@linutronix.de> <20180309222643.GC5926@hirez.programming.kicks-ass.net> <20180312105113.p7jifhwdwbhpvxds@linutronix.de> <20180312132729.GI4064@hirez.programming.kicks-ass.net> <20180312141107.roveviectc6a75s7@linutronix.de> <20180312142933.GF4043@hirez.programming.kicks-ass.net> <20180312195118.rye5lg2pb26kmavn@linutronix.de> <20180313184039.begptzircgb5ketk@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180313184039.begptzircgb5ketk@linutronix.de> User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org | BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:914 | in_atomic(): 1, irqs_disabled(): 0, pid: 255, name: kworker/u257:6 | 5 locks held by kworker/u257:6/255: | #0: ("events_unbound"){.+.+.+}, at: [] process_one_work+0x171/0x5e0 | #1: ((&entry->work)){+.+.+.}, at: [] process_one_work+0x171/0x5e0 | #2: (&shost->scan_mutex){+.+.+.}, at: [] __scsi_add_device+0xa3/0x130 [scsi_mod] | #3: (&set->tag_list_lock){+.+...}, at: [] blk_mq_init_queue+0x96a/0xa50 | #4: (rcu_read_lock_sched){......}, at: [] percpu_ref_kill_and_confirm+0x1d/0x120 | Preemption disabled at:[] blk_mq_freeze_queue_start+0x56/0x70 | | CPU: 2 PID: 255 Comm: kworker/u257:6 Not tainted 3.18.7-rt0+ #1 | Workqueue: events_unbound async_run_entry_fn | 0000000000000003 ffff8800bc29f998 ffffffff815b3a12 0000000000000000 | 0000000000000000 ffff8800bc29f9b8 ffffffff8109aa16 ffff8800bc29fa28 | ffff8800bc5d1bc8 ffff8800bc29f9e8 ffffffff815b8dd4 ffff880000000000 | Call Trace: | [] dump_stack+0x4f/0x7c | [] __might_sleep+0x116/0x190 | [] rt_spin_lock+0x24/0x60 | [] __wake_up+0x29/0x60 | [] blk_mq_usage_counter_release+0x1e/0x20 | [] percpu_ref_kill_and_confirm+0x106/0x120 | [] blk_mq_freeze_queue_start+0x56/0x70 | [] blk_mq_update_tag_set_depth+0x40/0xd0 | [] blk_mq_init_queue+0x98c/0xa50 | [] scsi_mq_alloc_queue+0x20/0x60 [scsi_mod] | [] scsi_alloc_sdev+0x2f5/0x370 [scsi_mod] | [] scsi_probe_and_add_lun+0x9e4/0xdd0 [scsi_mod] | [] __scsi_add_device+0x126/0x130 [scsi_mod] | [] ata_scsi_scan_host+0xaf/0x200 [libata] | [] async_port_probe+0x46/0x60 [libata] | [] async_run_entry_fn+0x3b/0xf0 | [] process_one_work+0x201/0x5e0 percpu_ref_kill_and_confirm() invokes blk_mq_usage_counter_release() in a rcu-sched region. swait based wake queue can't be used due to wake_up_all() usage and disabled interrupts in !RT configs (as reported by Corey Minyard). Uses work_queue() to invoke wake_up_all() in process context. Signed-off-by: Sebastian Andrzej Siewior --- block/blk-core.c | 13 ++++++++++++- include/linux/blkdev.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index f9ac6f169c67..4db4051724ea 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -814,12 +814,20 @@ void blk_queue_exit(struct request_queue *q) percpu_ref_put(&q->q_usage_counter); } +static void blk_queue_usage_counter_release_swork(struct swork_event *sev) +{ + struct request_queue *q = + container_of(sev, struct request_queue, mq_pcpu_wake); + + wake_up_all(&q->mq_freeze_wq); +} + static void blk_queue_usage_counter_release(struct percpu_ref *ref) { struct request_queue *q = container_of(ref, struct request_queue, q_usage_counter); - wake_up_all(&q->mq_freeze_wq); + swork_queue(&q->mq_pcpu_wake); } static void blk_rq_timed_out_timer(unsigned long data) @@ -896,6 +904,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) __set_bit(QUEUE_FLAG_BYPASS, &q->queue_flags); init_waitqueue_head(&q->mq_freeze_wq); + INIT_SWORK(&q->mq_pcpu_wake, blk_queue_usage_counter_release_swork); /* * Init percpu_ref in atomic mode so that it's faster to shutdown. @@ -3623,6 +3632,8 @@ int __init blk_dev_init(void) if (!kblockd_workqueue) panic("Failed to create kblockd\n"); + BUG_ON(swork_get()); + request_cachep = kmem_cache_create("blkdev_requests", sizeof(struct request), 0, SLAB_PANIC, NULL); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index b68752bfb645..49b53ad6d2d6 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -27,6 +27,7 @@ #include #include #include +#include struct module; struct scsi_ioctl_command; @@ -599,6 +600,7 @@ struct request_queue { #endif struct rcu_head rcu_head; wait_queue_head_t mq_freeze_wq; + struct swork_event mq_pcpu_wake; struct percpu_ref q_usage_counter; struct list_head all_q_node; -- 2.16.2