From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 628D8606A31A for ; Wed, 2 Dec 2026 17:13:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=E0mxdCAi; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AnWNKSUs DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Cc:To:Subject: From:Message-ID:MIME-Version:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=eA0Ovef84qpBpn7XCitoI6uwG4+mAgDx0hC7Q4M7+do=; b=E0mxdCAiPCpa6Gn3Zhbd6tBOA/ M+OFSxRhlywRjSPEjlhRwAbc7HDIF0FRgbcrI1Z3eYLjJ6LsHv4u1+TrzQoEIpFrMLFFlYsECjDia BzC4m5Bf1Il3kRbG53FwJKYfDikZESLaZIycxeuRSts79DwIix5URmytq+bOAHmn0hcCqwKuWgHO7 OObO9ILBy36q9/44x65fUKAvTdYYCTmNb8v5d+nEMbKcIf+4bKxvfdc0mSQPPCLbLpFSk184YAX60 Oeo4+33tNNoJtmyWmNW2lZYZyb0OhsbMu/V/h+OJBuMa1KraLHo7ZsDTMn2tDqNoFUzSQHA5E/fQ5 QA5Ez61w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYntU-0000000CKOd-1yNH; Wed, 02 Dec 2026 17:13:24 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYntT-0000000CKNO-0cjW for linux-nvme@lists.infradead.org; Wed, 02 Dec 2026 17:13:23 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id DF78740F83; Wed, 2 Dec 2026 17:13:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67AD71F00893; Wed, 2 Dec 2026 17:13:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796231602; bh=eA0Ovef84qpBpn7XCitoI6uwG4+mAgDx0hC7Q4M7+do=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=AnWNKSUsXYSEmo/HQNWp4g2vX4wl7jZ6dKEQ/Bj57S9jeGsOzw4P6SPPgc/oTXT6L xI8Xr7t1Cu4utrU9fJ32E5JmWY5nvIdVHfBMIIrCOOZnWUDekkCpdpujosTWNI1eiQ 4RbTJ+KvsTCuqB/jgSeXcHFETGU3LqqAXuiK6UM0AfzMhOp8H2qiTnOgouLcv7bXp1 UIgLY21gkD41czx//Psfp+j2BhU3TJxL56eP9y6JSW0Y1pQUe2g39z7QVXN524yQZd 1101qlWPdVcOEU29udAqyTfIsZI7buNvlbj3KtfT72bZle80B2/Am7+RtZQ/2AUvfP MB7NdEXGLV/0A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] nvme: requeue keep-alive work when a Keep Alive fails To: "Andrew Stellman" Cc: linux-nvme@lists.infradead.org In-Reply-To: <20261202164944.49770-1-bugs@stellman-greene.com> References: <20261202164944.49770-1-bugs@stellman-greene.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 17:13:21 +0000 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Linux-nvme" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] nvme: zero-delay ka_work loop in nvme_keep_alive_end_io() when deadline is 0 - [High] nvme: nvme_keep_alive_end_io() re-arms ka_work after nvme_stop_keep_alive() - [Medium] nvme: uncleared comp_seen on error in nvme_keep_alive_end_io() skips retry -- commit df70267c1d3880bdae24c7ceb3c48d593ea8973c Author: Andrew Stellman nvme: requeue keep-alive work when a Keep Alive fails This commit requeues ctrl->ka_work in nvme_keep_alive_end_io() when a Keep Alive command completes with an error while the controller is in NVME_CTRL_LIVE or NVME_CTRL_CONNECTING. > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index f43582e5f6c4a..ca04ff0f437d6 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -1387,6 +1387,8 @@ static enum rq_end_io_ret nvme_keep_alive_end_io(st= ruct request *rq, > dev_err(ctrl->device, > "failed nvme_keep_alive_end_io error=3D%d\n", > status); > + if (state =3D=3D NVME_CTRL_LIVE || state =3D=3D NVME_CTRL_CONNECTING) > + queue_delayed_work(nvme_wq, &ctrl->ka_work, delay); > return RQ_END_IO_NONE; > } > =20 [Severity: High] Can this spin in a zero-delay workqueue loop on nvme_wq if the request fails before nvme_start_request() sets rq->deadline? Keep Alive requests carry REQ_FAILFAST_DRIVER, so when ->queue_rq rejects a command on an unquiesced non-ready admin queue via nvme_fail_nonready_command() (for example in nvme_tcp_queue_rq() after nvme_tcp_complete_timed_out() stops queue 0 while in NVME_CTRL_CONNECTING), the request completes immediately with rq->deadline still 0. nvme_keep_alive_end_io() then computes rtt as jiffies + rq->timeout, logs an unratelimited warning, sets delay =3D 0, and requeues ctrl->ka_work with a delay of 0. [Severity: High] Can this re-arm ctrl->ka_work after nvme_stop_keep_alive() has already returned during admin queue teardown in NVME_CTRL_CONNECTING? In nvme_tcp_setup_ctrl() and nvme_rdma_setup_ctrl(), the destroy_admin error path (as well as the TLS secure concatenation admin queue restart) calls nvme_stop_keep_alive() before tearing down the admin queue: drivers/nvme/host/tcp.c:nvme_tcp_setup_ctrl() { ... destroy_admin: nvme_stop_keep_alive(ctrl); nvme_tcp_teardown_admin_queue(ctrl, new); return ret; } If a Keep Alive request is already in flight when nvme_stop_keep_alive() runs, cancel_delayed_work_sync(&ctrl->ka_work) returns while the request is still outstanding. nvme_tcp_teardown_admin_queue() then calls nvme_cancel_admin_tagset(), completing the request with NVME_SC_HOST_ABORTED_CMD while ctrl->state is still NVME_CTRL_CONNECTING, which now queues ctrl->ka_work again on the torn-down admin queue. [Severity: Medium] Should the error path also clear ctrl->comp_seen (or update ctrl->ka_last_check_time) before requeueing ctrl->ka_work? When the Keep Alive request completes with an error, __nvme_complete_rq() still sets ctrl->comp_seen =3D true because rq->deadline - rq->timeout >=3D ctrl->ka_last_check_time: drivers/nvme/host/core.c:__nvme_complete_rq() { ... if (ctrl->kas && req->deadline - req->timeout >=3D ctrl->ka_last_check_time) ctrl->comp_seen =3D true; ... } Returning before ctrl->comp_seen =3D false leaves comp_seen set on controllers with NVME_CTRL_ATTR_TBKAS enabled, so the next run of nvme_keep_alive_work() treats the failed Keep Alive completion itself as I/O traffic, skips sending a retry, and defers for another period, which can still let the target's keep-alive timer expire. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202164944.4977= 0-1-bugs@stellman-greene.com?part=3D1