[kernel/f19] Add patches to fix soft lockup from elevator changes (rhbz 902012)
Josh Boyer
jwboyer at fedoraproject.org
Fri Sep 27 13:26:35 UTC 2013
commit ccf7bdaaadcaf353f77986c0ee3bd44a446e4d5b
Author: Josh Boyer <jwboyer at fedoraproject.org>
Date: Fri Sep 27 09:22:47 2013 -0400
Add patches to fix soft lockup from elevator changes (rhbz 902012)
...r-Fix-a-race-in-elevator-switching-and-md.patch | 162 ++++++++++++++++++++
...r-acquire-q-sysfs_lock-in-elevator_change.patch | 121 +++++++++++++++
kernel.spec | 11 ++
3 files changed, 294 insertions(+), 0 deletions(-)
---
diff --git a/elevator-Fix-a-race-in-elevator-switching-and-md.patch b/elevator-Fix-a-race-in-elevator-switching-and-md.patch
new file mode 100644
index 0000000..5517687
--- /dev/null
+++ b/elevator-Fix-a-race-in-elevator-switching-and-md.patch
@@ -0,0 +1,162 @@
+
+Delivered-To: jwboyer at gmail.com
+Received: by 10.76.168.104 with SMTP id zv8csp55663oab;
+ Fri, 30 Aug 2013 15:52:46 -0700 (PDT)
+X-Received: by 10.68.244.168 with SMTP id xh8mr12419215pbc.3.1377903166373;
+ Fri, 30 Aug 2013 15:52:46 -0700 (PDT)
+Return-Path: <linux-kernel-owner at vger.kernel.org>
+Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
+ by mx.google.com with ESMTP id qc9si280431pac.269.1969.12.31.16.00.00;
+ Fri, 30 Aug 2013 15:52:46 -0700 (PDT)
+Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner at 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 at vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mail=linux-kernel-owner at vger.kernel.org;
+ dkim=neutral (bad format) header.i=@hds.com
+Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+ id S1753535Ab3H3WrV (ORCPT <rfc822;georgezhim at gmail.com>
+ + 99 others); Fri, 30 Aug 2013 18:47:21 -0400
+Received: from usindpps04.hds.com ([207.126.252.17]:35636 "EHLO
+ usindpps04.hds.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
+ with ESMTP id S1752650Ab3H3WrU (ORCPT
+ <rfc822;linux-kernel at vger.kernel.org>);
+ Fri, 30 Aug 2013 18:47:20 -0400
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hds.com; h=subject : to : from : cc
+ : date : message-id : mime-version : content-type :
+ content-transfer-encoding; s=mail1;
+ bh=VofHN8IMnygn2hbqnFjLmX0PPEPbvpzE377u1RxpGOY=;
+ b=piW6J78W57qDXBPJJuodWw/tvf0T//JbxKX6sLPvpuaOG2nBLMHzDqUeTYwFEQqUvdmf
+ ZTkiwsKi0WEku3MKcxJ7veR7wvTZcQ4fGMETFTf1c2J/1JOKpXLnft4ERuW89/FAxw25
+ wQM1ulsuQ3Cncl0I/sIaqMlaMOtvuQ/C8rsHorp+75eFiL6yx1jU5wMbuti4D/NprIET
+ 3r57cPZ0YCh6sLjvOgjay6mKyktMToyjHPx6X1TWCSWcwes33Popc1hpadxUdFI/0npL
+ mN3Tttbe7e2RcmkXAZbwg8xj+FwSu3nIRC4G9UpFCsMz518C/AWZj4puwWE6VHZWVvVZ Rg==
+Received: from usindmail01.hds.com (usindmail03 [207.126.252.22])
+ by usindpps04.hds.com (8.14.5/8.14.5) with ESMTP id r7UMlBjr025492;
+ Fri, 30 Aug 2013 18:47:11 -0400
+Received: from hds.com (usindnetf5d-vlan47float.corp.hds.com [10.74.73.11])
+ by usindmail01.hds.com (8.14.1/8.14.1) with ESMTP id r7UMl8SG058466;
+ Fri, 30 Aug 2013 18:47:10 -0400 (EDT)
+Subject: [PATCH v2 1/2] elevator: Fix a race in elevator switching and md
+ device initialization
+To: linux-kernel at vger.kernel.org
+From: Tomoki Sekiyama <tomoki.sekiyama at hds.com>
+Cc: axboe at kernel.dk, tj at kernel.org, seiji.aguchi at hds.com,
+ vgoyal at redhat.com, majianpeng at gmail.com
+Date: Fri, 30 Aug 2013 18:47:07 -0400
+Message-ID: <20130830224707.21812.63516.stgit at hds.com>
+User-Agent: StGit/0.16
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+X-Proofpoint-SPF-Result: pass
+X-Proofpoint-SPF-Record: v=spf1 mx ip4:207.126.244.0/26 ip4:207.126.252.0/25 include:mktomail.com
+ include:cloud.hds.com ~all
+X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794,1.0.431,0.0.0000
+ definitions=2013-08-30_09:2013-08-30,2013-08-30,1970-01-01 signatures=0
+X-Proofpoint-Spam-Details: rule=notspam policy=outbound_policy score=0 spamscore=0 suspectscore=1
+ phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx
+ scancount=1 engine=7.0.1-1305240000 definitions=main-1308300162
+Sender: linux-kernel-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List: linux-kernel at vger.kernel.org
+
+The soft lockup below happens at the boot time of the system using dm
+multipath and the udev rules to switch scheduler.
+
+[ 356.127001] BUG: soft lockup - CPU#3 stuck for 22s! [sh:483]
+[ 356.127001] RIP: 0010:[<ffffffff81072a7d>] [<ffffffff81072a7d>] lock_timer_base.isra.35+0x1d/0x50
+...
+[ 356.127001] Call Trace:
+[ 356.127001] [<ffffffff81073810>] try_to_del_timer_sync+0x20/0x70
+[ 356.127001] [<ffffffff8118b08a>] ? kmem_cache_alloc_node_trace+0x20a/0x230
+[ 356.127001] [<ffffffff810738b2>] del_timer_sync+0x52/0x60
+[ 356.127001] [<ffffffff812ece22>] cfq_exit_queue+0x32/0xf0
+[ 356.127001] [<ffffffff812c98df>] elevator_exit+0x2f/0x50
+[ 356.127001] [<ffffffff812c9f21>] elevator_change+0xf1/0x1c0
+[ 356.127001] [<ffffffff812caa50>] elv_iosched_store+0x20/0x50
+[ 356.127001] [<ffffffff812d1d09>] queue_attr_store+0x59/0xb0
+[ 356.127001] [<ffffffff812143f6>] sysfs_write_file+0xc6/0x140
+[ 356.127001] [<ffffffff811a326d>] vfs_write+0xbd/0x1e0
+[ 356.127001] [<ffffffff811a3ca9>] SyS_write+0x49/0xa0
+[ 356.127001] [<ffffffff8164e899>] system_call_fastpath+0x16/0x1b
+
+This is caused by a race between md device initialization by multipathd and
+shell script to switch the scheduler using sysfs.
+
+ - multipathd:
+ SyS_ioctl -> do_vfs_ioctl -> dm_ctl_ioctl -> ctl_ioctl -> table_load
+ -> dm_setup_md_queue -> blk_init_allocated_queue -> elevator_init
+ q->elevator = elevator_alloc(q, e); // not yet initialized
+
+ - sh -c 'echo deadline > /sys/$DEVPATH/queue/scheduler':
+ elevator_switch (in the call trace above)
+ struct elevator_queue *old = q->elevator;
+ q->elevator = elevator_alloc(q, new_e);
+ elevator_exit(old); // lockup! (*)
+
+ - multipathd: (cont.)
+ err = e->ops.elevator_init_fn(q); // init fails; q->elevator is modified
+
+(*) When del_timer_sync() is called, lock_timer_base() will loop infinitely
+while timer->base == NULL. In this case, as timer will never initialized,
+it results in lockup.
+
+This patch introduces acquisition of q->sysfs_lock around elevator_init()
+into blk_init_allocated_queue(), to provide mutual exclusion between
+initialization of the q->scheduler and switching of the scheduler.
+
+This should fix this bugzilla:
+https://bugzilla.redhat.com/show_bug.cgi?id=902012
+
+Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama at hds.com>
+---
+ block/blk-core.c | 10 +++++++++-
+ block/elevator.c | 6 ++++++
+ 2 files changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/block/blk-core.c b/block/blk-core.c
+index 93a18d1..2f6275f 100644
+--- a/block/blk-core.c
++++ b/block/blk-core.c
+@@ -739,9 +739,17 @@ blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn,
+
+ q->sg_reserved_size = INT_MAX;
+
++ /* Protect q->elevator from elevator_change */
++ mutex_lock(&q->sysfs_lock);
++
+ /* init elevator */
+- if (elevator_init(q, NULL))
++ if (elevator_init(q, NULL)) {
++ mutex_unlock(&q->sysfs_lock);
+ return NULL;
++ }
++
++ mutex_unlock(&q->sysfs_lock);
++
+ return q;
+ }
+ EXPORT_SYMBOL(blk_init_allocated_queue);
+diff --git a/block/elevator.c b/block/elevator.c
+index 668394d..02d4390 100644
+--- a/block/elevator.c
++++ b/block/elevator.c
+@@ -186,6 +186,12 @@ int elevator_init(struct request_queue *q, char *name)
+ struct elevator_type *e = NULL;
+ int err;
+
++ /*
++ * q->sysfs_lock must be held to provide mutual exclusion between
++ * elevator_switch() and here.
++ */
++ lockdep_assert_held(&q->sysfs_lock);
++
+ if (unlikely(q->elevator))
+ return 0;
+
+
+--
+To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at http://www.tux.org/lkml/
diff --git a/elevator-acquire-q-sysfs_lock-in-elevator_change.patch b/elevator-acquire-q-sysfs_lock-in-elevator_change.patch
new file mode 100644
index 0000000..6f112b8
--- /dev/null
+++ b/elevator-acquire-q-sysfs_lock-in-elevator_change.patch
@@ -0,0 +1,121 @@
+
+Delivered-To: jwboyer at gmail.com
+Received: by 10.76.168.104 with SMTP id zv8csp55623oab;
+ Fri, 30 Aug 2013 15:51:42 -0700 (PDT)
+X-Received: by 10.67.30.70 with SMTP id kc6mr13149193pad.32.1377903101609;
+ Fri, 30 Aug 2013 15:51:41 -0700 (PDT)
+Return-Path: <linux-kernel-owner at vger.kernel.org>
+Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
+ by mx.google.com with ESMTP id gg2si304840pac.217.1969.12.31.16.00.00;
+ Fri, 30 Aug 2013 15:51:41 -0700 (PDT)
+Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner at 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 at vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mail=linux-kernel-owner at vger.kernel.org;
+ dkim=neutral (bad format) header.i=@hds.com
+Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+ id S1756106Ab3H3WrX (ORCPT <rfc822;georgezhim at gmail.com>
+ + 99 others); Fri, 30 Aug 2013 18:47:23 -0400
+Received: from usindpps04.hds.com ([207.126.252.17]:35640 "EHLO
+ usindpps04.hds.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
+ with ESMTP id S1752650Ab3H3WrW (ORCPT
+ <rfc822;linux-kernel at vger.kernel.org>);
+ Fri, 30 Aug 2013 18:47:22 -0400
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hds.com; h=subject : to : from : cc
+ : date : message-id : in-reply-to : references : mime-version :
+ content-type : content-transfer-encoding; s=mail1;
+ bh=xbQuWVaSJrPfWG5E7bXFAbOFjf/sBaRZsPmpVgy0CYk=;
+ b=NW/A8Imu32MXoBi5FLrQ0FsK66RTWMQo1bFRtgQplVEQQIAXyf1XhCaAZyTkTplc0iEx
+ ovyGZHvLbmGL6w3I3pxkCFz1BPJCqoZtvQITir/WvfzyadYOK1cz+vuBUQSCmfkacvS/
+ w37h1jLAjsvWXkl0GY7pxB9HJMXdeLnhhuWxtNU8m8rKZ7t3LSByMeQi5/3OTkNojDEe
+ 70cKeZXCPQ/UIDJAF4cpSVXia5FwoJISjXvQIrvqkYhFelzq3OHMcC482PdpqNB475h3
+ yHHJ83HFOLRulUQdOG5ZVTB9qRg0zxRx/oedeXwzturFke68noRRa4f4izQ8sCwsWOCI Dw==
+Received: from usindmail01.hds.com (usindmail03 [207.126.252.22])
+ by usindpps04.hds.com (8.14.5/8.14.5) with ESMTP id r7UMlHIc025543;
+ Fri, 30 Aug 2013 18:47:17 -0400
+Received: from hds.com (usindnetf5d-vlan47float.corp.hds.com [10.74.73.11])
+ by usindmail01.hds.com (8.14.1/8.14.1) with ESMTP id r7UMlGiC058545;
+ Fri, 30 Aug 2013 18:47:17 -0400 (EDT)
+Subject: [PATCH v2 2/2] elevator: acquire q->sysfs_lock in elevator_change()
+To: linux-kernel at vger.kernel.org
+From: Tomoki Sekiyama <tomoki.sekiyama at hds.com>
+Cc: axboe at kernel.dk, tj at kernel.org, seiji.aguchi at hds.com,
+ vgoyal at redhat.com, majianpeng at gmail.com
+Date: Fri, 30 Aug 2013 18:47:16 -0400
+Message-ID: <20130830224716.21812.99333.stgit at hds.com>
+In-Reply-To: <20130830224707.21812.63516.stgit at hds.com>
+References: <20130830224707.21812.63516.stgit at hds.com>
+User-Agent: StGit/0.16
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+X-Proofpoint-SPF-Result: pass
+X-Proofpoint-SPF-Record: v=spf1 mx ip4:207.126.244.0/26 ip4:207.126.252.0/25 include:mktomail.com
+ include:cloud.hds.com ~all
+X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794,1.0.431,0.0.0000
+ definitions=2013-08-30_09:2013-08-30,2013-08-30,1970-01-01 signatures=0
+X-Proofpoint-Spam-Details: rule=notspam policy=outbound_policy score=0 spamscore=0 suspectscore=1
+ phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx
+ scancount=1 engine=7.0.1-1305240000 definitions=main-1308300162
+Sender: linux-kernel-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List: linux-kernel at vger.kernel.org
+
+Add locking of q->sysfs_lock into elevator_change() (an exported function)
+to ensure it is held to protect q->elevator from elevator_init(), even if
+elevator_change() is called from non-sysfs paths.
+sysfs path (elv_iosched_store) uses __elevator_change(), non-locking
+version, as the lock is already taken by elv_iosched_store().
+
+Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama at hds.com>
+---
+ block/elevator.c | 16 ++++++++++++++--
+ 1 file changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/block/elevator.c b/block/elevator.c
+index 02d4390..6d765f7 100644
+--- a/block/elevator.c
++++ b/block/elevator.c
+@@ -965,7 +965,7 @@ fail_init:
+ /*
+ * Switch this queue to the given IO scheduler.
+ */
+-int elevator_change(struct request_queue *q, const char *name)
++static int __elevator_change(struct request_queue *q, const char *name)
+ {
+ char elevator_name[ELV_NAME_MAX];
+ struct elevator_type *e;
+@@ -987,6 +987,18 @@ int elevator_change(struct request_queue *q, const char *name)
+
+ return elevator_switch(q, e);
+ }
++
++int elevator_change(struct request_queue *q, const char *name)
++{
++ int ret;
++
++ /* Protect q->elevator from elevator_init() */
++ mutex_lock(&q->sysfs_lock);
++ ret = __elevator_change(q, name);
++ mutex_unlock(&q->sysfs_lock);
++
++ return ret;
++}
+ EXPORT_SYMBOL(elevator_change);
+
+ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
+@@ -997,7 +1009,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
+ if (!q->elevator)
+ return count;
+
+- ret = elevator_change(q, name);
++ ret = __elevator_change(q, name);
+ if (!ret)
+ return count;
+
+
+--
+To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at http://www.tux.org/lkml/
diff --git a/kernel.spec b/kernel.spec
index 895db18..3b6b131 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -773,6 +773,10 @@ Patch25111: rpc-comment-on-linux_cred-encoding-treat-all-as-unsigned.patch
Patch25112: rpc-fix-huge-kmallocs-in-gss-proxy.patch
Patch25113: rpc-let-xdr-layer-allocate-gssproxy-receieve-pages.patch
+#rhbz 902012
+Patch25114: elevator-Fix-a-race-in-elevator-switching-and-md.patch
+Patch25115: elevator-acquire-q-sysfs_lock-in-elevator_change.patch
+
# END OF PATCH DEFINITIONS
%endif
@@ -1494,6 +1498,10 @@ ApplyPatch rpc-let-xdr-layer-allocate-gssproxy-receieve-pages.patch
ApplyPatch 0001-skge-fix-broken-driver.patch
ApplyPatch skge-fix-invalid-value-passed-to-pci_unmap_sigle.patch
+#rhbz 902012
+ApplyPatch elevator-Fix-a-race-in-elevator-switching-and-md.patch
+ApplyPatch elevator-acquire-q-sysfs_lock-in-elevator_change.patch
+
# END OF PATCH APPLICATIONS
%endif
@@ -2306,6 +2314,9 @@ fi
# and build.
%changelog
+* Fri Sep 27 2013 Josh Boyer <jwboyer at fedoraproject.org>
+- Add patches to fix soft lockup from elevator changes (rhbz 902012)
+
* Fri Sep 27 2013 Justin M. Forbes <jforbes at fedoraproject.org> - 3.11.2-200
- Linux v3.11.2
More information about the scm-commits
mailing list