From nobody Thu Dec 18 00:10:56 2025 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 5C57E79DC7 for ; Fri, 6 Dec 2024 01:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447514; cv=none; b=KF+VIkBD2V8nEY+M9inODPirZsjtSz/7R8Da2oEJLZYT6uY0hmfFB6m+pW8wyAtyxsElwKbZb3A5FovQBL7W5WP2tiwWvMP5r3KEqlYi1WucEMQriZdzIm1ugInZG2eK09E3WQ5ID/bw2/r0tfU3hFcVEmWQYnhzOuxFdt0iRyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447514; c=relaxed/simple; bh=rVcdyY36jXP8VR48lEsirdddIfzXUXd85EOYsURna2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fm8m4GvlRPhM6JPkDOZgJjP+9fVXaC1VSWP5uBuJMc1tuwdOvs5a3UnDuwlPGtofvt0THBhLA/GhEneeuTidhxbXViQ5QHE9iHeCi44gJBWhAVVTnkoPhvVLrVXJ/npCdLDLV7cXDJMSjUgPDeKitQgAdXNt2sLsNfinE4HKzSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=I43F449z; arc=none smtp.client-ip=185.125.188.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="I43F449z" Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 4248A40D9D for ; Fri, 6 Dec 2024 01:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733447509; bh=n9flHQ4SOu3Ah+O2it+FSTfX6wWhyXV+9acYEWVQW/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I43F449zo+iyZZdHdgY+JnnfpEpsarv/2zY9bNwLSuKwOMTqbVycVe0quFYDFPp2P RXeglmju/UpJ4hkUx2+xNYGitA+sYwp2XeMQsbP0NY+UlzWYog1ekLlSuIjMxly2c6 Yi5CFey1VvTnTM16mB1XFZrrwOM4qFEYh7j0fZBwQmI2RDvkseCdsU/XSTwMtrozGb L6JGE0u5wgDjtfDCkZ9UvOTHbelzT6dVU+LmhgBucTUIiAsmxIP+VippelPBURYcW3 5p3K2pW6fiHO86PNhTkd7OJSHsG1GJrOHolgTZEShbTsbRY6xkREXNxUC+fnJs9oHh UheFO1Fi67lhQ== Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-215ce784342so15542505ad.3 for ; Thu, 05 Dec 2024 17:11:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733447507; x=1734052307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n9flHQ4SOu3Ah+O2it+FSTfX6wWhyXV+9acYEWVQW/0=; b=cD6H9eRsbX+9vYR4VKTaGwJcSyiKI/rH0s+GGxBJV//S5xRWdMoOLSyLEYlOwP3oB1 yLfhMGx5O1zBaY7iii9Auz/ew7F/qLEt9G0myoGItr+jJ+OlUnjTbsTnYU+afanGuQWi PLpmC7FhS5GbEY7+uAJNPcIuGXwFGJCwGdxeaeqH+/XOIwccP1UjnbzBdWrrWkA5b+4z tkn4v/LGaYWY/MdPZijNUuM4DEpYHywTWpVdIcWl2vQZKR5bg8bqoq8s4fp/spjacqzw s6jrt5B4AtecB6zfULYr4ygb98bVHeN7HPjluNyS9O/tM87Tla2glQcgej4SVosiuTfs hBXQ== X-Forwarded-Encrypted: i=1; AJvYcCWfniKLkQmuhdSx+dzQ0YSXdf7WcpK47v9juye9RZFCWPp+FP5jU81UhyxZgcl+I11lIeQ0PX5RB+mji0Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yyypbs8FU2smFPi6WeGotIKgb83L5kEBpWmttLP+c6N6BQS2GwE PlR0r+/ZrQo5KeMOuF8H6dW9TXE2FRLKPEHTb1fBOOsYXY4irubbgRmUnqB9iJOmAOF5vZ/VR3s FAeZzslf0NL/iLGhOTVKOwrz6/r+tZa+uc3BLMUD+cdZghD6kSZrz/Jbp8SIHhlthucVGv7U64T 0zOQ== X-Gm-Gg: ASbGnctM80IJZYqNdYFLWS9897C0kN5KQ1R43ht1Fjhv98tr04IlUCoGWvvgrvK9Yga cGCc5I66WFXXLe/Hwh4tOaUirTz1e9X2V6VfDGqDseYeC7GpSuZPCcwHJwnYH+Ixp40wlYQ0nly iNjZqXTFWlXN8OxfTtOWnodlUIg9nxvRG5E2YPRROUDDzfFh08lQZ0HYLrvujm6ZJuQBROcGC1I mMiFWAUEsSOEXhrePkQuUH5hlh/tnoFpNbcjJ3bUmGE2i4+71o= X-Received: by 2002:a17:903:110e:b0:215:522d:72d6 with SMTP id d9443c01a7336-21614da9cfdmr17359235ad.38.1733447507480; Thu, 05 Dec 2024 17:11:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IETbG0l6/BuAZMeE4s2ab6Ur7szbre8sLSSO+/KGmcA4XICDxoWsxBAxpFB26bnxyx9Yr77tA== X-Received: by 2002:a17:903:110e:b0:215:522d:72d6 with SMTP id d9443c01a7336-21614da9cfdmr17358835ad.38.1733447507068; Thu, 05 Dec 2024 17:11:47 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:9740:f048:7177:db2e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8efa18esm17979355ad.123.2024.12.05.17.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 17:11:46 -0800 (PST) From: Koichiro Den To: virtualization@lists.linux.dev Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v4 1/6] virtio_net: correct netdev_tx_reset_queue() invocation point Date: Fri, 6 Dec 2024 10:10:42 +0900 Message-ID: <20241206011047.923923-2-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206011047.923923-1-koichiro.den@canonical.com> References: <20241206011047.923923-1-koichiro.den@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When virtnet_close is followed by virtnet_open, some TX completions can possibly remain unconsumed, until they are finally processed during the first NAPI poll after the netdev_tx_reset_queue(), resulting in a crash [1]. Commit b96ed2c97c79 ("virtio_net: move netdev_tx_reset_queue() call before RX napi enable") was not sufficient to eliminate all BQL crash cases for virtio-net. This issue can be reproduced with the latest net-next master by running: `while :; do ip l set DEV down; ip l set DEV up; done` under heavy network TX load from inside the machine. netdev_tx_reset_queue() can actually be dropped from virtnet_open path; the device is not stopped in any case. For BQL core part, it's just like traffic nearly ceases to exist for some period. For stall detector added to BQL, even if virtnet_close could somehow lead to some TX completions delayed for long, followed by virtnet_open, we can just take it as stall as mentioned in commit 6025b9135f7a ("net: dqs: add NIC stall detector based on BQL"). Note also that users can still reset stall_max via sysfs. So, drop netdev_tx_reset_queue() from virtnet_enable_queue_pair(). This eliminates the BQL crashes. As a result, netdev_tx_reset_queue() is now explicitly required in freeze/restore path. This patch adds it to immediately after free_unused_bufs(), following the rule of thumb: netdev_tx_reset_queue() should follow any SKB freeing not followed by netdev_tx_completed_queue(). This seems the most consistent and streamlined approach, and now netdev_tx_reset_queue() runs whenever free_unused_bufs() is done. [1]: Acked-by: Jason Wang Reviewed-by: Xuan Zhuo ------------[ cut here ]------------ kernel BUG at lib/dynamic_queue_limits.c:99! Oops: invalid opcode: 0000 [#1] PREEMPT SMP NOPTI CPU: 7 UID: 0 PID: 1598 Comm: ip Tainted: G N 6.12.0net-next_main+ #2 Tainted: [N]=3DTEST Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), \ BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 RIP: 0010:dql_completed+0x26b/0x290 Code: b7 c2 49 89 e9 44 89 da 89 c6 4c 89 d7 e8 ed 17 47 00 58 65 ff 0d 4d 27 90 7e 0f 85 fd fe ff ff e8 ea 53 8d ff e9 f3 fe ff ff <0f> 0b 01 d2 44 89 d1 29 d1 ba 00 00 00 00 0f 48 ca e9 28 ff ff ff RSP: 0018:ffffc900002b0d08 EFLAGS: 00010297 RAX: 0000000000000000 RBX: ffff888102398c80 RCX: 0000000080190009 RDX: 0000000000000000 RSI: 000000000000006a RDI: 0000000000000000 RBP: ffff888102398c00 R08: 0000000000000000 R09: 0000000000000000 R10: 00000000000000ca R11: 0000000000015681 R12: 0000000000000001 R13: ffffc900002b0d68 R14: ffff88811115e000 R15: ffff8881107aca40 FS: 00007f41ded69500(0000) GS:ffff888667dc0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000556ccc2dc1a0 CR3: 0000000104fd8003 CR4: 0000000000772ef0 PKRU: 55555554 Call Trace: ? die+0x32/0x80 ? do_trap+0xd9/0x100 ? dql_completed+0x26b/0x290 ? dql_completed+0x26b/0x290 ? do_error_trap+0x6d/0xb0 ? dql_completed+0x26b/0x290 ? exc_invalid_op+0x4c/0x60 ? dql_completed+0x26b/0x290 ? asm_exc_invalid_op+0x16/0x20 ? dql_completed+0x26b/0x290 __free_old_xmit+0xff/0x170 [virtio_net] free_old_xmit+0x54/0xc0 [virtio_net] virtnet_poll+0xf4/0xe30 [virtio_net] ? __update_load_avg_cfs_rq+0x264/0x2d0 ? update_curr+0x35/0x260 ? reweight_entity+0x1be/0x260 __napi_poll.constprop.0+0x28/0x1c0 net_rx_action+0x329/0x420 ? enqueue_hrtimer+0x35/0x90 ? trace_hardirqs_on+0x1d/0x80 ? kvm_sched_clock_read+0xd/0x20 ? sched_clock+0xc/0x30 ? kvm_sched_clock_read+0xd/0x20 ? sched_clock+0xc/0x30 ? sched_clock_cpu+0xd/0x1a0 handle_softirqs+0x138/0x3e0 do_softirq.part.0+0x89/0xc0 __local_bh_enable_ip+0xa7/0xb0 virtnet_open+0xc8/0x310 [virtio_net] __dev_open+0xfa/0x1b0 __dev_change_flags+0x1de/0x250 dev_change_flags+0x22/0x60 do_setlink.isra.0+0x2df/0x10b0 ? rtnetlink_rcv_msg+0x34f/0x3f0 ? netlink_rcv_skb+0x54/0x100 ? netlink_unicast+0x23e/0x390 ? netlink_sendmsg+0x21e/0x490 ? ____sys_sendmsg+0x31b/0x350 ? avc_has_perm_noaudit+0x67/0xf0 ? cred_has_capability.isra.0+0x75/0x110 ? __nla_validate_parse+0x5f/0xee0 ? __pfx___probestub_irq_enable+0x3/0x10 ? __create_object+0x5e/0x90 ? security_capable+0x3b/0x70 rtnl_newlink+0x784/0xaf0 ? avc_has_perm_noaudit+0x67/0xf0 ? cred_has_capability.isra.0+0x75/0x110 ? stack_depot_save_flags+0x24/0x6d0 ? __pfx_rtnl_newlink+0x10/0x10 rtnetlink_rcv_msg+0x34f/0x3f0 ? do_syscall_64+0x6c/0x180 ? entry_SYSCALL_64_after_hwframe+0x76/0x7e ? __pfx_rtnetlink_rcv_msg+0x10/0x10 netlink_rcv_skb+0x54/0x100 netlink_unicast+0x23e/0x390 netlink_sendmsg+0x21e/0x490 ____sys_sendmsg+0x31b/0x350 ? copy_msghdr_from_user+0x6d/0xa0 ___sys_sendmsg+0x86/0xd0 ? __pte_offset_map+0x17/0x160 ? preempt_count_add+0x69/0xa0 ? __call_rcu_common.constprop.0+0x147/0x610 ? preempt_count_add+0x69/0xa0 ? preempt_count_add+0x69/0xa0 ? _raw_spin_trylock+0x13/0x60 ? trace_hardirqs_on+0x1d/0x80 __sys_sendmsg+0x66/0xc0 do_syscall_64+0x6c/0x180 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f41defe5b34 Code: 15 e1 12 0f 00 f7 d8 64 89 02 b8 ff ff ff ff eb bf 0f 1f 44 00 00 f3 0f 1e fa 80 3d 35 95 0f 00 00 74 13 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 4c c3 0f 1f 00 55 48 89 e5 48 83 ec 20 89 55 RSP: 002b:00007ffe5336ecc8 EFLAGS: 00000202 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f41defe5b34 RDX: 0000000000000000 RSI: 00007ffe5336ed30 RDI: 0000000000000003 RBP: 00007ffe5336eda0 R08: 0000000000000010 R09: 0000000000000001 R10: 00007ffe5336f6f9 R11: 0000000000000202 R12: 0000000000000003 R13: 0000000067452259 R14: 0000556ccc28b040 R15: 0000000000000000 [...] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]--- Fixes: c8bd1f7f3e61 ("virtio_net: add support for Byte Queue Limits") Cc: # v6.11+ Signed-off-by: Koichiro Den --- drivers/net/virtio_net.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 64c87bb48a41..6e0925f7f182 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3054,7 +3054,6 @@ static int virtnet_enable_queue_pair(struct virtnet_i= nfo *vi, int qp_index) if (err < 0) goto err_xdp_reg_mem_model; =20 - netdev_tx_reset_queue(netdev_get_tx_queue(vi->dev, qp_index)); virtnet_napi_enable(vi->rq[qp_index].vq, &vi->rq[qp_index].napi); virtnet_napi_tx_enable(vi, vi->sq[qp_index].vq, &vi->sq[qp_index].napi); =20 @@ -6966,11 +6965,20 @@ static int virtnet_probe(struct virtio_device *vdev) =20 static void remove_vq_common(struct virtnet_info *vi) { + int i; + virtio_reset_device(vi->vdev); =20 /* Free unused buffers in both send and recv, if any. */ free_unused_bufs(vi); =20 + /* + * Rule of thumb is netdev_tx_reset_queue() should follow any + * skb freeing not followed by netdev_tx_completed_queue() + */ + for (i =3D 0; i < vi->max_queue_pairs; i++) + netdev_tx_reset_queue(netdev_get_tx_queue(vi->dev, i)); + free_receive_bufs(vi); =20 free_receive_page_frags(vi); --=20 2.43.0 From nobody Thu Dec 18 00:10:56 2025 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 2483F47F4A for ; Fri, 6 Dec 2024 01:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447516; cv=none; b=gyrS+Kmk+6o9CNnbOtSUQ3jcDGxAEtMAUYZSZmmTw29X2c2nVCZlhXFI4sFM469CEK/Gyx97PZ/JV+nOed/j6YH4c3j9fbjSvpKPLCYRXI8vbh8nUSU+HL3XPVozyAYDgD4E5in9lMRbohoV5xWO3lORFnxQ6ymBeodNZO5v6Sc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447516; c=relaxed/simple; bh=96Kfacf61eXHoKwnotb++f8dB1xgmK90ltAc50Mdduk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o2onaTghhbzLoCZRtB9LuDz+zeU1T2dtZd32tIxvYv51aOeGh2Q+QZl1cHphJ/f5iXwu3MdYoChc6Rvj3rL/E3J5ZV5JXGgqqvXy83dDZlzRq3rFZ2S/A/w+zv+zE8fM79akqMxiDPLt1H9QP8wrSOcV+vDyv0XSM4glo2QyXYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=NXnVseF2; arc=none smtp.client-ip=185.125.188.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="NXnVseF2" Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 9B26F40CEB for ; Fri, 6 Dec 2024 01:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733447512; bh=nSlPIIC6AcIBGV2PkIN03d/6vzcJU5ZO51l3In2QAJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NXnVseF2BK/+kneXib7M5ueeP5D+lW5hYcUJ4fvjP5UF5++OIBHv+ZaFumjy7kQyS 2QgofyOIDDIg27/JQvhHpK2UJqc0d1J2is++Gwt3nuEf04g+S9fUT+sbu7ZBB/rp8t /t5emsbl31b+lBfaIFbNA/146ebdih4wiKJq3ImiFgcaSAME+/NWiIh9MfQn/8dfOY HAs5tlbbSVKjjmcj44a3GeCqjXrIT02KtsOmtWZvEAY0n2nyQkQbJfOgMLxUDj6bWK BoWmvc6oBgxm+p8ebHnKBz6pZ9pk59IZ6dqQfl+4D4NiX4OiRvv/zxrc4moxoYtF7W UruH7XwkHer5w== Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-215d54af511so12790425ad.1 for ; Thu, 05 Dec 2024 17:11:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733447511; x=1734052311; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nSlPIIC6AcIBGV2PkIN03d/6vzcJU5ZO51l3In2QAJw=; b=DNQlqXm5XSpW2JNLauLu6pzdLzBEvIRBlK07Afuy5OjpYWoNFAd5gR7W+FBsvYAs8Q 28tj9a18PBvvmnqUT9X9YZo0BtPiIriy3GxJYHKd/c/OLslJO2ThmPxU6vUTHCDNDKth 4UGYHrLOLHARrrywZa2C37EzJ4zQtVap0ZB6bqe2iMDyQZvpA/BNupHbnD9bpV+ERemV FgV2H23y5+bPVNE2n2DOBJLH2AbHouoHAUNbqS0r3fGdlpMW8iLVG14V/I0Z2k9UeSbn qSnMjsOcbTjDNeuOhWYCDmzS7CSfmPrCoy3ijlioPVVnNzIvgbkEcwp7MbCm9eTS6Ls5 62NA== X-Forwarded-Encrypted: i=1; AJvYcCUNWH3AzJ+LLdZp2j7MR54/Cy24Fw6MGdZBDjdXP1eeI0Pg8n6kU5OJ85ayySRfan6E88cLN3i4w9O4RaI=@vger.kernel.org X-Gm-Message-State: AOJu0YzfiF9d7b2IyaVPVSgJ/66g77+pwi/vcU6k04VhuhY84ZiTbMI2 /g4qKehwZ5Mc+rAy8xsAilihjPwRewxx1uWYjCo9JeFdhyJobpWskaInJ/4fOlQNoe197D16o54 TCO9SxFSVmVTmKkMpwIZvPs7lBuZKh3oxwIckhza3YSD7LGYjVk9cc1OjurISZfjsXONR75oZXJ AdRngKl+mMlQ== X-Gm-Gg: ASbGncuh0M0SWsxtG+eyfG29ecC9ZgEkfkLgZxEYLdiuXFn4CVIZ0DoGr/gxX1sAojU 8DuX6xg+atzDEsYKwOZZ9pzAeg3SXYg6WBz4/mGRoheNDSkZ8+XPxaXarwfuC4YOpzrI0Sfs3Cj lXnlutCxyjIl+UJHaC/uuWi7WWzI5VKy7nNcyOiX/A+opUMP7bOx7yW7u6kM/DftkINuNHlevmL 8U13E0XA+9TU6Vr1qGgmSp7DSKeCNNEdNKoYdP0D4GGe0h2ccc= X-Received: by 2002:a17:902:f542:b0:215:e76d:debe with SMTP id d9443c01a7336-21614d1f258mr13747045ad.10.1733447510925; Thu, 05 Dec 2024 17:11:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKbHax0jjSvtZYTNxWpYl5lGbpKdIWP0A58s2CxR3vPhspLqJQTgD+Jp4LCBdjfkXKt7Ymdg== X-Received: by 2002:a17:902:f542:b0:215:e76d:debe with SMTP id d9443c01a7336-21614d1f258mr13746705ad.10.1733447510661; Thu, 05 Dec 2024 17:11:50 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:9740:f048:7177:db2e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8efa18esm17979355ad.123.2024.12.05.17.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 17:11:50 -0800 (PST) From: Koichiro Den To: virtualization@lists.linux.dev Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v4 2/6] virtio_net: replace vq2rxq with vq2txq where appropriate Date: Fri, 6 Dec 2024 10:10:43 +0900 Message-ID: <20241206011047.923923-3-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206011047.923923-1-koichiro.den@canonical.com> References: <20241206011047.923923-1-koichiro.den@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While not harmful, using vq2rxq where it's always sq appears odd. Replace it with the more appropriate vq2txq for clarity and correctness. Fixes: 89f86675cb03 ("virtio_net: xsk: tx: support xmit xsk buffer") Signed-off-by: Koichiro Den Acked-by: Jason Wang Reviewed-by: Xuan Zhuo --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 6e0925f7f182..fc89c5e1a207 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -6213,7 +6213,7 @@ static void virtnet_sq_free_unused_buf(struct virtque= ue *vq, void *buf) { struct virtnet_info *vi =3D vq->vdev->priv; struct send_queue *sq; - int i =3D vq2rxq(vq); + int i =3D vq2txq(vq); =20 sq =3D &vi->sq[i]; =20 --=20 2.43.0 From nobody Thu Dec 18 00:10:56 2025 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 895E214830F for ; Fri, 6 Dec 2024 01:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447520; cv=none; b=uMhRXeMdgz+zoSW97LKgWmnKfZOKpzeJIECFNoPfiFJXhQ3SSfVHQ1//YHO8++a3fInSzsLsz9F60VE/WPrtfWocGvkbCwM80jxW/9blUV7OsDTcGP2Y6RJ3VRsSflM2xO8pH214Fk0wG9xJ7a7LZSW6WmU9aG8oppg3Kqxsc2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447520; c=relaxed/simple; bh=RqlqljCEL65bX/4/99BjDeGnmkrxramPpNz4DWizEy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XunyEWSmWqmZpY6Yy1DuFri5VromFmS8VohDGWU5KP0dyVP9Y5ooZIaRq607z83onJqmBjbGWVxb4Geg86EeZ25g1RO511HoPMcCvCYvFfLoXcD3kqJHbD2OPn8wsJK0ImXukoX09mNU0OXTNxuSuDqznV4798fyrktSKQBWUII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=pS47XYtL; arc=none smtp.client-ip=185.125.188.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="pS47XYtL" Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id CDDA740CE6 for ; Fri, 6 Dec 2024 01:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733447516; bh=0DkRrRdtwcxltiw3a2XZYsY1oAxq6KLTi5TBwA0X+38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pS47XYtL+oAcOL1+shxEHUTnGs6ELQ1P/SUqrrl6TA7BFzQ9nel40X45fzVwRV/47 PlE5ngf+cglyM7PofZJSA3YKAB2rs2nkzqJy0/hIiVp4imyIYSLGGRUXCGQYUauiYE Fd7x9pYQCejksjO+Q0wL8kDenFFP+XX/OlpTiTYTIfMmSGrHypxFHU7PsWCqu2akxh Qo/Tw/seb7v0dTqvSRUWpeHr+pEkv3bI9K1mgzTIURcqzfctEahMJJccSchhJGlibq f7mWbSX+SphkhS9xt/2kJoL0iZdqub7xZsnI3GwpaE51aLWAkV5CPWnR90OR5qYJqx 6BPZRiOEPtQrQ== Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-7250da8a2a5so1343609b3a.0 for ; Thu, 05 Dec 2024 17:11:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733447515; x=1734052315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0DkRrRdtwcxltiw3a2XZYsY1oAxq6KLTi5TBwA0X+38=; b=uPD0ECap3goVjIKMpbB8CBYs99dupYu/xKjBEtsvOREjKkEQ0R7HMdQf5fpGUP6O3E 1jEmy05A14OgUX4yPNr86xPIc5kC1JxzcB2hH5YDL4l6U3mnYZrta4jKgkvu2itQswUS NvH087zu+EnP6QSao5uxygrV3qirtm2vAr839c+5TjFl0PI4ggim+VxLZLSepNe3aDN+ 6tSo7UrzTk28iCDCGmehmDuebpzpn87Xpx3hkiFZlMnH3Sj1OF1YIhhR7HGO1ScU+X1F mKzjkprVsFAuZPBKha1NcXsI6fBLGvObRv8DK9jSxpRQKDM96bi2h2nRPwo7f9eqsy5E 0MiQ== X-Forwarded-Encrypted: i=1; AJvYcCXV4+7nbhj0LsCYjVS2OAp6ygjyMkGH3bTEswR202J+OJ2LiNQT+rBVvGbu+FVmOgfB1zSBwowBMAsb0nw=@vger.kernel.org X-Gm-Message-State: AOJu0YwIkVkLSJOfVSLTztFAltFsV3RgmWvm2bFrdQ2/J6cWqq9eIZag 2W0tquqa1d/Rkjdn9t1Gny9HQmoIq6VpOvciwVdm+9ateJPzN8m9TD6n/3K+LGAm6/21Jte9QwU AU7ZYQmi9K4Vt2TeBt2ljBi+w6Efja1a6gRk/PyixpsSnTmD3TF3rIFMXE9HVZ99RYE8wRVzXKp D8bg== X-Gm-Gg: ASbGncuLCAXXs3WlZVMLrpcyOOE2MzogAoOeekz5bMPWVp/Ylc32O9f6rA4uumUm2qH IICVlYH1CVjHhzC1Azs1XLT6T4CQObsiqysEIlM444eQe8bGbXcXibOOjPyYbBxZEBXInj7In5Q bQQUORNmkLGnmdcDct9K4V9NFnwrMWlWEEpCjkEdBS+2+RUqjbxtaWiZXETshdLgvuHijbgIV1V tP5xzwsdtgSmimx7fjD3d9Eui2HvkWl+O6KzINM/ZjEJ1MnnBE= X-Received: by 2002:a17:903:24e:b0:215:9d29:9724 with SMTP id d9443c01a7336-21614dc51d0mr16338825ad.38.1733447514874; Thu, 05 Dec 2024 17:11:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiAxk12TLEAZVlXN3AMx9CBNnCG3b9Crg3EPVg0Vc1+/w62vhDV/vWjq+VCbS4eYtWIXUo4Q== X-Received: by 2002:a17:903:24e:b0:215:9d29:9724 with SMTP id d9443c01a7336-21614dc51d0mr16338465ad.38.1733447514451; Thu, 05 Dec 2024 17:11:54 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:9740:f048:7177:db2e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8efa18esm17979355ad.123.2024.12.05.17.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 17:11:54 -0800 (PST) From: Koichiro Den To: virtualization@lists.linux.dev Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v4 3/6] virtio_ring: add a func argument 'recycle_done' to virtqueue_resize() Date: Fri, 6 Dec 2024 10:10:44 +0900 Message-ID: <20241206011047.923923-4-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206011047.923923-1-koichiro.den@canonical.com> References: <20241206011047.923923-1-koichiro.den@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When virtqueue_resize() has actually recycled all unused buffers, additional work may be required in some cases. Relying solely on its return status is fragile, so introduce a new function argument 'recycle_done', which is invoked when the recycle really occurs. Cc: # v6.11+ Signed-off-by: Koichiro Den Acked-by: Jason Wang Reviewed-by: Xuan Zhuo --- drivers/net/virtio_net.c | 4 ++-- drivers/virtio/virtio_ring.c | 6 +++++- include/linux/virtio.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index fc89c5e1a207..e10bc9e6b072 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3331,7 +3331,7 @@ static int virtnet_rx_resize(struct virtnet_info *vi, =20 virtnet_rx_pause(vi, rq); =20 - err =3D virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf); + err =3D virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf, NUL= L); if (err) netdev_err(vi->dev, "resize rx fail: rx queue index: %d err: %d\n", qind= ex, err); =20 @@ -3394,7 +3394,7 @@ static int virtnet_tx_resize(struct virtnet_info *vi,= struct send_queue *sq, =20 virtnet_tx_pause(vi, sq); =20 - err =3D virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf); + err =3D virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf, NU= LL); if (err) netdev_err(vi->dev, "resize tx fail: tx queue index: %d err: %d\n", qind= ex, err); =20 diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 82a7d2cbc704..6af8cf6a619e 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -2772,6 +2772,7 @@ EXPORT_SYMBOL_GPL(vring_create_virtqueue_dma); * @_vq: the struct virtqueue we're talking about. * @num: new ring num * @recycle: callback to recycle unused buffers + * @recycle_done: callback to be invoked when recycle for all unused buffe= rs done * * When it is really necessary to create a new vring, it will set the curr= ent vq * into the reset state. Then call the passed callback to recycle the buff= er @@ -2792,7 +2793,8 @@ EXPORT_SYMBOL_GPL(vring_create_virtqueue_dma); * */ int virtqueue_resize(struct virtqueue *_vq, u32 num, - void (*recycle)(struct virtqueue *vq, void *buf)) + void (*recycle)(struct virtqueue *vq, void *buf), + void (*recycle_done)(struct virtqueue *vq)) { struct vring_virtqueue *vq =3D to_vvq(_vq); int err; @@ -2809,6 +2811,8 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num, err =3D virtqueue_disable_and_recycle(_vq, recycle); if (err) return err; + if (recycle_done) + recycle_done(_vq); =20 if (vq->packed_ring) err =3D virtqueue_resize_packed(_vq, num); diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 57cc4b07fd17..0aa7df4ed5ca 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -109,7 +109,8 @@ dma_addr_t virtqueue_get_avail_addr(const struct virtqu= eue *vq); dma_addr_t virtqueue_get_used_addr(const struct virtqueue *vq); =20 int virtqueue_resize(struct virtqueue *vq, u32 num, - void (*recycle)(struct virtqueue *vq, void *buf)); + void (*recycle)(struct virtqueue *vq, void *buf), + void (*recycle_done)(struct virtqueue *vq)); int virtqueue_reset(struct virtqueue *vq, void (*recycle)(struct virtqueue *vq, void *buf)); =20 --=20 2.43.0 From nobody Thu Dec 18 00:10:56 2025 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (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 075D41537D4 for ; Fri, 6 Dec 2024 01:12:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447525; cv=none; b=Pbc6P3FOYOGq7keOZzlOrEWoUcS+VRSTT3iYEl4WNSNs17PgLKqEClMX9grQAr5CT7Wvdnm2z40aHUBUWcIpk4Bl1D7ihCAbg+JF8/G5Z3buP+hVbiA4tAJra/jiqu47+dRW5OmkDraJJ46tG8YmHVL2WFFYhdana3uiKc4RS5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447525; c=relaxed/simple; bh=HSdpSrosBpFjoXoHgEPxOFMdxecD/sTFHyHuYcmRo44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QCgH9eSyltu+JDypk+CGztGJ2q52z/UQzvXFHaoJpMTcDzJaeNyjtrbRccya/CEntHEs0uBl0OO86h7qJk+3+nhuIFTAR4y9vaFJlZDLuBgcur7Ko4kVWqfZ9Vzf6w9LwS+Sl+nlMoku/MSoGOsna/shPaEFk1Lk6K9JIYWnJz8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=tbca2gfv; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="tbca2gfv" Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 3549A40AFF for ; Fri, 6 Dec 2024 01:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733447522; bh=3okZ7Dk5bsE+ZlwnvoQtqX4jE3/LzcC69p28rg/sS/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tbca2gfv2PwPq0DU19SM1pmigc1fn0BZaJvbxBrAJMD3swtG4VWCOvQPozh5UA1AS M31/yHYVuq0VqFg1BH+mUEu4o15cnyyVILDUj4WUOIK3xslNK8mraF0RBJXCIIMUC5 QgDe9sMs/mFs+Yf/LRbHO6tqFuzr8WgxUuBUzJgYiJFCshgOFnzhIblluovSwPVZuD ahyd4pPdc6i4PQa5pYeTugFmA9nomhNUsDSaZkT0WJUYHkYh2HKNIrbKMMFVQeZi9J wMErPd1BLaiEHFQWOV6mepi9M5fzE38e5mVAQFGLfSvGYrSdQsgawkOIqjVT2V+IQ4 U4SOx1Tt8mb8Q== Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-215c54e5ceeso14102475ad.0 for ; Thu, 05 Dec 2024 17:12:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733447519; x=1734052319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3okZ7Dk5bsE+ZlwnvoQtqX4jE3/LzcC69p28rg/sS/E=; b=sKzv2dQ9Os0IUhXsoWQcw0f/CXsB3Px5lT3/mTlizbUBqsy/j9L9+UwVTC5a1wYiS5 Ny5UH5CRR8BjZIMoRadFNcdXXs8AZQbb88yvuZkUrBbq34TDqMgBcIC6EsCtr/CR95uK nmhcgrfecOymq0ipR6hgoIh1iiuj+UUwPmprq9hONA/k7yrVPim5QKjqQem4LFwg+w3B xiz9aaARe97PCPsUo73T68tZkrP7Fqdar5ssZIpnyejCb6112OF2AmxLbM4EIgGLhK5T vRizxr1Y3Y0bL0tRIM4d8GwKxjalexOMWMsb++zns8JxbV5vQ5DLJw9O24DgXgVjtZSE oZHw== X-Forwarded-Encrypted: i=1; AJvYcCV3CbbJVpwqnsHWIwwYciQ3M2ExwwFSBfo44uxqHZGfjkrzxysLPh4qbytwiIujGGZRUmMVbVclN67S0vM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxlnset3E2u9rynyCKo6aTm4XyCxvqy6Ovw/h4WStD/N78sGv02 qMpPhRWCyivNRH3OgxIf7In+UE6HyAeMO3U0PU2YWCvozCpYilBw4+9Dus4J4Fu/26RDNRKsd3Q anXJphbuoxW7KLeIN0drkqsZRFYorNovwrHfOMYojEnBLQhvUTmionHQZciIevqcdHDq4D/DSMR nz3A== X-Gm-Gg: ASbGncuBqyAfx+n2hiKl3RlecAwpMPvzmq5lGSH5hblZTzLjUdgwKPZLuZjycTcPeBY xGbdLQBsMn+QXS2NQdBl2ixpejSB3C8AgIWww0MNd1hNt3nNZiADp35H5cO9xxyGdO56W3irQM9 xE5IQf5hbpq2YhVS7G8AaE3hKu9ha0GwwxYuoGFcOJefBQbpLWGhZBheXYAW59ETIuL6T4ZhguZ 54/zZ1N0zlfL6IzFb4U3xxPylcBGZ4gow4ypERux+qCmVno2FM= X-Received: by 2002:a17:902:f601:b0:215:b13e:9b14 with SMTP id d9443c01a7336-21614d75a53mr12429215ad.25.1733447519043; Thu, 05 Dec 2024 17:11:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQJN3aYvWonWOaVQbbwag0krwaPJYzGL0PhqRtYyRPCKfavtSDhMd7s04xv5fglvYMegTrDg== X-Received: by 2002:a17:902:f601:b0:215:b13e:9b14 with SMTP id d9443c01a7336-21614d75a53mr12428985ad.25.1733447518781; Thu, 05 Dec 2024 17:11:58 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:9740:f048:7177:db2e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8efa18esm17979355ad.123.2024.12.05.17.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 17:11:58 -0800 (PST) From: Koichiro Den To: virtualization@lists.linux.dev Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v4 4/6] virtio_net: ensure netdev_tx_reset_queue is called on tx ring resize Date: Fri, 6 Dec 2024 10:10:45 +0900 Message-ID: <20241206011047.923923-5-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206011047.923923-1-koichiro.den@canonical.com> References: <20241206011047.923923-1-koichiro.den@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtnet_tx_resize() flushes remaining tx skbs, requiring DQL counters to be reset when flushing has actually occurred. Add virtnet_sq_free_unused_buf_done() as a callback for virtqueue_reset() to handle this. Fixes: c8bd1f7f3e61 ("virtio_net: add support for Byte Queue Limits") Cc: # v6.11+ Signed-off-by: Koichiro Den Acked-by: Jason Wang Reviewed-by: Xuan Zhuo --- drivers/net/virtio_net.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index e10bc9e6b072..3a0341cc6085 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -503,6 +503,7 @@ struct virtio_net_common_hdr { static struct virtio_net_common_hdr xsk_hdr; =20 static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf); +static void virtnet_sq_free_unused_buf_done(struct virtqueue *vq); static int virtnet_xdp_handler(struct bpf_prog *xdp_prog, struct xdp_buff = *xdp, struct net_device *dev, unsigned int *xdp_xmit, @@ -3394,7 +3395,8 @@ static int virtnet_tx_resize(struct virtnet_info *vi,= struct send_queue *sq, =20 virtnet_tx_pause(vi, sq); =20 - err =3D virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf, NU= LL); + err =3D virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf, + virtnet_sq_free_unused_buf_done); if (err) netdev_err(vi->dev, "resize tx fail: tx queue index: %d err: %d\n", qind= ex, err); =20 @@ -6233,6 +6235,14 @@ static void virtnet_sq_free_unused_buf(struct virtqu= eue *vq, void *buf) } } =20 +static void virtnet_sq_free_unused_buf_done(struct virtqueue *vq) +{ + struct virtnet_info *vi =3D vq->vdev->priv; + int i =3D vq2txq(vq); + + netdev_tx_reset_queue(netdev_get_tx_queue(vi->dev, i)); +} + static void free_unused_bufs(struct virtnet_info *vi) { void *buf; --=20 2.43.0 From nobody Thu Dec 18 00:10:56 2025 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 115E7154426 for ; Fri, 6 Dec 2024 01:12:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447528; cv=none; b=EHO6qOnZpoO/wlMJBIbvKPBdxFuOusoq3OvAnRLmrc0eIVMARAkw/2gOOBOBuzmYeoBOxVUrR+L75tQrzX70vP0fH5+HUq2rfkqrObflS5Zh30M6r9jBIYm0W4CpwHdOmZZfWqT60wno4P5nmPHSgfVfKjLb/cPdfvpGxC0XrmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447528; c=relaxed/simple; bh=PA8/nHkFzKyb0DBtcvKTmZDujViTonA6IYtFxIJd3EM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rUYrd9w/2HO1Rcxx4ww6bDqclTcFtBz6HQJ9ApZe8fdiP5PbiSjiWafU+60BtQO3BKduw+r6FbgQSAYpyYe0D3sWwfLQKpjLdbUbCI83lrdQwBRjpL0M7B5RmgLS2WWzjEI3P5zVKvMlRLqrv7lXSIHR/Jy+osmgCQ/+tpBBzo8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=XR7jBx98; arc=none smtp.client-ip=185.125.188.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="XR7jBx98" Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 7042D40CEA for ; Fri, 6 Dec 2024 01:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733447524; bh=EaIKOfv6bk/O45LzQBb832X2umTA/PIxnCqcZGBeU+M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XR7jBx98txklshiqfsevz5ZWa16wTrmt92/8IpqgN7AAU8hLgNxRwFNr+LYbqEaWr UUoujra0egQdqL/UOOC1guknawWo3dxB3QqEYLCnLZKZQy+hrBij/RyjgoQTWguGpv SXWBIL0FSB+y/HYr/sAc9gQoSA4QmkiRUvIEeKJ393AJVwq8lsLlHzK8on8fNhVfPg Mw803lVS13/4KiB0n9nmoxrC9Rj0QIut8h7zM1hvwjGDdD1KkUb+OEKxyt805P3du9 FtcdCke83US3UAbZ1gqIC25fY/rWvJk/GVha+X/v97vqdihWYI+MYnOyGDzDLnv9Ds dCENIoX3p8RGQ== Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-211c1c131c4so26258075ad.1 for ; Thu, 05 Dec 2024 17:12:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733447523; x=1734052323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EaIKOfv6bk/O45LzQBb832X2umTA/PIxnCqcZGBeU+M=; b=UGFC3VBS9WE9L0Hyuiy62YCT8HtcWM8YbsIjNDnGurYOLR28LcmZifgAf1E7cgskQJ G0YJC8/a++YFK/shWHIIxnP2EvE/Bd6GU/PFwLw6y70WxwVQxik+pf7h3q3sKXKLltuj uhMHSCFLLnRIyUlkbRxBqlaWATCEbSEz4Zu/v9Vvij7H4l4IoWnyNeaH6T9z9Q6rkUAU 7bro4VZJ0l3fGMDOIwQR0cmlclKIjYr1VG5okrRNRsl7mRzcWlGRgpLH51kyKQYVYgrc LWMVydWxha3V/7nYzSAij4Q294T38kn2j0RvMF2VRGJ6F10Q8/0dEitm8Lelo0Y3tIty wsCQ== X-Forwarded-Encrypted: i=1; AJvYcCWf0cEwaE1q/6jn2sfvhdATcOd4PJUxS3cWR+gRilUpGySpjHmZz4rBtQi51m627kI3pRzMEZLwZmXA6MM=@vger.kernel.org X-Gm-Message-State: AOJu0YxKak4pSfJrz4CrGGddSeNFE72stv2WW4MR/lGRfpp63bch6HtB a2ymOUJIO81hkrlbcFyUPx7OSr47L/MJW+h6jeMXpGTDfbpMvUpXht/1XMDyG/mK7FiA4r6zRa1 BU8e2uW2IGIp3DSP0w7z3Zyzs6UsXzF36VpxiGVPXesHVizt2Ha8Bjsm4MRotyOUV4FSdxvZ7ie EGsA== X-Gm-Gg: ASbGnctrcahG9DCSusRqHSUcmW3Va/TZziMD9MvnRUWBe24WWYehevPeR+opHnyI58P Mk0EvDp/hZn0RsNtII0IWJOQes+6Eh93jAlpJeI4DFQP5/hB1P2YUxjhMaRk5OM1Czx3Rx+rXtO v3a2ApAjIP5fqNop9EU3oHKKKQijlnahF0LD6DkQZFwSL8RWi80U+57/pRPTBpGA6Z0sTlsc/8B aglX8nrNQp8aaUstbxpiUzu/7XqS2AOaN++SX5/qyYxL//bpNU= X-Received: by 2002:a17:902:d2c3:b0:215:5a82:3f8c with SMTP id d9443c01a7336-215f3ce4fa4mr81930315ad.20.1733447523057; Thu, 05 Dec 2024 17:12:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXqJiZIYbDQc+sRm11CP5WOXPhB8Q1WFXfqgl8yxVSWKPwnlYc7wDaqcK9TVVx9Gd1p79dsg== X-Received: by 2002:a17:902:d2c3:b0:215:5a82:3f8c with SMTP id d9443c01a7336-215f3ce4fa4mr81929985ad.20.1733447522743; Thu, 05 Dec 2024 17:12:02 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:9740:f048:7177:db2e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8efa18esm17979355ad.123.2024.12.05.17.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 17:12:02 -0800 (PST) From: Koichiro Den To: virtualization@lists.linux.dev Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v4 5/6] virtio_ring: add a func argument 'recycle_done' to virtqueue_reset() Date: Fri, 6 Dec 2024 10:10:46 +0900 Message-ID: <20241206011047.923923-6-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206011047.923923-1-koichiro.den@canonical.com> References: <20241206011047.923923-1-koichiro.den@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When virtqueue_reset() has actually recycled all unused buffers, additional work may be required in some cases. Relying solely on its return status is fragile, so introduce a new function argument 'recycle_done', which is invoked when it really occurs. Signed-off-by: Koichiro Den Acked-by: Jason Wang Reviewed-by: Xuan Zhuo --- drivers/net/virtio_net.c | 4 ++-- drivers/virtio/virtio_ring.c | 6 +++++- include/linux/virtio.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 3a0341cc6085..5cf4b2b20431 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -5711,7 +5711,7 @@ static int virtnet_rq_bind_xsk_pool(struct virtnet_in= fo *vi, struct receive_queu =20 virtnet_rx_pause(vi, rq); =20 - err =3D virtqueue_reset(rq->vq, virtnet_rq_unmap_free_buf); + err =3D virtqueue_reset(rq->vq, virtnet_rq_unmap_free_buf, NULL); if (err) { netdev_err(vi->dev, "reset rx fail: rx queue index: %d err: %d\n", qinde= x, err); =20 @@ -5740,7 +5740,7 @@ static int virtnet_sq_bind_xsk_pool(struct virtnet_in= fo *vi, =20 virtnet_tx_pause(vi, sq); =20 - err =3D virtqueue_reset(sq->vq, virtnet_sq_free_unused_buf); + err =3D virtqueue_reset(sq->vq, virtnet_sq_free_unused_buf, NULL); if (err) { netdev_err(vi->dev, "reset tx fail: tx queue index: %d err: %d\n", qinde= x, err); pool =3D NULL; diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 6af8cf6a619e..fdd2d2b07b5a 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -2827,6 +2827,7 @@ EXPORT_SYMBOL_GPL(virtqueue_resize); * virtqueue_reset - detach and recycle all unused buffers * @_vq: the struct virtqueue we're talking about. * @recycle: callback to recycle unused buffers + * @recycle_done: callback to be invoked when recycle for all unused buffe= rs done * * Caller must ensure we don't call this with other virtqueue operations * at the same time (except where noted). @@ -2838,7 +2839,8 @@ EXPORT_SYMBOL_GPL(virtqueue_resize); * -EPERM: Operation not permitted */ int virtqueue_reset(struct virtqueue *_vq, - void (*recycle)(struct virtqueue *vq, void *buf)) + void (*recycle)(struct virtqueue *vq, void *buf), + void (*recycle_done)(struct virtqueue *vq)) { struct vring_virtqueue *vq =3D to_vvq(_vq); int err; @@ -2846,6 +2848,8 @@ int virtqueue_reset(struct virtqueue *_vq, err =3D virtqueue_disable_and_recycle(_vq, recycle); if (err) return err; + if (recycle_done) + recycle_done(_vq); =20 if (vq->packed_ring) virtqueue_reinit_packed(vq); diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 0aa7df4ed5ca..dd88682e27e3 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -112,7 +112,8 @@ int virtqueue_resize(struct virtqueue *vq, u32 num, void (*recycle)(struct virtqueue *vq, void *buf), void (*recycle_done)(struct virtqueue *vq)); int virtqueue_reset(struct virtqueue *vq, - void (*recycle)(struct virtqueue *vq, void *buf)); + void (*recycle)(struct virtqueue *vq, void *buf), + void (*recycle_done)(struct virtqueue *vq)); =20 struct virtio_admin_cmd { __le16 opcode; --=20 2.43.0 From nobody Thu Dec 18 00:10:56 2025 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (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 02D5513C9D9 for ; Fri, 6 Dec 2024 01:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447531; cv=none; b=e2vXzaadXA0oss+tVwrDTgcwnPeY7uioWCALh5ddWhdGKA1qxf8lWX4P+7Z3Tuzh+UyIU8dwPqQ1KWlTJXjpgYMl9cw72R/2Cs5TdzB5CWsTycNTRW01/pzk6BZ+uKOs5JXkFdv7tD/xsEYUIQxinBRt9vnK9Phq+DjjJDrSw6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733447531; c=relaxed/simple; bh=6hQW/GNmPuXyiRMQuoJ6EZUo9ki9tFcrjiw8b7LwAbs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GPZDgXjxPreF66ikK5ACVKos0tp//FTtvNvVa8GmKoB0Zf0MD5j9jKiXB4Jk1HBYu51SQopoCpMv3zpi7FmxJ0vvVlOiNYKy7idfym8gELvgAsYjufaNT1LvtRVnm6LQ4tg5RxogJLjBvsl4mPpSJGJ3UWc/pqfD1Cy6aUgSwUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=rgB1jWUd; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="rgB1jWUd" Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 78BA53F2A3 for ; Fri, 6 Dec 2024 01:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733447528; bh=gPawsTtuEBPD/KPKBNzHBHV5THR/q5cTrBGd8UniWNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rgB1jWUdz9oWqyzNLwjxgaL/yyEMQNUW0WXxGV77IDk6tyO8oJ985gGsHzjCETp1H zWhguCVwJlc8V3RcIZ+FjGOuWLjbB3SUGsIpDEZENhepu1gON9cR/9EWuYyymJxIjU nN55ZeRSo9Hcj318+dU5KuO/m9aFiZ+BPGUdhATKqe8rmk+aooShCY19+WEQ3R9I0a FmpBxTIKkth/eEhj6gdc00uPctb8haQf4G3PePHMfAN1v6FQ/AjpRfu/YS7pi0Kjq+ SaUVAHqBz6uSLBL4/PrhzMBLwIy5FQ8HaclFfSYnymnhA+3akXq5IH9h+R0ZUouoHW CjZ374EvabUgA== Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-21544fd8434so14579485ad.0 for ; Thu, 05 Dec 2024 17:12:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733447527; x=1734052327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gPawsTtuEBPD/KPKBNzHBHV5THR/q5cTrBGd8UniWNk=; b=wEWTFOOytMEnOyyoR556zU8YKmPhCHJLWicjytdCgzu3If9uWqm8dsvu4D5NF3ZtdI o7763IvIOjYbVKJTbwcO/FDutgQNse/PYviGNoyLNTE/q/Y/mkTOSVvGPwyl0pVWQFZN 2wrZciW7yDta2RQP2te2KKm+C1VXA/ltyS6SEenf8F0jNlx9vxnbpFaIYHIc9O63n0wM d0t223Qcl9yVEtvRBv0iwlk7XtdCDKcTKs6yHn3G8AkZDP6evzjOXBYfHoOuYsxgZLgg 5Bx//Zoxv6zWcvNTjDhANh4jpilgQpEAh1iSLR37nJZpIWoTqcMv5sJ0DSceUhKCJcWt p1cw== X-Forwarded-Encrypted: i=1; AJvYcCVShR7lMbRJNnPO/HoaqmU9hl9Yx6VO3Nt0B84F9Sz903ZgAxWkRQN/NBrOxQOEpcq9VMIUBd6reeFhew4=@vger.kernel.org X-Gm-Message-State: AOJu0YwnWrybuaqytPOOlUeBsf7V4iDhGRTBImbAUvcu5ko30BbPzt2S HnFtSxiB1MsXmI7pLcA9cvfutGalnXtLaPKrJgGaOeFhWVmq91uX5e9/5tzTAsbWiv7sLUZgtzr 2q3ZDZGk7g/Z5yfUy6FGcMrMupW7KHVUSXUV0mSRKxHmJNz+HgwC/VpOzA7PfpNKoFF71L6cNVH HDQw== X-Gm-Gg: ASbGncsF+NJ7+g0t3t457Ha4yXRY8XBhQFRiLdkftBkAYoi2G3COU3nNzgLfaEt8kol +x/STR5cYjT03Xu0gVJfXUbBZMzoF5sVlBhsT9omB52Kw2Jqx5DV8dj0Q0RHgI+e5fd74qgAzW1 tYeyrLtP6NSDuHPsZGsNogZYrd9v+hJUn2OkOAEU6H/IQSV1vvOBJQOVH3hTnWv+M+YaDXZm9O4 Fr7OUXXYaG+8rC/zsW8cx5HeJaez550hYNu9mUl/xElLAzavjo= X-Received: by 2002:a17:902:d4cb:b0:215:827e:649c with SMTP id d9443c01a7336-21614da98bemr12028125ad.37.1733447526977; Thu, 05 Dec 2024 17:12:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3hKgEtavuk/lPGuhbmEd6DMI7J2o7R7dxsGfXdXbPYpoB50i9XnBvW0RBnmyBI3MXmGOMsQ== X-Received: by 2002:a17:902:d4cb:b0:215:827e:649c with SMTP id d9443c01a7336-21614da98bemr12027965ad.37.1733447526722; Thu, 05 Dec 2024 17:12:06 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:9740:f048:7177:db2e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8efa18esm17979355ad.123.2024.12.05.17.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 17:12:06 -0800 (PST) From: Koichiro Den To: virtualization@lists.linux.dev Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v4 6/6] virtio_net: ensure netdev_tx_reset_queue is called on bind xsk for tx Date: Fri, 6 Dec 2024 10:10:47 +0900 Message-ID: <20241206011047.923923-7-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206011047.923923-1-koichiro.den@canonical.com> References: <20241206011047.923923-1-koichiro.den@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtnet_sq_bind_xsk_pool() flushes tx skbs and then resets tx queue, so DQL counters need to be reset when flushing has actually occurred, Add virtnet_sq_free_unused_buf_done() as a callback for virtqueue_resize() to handle this. Fixes: 21a4e3ce6dc7 ("virtio_net: xsk: bind/unbind xsk for tx") Signed-off-by: Koichiro Den Acked-by: Jason Wang Reviewed-by: Xuan Zhuo --- drivers/net/virtio_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 5cf4b2b20431..7646ddd9bef7 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -5740,7 +5740,8 @@ static int virtnet_sq_bind_xsk_pool(struct virtnet_in= fo *vi, =20 virtnet_tx_pause(vi, sq); =20 - err =3D virtqueue_reset(sq->vq, virtnet_sq_free_unused_buf, NULL); + err =3D virtqueue_reset(sq->vq, virtnet_sq_free_unused_buf, + virtnet_sq_free_unused_buf_done); if (err) { netdev_err(vi->dev, "reset tx fail: tx queue index: %d err: %d\n", qinde= x, err); pool =3D NULL; --=20 2.43.0