Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6422CCA0FFF for ; Sat, 30 Aug 2025 15:34:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNNy-0002gV-JW; Sat, 30 Aug 2025 11:20:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us0oj-0005Xj-Kp for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:15:06 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us0og-0005Zs-MM for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:15:05 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id A06C214D587; Fri, 29 Aug 2025 18:14:22 +0300 (MSK) Received: from [192.168.177.146] (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 12BEA26A7D7; Fri, 29 Aug 2025 18:14:53 +0300 (MSK) Message-ID: Date: Fri, 29 Aug 2025 18:14:53 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] virtio: Call set_features during reset To: Akihiko Odaki Cc: qemu-devel@nongnu.org References: <871pudmlmj.fsf@suse.de> <87plchkaxo.fsf@suse.de> <3983904c-9530-4cf5-b294-12ca04658b23@rsg.ci.i.u-tokyo.ac.jp> <3b17f289-876d-4cbd-bda7-1bbd83832e85@tls.msk.ru> <942ae41e-931f-4d09-85d8-8849d36b88db@rsg.ci.i.u-tokyo.ac.jp> Content-Language: en-US, ru-RU From: Michael Tokarev Autocrypt: addr=mjt@tls.msk.ru; keydata= xsFNBGYpLkcBEACsajkUXU2lngbm6RyZuCljo19q/XjZTMikctzMoJnBGVSmFV66kylUghxs HDQQF2YZJbnhSVt/mP6+V7gG6MKR5gYXYxLmypgu2lJdqelrtGf1XtMrobG6kuKFiD8OqV6l 2M5iyOZT3ydIFOUX0WB/B9Lz9WcQ6zYO9Ohm92tiWWORCqhAnwZy4ua/nMZW3RgO7bM6GZKt /SFIorK9rVqzv40D6KNnSyeWfqf4WN3EvEOozMfWrXbEqA7kvd6ShjJoe1FzCEQ71Fj9dQHL DZG+44QXvN650DqEtQ4RW9ozFk3Du9u8lbrXC5cqaCIO4dx4E3zxIddqf6xFfu4Oa5cotCM6 /4dgxDoF9udvmC36qYta+zuDsnAXrYSrut5RBb0moez/AR8HD/cs/dS360CLMrl67dpmA+XD 7KKF+6g0RH46CD4cbj9c2egfoBOc+N5XYyr+6ejzeZNf40yjMZ9SFLrcWp4yQ7cpLsSz08lk a0RBKTpNWJdblviPQaLW5gair3tyJR+J1ER1UWRmKErm+Uq0VgLDBDQoFd9eqfJjCwuWZECp z2JUO+zBuGoKDzrDIZH2ErdcPx3oSlVC2VYOk6H4cH1CWr9Ri8i91ClivRAyVTbs67ha295B y4XnxIVaZU+jJzNgLvrXrkI1fTg4FJSQfN4W5BLCxT4sq8BDtwARAQABzSBNaWNoYWVsIFRv a2FyZXYgPG1qdEB0bHMubXNrLnJ1PsLBlAQTAQoAPhYhBJ2L4U4/Kp3XkZko8WGtPZjs3yyO BQJmKS5HAhsDBQkSzAMABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEGGtPZjs3yyOZSAP /ibilK1gbHqEI2zR2J59Dc0tjtbByVmQ8IMh0SYU3j1jeUoku2UCgdnGKpwvL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text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 29.08.2025 17:40, Akihiko Odaki wrote: > On 2025/08/29 17:34, Michael Tokarev wrote: >> On 28.08.2025 03:57, Akihiko Odaki wrote: ... >> Please note: this is stable-7.2 series, it is *not* master (I picked >> up this commit to 7.2.x).  It'd be interesting to check if master is >> affected too.  Unfortunately I never tried migration, and now I only >> have my notebook, so can only migrate between two qemu instances on >> the same box - which is probably okay too. > > I think you need to backport commit 9379ea9db3c0 ("virtio-net: Add > queues before loading them") and adda0ad56bd2 ("virtio-net: Add queues > for RSS during migration"). Here is an explanation: "Add queues before loading them" is marked as fixing Both the mentioned commits were tagged with Cc: qemu-stable, but both has Fixes: the same commit 8c49756825da ("virtio-net: Add only one queue pair when realizing"), which is in 9.1, but not in 7.2. I guess, in this case, I also need 8c49756825da - let's first break things, and next fix them :) > First, let me define two variables for conciseness: > N: the number of queue pairs > M: the maximum number of queue pairs, which is determined with >    n->max_queue_pairs > > The problem is that QEMU inconsistently chose N for virtio-net in the > past. Before commit 8c49756825da ("virtio-net: Add only one queue pair > when realizing"): > 1) realize() chose M. > 2) set_features() chose: 1 (when RSS and MQ are disabled) >                          M (otherwise) > > This itself was a problem; both RSS and MQ were disabled when realize() > but N was M, which is inconsistent with 2) and this inconsistency was > guest-visible. > > I wrote commit 8c49756825da ("virtio-net: Add only one queue pair when > realizing") to make QEMU implement the behavior in 2) also during > realization and fix the inconsistency, but it broke migration when the > migrated VM had enabled VIRTIO_NET_F_RSS and VIRTIO_NET_F_MQ because it > expected that N == M. Yup, 8c49756825da it is, which is missing in 7.2, which broke things :)) > This is also why the backported commit also broke migration; it > accidentally fixed the inconsistency between the first reset state and > the state after set_features() and caused the same problem. > > I wrote commit 9379ea9db3c0 ("virtio-net: Add queues before loading > them") to fix the issue and later complemented it with commit > adda0ad56bd2 ("virtio-net: Add queues for RSS during migration"). > > There are several relevant commits because I could not fix the > underlying problem at once, but hopefully this email clarifies how the > two commits fixed it in the end. Now, with 3 commits picked up to 7.2, things are at least compiles :)) Let's test the result.. hopefully I didn't break something else in the process of breaking+fixing stuff :)) Thank you very much for the detailed explanation and attention to details. It makes sense. An for the 7.2.x series which is getting old(ish) - I plan to end support for it in the near future, so there will be less surprises like this one.. if not only for 10.0.x :) /mjt