From patchwork Thu Oct 26 15:28:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark O'Donovan X-Patchwork-Id: 158594 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp760459vqb; Thu, 26 Oct 2023 08:29:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRTcIRiMV+LDXDYB46Sn2ARBPjI12mBAyl2MF7ypVQNQZbU4I76sdinyR+opNdrcZ1W6v/ X-Received: by 2002:a9d:6b0f:0:b0:6b7:4a52:a33a with SMTP id g15-20020a9d6b0f000000b006b74a52a33amr18166187otp.14.1698334169934; Thu, 26 Oct 2023 08:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698334169; cv=none; d=google.com; s=arc-20160816; b=x9c8uzWoiay1XyPN6rGzzbfmXa3ny10NFbayS+GZDicEDOyozTu6NFTr5094/bkFa5 Edmw1trlRIOClc9i2oU24ugFjLpQroZVFLHQ2/H6VEt2PzY5US+FXRS0IA+2c6svxuh8 UK7T0YggaiKR0GgAMDN/4V31J+7W04XddPtARq0HnKLg/L8Klv9k8gtMqsUh447OzXf1 XzAv73F451UX8G5Th51+7Hs/vfBYw9OGmqo2vj7XnPgUArrvmHoZ9upHSnfhjjgJnKso a0FAc0EzVEGbHMftKuHI+EYgIGPX6BfI2X5KtwZzaN1aSOr7aGiH7XzL3SVVIdO6Ils4 FzOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Qg8xenpWV+v5VQuCTbPy80HRMo47tpWqPdmDb0kVSN8=; fh=nK/B2gIzvYPsKU0sJgdKEVdz5eoE00hHt727sEimwsQ=; b=OtyyRF20wgEzPzKnzSMEtJ7oRkQEMF3q8fdEZUeiBLrug6zQUc8o348JnNbCbuWdLr +xN9wsEYeZqhFF0wT/+4WPcCQ4EF2lXfPYL/zp0a7LhUsVy0VcSusOQjolXuyz9vHJ6C qRZcey/Y5MLo1BJZZUAWy1nXngdmQrXPuhzq36aCqoGhrv806gXJznPHIAv1UiuEUgM4 3/l9lpH+DITI9T7rueZDUjInK/y95uJdA/wqgS85vGCCbNPEXF6ozOHldt0JswC+P/1H CuEq4OWPjGbitJr5p1+Vh8jkpe88jGuYyHAkQ3eCoI2+Wc6JznuDMGLUh2FfrgUcy8MN uDrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=PpyfEGVH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id a135-20020a0dd88d000000b005a7a7313354si15774276ywe.113.2023.10.26.08.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:29:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=PpyfEGVH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5A723801B679; Thu, 26 Oct 2023 08:29:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345442AbjJZP3P (ORCPT + 26 others); Thu, 26 Oct 2023 11:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231200AbjJZP3N (ORCPT ); Thu, 26 Oct 2023 11:29:13 -0400 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A99D187 for ; Thu, 26 Oct 2023 08:29:08 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 73AAB240106 for ; Thu, 26 Oct 2023 17:29:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698334146; bh=H64qUyJiele93axV3rB3BVXjSk5GIMWyc2Mutlt6LLs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=PpyfEGVH22Gu+tpAxSQXOPSj556OPsPQV3DIadsQDbDG226YkoPexZurUNJIGzgHa 79vfltvsc6QBRvPLz+OPYpDLmXq4h7cFqFs5YZyrUyLAlHCf1YL513LRsEFApuUsWK kXCp/+l4UdqS8/X9xpdwisxQsawxKSlyR7aylWYOxoQSh6jIFVKfKnFPVxxfzNyZjE UCyKD2CGfyQIFV3KKjPbwgZcA2HBwsQPFxnh/Se3MnYxqxrBajiBITmhFbNsT8Cm6E Uz2EY15Ki77Yqg+Ac0YgdCIURJIcidT+UxZKUHF1GZhjblNwysvkMdOc/rtYnrUVpM +ym2OeADlpIPw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SGV800Z7cz9rxN; Thu, 26 Oct 2023 17:29:03 +0200 (CEST) From: Mark O'Donovan To: linux-kernel@vger.kernel.org Cc: linux-nvme@lists.infradead.org, sagi@grimberg.me, hch@lst.de, axboe@kernel.dk, kbusch@kernel.org, hare@suse.de, Mark O'Donovan Subject: [PATCH] nvme: fine-tune sending of first keep-alive Date: Thu, 26 Oct 2023 15:28:57 +0000 Message-Id: <20231026152857.176594-1-shiftee@posteo.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 08:29:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780832450551858742 X-GMAIL-MSGID: 1780832450551858742 Keep-alive commands are sent half-way through the kato period. This normally works well but fails when the keep-alive system is started when we are more than half way through the kato. This can happen on larger setups or due to host delays. With this change we now time the initial keep-alive command from the controller initialisation time, rather than the keep-alive mechanism activation time. Signed-off-by: Mark O'Donovan --- drivers/nvme/host/core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) base-commit: 611da07b89fdd53f140d7b33013f255bf0ed8f34 diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 21783aa2ee8e..f3ca3e1d4a74 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1192,8 +1192,16 @@ static unsigned long nvme_keep_alive_work_period(struct nvme_ctrl *ctrl) static void nvme_queue_keep_alive_work(struct nvme_ctrl *ctrl) { - queue_delayed_work(nvme_wq, &ctrl->ka_work, - nvme_keep_alive_work_period(ctrl)); + unsigned long now = jiffies; + unsigned long delay = nvme_keep_alive_work_period(ctrl); + unsigned long ka_next_check_tm = ctrl->ka_last_check_time + delay; + + if (time_after(now, ka_next_check_tm)) + delay = 0; + else + delay = ka_next_check_tm - now; + + queue_delayed_work(nvme_wq, &ctrl->ka_work, delay); } static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq, @@ -4451,6 +4459,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, INIT_DELAYED_WORK(&ctrl->failfast_work, nvme_failfast_work); memset(&ctrl->ka_cmd, 0, sizeof(ctrl->ka_cmd)); ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive; + ctrl->ka_last_check_time = jiffies; BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) > PAGE_SIZE);