From patchwork Mon Apr 2 22:04:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10320417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C55DC60116 for ; Mon, 2 Apr 2018 22:05:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD91528A37 for ; Mon, 2 Apr 2018 22:05:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AF6128A3A; Mon, 2 Apr 2018 22:05:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 908A128A37 for ; Mon, 2 Apr 2018 22:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754469AbeDBWFC (ORCPT ); Mon, 2 Apr 2018 18:05:02 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:37794 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754429AbeDBWFB (ORCPT ); Mon, 2 Apr 2018 18:05:01 -0400 Received: by mail-yw0-f194.google.com with SMTP id y23so5477049ywy.4; Mon, 02 Apr 2018 15:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rJDRbeg2sSNMCnRH4JiImrcoR9XZ0YOArJrm/vHcnSg=; b=e2B8X+Ym2tWCcCCH5TMLkjAi84J8YHZ2SN3m/Fe7RlxoBadstcXN11VFQBGpErltK1 N/gUizuOYbeXC2a/ao4Q7iYaRrg5OSBoOu44QdCzTgX9YUTHjeSnaXHZSuUe+fXe9KVV KJaNB9SypdLCJih8Kh3zXxup8muDOUpyO9wzLN/3Hjh+AXBH0oHOBExJ4NY4Uifw/E31 RPh2oAI8c8w1AdVPRtcwNvuPGysS7xaZxyR1SD/2azY2bXElC2B9p147TnTwPw4Z182h AUemy1fqDkat7yMm907HU+UB7EaXBCtXsMbV8QFjMowV3jPlbflmtcw62sJ2OfD6FnOh MTPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=rJDRbeg2sSNMCnRH4JiImrcoR9XZ0YOArJrm/vHcnSg=; b=GaHfYvOfpcEFoMQa1OjdrHJdbFfSIiifl6wYng8WVKykO2y4W8NhUZLWmj5/FD893P OLW/++oqzkv4mUn44qOqDNFPQNRsIzQsKKmx43k+TofpMSBQWNs03rgTqh40zY+jV3EA bbab2bhy+mRW2fyORvnRh9b+UHVU9mRRbklnTGdHGCamPCNVWMPqk/pBEQJHtgj/YheW mZGfshplOox5wFhzBn0SG9W9oFjVuVSbpuHIOgEqP4cTd7sbLVigG0RtMUEBJBjScZc9 UMIQSMfCW5kLz/OZLQEGxnBRNobjqQvzGpo+d64Bo1njK7AbXFgz3Z56L+SQWaOgSwkK 3qRg== X-Gm-Message-State: AElRT7HOZDy+OhDWtPqycxyI7ET2LgpQkTNtNOBZ4Bs7BXLzXOj+V3CW g0bNiUU/sWfa6TwYhkjnuc1/ZCjD X-Google-Smtp-Source: AIpwx4//kOqgU4RMDptHMKjibCHNJXc7SjgrkxnSdbVTwi/VrOoITvtARK4Re94lf493XrgeatfM9g== X-Received: by 10.129.69.31 with SMTP id s31mr6222379ywa.367.1522706701059; Mon, 02 Apr 2018 15:05:01 -0700 (PDT) Received: from localhost ([2620:10d:c091:180::1:23de]) by smtp.gmail.com with ESMTPSA id z76sm608675ywz.49.2018.04.02.15.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 15:05:00 -0700 (PDT) Date: Mon, 2 Apr 2018 15:04:58 -0700 From: Tejun Heo To: Sitsofe Wheeler Cc: Jens Axboe , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Stefan Haberland , Jan Hoeppner , Bart Van Assche Subject: [PATCH] blk-mq: Directly schedule q->timeout_work when aborting a request Message-ID: <20180402220458.GJ388343@devbig577.frc2.facebook.com> References: <20180402202951.GE388343@devbig577.frc2.facebook.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Request abortion is performed by overriding deadline to now and scheduling timeout handling immediately. For the latter part, the code was using mod_timer(timeout, 0) which can't guarantee that the timer runs afterwards. Let's schedule the underlying work item directly instead. This fixes the hangs during probing reported by Sitsofe but it isn't yet clear to me how the failure can happen reliably if it's just the above described race condition. Signed-off-by: Tejun Heo Reported-by: Sitsofe Wheeler Reported-by: Meelis Roos Fixes: 358f70da49d7 ("blk-mq: make blk_abort_request() trigger timeout path") Cc: stable@vger.kernel.org # v4.16 Link: http://lkml.kernel.org/r/CALjAwxh-PVYFnYFCJpGOja+m5SzZ8Sa4J7ohxdK=r8NyOF-EMA@mail.gmail.com Link: http://lkml.kernel.org/r/alpine.LRH.2.21.1802261049140.4893@math.ut.ee --- Hello, I don't have the full explanation yet but here's a preliminary patch. Thanks. block/blk-timeout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-timeout.c b/block/blk-timeout.c index a05e367..f0e6e41 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c @@ -165,7 +165,7 @@ void blk_abort_request(struct request *req) * No need for fancy synchronizations. */ blk_rq_set_deadline(req, jiffies); - mod_timer(&req->q->timeout, 0); + kblockd_schedule_work(&req->q->timeout_work); } else { if (blk_mark_rq_complete(req)) return;