Received: by 10.223.176.46 with SMTP id f43csp413428wra; Fri, 19 Jan 2018 20:29:36 -0800 (PST) X-Google-Smtp-Source: AH8x226gMPbIo73w+s6WfLV5Zy+eqoxIn2Zf33/9/7ak/BXHU6KyJCMltMI2MlPqpK7TmdYnmCuY X-Received: by 10.101.74.71 with SMTP id a7mr821682pgu.32.1516422575946; Fri, 19 Jan 2018 20:29:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516422575; cv=none; d=google.com; s=arc-20160816; b=pXprBEagMSI4bNbhEJk3IhBVZvw4QmewISr7DA5BpryQyTaKJF+te70XwQqEA3UtGl UzvvUePkAwpjqQAvLp9Tyo1NdnkpE/NDTXidVahhwSlmJUFBD1h5tWXzLxE4vzYkglqi 31X3MGIAeIDGn+AfOg9vKhCbYjhAmVXYv8yJgmfkE+7Ysr4Sa0DQwzFnc7VtN2kHSn1/ TIecKORDBu/cq6aiefPbetmn7wYp7grHUjuwCwG3R4UqgTb0G8zOKYNz7J9N7RD3T8dl +cInu3qc5WPeEUAnCEcVoxVnLhk3YU582pGXNlKQdW2tsgnkuBp3WAoLBmaGyAbqZsWq lyVA== 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:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Outwp7Khq0mrywQdozCaL8nqpE1DfUelN3/gjXXiIz4=; b=N0TdbNVhv34n6XTqtLA3kbG9Nsq+FrLfqC6U4uiseh3s/V0s4jioyzen+o2NVm9WIA YcxDWSfw6Ld7YB3jmrIe7MC1dOztm5A1lmutGkpbUO+UZXYrlxoQYswVXV+MfJ4jwJlx eKIviy4P8fuuwus4oWTjHascsPo0cesKVe4O+BaSWuQ3HooOkwRL/lM0WDp86QPOWc0A m7HKyw3bZr45QDlX9jNminzp9SdB65gemUso83a7/daX3jGTMY6ZMv3LjNKJhlbpa7zT UZ/84lY7QXcQhkM4aGO4kaUiLmp3TFhthzexGEhfFDDZa4RrHBVTKMvx8lYH+X8tzd9d p5Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=peNLJcSi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k126si9703492pgc.638.2018.01.19.20.29.22; Fri, 19 Jan 2018 20:29:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=peNLJcSi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754862AbeATE1c (ORCPT + 99 others); Fri, 19 Jan 2018 23:27:32 -0500 Received: from mail-pg0-f47.google.com ([74.125.83.47]:35010 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753427AbeATE1Y (ORCPT ); Fri, 19 Jan 2018 23:27:24 -0500 Received: by mail-pg0-f47.google.com with SMTP id d6so2915860pgv.2 for ; Fri, 19 Jan 2018 20:27:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Outwp7Khq0mrywQdozCaL8nqpE1DfUelN3/gjXXiIz4=; b=peNLJcSiIwl3fGpxzf39FK3jqTTfcnS9K3f3kDBXqZ/nSQECWE81cKVrX7t3byuzL4 rVv2XrrTw6Hc8kT3Yxj1CLJIafwBoJEAAocQ+qNKMLkGXuadUI+Kh3giAqQFG4LvoMkO YQnUEH2ZBhcavxsZA9Po1gA+CbTC1SMuBhHP6PcSoIKaBDZF/y06h3WTU8ys7PieGmCl MB78Qp+sbErNF9xajYmaEgb5S+lkmW53z/U2dBSKY09pgcWwv4dEZSgNvCXZKb7Yh8FB hGtnIvb26oHnMgBcqbISHoqgac7GtfdJehvNb+zssjJw36UYxpIFau1eLUGZJ85h5N1S ZZVg== 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:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Outwp7Khq0mrywQdozCaL8nqpE1DfUelN3/gjXXiIz4=; b=lnQkl0KswgBq/y+VZSsV0Zp1ZF+FB9hbFYf/txdz8mbC7TZN/05ZwWgS2HGxXFJZqT bmAKABvzTteXKAWO1fHA04DKv2DJOuYq//5taixx09l82kHvKwTkhumGCMHE6AF6Q+2z QZY7Q1VVY7aVDBbtH0N4MO6yRWHRIECJ9D/sZJXp7FI5uZ8ziFr+oxdjz4eHS155QSsU 5com+jg/mWeMCF373cM/eLGgflkv+SIX07angJO2VaZn1T2Qyn7dDZHFueYStSoMIN0+ WnxS+naJ6e5avbBW1fb7sENUuuMJdPLn5G0XCuVzyndmnj+haLbgDPCPNCDvCSmoXeQR etTQ== X-Gm-Message-State: AKwxytfL+yWkq7QC7M6sOC3Q8vo6hbxfpxSjj8RzUSUV3oDcpQNoy3yp 1L4LgrRNwK15CskRxGccqPesVQ== X-Received: by 10.99.95.4 with SMTP id t4mr746831pgb.291.1516422443367; Fri, 19 Jan 2018 20:27:23 -0800 (PST) Received: from ?IPv6:2620:10d:c081:1130::1575? ([2620:10d:c090:180::68d8]) by smtp.gmail.com with ESMTPSA id n66sm11115060pfn.111.2018.01.19.20.27.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jan 2018 20:27:21 -0800 (PST) Subject: Re: [RFC PATCH] blk-mq: fixup RESTART when queue becomes idle To: Ming Lei Cc: Bart Van Assche , "snitzer@redhat.com" , "dm-devel@redhat.com" , "hch@infradead.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "osandov@fb.com" References: <20180119072623.GB25369@ming.t460p> <047f68ec-f51b-190f-2f89-f413325c2540@kernel.dk> <20180119154047.GB14827@ming.t460p> <540e1239-c415-766b-d4ff-bb0b7f3517a7@kernel.dk> <20180119160518.GC14827@ming.t460p> <4a5c049f-0fab-bbaf-bfe2-eb5bca73f2c8@kernel.dk> <20180119162618.GD14827@ming.t460p> <1f072086-533e-4b75-d0e3-9e621b2120d8@kernel.dk> <20180119163736.GE14827@ming.t460p> <20180119235247.GA17195@ming.t460p> From: Jens Axboe Message-ID: Date: Fri, 19 Jan 2018 21:27:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Thunderbird/58.0 MIME-Version: 1.0 In-Reply-To: <20180119235247.GA17195@ming.t460p> 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 1/19/18 4:52 PM, Ming Lei wrote: > On Fri, Jan 19, 2018 at 10:38:41AM -0700, Jens Axboe wrote: >> On 1/19/18 9:37 AM, Ming Lei wrote: >>> On Fri, Jan 19, 2018 at 09:27:46AM -0700, Jens Axboe wrote: >>>> On 1/19/18 9:26 AM, Ming Lei wrote: >>>>> On Fri, Jan 19, 2018 at 09:19:24AM -0700, Jens Axboe wrote: >>>>>> On 1/19/18 9:05 AM, Ming Lei wrote: >>>>>>> On Fri, Jan 19, 2018 at 08:48:55AM -0700, Jens Axboe wrote: >>>>>>>> On 1/19/18 8:40 AM, Ming Lei wrote: >>>>>>>>>>>> Where does the dm STS_RESOURCE error usually come from - what's exact >>>>>>>>>>>> resource are we running out of? >>>>>>>>>>> >>>>>>>>>>> It is from blk_get_request(underlying queue), see >>>>>>>>>>> multipath_clone_and_map(). >>>>>>>>>> >>>>>>>>>> That's what I thought. So for a low queue depth underlying queue, it's >>>>>>>>>> quite possible that this situation can happen. Two potential solutions >>>>>>>>>> I see: >>>>>>>>>> >>>>>>>>>> 1) As described earlier in this thread, having a mechanism for being >>>>>>>>>> notified when the scarce resource becomes available. It would not >>>>>>>>>> be hard to tap into the existing sbitmap wait queue for that. >>>>>>>>>> >>>>>>>>>> 2) Have dm set BLK_MQ_F_BLOCKING and just sleep on the resource >>>>>>>>>> allocation. I haven't read the dm code to know if this is a >>>>>>>>>> possibility or not. >>>>>>>>>> >>>>>>>>>> I'd probably prefer #1. It's a classic case of trying to get the >>>>>>>>>> request, and if it fails, add ourselves to the sbitmap tag wait >>>>>>>>>> queue head, retry, and bail if that also fails. Connecting the >>>>>>>>>> scarce resource and the consumer is the only way to really fix >>>>>>>>>> this, without bogus arbitrary delays. >>>>>>>>> >>>>>>>>> Right, as I have replied to Bart, using mod_delayed_work_on() with >>>>>>>>> returning BLK_STS_NO_DEV_RESOURCE(or sort of name) for the scarce >>>>>>>>> resource should fix this issue. >>>>>>>> >>>>>>>> It'll fix the forever stall, but it won't really fix it, as we'll slow >>>>>>>> down the dm device by some random amount. >>>>>>>> >>>>>>>> A simple test case would be to have a null_blk device with a queue depth >>>>>>>> of one, and dm on top of that. Start a fio job that runs two jobs: one >>>>>>>> that does IO to the underlying device, and one that does IO to the dm >>>>>>>> device. If the job on the dm device runs substantially slower than the >>>>>>>> one to the underlying device, then the problem isn't really fixed. >>>>>>> >>>>>>> I remembered that I tried this test on scsi-debug & dm-mpath over scsi-debug, >>>>>>> seems not observed this issue, could you explain a bit why IO over dm-mpath >>>>>>> may be slower? Because both two IO contexts call same get_request(), and >>>>>>> in theory dm-mpath should be a bit quicker since it uses direct issue for >>>>>>> underlying queue, without io scheduler involved. >>>>>> >>>>>> Because if you lose the race for getting the request, you'll have some >>>>>> arbitrary delay before trying again, potentially. Compared to the direct >>>>> >>>>> But the restart still works, one request is completed, then the queue >>>>> is return immediately because we use mod_delayed_work_on(0), so looks >>>>> no such issue. >>>> >>>> There are no pending requests for this case, nothing to restart the >>>> queue. When you fail that blk_get_request(), you are idle, nothing >>>> is pending. >>> >>> I think we needn't worry about that, once a device is attached to >>> dm-rq, it can't be mounted any more, and usually user don't use the device >>> directly and by dm-mpath at the same time. >> >> Here's an example of that, using my current block tree (merged into >> master). The setup is dm-mpath on top of null_blk, the latter having >> just a single request. Both are mq devices. >> >> Fio direct 4k random reads on dm_mq: ~250K iops >> >> Start dd on underlying device (or partition on same device), just doing >> sequential reads. >> >> Fio direct 4k random reads on dm_mq with dd running: 9 iops >> >> No schedulers involved. >> >> https://i.imgur.com/WTDnnwE.gif > > If null_blk's timer mode is used with a bit delay introduced, I guess > the effect from direct access to underlying queue shouldn't be so > serious. But it still won't be good as direct access. Doesn't matter if it's used at the default of 10usec completion latency, or inline complete. Same result, I ran both. > Another way may be to introduce a variants blk_get_request(), such as > blk_get_request_with_notify(), then pass the current dm-rq's hctx to > it, and use the tag's waitqueue to handle that. But the change can be > a bit big. Yes, that's exactly the solution I suggested both yesterday and today. -- Jens Axboe