From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4FB81AD3FA; Mon, 23 Jun 2025 21:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750715692; cv=none; b=R2V6TLTpya/ZK5p721pFJslTeekdLHOkS8wBFzgT0hTB0JkFcF66qeV9ZcVb3DLtO0VPeoKDErhcwMwm4TT0ZnyEyyaIG0b8f3LHHku+CQNu7K88+wsm+5j7RGjM1HsehMfIpwcL5E40bV1mVokbPvTvZFpGfKAkFsl1vXWP6b4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750715692; c=relaxed/simple; bh=Bj1KRaAAZuKGjU7TEgNsGXSy/vw3GAyKuKS06LGHFN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OiIDXFiZYSYHOM9EAqVxRiQTUFqkEPI59PLWRKk/GYc1FOLd8q+EiIyU1LtYQT496xF5zJ3a0fYdrpUux/tdWxpsTg4Y8L95TX3JI+KZ5ZAKdcWnUqZSCY3QNKdRwK3NqaZh6FiXXO4GRLGqn0gzW4p25YuzUGAtPBO0suIYxeM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Wt4B3qHe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Wt4B3qHe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49FDAC4CEEA; Mon, 23 Jun 2025 21:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750715692; bh=Bj1KRaAAZuKGjU7TEgNsGXSy/vw3GAyKuKS06LGHFN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wt4B3qHe39Uz9F2zXw6/L/RsvmdmYTM3YDz9UV2Mo+pwuqnO0v760TAv0FM70Jj6K AuOpjA5LKwrElbBpncJful6XzCR+60CpMX0rs221N8HBiaJoNPgDd0gLolMEhKCRXv WwfUsLB0I8seRPaUZZ1+yXo2dfHAXe/Zd8KE61is= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shyam Prasad N , Steve French Subject: [PATCH 6.6 215/290] cifs: deal with the channel loading lag while picking channels Date: Mon, 23 Jun 2025 15:07:56 +0200 Message-ID: <20250623130633.396427507@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.910356556@linuxfoundation.org> References: <20250623130626.910356556@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shyam Prasad N commit 66d590b828b1fd9fa337047ae58fe1c4c6f43609 upstream. Our current approach to select a channel for sending requests is this: 1. iterate all channels to find the min and max queue depth 2. if min and max are not the same, pick the channel with min depth 3. if min and max are same, round robin, as all channels are equally loaded The problem with this approach is that there's a lag between selecting a channel and sending the request (that increases the queue depth on the channel). While these numbers will eventually catch up, there could be a skew in the channel usage, depending on the application's I/O parallelism and the server's speed of handling requests. With sufficient parallelism, this lag can artificially increase the queue depth, thereby impacting the performance negatively. This change will change the step 1 above to start the iteration from the last selected channel. This is to reduce the skew in channel usage even in the presence of this lag. Fixes: ea90708d3cf3 ("cifs: use the least loaded channel for sending requests") Cc: Signed-off-by: Shyam Prasad N Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/transport.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/fs/smb/client/transport.c +++ b/fs/smb/client/transport.c @@ -1025,14 +1025,16 @@ struct TCP_Server_Info *cifs_pick_channe uint index = 0; unsigned int min_in_flight = UINT_MAX, max_in_flight = 0; struct TCP_Server_Info *server = NULL; - int i; + int i, start, cur; if (!ses) return NULL; spin_lock(&ses->chan_lock); + start = atomic_inc_return(&ses->chan_seq); for (i = 0; i < ses->chan_count; i++) { - server = ses->chans[i].server; + cur = (start + i) % ses->chan_count; + server = ses->chans[cur].server; if (!server || server->terminate) continue; @@ -1049,17 +1051,15 @@ struct TCP_Server_Info *cifs_pick_channe */ if (server->in_flight < min_in_flight) { min_in_flight = server->in_flight; - index = i; + index = cur; } if (server->in_flight > max_in_flight) max_in_flight = server->in_flight; } /* if all channels are equally loaded, fall back to round-robin */ - if (min_in_flight == max_in_flight) { - index = (uint)atomic_inc_return(&ses->chan_seq); - index %= ses->chan_count; - } + if (min_in_flight == max_in_flight) + index = (uint)start % ses->chan_count; server = ses->chans[index].server; spin_unlock(&ses->chan_lock);