From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=13.77.154.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796416847; b=P39B3pL1SZz2VmtfC/8sHuUYWjzJ3MpdLF23kJnkaIeJaZ5R1eRylh4rbckVG9C9Fs9J pA66KvXyxqMe1vuu+2DnWgyiv8EPhfrLNlAF+Y9yt2Ctvhu45vejTWlEp6ANLnWPPNz4F gAAYClCpIL4WPgfuXSeojkhCO04Y4TDVGyMTQBh7d88BbDly5mWQsEhxxDJVsxkDnQsbF lRwMJA2gjQwx/bQ21HkLNUfxctPNQyou55T7mJG+Hd7jZ7HO8Qyor4LvXtApPq/IyELD3 hPQImVWPcFF2CGiGAayYfnr7Fu9wbik4gBx6uhdYZ5v6cNo2ZAKqRh/O800M0STTMoQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796416847; h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Spam-Status: X-Spam-Checker-Version; bh=BBLJlOaaj8TQ+9+OEBQZBE8b0MZf5DZ5xc4fGZ2uh58=; b=ypX2MGjQfPploZwjiH+5BPqHem7s5IRCn9h3RFrBj6dCn55PoxtddVuV7kEV3M9ebmRf k228uOFGpUct3aNhcbM3C0JYqNr5DcEjL7xhjqK2wJKEoSTULULbflKdmS9DAoe0939Yf W996KJMx716JpOtOYmq5v2RwbPRWHWChIAA5RvxWX7pvU4Rfm1z4wBsCejH+yvCBLxIw/ V7Fnq/Ik32kI+9nq2yRuA8/cXfAEpcjRxEo+4vsN4Z3rtha32cRcunjDdVtM28KBP5FJr ssnnloOLEiP2Q2ZsZAMZjC7eXuHcBjJPSqBkJDN3uC8XHeZHoFxnrKeLOnLae70u5bA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=mnLg+kpu; arc=none smtp.remote-ip=13.77.154.182 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83C9E606A322; Fri, 4 Dec 2026 20:40:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 83C9E606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=mnLg+kpu Received: from [192.168.1.70] (unknown [103.172.5.150]) by linux.microsoft.com (Postfix) with ESMTPSA id 2BE2420B7178; Fri, 4 Dec 2026 12:40:40 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2BE2420B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1796416845; bh=BBLJlOaaj8TQ+9+OEBQZBE8b0MZf5DZ5xc4fGZ2uh58=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=mnLg+kpuVgBW0rkuwiwQXbfXFpE3kJQAl8PKXTtjGPMr10jpXe3vEILpMpxVK4uMW sFf7CB92Ol4Wd8UEYI2+LHbTw8XXRxDhXbgsxFHeiTWzb16eEUVeJirozKwuX2dWPH c8KnSPg9c9we+HM3j9+NnrTICDXc1aDak0jObNls= Message-ID: Date: Sat, 5 Dec 2026 02:10:37 +0530 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v2] net: hv_netvsc: Preserve RSS indirection table across device recreation To: netdev-bot+sashiko@kernel.org Cc: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, shradhagupta@linux.microsoft.com, horms@kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, gargaditya@microsoft.com, ssengar@linux.microsoft.com, amir@boussejra.com References: <20261203071129.396360-1-gargaditya@linux.microsoft.com> <179637046957.3146.6988724081260927365@kernel.org> Content-Language: en-US From: Aditya Garg In-Reply-To: <179637046957.3146.6988724081260927365@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 04-12-2026 13:17, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issue(s) to consider. > > Critical: 0 · High: 0 · Medium: 2 · Low: 0 > > If you believe none of the issues are legitimate, please reply to each > issue of Medium severity or higher and explain why the AI is wrong. > If any of them are legitimate and you plan to respin, please let patchwork > know by including "pw-bot: cr" as a separate line at the end of your reply > (one such reply per series is enough). > > - [Medium] When netvsc_attach() hits its multi-queue error fallback, it > zeroes the only cached copy of the RSS Toeplitz key. > - [Medium] If rndis_set_subchannel() succeeds and only the new > rndis_filter_set_rss_param() call fails, netvsc_attach() zeroes… > > -- > > net: hv_netvsc: Preserve RSS indirection table across device recreation > > This patch saves a user-configured RSS indirection table in > netvsc_device_info before the RNDIS device is recreated. The table is > restored after subchannel negotiation if it is still valid. Otherwise > defaults are used and the loss is reported with ethtool_rxfh_indir_lost(). > On subchannel or RSS programming failure in netvsc_attach(), the patch > also clears the cached table and key. > > Closes: https://lore.kernel.org/all/40fb2352-4859-4334-849b-f6a4229605a1@boussejra.com/ > >> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c >> index 1d43c73fd73f1..4df17d7baa30c 100644 >> --- a/drivers/net/hyperv/netvsc_drv.c >> +++ b/drivers/net/hyperv/netvsc_drv.c > > [ ... ] > >> @@ -1036,6 +1054,19 @@ static int netvsc_attach(struct net_device *ndev, >> if (ret) { >> nvdev->max_chn = 1; >> nvdev->num_chn = 1; >> + } else { >> + ret = rndis_filter_set_rss_param(nvdev->extension, dev_info->rss_key); >> + } >> + >> + if (ret) { >> + netdev_err(ndev, >> + "unable to restore RSS parameters (ret %d).\n", >> + ret); >> + /* Do not report the saved parameters as restored. */ >> + memset(ndev_ctx->rx_table, 0, >> + ndev_ctx->rx_table_sz * sizeof(*ndev_ctx->rx_table)); > > [Severity: Medium] > > Suppose rndis_set_subchannel() succeeds and only the new > rndis_filter_set_rss_param() call fails. This memset then zeroes rx_table, > but nvdev->num_chn is still greater than 1, and rndis_set_subchannel() has > already set the real rx queue count to num_chn. Is an all-zero table the > intended state for a multi-queue device here? > > If the table was user-configured, the check further down calls > ethtool_rxfh_indir_lost(). That clears rss_indir_user_size, so the ethtool > core treats the device as using the default table. The driver, however, > holds all zeros, not ethtool_rxfh_indir_default(i, num_chn). The same > all-zero table is left behind when no custom table was configured. > > A later key-only update such as "ethtool -X ethX hkey ..." reaches > netvsc_set_rxfh() with rxfh->indir == NULL. It leaves rx_table untouched > and programs it to the host: > > drivers/net/hyperv/netvsc_drv.c:netvsc_set_rxfh() { > ... > rndis_dev = ndev->extension; > if (rxfh->indir) { > ... > } > ... > return rndis_filter_set_rss_param(rndis_dev, key); > } > > rndis_set_rss_param_msg() then copies ndc->rx_table straight into the > request: > > for (i = 0; i < ndc->rx_table_sz; i++) > itab[i] = ndc->rx_table[i]; > > Wouldn't that enable RSS with every entry pointing at queue 0? ethtool -x > would also show an all-zero table on a multi-queue device that the core > reports as unconfigured. > > Before this patch, rndis_set_subchannel() ignored set_rss_param failures > here and rx_table kept valid entries. An all-zero table matches the > num_chn == 1 case on the out: path of rndis_filter_device_add(), but this > branch keeps the subchannels. > > When only RSS programming failed, should rx_table be filled with defaults > for num_chn instead? > The caches are cleared deliberately. Once RSS restoration fails, retaining the saved values would misleadingly report them as restored. Substituting defaults would be no more accurate and could suppress matching netlink retries before they reach the driver. The failure is logged. Recovery under this policy requires explicitly configuring both the key and table again. >> + memset(nvdev->extension->rss_key, 0, NETVSC_HASH_KEYLEN); > > [Severity: Medium] > > This memset runs on both the subchannel failure path and the RSS > programming failure path, whether or not netif_is_rxfh_configured() is > true. Is it safe to clear rdev->rss_key here, when the same cache is the > source for later host programming? > > On the next recreation (MTU change, ethtool -L, ringparam change or > suspend/resume), netvsc_devinfo_get() copies the zeroed key into dev_info: > > memcpy(dev_info->rss_key, nvdev->extension->rss_key, > NETVSC_HASH_KEYLEN); > > The new memcpy in rndis_filter_device_add() carries that key into the new > rndis_device: > > memcpy(rndis_device->rss_key, device_info->rss_key, > NETVSC_HASH_KEYLEN); > > netvsc_attach() then calls rndis_filter_set_rss_param(nvdev->extension, > dev_info->rss_key). rndis_set_rss_param_msg() copies the 40 zero bytes into > the Toeplitz OID_GEN_RECEIVE_SCALE_PARAMETERS request: > > memcpy(keyp, rss_key, NETVSC_HASH_KEYLEN); > > A table-only retry such as "ethtool -X ethX equal N" without hkey takes > this fallback in netvsc_set_rxfh(), so it also programs the zero key: > > if (!key) { > if (!rxfh->indir) > return 0; > > key = rndis_dev->rss_key; > } > > A Toeplitz hash with an all-zero key is 0 for every input. If the host > accepts the key, wouldn't every flow land on rx_table[0]? That is the > all-RX-on-queue-0 symptom this patch is meant to fix. If the host rejects > the key, RSS programming would fail on every recreation and the device > would stay single-queue. > > rndis_set_rss_param_msg() refreshes rdev->rss_key only when the host > reports success. netvsc_hash_key is used only on the probe path, where > dev_info is NULL. So nothing seems to restore a valid key unless the user > supplies an explicit hkey. The same reasoning applies to the key as explained above: the failed request does not tell us whether the host accepted either parameter. Yes, a table-only update or a later recreation can reuse the zero key; recovery under this policy requires explicitly reconfiguring both parameters, as noted above. > > The commit message says: > > Preserve the cached RSS key and zero table entries on single-queue error > fallbacks. > > The out: single-queue fallback in rndis_filter_device_add() keeps the key. > The single-queue fallback here, after a subchannel failure, clears it. > Should these two paths behave the same way? > Agreed, these single-channel fallback paths should behave consistently. I will clear the cached RSS hash key in both paths in v3, alongside the zeroed indirection table. After device teardown and reinitialization, the driver cannot assume that the host retained the previous key. Preserving it in the cache could also cause a same-key netlink request to be treated as a no-op without programming the host. >> + rss_failed = true; >> } >> } > > [ ... ] > pw-bot: cr