Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13939320rwd; Sat, 24 Jun 2023 09:00:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zbPFktDnp4Q80TXlLgSteZadq9D2mtk9df7NU47lTT8rb1pemgeH+vutfCoFNLrqespHM X-Received: by 2002:a9d:6188:0:b0:6b1:6958:9e1a with SMTP id g8-20020a9d6188000000b006b169589e1amr23269955otk.15.1687622408161; Sat, 24 Jun 2023 09:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687622408; cv=none; d=google.com; s=arc-20160816; b=mKxJJsRB+CzEjjCpTnj6UC8Gqg34WaklVtCrSLglb1hM1/07O5TemjIVf9MqUN3dwE xDK2Di7aeg+ujwLBRvbNdY8/zBecRE3HYsP1Y06aOC5in5W3hRycvZhYX04MQytR1Z1l HHNV53Mcfu1Cl23bwSY3w5w1nUW9edwTcU5KeC79Z5vAtix3Cdz/E2itptTOsy9A0DU+ BbwZbDyJxhU/D1wJfV5uZsVX7IJzftvivtPyTQiC1HLqydu1NvDhn/f7Xpeq3aXfl7oY Qpv//eDh/xwYrtyjmIWKcQ7/Oa9x1QvB77FVoa2f442ET1fudhYO8iFTwrGKo9Ew0rlF coqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=L847Z/bfhdpzZCa7enwUjky+WHNRgKn/tnqWKrdAgwg=; fh=NAZcr8fXepb2CjCGMfqk91xmxK352kA1xOCS5ahYQ4o=; b=gTQ1SOes35x4LKcvoZaSL95J2bRXNotz18BmbMLW+OmrhcEbHiYByTc0VE2uwsob/W iHuCiS+a+dOyu79i/C+HDbcCfuMfqyNRzJN/sUXGTSi8w8LMlwymE/qxymPXJYLomqwa +g83FOxHqD/SBWu+NvZl43XvF7FJBQ04BEl1ZlA8OZ7CgLhuS8gP3NimvuI72hg31Cb0 2BTFNC9LO64bZlhzUz9rmsG10hkXqm2Vi1I3p4jjbDs8Z+vFIo1cPUOgVmJjReUszPzD CcG1C8uFJ3PoZtJFsKc1Xk2efLnnVIOckqNuJrQ0q5meWgfmvHdC3+auIvkv04Mo0yfe ++5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ZBtcsnr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020a656245000000b005533647f7c5si1586074pgv.420.2023.06.24.08.59.55; Sat, 24 Jun 2023 09:00:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ZBtcsnr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231407AbjFXPYf (ORCPT + 99 others); Sat, 24 Jun 2023 11:24:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjFXPYe (ORCPT ); Sat, 24 Jun 2023 11:24:34 -0400 Received: from out-4.mta1.migadu.com (out-4.mta1.migadu.com [IPv6:2001:41d0:203:375::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33FB81987 for ; Sat, 24 Jun 2023 08:24:33 -0700 (PDT) Message-ID: <70ade937-1f94-52a3-7add-b43d3b79e471@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687620269; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L847Z/bfhdpzZCa7enwUjky+WHNRgKn/tnqWKrdAgwg=; b=ZBtcsnr7Gxhz9QxbSy4XAeGU/NKIsReDYjrRoLYMn/1nb+CmQYH/V/j0GK6kLMBb+ZeGka b+TVV6plYkNj6pmz3X3uG8GErqiU2WSVALvNU/SIUE7/+cd2u72uZ5U293j2tQ8Ko6d6vE apoxccqIOZK337h0cjTV6F0LlA3CbzE= Date: Sat, 24 Jun 2023 23:24:04 +0800 MIME-Version: 1.0 Subject: Re: [PATCH] blk-mq: fix incorrect rq start_time_ns and alloc_time_ns after throttled Content-Language: en-US To: Tejun Heo Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chengming Zhou References: <20230601053919.3639954-1-chengming.zhou@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 2023/6/9 06:56, Tejun Heo wrote: > Hello, > > On Tue, Jun 06, 2023 at 06:22:28PM +0800, Chengming Zhou wrote: > ... >> But for plug batched allocation introduced by the commit 47c122e35d7e >> ("block: pre-allocate requests if plug is started and is a batch"), we can >> rq_qos_throttle() after the allocation of the request. This is what the >> blk_mq_get_cached_request() does. >> >> In this case, the cached request alloc_time_ns or start_time_ns is much ahead >> if block in any qos ->throttle(). > > Ah, okay, that's problematic. > Thanks for your review! Sorry for my delay, I was out of the office. >>>> This patch add nr_flush counter in blk_plug, so we can tell if the task >>>> has throttled in any qos ->throttle(), in which case we need to correct >>>> the rq start_time_ns and alloc_time_ns. >>>> >>>> Another solution may be make rq_qos_throttle() return bool to indicate >>>> if it has throttled in any qos ->throttle(). But this need more changes. >>>> >>>> Signed-off-by: Chengming Zhou >>> >>> Depending on the flush behavior and adjusting alloc_time_ns seems fragile to >>> me and will likely confuse other users of alloc_time_ns too. >> >> I agree with you, this code is not good. My basic idea is to adjust the cached >> request alloc_time_ns and start_time_ns when throttled. > > Would it make sense to skip setting the alloc_time_ns during pre-allocation > and set it later when the pre-allocated rq is actually used? That should > jive better. > Ok, I think it's much clearer that we set the alloc_time_ns and start_time_ns to "now" when the pre-allocated rq is actually used. I will send an updated version later. Thanks.