request for 4.14-stable: 1dc3039bc87a ("block: do not use interruptible wait anywhere")
Subsystems (2)
Hi Greg,
This was missing in 4.14-stable. Please apply to your queue.
--
Regards
Sudip
Quoted 1 line
From
d82c7fab69ca2f088c41af99959e37dd3ee76d1dMon Sep 17 00:00:00 2001
From: Alan Jenkins <[email protected]>
Date: Thu, 12 Apr 2018 19:11:58 +0100
Subject: [PATCH] block: do not use interruptible wait anywhere
commit 1dc3039bc87ae7d19a990c3ee71cfd8a9068f428 upstream
When blk_queue_enter() waits for a queue to unfreeze, or unset the PREEMPT_ONLY flag, do not allow it to be interrupted by a signal.
The PREEMPT_ONLY flag was introduced later in commit 3a0a529971ec ("block, scsi: Make SCSI quiesce and resume work reliably"). Note the SCSI device is resumed asynchronously, i.e. after un-freezing userspace tasks.
So that commit exposed the bug as a regression in v4.15. A mysterious SIGBUS (or -EIO) sometimes happened during the time the device was being resumed. Most frequently, there was no kernel log message, and we saw Xorg or Xwayland killed by SIGBUS.[1]
[1] E.g. https://bugzilla.redhat.com/show_bug.cgi?id=1553979
Without this fix, I get an IO error in this test:
while killall -SIGUSR1 dd; do sleep 0.1; done & \ echo mem > /sys/power/state ; \ sleep 5; killall dd # stop after 5 seconds
The interruptible wait was added to blk_queue_enter in
commit 3ef28e83ab15 ("block: generic request_queue reference counting"). Before then, the interruptible wait was only in blk-mq, but I don't think it could ever have been correct.
--- block/blk-core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
block/blk-core.c +3 -6
@@ -779,7 +779,6 @@ EXPORT_SYMBOL(blk_alloc_queue);int blk_queue_enter (struct request_queue *q,bool nowait) {while (true) { -int ret;if (percpu_ref_tryget_live (&q->q_usage_counter))return 0 ;
@@ -796,13 +795,11 @@ int blk_queue_enter(struct request_queue *q, bool nowait)*/ smp_rmb (); - ret =wait_event_interruptible (q->mq_freeze_wq, - !atomic_read (&q->mq_freeze_depth) || -blk_queue_dying (q)); +wait_event (q->mq_freeze_wq, + !atomic_read (&q->mq_freeze_depth) || +blk_queue_dying (q));if (blk_queue_dying (q))return -ENODEV ; -if (ret) -return ret; } }
Signature · 1 line
2.11.0
Greg Kroah-Hartman
maintainerQuoted 3 lines · Sudip Mukherjee
Hi Greg,
This was missing in 4.14-stable. Please apply to your queue.
now applied, thanks.
greg k-h
Quoted 7 lines · Sudip Mukherjee
Hi Greg,
This was missing in 4.14-stable. Please apply to your queue.
--
Regards
Sudip
Hi Sudip,
This is correct, seems low-risk, and I don't mind it going ahead. But I'm curious� why you're interested in it for v4.14.� Mostly, I wonder if the same reason would apply to older kernels as well?
While the bugfix is applicable to v4.14, the nasty X crash on suspend is only on v4.15 and v4.16.� I think I left it to other's judgement, as to whether the bugfix would be wanted outside that case.
IIUC, the bugfix could be applied to *three* of the "longterm" kernel lines: 4.14.56, 4.9.113, 4.4.142.� Since the commit says this bug was introduced to the single-queue block layer in v4.4, commit 3ef28e8 ("block: generic request_queue reference counting").
Regards
Alan******
Hi Alan,
Quoted 9 lines · Alan Jenkins
Quoted 7 lines · Sudip Mukherjee
Hi Greg,
This was missing in 4.14-stable. Please apply to your queue.
--
Regards
Sudip
Quoted 5 lines
Hi Sudip,
This is correct, seems low-risk, and I don't mind it going ahead. But I'm curious� why you're interested in it for v4.14.� Mostly, I wonder if the same reason would apply to older kernels as well?
Well, since I have to use v4.14.y for my dayjob I will like to see all possible fixes landing in 4.14-stable. That makes my dayjob a little easier. :)
Quoted 4 lines
While the bugfix is applicable to v4.14, the nasty X crash on suspend is only on v4.15 and v4.16.� I think I left it to other's judgement, as to whether the bugfix would be wanted outside that case.
My thought was that since you said "or" in your commit message:
"When blk_queue_enter() waits for a queue to unfreeze, or unset the PREEMPT_ONLY flag, do not allow it to be interrupted by a signal", so the fault condition can be when it is waiting on the queue and is interrupted. So even though 'PREEMPT_ONLY' is not there in v4.14.y, we can see the problem just because of getting interrupted while on queue.
Plesase correct me if I was wrong.
Quoted 5 lines
IIUC, the bugfix could be applied to *three* of the "longterm" kernel lines:
4.14.56, 4.9.113, 4.4.142.� Since the commit says this bug was introduced to the single-queue block layer in v4.4, commit 3ef28e8 ("block: genericrequest_queuereference counting").
I will send the backport for v4.9.y and v4.4.y also.
--
Regards
Sudip
Quoted 9 lines · Sudip Mukherjee
Hi Alan,
My thought was that since you said "or" in your commit message:
"Whenblk_queue_enter()waits for a queue to unfreeze, or unset thePREEMPT_ONLYflag, do not allow it to be interrupted by a signal", so the fault condition can be when it is waiting on the queue and is interrupted. So even though 'PREEMPT_ONLY' is not there in v4.14.y, we can see the problem just because of getting interrupted while on queue.Plesase correct me if I was wrong.
You're absolutely right.
I suppose the original commit message might not be quite as clear when added in 4.14.x, so I had biased against that a bit.
pre-v4.15 doesn't fail the suspend test in the commit message, but a test was added to blktests afterwards, which should exactly cover the "or" part.
https://github.com/osandov/blktests/blob/master/tests/block/016
Quoted 5 lines
Quoted 4 lines
IIUC, the bugfix could be applied to *three* of the "longterm" kernel lines:
4.14.56, 4.9.113, 4.4.142. Since the commit says this bug was introduced to the single-queue block layer in v4.4, commit 3ef28e8 ("block: genericrequest_queuereference counting").I will send the backport for v4.9.y and v4.4.y also.