From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7429EC47404 for ; Sun, 6 Oct 2019 00:01:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3AFC8222C0 for ; Sun, 6 Oct 2019 00:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570320093; bh=4oeBq7insg46SLcvkfh+2e9rk9Uf26qTSsU/Q2XHRX0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=xMLhiDte8zkB1hkrgqCTah34/fkq+926+gq6RPogeQ+Iu7d2hmGf6HXMC9ne8iTQc 466PmqqlcIv3hvYQtTtO1HVURvcdSATX3SLqohsL4e4+4wv9DcvUJy693GK7TXIyrV lv/F3lLApaQ78n2An9wH45DmjcUyZHaHk6VneMLA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbfJFABc (ORCPT ); Sat, 5 Oct 2019 20:01:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:60502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726706AbfJFABc (ORCPT ); Sat, 5 Oct 2019 20:01:32 -0400 Received: from localhost (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5979C222C0; Sun, 6 Oct 2019 00:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570320091; bh=4oeBq7insg46SLcvkfh+2e9rk9Uf26qTSsU/Q2XHRX0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JSirJ8HY9KKN8GZpCo/Q6b6tBB346n9IdwHfET0zCQKeRmy+l0ztoL8seAW0QHkAI JYuTcqWfSjUL24jfPFn/keUjrnvNKugbv3XRt4iM9lBhCIPtSYOseSqkfDoJmVD48i Ad5x4Jmt2cVK1xxTrWhugpTycMXyh4ZD9H+aH+A4= Date: Sat, 5 Oct 2019 20:01:30 -0400 From: Sasha Levin To: Damien Le Moal Cc: stable@vger.kernel.org, Greg Kroah-Hartman , Jens Axboe Subject: Re: [PATCH] block: mq-deadline: Fix queue restart handling Message-ID: <20191006000130.GE25255@sasha-vm> References: <20191005030318.3786-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20191005030318.3786-1-damien.lemoal@wdc.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Sat, Oct 05, 2019 at 12:03:18PM +0900, Damien Le Moal wrote: >[ Upstream commit cb8acabbe33b110157955a7425ee876fb81e6bbc ] > >Commit 7211aef86f79 ("block: mq-deadline: Fix write completion >handling") added a call to blk_mq_sched_mark_restart_hctx() in >dd_dispatch_request() to make sure that write request dispatching does >not stall when all target zones are locked. This fix left a subtle race >when a write completion happens during a dispatch execution on another >CPU: > >CPU 0: Dispatch CPU1: write completion > >dd_dispatch_request() > lock(&dd->lock); > ... > lock(&dd->zone_lock); dd_finish_request() > rq = find request lock(&dd->zone_lock); > unlock(&dd->zone_lock); > zone write unlock > unlock(&dd->zone_lock); > ... > __blk_mq_free_request > check restart flag (not set) > -> queue not run > ... > if (!rq && have writes) > blk_mq_sched_mark_restart_hctx() > unlock(&dd->lock) > >Since the dispatch context finishes after the write request completion >handling, marking the queue as needing a restart is not seen from >__blk_mq_free_request() and blk_mq_sched_restart() not executed leading >to the dispatch stall under 100% write workloads. > >Fix this by moving the call to blk_mq_sched_mark_restart_hctx() from >dd_dispatch_request() into dd_finish_request() under the zone lock to >ensure full mutual exclusion between write request dispatch selection >and zone unlock on write request completion. > >Fixes: 7211aef86f79 ("block: mq-deadline: Fix write completion handling") >Cc: stable@vger.kernel.org >Reported-by: Hans Holmberg >Reviewed-by: Hans Holmberg >Reviewed-by: Christoph Hellwig >Signed-off-by: Damien Le Moal >Signed-off-by: Jens Axboe I've queued it up for 4.19, thanks! -- Thanks, Sasha