Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2313291pxk; Mon, 14 Sep 2020 09:57:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxltTM7f+hUUJUZNqpMfUI/uxhCXwZ6KEtaNH8XPrelOVje8FyyVEF+qrcq1/cyJ+jUZE24 X-Received: by 2002:a17:906:49cd:: with SMTP id w13mr15418123ejv.151.1600102651876; Mon, 14 Sep 2020 09:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600102651; cv=none; d=google.com; s=arc-20160816; b=QaZKdsqehqnPxl1OfL1yACHxML7xVMOKAv4o08dIj6t4z0Ui+C54uexv5r/EWw7ts6 GzbBIX9B3+6tfZx9lkpM2X/LNFcCqQha5lsqeKSLiduaGcaYePaL5qKWCeZ+LjG/jPGB hIgOC/QFKQPiv7QsguKuhnyppf+gIErVTrOSc6Bw/Q9seNGnG1SpfMfSQ4AeOCP1wXEY VJBI8Nk+PcDOQTOP4TCQhA1MX6YGW+zaoDE2YfFces0qW1jI6n5MwN+hCWBlbeNUrlct iAR30xnz3e/ayYcIg+CRnLEu24H/S1tSs1XfaVSWgWAXnZebNRp8guPMPWGY4Cr/Btaf ekgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=v48L7JGX53l/CPfgPRdRY47vGmb+Jr3vZoi7acfa0+s=; b=ao8h08PmvAwpCtna71GRhCoJh6CT/DeUIWG8ZXFZa8DedNtxfiifVTsDrqFo63CeQH mLA789BQLfMtNRBZnfK3cpmBGTzegrGNsLu5gltKUpN0WA9GJI30gbteGkIRDKOONFyJ eNf8s6NbonuPyVP7Be0cNLIejRGA3kepNCRbSBeWfqLV9Y9BEsMtpM3RhhBy2BTAZG8x RgHOh8DtZna2EUrmD3Qe2EcvzTWe5S9tmBx7J4je591MCgbNb7sztzQ3p8Zx+2rI7M6L F4GQOwooaiDpxZUckxj29GkLMYbMnLzGHE+AGYMr6cPn1oYP1FEISAkKVu95b7u45FPT oNew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v26si7722753edd.443.2020.09.14.09.57.08; Mon, 14 Sep 2020 09:57:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726189AbgINQ42 (ORCPT + 99 others); Mon, 14 Sep 2020 12:56:28 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44888 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbgINQsk (ORCPT ); Mon, 14 Sep 2020 12:48:40 -0400 Received: by mail-pg1-f195.google.com with SMTP id 7so211228pgm.11; Mon, 14 Sep 2020 09:48:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=v48L7JGX53l/CPfgPRdRY47vGmb+Jr3vZoi7acfa0+s=; b=R1otZGJKzYcNcf/JYO0gR3t3fgIgp5hM03CWtrRL4qEeO9VFvVY/9tpQDjM4OiQU2f Ys90t0atxrSx5Ya2X9UuzX37h/hvEi1zSnusYYziBYV2NTaxgszkEuhD/ZoTNK97OiT/ yCqIzwT4eGRIaRxOjy9iYrRqo8DPp+FGaOEkyiZxsTp4muJ85gTwxbPiKiymvnccV4Xy AQI/ksytNeCmMNmZshCKFGIYR97IB1kBtLybkAOi23jOsgF/6Upa8xLoP9DgLa0kB510 MKM08AFmilTy0b9oqryyaQB2dhzrBypTFoXiDt8m/2WxY5jRF4++DYPHoxLG7GhXal6R ci/Q== X-Gm-Message-State: AOAM531O8FrBWLVWpX7mKw7E7pV1kWEjjviw/McpFImNlIgtMs5A64VA zAjPpSdFK5/sHj7tP+fyNQh4ADD24Xk= X-Received: by 2002:a62:d44e:0:b029:13c:1611:652f with SMTP id u14-20020a62d44e0000b029013c1611652fmr14027695pfl.15.1600102089878; Mon, 14 Sep 2020 09:48:09 -0700 (PDT) Received: from ?IPv6:2601:647:4000:d7:3f5a:7698:1b81:cc96? ([2601:647:4000:d7:3f5a:7698:1b81:cc96]) by smtp.gmail.com with ESMTPSA id g23sm10805716pfh.133.2020.09.14.09.48.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 09:48:08 -0700 (PDT) Subject: Re: [PATCH] blk-mq: fix hang issue in blk_queue_enter() To: Yang Yang , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: onlyfever@icloud.com References: <20200914071903.65704-1-yang.yang@vivo.com> From: Bart Van Assche Autocrypt: addr=bvanassche@acm.org; prefer-encrypt=mutual; keydata= mQENBFSOu4oBCADcRWxVUvkkvRmmwTwIjIJvZOu6wNm+dz5AF4z0FHW2KNZL3oheO3P8UZWr LQOrCfRcK8e/sIs2Y2D3Lg/SL7qqbMehGEYcJptu6mKkywBfoYbtBkVoJ/jQsi2H0vBiiCOy fmxMHIPcYxaJdXxrOG2UO4B60Y/BzE6OrPDT44w4cZA9DH5xialliWU447Bts8TJNa3lZKS1 AvW1ZklbvJfAJJAwzDih35LxU2fcWbmhPa7EO2DCv/LM1B10GBB/oQB5kvlq4aA2PSIWkqz4 3SI5kCPSsygD6wKnbR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v1By4SKGhmzwH87uXxbTJAUxiWIi1np0z3/RDnoVyfmfbbL1DY7zf2hYXLLzsJR mSsED/1nlJ9Oq5fALdNEPgDyPUerqHxcmIub+pF0AzJoYHK5punqpqfGmqPbjxrJLPJfHVKy goMj5DlBMoYqEgpbwdUYkH6QdizJJCur4icy8GUNbisFYABeoJ91pnD4IGei3MTdvINSZI5e Message-ID: <1f7aa460-6a6c-d200-786e-bfccf5fc2bff@acm.org> Date: Mon, 14 Sep 2020 09:48:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200914071903.65704-1-yang.yang@vivo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-09-14 00:19, Yang Yang wrote: > There is a race between blk_queue_enter() and block layer's runtime > suspend. > > CPU0 CPU1 > --------------------------------- ------------------------------- > blk_pre_runtime_suspend(q) { blk_queue_enter() { > /* q->rpm_status=RPM_ACTIVE */ > blk_set_pm_only(q) > /* q->pm_only=1 */ > blk_freeze_queue_start(q) > blk_mq_unfreeze_queue(q) > if (percpu_ref_tryget_live()) { > /* pm=0 && q->pm_only=1 */ > if (pm || !blk_queue_pm_only(q)) { > } else { > percpu_ref_put() > } > } > wait_event(q->mq_freeze_wq, > (!q->mq_freeze_depth && > /* q->rpm_status=RPM_ACTIVE > q->pm_only=1 */ > (pm || (blk_pm_request_resume(q), > !blk_queue_pm_only(q)))) || > blk_queue_dying(q)) > } > spin_lock_irq(&q->queue_lock) > q->rpm_status = RPM_SUSPENDING > spin_unlock_irq(&q->queue_lock) > } > > At this point blk_pm_request_resume() missed the chance to resume the > queue, so blk_queue_enter() may wait here forever. > The solution is to wake up the mq_freeze_wq after runtime suspend > completed, make blk_pm_request_resume() reexamine the q->rpm_status flag. > > Signed-off-by: Yang Yang > --- > block/blk-pm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/block/blk-pm.c b/block/blk-pm.c > index b85234d758f7..dec7d0aef606 100644 > --- a/block/blk-pm.c > +++ b/block/blk-pm.c > @@ -132,6 +132,8 @@ void blk_post_runtime_suspend(struct request_queue *q, int err) > > if (err) > blk_clear_pm_only(q); > + else > + wake_up_all(&q->mq_freeze_wq); > } > EXPORT_SYMBOL(blk_post_runtime_suspend); Please verify whether the following patch series also fixes the reported hang: https://lore.kernel.org/linux-block/20200906012219.17893-1-bvanassche@acm.org/T/#t Thanks, Bart.