Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp180798imm; Tue, 19 Jun 2018 18:46:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlgUmblC1vFa2A1qzsfzU9CI2AjWTPDj63qENQu6I5Gvrmt4Em5f8HGIK3K/vMs8QGuXad X-Received: by 2002:a65:55c6:: with SMTP id k6-v6mr16782918pgs.6.1529459186407; Tue, 19 Jun 2018 18:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529459186; cv=none; d=google.com; s=arc-20160816; b=dkuh1HHXVaJbvA4d09O5jq1Ae1THs9SJamorPcmzkuaZaf1nGOMF8/3mov3tQZ8aGg zFDscg741ebwQh8aWGGrtKLmWrVtqa/ElNihh2VN6QUcaY/mesfCzVGs3ROjJcp5wkbk QK8OsO2iOz0SgBnbRyUar5Uu0Nu7WYR4uCFeBr09jrSzf3gGUIA3Fnu6jXgLFyCQUCwz zgKJX3zsHX+PnepdNXQiEOIK6g0+zGEqk7x/nvkAc8uPGcf4fzEQTAhuMi/ts4B6T0g4 xe1u8XcTLagKqIQk3S7kNhNHP7IU5/vzKNpxh2hkRFQrCqq9qSrLH3xIiD0nqES6NjqF HBNQ== 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=EKGq6x9fO7+YfmfTEuW519s22L73T5vMVoDu8mUS+sA=; b=eyZ9AGUFB384VablY9ZukEDZ4BSNIo+kTAEz3GosYlmpXjJ1JEqEvOGHS/nahtNedr 02rXclgoG99ey2scOcC7tjvSuFNxSwL5d/0tXx2QJhfKLb0ZLKsoK11kpXLRvmxpuCbM SyJ76cUrUaNlHftd0bdsAMpl/aUK/s4vE5i/IDETEODKvZy1jiSfBY5VnuVNx+f4lL9Z zhBOfPBX4Owkjzp2BFYU0jasXGUn8euYzjrQPjHdRZR7kUVQROpS59qSuD8jx9VurnmF cg2TEWB+khiw4YXsklmMUXA2/3SMLCK2Hcp76EDPxZKqsg8W46yziG/bWKg39s5haEbM CVlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=s7kLRTle; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12-v6si887963pgn.459.2018.06.19.18.46.12; Tue, 19 Jun 2018 18:46:26 -0700 (PDT) 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=@oracle.com header.s=corp-2017-10-26 header.b=s7kLRTle; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754097AbeFTBpN (ORCPT + 99 others); Tue, 19 Jun 2018 21:45:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33532 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861AbeFTBpK (ORCPT ); Tue, 19 Jun 2018 21:45:10 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5K1j9Jw042734; Wed, 20 Jun 2018 01:45:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=EKGq6x9fO7+YfmfTEuW519s22L73T5vMVoDu8mUS+sA=; b=s7kLRTleMiA+DtH4cCL2hCYp5JxPrvRpcaRf+DF6ecNOn4yMdenCa08/7Rr/g1XX25Ji T4NjsTb9QNQ4emYEfjXlFxwy52WUsbv6a3SVr1oNh+6bJFthPIKnjCAM4y0y/1YzgJz3 N4k74ac/zwNaDH8kzOcbr4IgieQzZiP3K3kozjkspeT9JEzkWGZqNKlPnx0xZXu47wdS gizUvPQ3i/GvzveNVY7AkOP3w6AFaJ4xvypLSwBxihspUfKqdP7gWx8jZOQIQuLAUSvm 8jIIX0Br6d4RzcvAWvgIqqRSmkzyjxJo61FxvFrxnQQSs8NMr4Ku7gsG7OrgjW3DXCwP GQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2jmtgwtfuu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jun 2018 01:45:08 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5K1j8XR007421 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jun 2018 01:45:08 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5K1j7xg023420; Wed, 20 Jun 2018 01:45:07 GMT Received: from [10.182.69.179] (/10.182.69.179) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 19 Jun 2018 18:45:07 -0700 Subject: Re: [PATCH] blk-mq: use blk_mq_timeout_work to limit the max timeout To: Bart Van Assche , "axboe@kernel.dk" Cc: "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" References: <1529391610-1654-1-git-send-email-jianchao.w.wang@oracle.com> <884a5cbb5622ca5c890585a8d5dff0e3a1d60cfe.camel@wdc.com> <08b5a3e94f2265815a98abae7a8dde0894512d4e.camel@wdc.com> From: "jianchao.wang" Message-ID: Date: Wed, 20 Jun 2018 09:45:26 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8929 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806200017 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/20/2018 09:37 AM, jianchao.wang wrote: > > > On 06/20/2018 09:35 AM, Bart Van Assche wrote: >> On Wed, 2018-06-20 at 09:28 +0800, jianchao.wang wrote: >>> Hi Bart >>> >>> Thanks for your kindly response. >>> >>> On 06/19/2018 11:18 PM, Bart Van Assche wrote: >>>> On Tue, 2018-06-19 at 15:00 +0800, Jianchao Wang wrote: >>>>> blk_rq_timeout is needed to limit the max timeout value, otherwise, >>>>> a idle hctx cannot be deactivated timely in shared-tag case. >>>>> >>>>> Fixes: 12f5b931 (blk-mq: Remove generation seqeunce) >>>>> Signed-off-by: Jianchao Wang >>>>> --- >>>>> block/blk-mq.c | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/block/blk-mq.c b/block/blk-mq.c >>>>> index 70c65bb..ccebe7b 100644 >>>>> --- a/block/blk-mq.c >>>>> +++ b/block/blk-mq.c >>>>> @@ -868,7 +868,7 @@ static void blk_mq_timeout_work(struct work_struct *work) >>>>> blk_mq_queue_tag_busy_iter(q, blk_mq_check_expired, &next); >>>>> >>>>> if (next != 0) { >>>>> - mod_timer(&q->timeout, next); >>>>> + mod_timer(&q->timeout, blk_rq_timeout(round_jiffies_up(next))); >>>>> } else { >>>>> /* >>>>> * Request timeouts are handled as a forward rolling timer. If >>>> >>>> Hello Jianchao, >>>> >>>> What makes you think that it would be necessary to call blk_rq_timeout() from >>>> blk_mq_timeout_work()? Have you noticed that blk_add_timer() already calls that >>>> function? I think it is not necessary to call blk_rq_timeout() from >>>> blk_mq_timeout_work() because it is guaranteed in that function that the next >>>> timeout is less than BLK_MAX_TIMEOUT jiffies in the future. >>>> >>> >>> blk_add_timer will not re-arm the timer if the timer's expire value is before the new rq's expire value. >>> >>> Let's look at the following scenario. >>> >>> 0 +30s >>>> __________________|___| >>> >>> T0 T1 T2 >>> >>> T1 = T2 - 1 jiffies >>> >>> T0: rq_a is issued and q->timer is armed and will expire at T2 >>> then rq_a is completed. >>> T1: rq_b is issued and q->timer is not re-armed, because its next expire time is T2 < (T1 + 30s) >>> >>> T2: if rq_b have not been completed when timer expires at T2, timer would be re-armed based on the rq_b >>> If we don't have blk_rq_timeout here, the next expire time is about T2 + 30s. >> >> Hello Jianchao, >> >> I disagree with the last sentence above. I think for your example blk_mq_req_expired() >> will set next to T1 + 30s instead of T2 + 30s. >> > > Would you please explain the reason ? > Oops, yes, it is T1. I thought you were saying T0. :) In this scenario, I have said, the T1 = T2 - 1 jiifies, it is very closed to T2. So I said "the next expire time is about T2 + 30s" It's my bad description. The next time is T1 + 30s, but it is also not a good value > Thanks > Jianchao > >> Bart. >> >> >