From nobody Wed Apr 29 08:13:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9119C43334 for ; Sat, 11 Jun 2022 04:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347516AbiFKEqz (ORCPT ); Sat, 11 Jun 2022 00:46:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347541AbiFKEqu (ORCPT ); Sat, 11 Jun 2022 00:46:50 -0400 Received: from out0-138.mail.aliyun.com (out0-138.mail.aliyun.com [140.205.0.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D5D3719E1; Fri, 10 Jun 2022 21:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alibaba-inc.com; s=default; t=1654922803; h=Date:From:To:Message-ID:Subject:MIME-Version:Content-Type; bh=QTu5c2AsKOp6O4fWUnSs1v4gHqsCVklvaNllZ7AbTYI=; b=i+8/E59a3TELE0fLZsavCKoN6pSlIfGhQEDu2po/PbHBNJYsDdvtvbE1WFQ2789ts47IIs/TBE+BGLUjyar/0XvyYx+hEuPMERtdX0cehaC+1AM6JUw9NiVuQC/K4LPIVzkO39M3widePjZpUSI53mCrV7IEnoBPIxlbuad729U= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047205;MF=zhaowuyun.zwy@alibaba-inc.com;NM=1;PH=DW;RN=5;SR=0;TI=W4_0.1.30_v5ForWebDing_212543F5_1654922517723_o7001c314; Received: from WS-web (zhaowuyun.zwy@alibaba-inc.com[W4_0.1.30_v5ForWebDing_212543F5_1654922517723_o7001c314]) by ay29a011140100218.et135 at Sat, 11 Jun 2022 12:46:42 +0800 Date: Sat, 11 Jun 2022 12:46:42 +0800 From: "=?UTF-8?B?6LW15q2m5LqR?=" To: "axboe" , "jejb" , "martin.petersen" Cc: "linux-block" , "linux-kernel" Reply-To: "=?UTF-8?B?6LW15q2m5LqR?=" Message-ID: <4a2754ad-d76d-482f-9337-5364d46cd38d.zhaowuyun.zwy@alibaba-inc.com> Subject: =?UTF-8?B?W1BBVENIXSBibG9jazogcGVlayBQTSByZXF1ZXN0cyBkdXJpbmcgcnVudGltZSBQTQ==?= X-Mailer: [Alimail-Mailagent revision 5][W4_0.1.30][v5ForWebDing][Chrome] MIME-Version: 1.0 x-aliyun-mail-creator: W4_0.1.30_v5ForWebDing_M3LTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTVfNykgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzEwMi4wLjUwMDUuNjEgU2FmYXJpLzUzNy4zNg==vN Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zhao Wuyun queue blocked during runtime PM when at the following situation: process A: runtime suspend run and set the PM status to RPM_SUSPENDING then run req with RQF_PM with blk_execute_rq(req->q, NULL, req, 1) then the req queued to head it is not executed when the driver is busy process B: normal device management operation run req with no RQF_PM with blk_execute_rq(req->q, NULL, req, 1) the the req is queued in front of the RQF_PM req of process A __blk_run_queue still not run because the first req is non RQF_PM req and with RQF_SOFTBARRIER, so the queue is totally blocked when at RPM_SUSPENDING status. see the following task calltrace: process A: [] __switch_to+0x10c [] __schedule+0x670 [] schedule+0x74 [] schedule_timeout+0x328 [] io_schedule_timeout+0x24 [] wait_for_common_io+0x90 [] wait_for_completion_io_timeout+0x24 [] blk_execute_rq+0x88 [] scsi_execute+0x114 [] sd_sync_cache+0xfc [] sd_suspend_common+0x58 [] sd_suspend_runtime+0x20 [] scsi_runtime_suspend+0x70 [] __rpm_callback+0xcc [] rpm_callback+0x5c [] rpm_suspend+0x1e8 [] pm_runtime_work+0x7c [] process_one_work+0x1bc [] worker_thread+0x214 [] kthread+0x11c [] ret_from_fork+0x10 process B: [] __switch_to+0x10c [] __schedule+0x670 [] schedule+0x74 [] schedule_timeout+0x328 [] io_schedule_timeout+0x24 [] wait_for_common_io+0x90 [] wait_for_completion_io_timeout+0x24 [] blk_execute_rq+0x88 [] scsi_execute+0x114 [] scsi_test_unit_ready+0x70 [] sd_check_events+0xd4 [] disk_check_events+0x58 [] disk_events_workfn+0x20 [] process_one_work+0x1bc [] worker_thread+0x214 [] kthread+0x11c [] ret_from_fork+0x10 Signed-off-by: Zhao Wuyun --- block/blk-core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index a33775cd97be..8b9272bfdc09 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2856,6 +2856,15 @@ static struct request *elv_next_request(struct reque= st_queue *q) if (blk_pm_allow_request(rq)) return rq; =20 + /* + * let the PM request run, + * or the queue may be blocked by the non-PM request + * with RQF_SOFTBARRIER forever while doing runtime PM. + */ + if (q->rpm_status =3D=3D RPM_SUSPENDING + || q->rpm_status =3D=3D RPM_RESUMING) + continue; + if (rq->rq_flags & RQF_SOFTBARRIER) break; } --=20 2.32.1 (Apple Git-133)