From nobody Fri Dec 19 06:37:39 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 77CE417E019 for ; Wed, 4 Dec 2024 05:08:01 +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=1733288884; cv=none; b=mv7fkbMX2C+5NzbByqUEgzA+atfK4yfmrhvmZdZ8Mjdiev0ZDsQgN0jCXp7UEjEvbuhIkZ1qejpglq6nb556+rroSOGI7T0KVQlk0HWVEW1nkeHEbLeR9+7wcNs/KWVxhsNWOidNhrseK1gGmydPspctFmnm2242qcjUW/eCZiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733288884; c=relaxed/simple; bh=hM3TSWI+eWAZK1GQuQ4ljeW5GtUNvTvSlHAiQfkse1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qrHfbbM8O4uPSMdQhlHPhjL52ecNxvbt/tX801PAPR2yE3YoOX5K/3qxNTs4Tc2xKkG8wHAI8AmN4oy99yI47SijLKXjC8K9Nr78Z/qXNSjbP2W79jx0+DCkvtKk8pJFb+QDCfkYvFWrdpsV48VxZ6LxbcUJs/lUDA0gHrTK9Ok= 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=I6baVxVz; 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="I6baVxVz" Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.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-1.canonical.com (Postfix) with ESMTPS id D247340CD5 for ; Wed, 4 Dec 2024 05:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733288879; bh=rn0yafvxR+rgXFWM/3BvoQL8ErZXVisWsjUhy9aKjNw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I6baVxVzaJoROpEDsE/3ey2a/MR95NEYvdS2ZbXTchMDbkaTPeXujg6bd/MDD6xav 1iZzK7EHwTXDtiuvbrujMULmu5770LJbqMfYZ6PPRbb9halC0FIR3LMDeKLH2ebqAH G2veu2XGTH+KJDCXSZd0E7eQH2swHOeDVZPQ3l1T6m/6IzimOMoxNHi4d3inziN2io Opq5CNH2FPaG2kSSUkNysJyLU0GBLlJeMZLPxx/47yehdWdJSqnKLIF6RQ1E/v+QLm O5twUyLgsf0eyDaQHbnmJnM/Dav00udrIZgh66ukhOh0iteDRZuCshyqhV+8QvSErh 6ejeoQXR147eQ== Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-7ea69eeb659so4637636a12.0 for ; Tue, 03 Dec 2024 21:07:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733288878; x=1733893678; 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=rn0yafvxR+rgXFWM/3BvoQL8ErZXVisWsjUhy9aKjNw=; b=VjG4n3ceahSCPjns0r96qaxitSn+lQohhTarlfCNJHamT9ILOq9ZEf+3KNqU2vyDQg 2G9jQaY0qxy59B+9gCJoY3kHok2ooQf/RrkkprfpORMKsDZXM7WseRC9SC8yUbVLO21x w1jSICHcSMP/UPVfEmHbcqfZP2VDHyMcA8pSmogTw0ZNQIjn9B8AXc6z97Qobek1Puf9 8IOlskXs7RYr7fK5sH1vN2OaDqAzLpMbqLsUcFsru8ihA0o7PIbX6LQVIn86xLIv0azA uOHmkrIXxUjSO6VPlXhWrswhPahqz55bVEcCrrOpQIc4I0i9jJUJQRJumnIwzum+uKPT vyPg== X-Forwarded-Encrypted: i=1; AJvYcCUeQvTWhBEGcFInI7R0Gry1PBNoMH2RDME2stdf1+vqo1wCd3kTlcZMrGMTtGo6fUngBdER5p760b1PzwE=@vger.kernel.org X-Gm-Message-State: AOJu0YzZKmDnsjZGWKMeOCruNomnleX5birjRO6hul93uBtTf2p5ghjS vvSRfoJoBpCOxHlDqloSHLYUufc6JF0IKpUeZ2QZjnHIDvKS8BpCzEVSV7VxOXep9h2l8Jqyl+0 9dtmq8UMOv/FPs532ic9fOY9wwBkrbZzKQgvGtfOytRK9CEGg7Yy1pZCfNKKNrpvCy+MqKA1BWN 8j2Q== X-Gm-Gg: ASbGncsB9zZL+YAh2VkW9RaAPHSGoMBuK534iXwu18OQrXbI2rzHJvAjn2XG9BGEeFt +DILDdRO0rHDgzpY0TU+6HdSW/hTFKIm3EQj8BNcKrCg/hGNyxArKs/kZTN+qn3IzAlbK06YdiJ 6rIreZM4qLmGRgn6h2rvZo7bXdSK5+l0D4nKMS+QPMxNZGBaDuJB0hH8cKAIt7zBM03dCBe7fSb qnszSaH5uOdKZcYTJILG5mJTP+bSnNcCdp9SobDZikex2rcSQsiSUv/1clvHMKuHioz X-Received: by 2002:a05:6a21:99a7:b0:1e0:cfc0:df34 with SMTP id adf61e73a8af0-1e1653b7b73mr7608969637.16.1733288878287; Tue, 03 Dec 2024 21:07:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEysp0HtOVqClK9sw+sZa+rGz782YX2HQNluIEnhdoS3IDFDXbm7mTKBDtu+0lCElrabYClkw== X-Received: by 2002:a05:6a21:99a7:b0:1e0:cfc0:df34 with SMTP id adf61e73a8af0-1e1653b7b73mr7608940637.16.1733288877916; Tue, 03 Dec 2024 21:07:57 -0800 (PST) Received: from localhost.localdomain ([240f:74:7be:1:9c88:3d14:cbea:e537]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd0a0682d6sm145466a12.10.2024.12.03.21.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 21:07:57 -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-next v3 1/7] virtio_net: correct netdev_tx_reset_queue() invocation point Date: Wed, 4 Dec 2024 14:07:18 +0900 Message-ID: <20241204050724.307544-2-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204050724.307544-1-koichiro.den@canonical.com> References: <20241204050724.307544-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. Note that netdev_tx_reset_queue() is now explicitly required in freeze/restore path, so this patch adds it to free_unused_bufs(). [1]: Acked-by: Jason Wang ------------[ 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 64c87bb48a41..48ce8b3881b6 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 @@ -6243,6 +6242,7 @@ static void free_unused_bufs(struct virtnet_info *vi) struct virtqueue *vq =3D vi->sq[i].vq; while ((buf =3D virtqueue_detach_unused_buf(vq)) !=3D NULL) virtnet_sq_free_unused_buf(vq, buf); + netdev_tx_reset_queue(netdev_get_tx_queue(vi->dev, i)); cond_resched(); } =20 --=20 2.43.0 From nobody Fri Dec 19 06:37:39 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 7E5E7188006 for ; Wed, 4 Dec 2024 05:08:05 +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=1733288887; cv=none; b=bbX+w0xE4d1NYO1o5pQveRcd7KvxdLkiKrVo1eaf1psb9gSS+swlP/H7v66fuetvB+WNfu9dtY4o2h4/f2oOiLECirLBkbz2zcMFti2K4EPmxfBpJzcBeP+vlB9JFPf5+7QEaLdJZzq8LnEnVtBf/v7IHqA6Ig8DRZG1HfSbF9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733288887; c=relaxed/simple; bh=QyB99KR/E5dyuun3oXDM9y/WJ8QG5my98H0Do5AE/aY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ew8KJ3p348pl3B8e100XhMkfUUTRH2kC9BfFzppCbrsoKFRDZpEX8BJxt7+lY0q37vPdi+SWA3l70rMfnnnMIQUwtfJ3EzpXFURJ91gdVjYRA4OrKTU3gNrLGVb3Ty0Sy0iMMrpXTFWueD2h/4C3ThrYUFyl0tb35rq9E2BTuiY= 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=tA25twWE; 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="tA25twWE" Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (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 085703F767 for ; Wed, 4 Dec 2024 05:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733288884; bh=/pCx9eaXWcL4ixwAWHstQXvOGcUbbmljwAztWY9crP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tA25twWEuEa95gb/WvkSsWO8gOpoK2ee1ZMjyAYQh17VuktUoz8bJtOHof0mf4Q3L 4NvsdkhoEYE/g+/30JzCPWuWpXHk1C6SBMkiLIs6EKEoj4jK+1KcKY4Z+2eMIaP/a+ Fl6z4rMQHjDuRetTqPTD56lkDC4hcCATlNakOszMiBCBVLdRaPm1Kq91B5HhEkGXgA k+XmcwiI0ORKKIeFJtBmQIMOHXoVAnOcD5PIuJ5E7ky4Ua44LQzZgRIMisbyp3SAB/ UYMvjZ5jl0r4yKscS5UcS61j1jZ+zskpyL6B/rzqK9dfZPC0yAWhtwlbN2MydkJSB4 w0gIvRhQGEyKg== Received: by mail-ot1-f72.google.com with SMTP id 46e09a7af769-71d45ffb04cso3382710a34.2 for ; Tue, 03 Dec 2024 21:08:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733288882; x=1733893682; 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=/pCx9eaXWcL4ixwAWHstQXvOGcUbbmljwAztWY9crP4=; b=FMnRp7XZvkDEGP/hOSwm565ZbmTMglESxtWK5ig0YjeuafRFeuGp3P5zkskgGHuWwa V4n0JBUwf6FMMSLVqWmtBzvGZqbffsO3R3/kG5EkL4bZjpbOSY6IMAGS/fMSGWKiE1nl L2O8aFpclErjoaKESFm0CDl+LoIH5drbwfveaHuQvyyjbtLnKwy5BIb1T1l6N/xM4jTp uURWwhVlg7PDBAqRsQIvDp2iMMLDBzWvQVgVJQoQL1PSMDLC5hSJMqXm30S28jUn/3OP kWJTEJ+Frip2fyy2ivfSAaF6iJGY8nUJL9gLxWXHJKFu+dyoTLZMTRbRaMgclMxqoykP 0k/w== X-Forwarded-Encrypted: i=1; AJvYcCXhzBv9GNrUIPQFBkq/meCEOTl8f8Uq+CmPRM4ezPcIhfUKyOYCo4C0W6ROfoSL5ZXXd93qD80m1eASSWI=@vger.kernel.org X-Gm-Message-State: AOJu0YyZmc8+8vbZ+OWZT/OrA7oXbkSKf4/Yt4I08YlNq3DH0LEckc3D vT8Ma02835tl3djKn9cYAYmUSH1A0eLudISKE66pVSxM+kXuZjl0WkDFA6+l+lXLbxcdWU625yx DR9A4xkCjRRGjkdNIa1nQd0VM5mokSoiDgP2BNLTtdIKXpyWVWDE1tRCYJxw+KVOZUEejeEEthm qI7Q== X-Gm-Gg: ASbGncs0lvvymIaPG+YqzAMR+dH2wTCbGZGm4vMGW43rR+crVePMgDcsxhyqQ84TLWX pG4oHixa3PNUsc6Vh1vlWGL3goLv3rZ7ccWdQkA6588xysMlst8Sqmt+vLjfSTm3792GkLuCa7A V/o4QQuBz7aiO3wfxrm/RAXKpkBpIeGcWeNCIP+Bco0R6pzpKgpXABnGnlS3fvV7OFN+8FNLh+7 P/FrXJQA2qMmcDgqLWa+2aJNtJI1SKbQhLO750Ftn6VC220yv8tDefETBlZ2iitHMIG X-Received: by 2002:a05:6359:5f8b:b0:1c3:38a:2143 with SMTP id e5c5f4694b2df-1caea790375mr503389155d.0.1733288882545; Tue, 03 Dec 2024 21:08:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEs3DkY/VwOKGPPt8+iJ+sQPX2t2a1HIu9jL1g2fxiv2RrXsi55RCQsiq+IatRf8oAeRlGmPQ== X-Received: by 2002:a05:6359:5f8b:b0:1c3:38a:2143 with SMTP id e5c5f4694b2df-1caea790375mr503387455d.0.1733288882234; Tue, 03 Dec 2024 21:08:02 -0800 (PST) Received: from localhost.localdomain ([240f:74:7be:1:9c88:3d14:cbea:e537]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd0a0682d6sm145466a12.10.2024.12.03.21.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 21:08:01 -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-next v3 2/7] virtio_net: replace vq2rxq with vq2txq where appropriate Date: Wed, 4 Dec 2024 14:07:19 +0900 Message-ID: <20241204050724.307544-3-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204050724.307544-1-koichiro.den@canonical.com> References: <20241204050724.307544-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 Acked-by: Michael S. Tsirkin --- 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 48ce8b3881b6..1b7a85e75e14 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 Fri Dec 19 06:37:39 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 7A7C218B475 for ; Wed, 4 Dec 2024 05:08: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=1733288891; cv=none; b=niEFRJj9oP3MrTusOxnF/uvs3/KpJ6XvGVXKxsQ7joTv2gEMufpCKAtxiAwwsmzqcv1etgAvQrN9066rjEqaRQin/eXEORqR1F3cOPtyRPkqbrrIRSrUXmGzRiWpXJ+g+TPWhOQJk/4CrnTqo0USTlyUgxHOU0V/e+bTO17lPOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733288891; c=relaxed/simple; bh=hqMbrbaYzCq+7XyNHSdUPNm5e7GvSWtAGjiRKisOUa0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dK9GVK6wGSKWgC80WYjLtwMYwECu52pHEYWgGWjmiNpxT+tqbSRR+6QvOhKnJRcTP8TY4eYDG7vNfj+MnNEgoiBVSAKD/mmJTJr31LmNr63nr6eBs6iaYy/PMwpeFxGCKi4slXaXIkhqn0GtlrQkNwobGA56HH+8Mg304CFIFxg= 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=Qyu9S9mC; 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="Qyu9S9mC" Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 33C353F767 for ; Wed, 4 Dec 2024 05:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733288888; bh=FIgKTk0jFKfzwEEyDT2sgiCPxqET1PFOW7qhpD89ECQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qyu9S9mCnx4pcYekkU190n1p39grb+EJu7YtPUBXvKPEUShglzziXTqE2DTDMYUA0 9KQssvONmiVWaFF/Txt8pUnMeMcTVZvmxNjtl8TDpKcf4c+sryIvfqE+VewwuoFGNg I8s16N5y/sMzX4k0awSmBLtAtJuAQWIu4O5eZFsDDelJfubJtnvZIKa71pZy9KPZ4P nce9h9hGCprVU+bh6nJhkYs+sEpyLpirAGKijXectYyUN6/ld8UDyspgMy+RbgMElT DueY2B/N1dm5QYMYNhvxgXXy8HaTT0tkefBtOqCRoEdPOkdshnjs6Q9oqhzGFhmSgo DpNBwmCvKEIqw== Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-7d4dee4dfdcso4054375a12.2 for ; Tue, 03 Dec 2024 21:08:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733288887; x=1733893687; 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=FIgKTk0jFKfzwEEyDT2sgiCPxqET1PFOW7qhpD89ECQ=; b=r7vNZXz+Xkn/Dy6I6L9oDB0F6awdKb5DGb+jfbTCATCCxpkNe6NCAPSjfF+4Ekvffx 5WLvhBKEMMZ4V9zQdUz/EPk0OwNKxAI03fys5zk69PBMXfyx0SB9mqIeY0wfxr32+qj3 MqWbV14u3K991Olf2KP/aRyyFFdu3hU4NONhAIibQlyPAmuNyP15NPIRPsFu58ZB7F3l R0ev8TvIOe+/eYpe/oHoLAT2DXRT+bsmdLrj5VRqsia4ikVhOekKfacsnHEHGEzjG5Ik h6Pp+kWGMeRv+sX3xmbJURAWr8SoC0ovt3dTSQ0vrYpHzIYROVBtS8i15cxBdPKCFmnC jutQ== X-Forwarded-Encrypted: i=1; AJvYcCVRzmZZVOOjEB+EerVeZw0JMT7SlsJU27Y0Ihx/OQgb9t+gr1M7YvyOS0PSx2aqSyHBIgWAetf+pxRTg44=@vger.kernel.org X-Gm-Message-State: AOJu0YyAsMU7duWXzIQU1RldFC3XNxdaAKKkjqRg2s2cuqbyuF/lyHIo /nIpeBYDbPMpJsK1SKOaimVd8lxiLF6RMJNVGqQzCdnX9xRdB5TvCb79ee2UyhHgbzF9Bogd07P c9QKqSearLDlriMoy7q45FYyEQRWhFpud2fqCbECas7ru30JDWo0olOiAWKk7URVOA3p6nkGeqU 9b5Q== X-Gm-Gg: ASbGncvjj0xJMaGFXYwtFgnOsw7K5mGU1jzuPnB10AJdtQ+PamcysV0rwPUGh56Ma18 IFY9OBVjtrJSSuivfWjli8g7MyNXjDE2NmMlVMUApkOMz/tdpHtfi8xbX7FUsRTIRR329c18ewn r8PT2JA1nNpnBUF7ji+Gq/e5rtRIprEelki0PKuuYgvs8HDDshUE7yabtRGt4ilC8cN3S5WvxUC gExuqpe6X3UBSu1GM51mslC3S4JXCwwDkeHFF77Z6jgnbi6r1DpOnA8fzTO5Gk5jVwF X-Received: by 2002:a05:6a20:9149:b0:1e0:d1c3:97d1 with SMTP id adf61e73a8af0-1e16bee16efmr4965545637.29.1733288886648; Tue, 03 Dec 2024 21:08:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPKUJ5bAB237DtTojPXFWcCu5gDgXnbdRSrhZV9hCNjaygoT5Of7Xd97gtubjWTrohnL5HSg== X-Received: by 2002:a05:6a20:9149:b0:1e0:d1c3:97d1 with SMTP id adf61e73a8af0-1e16bee16efmr4965473637.29.1733288885901; Tue, 03 Dec 2024 21:08:05 -0800 (PST) Received: from localhost.localdomain ([240f:74:7be:1:9c88:3d14:cbea:e537]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd0a0682d6sm145466a12.10.2024.12.03.21.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 21:08:05 -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-next v3 3/7] virtio_net: introduce virtnet_sq_free_unused_buf_done() Date: Wed, 4 Dec 2024 14:07:20 +0900 Message-ID: <20241204050724.307544-4-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204050724.307544-1-koichiro.den@canonical.com> References: <20241204050724.307544-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" This will be used in the following commits, to ensure DQL reset occurs iff. all unused buffers are actually recycled. Cc: # v6.11+ Signed-off-by: Koichiro Den Acked-by: Jason Wang --- drivers/net/virtio_net.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 1b7a85e75e14..b3cbbd8052e4 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, @@ -6233,6 +6234,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 Fri Dec 19 06:37:39 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 3409B18C32C for ; Wed, 4 Dec 2024 05:08:13 +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=1733288894; cv=none; b=q+jSLJzqXr2Tg0t8L0o7pFFx0iEaWIbjiaO7i9K/nuKaCGK5i94hlNbjjsKGXHrjjwaJQCAfnQKlfio3X0pxphXRETxgW9kWaOS573sYqQJDCR//1F8U23gPbjxhcCswGljwV5TPXZTku1tDmz2apYY6LC9+7WotUaNxxYILf5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733288894; c=relaxed/simple; bh=2ASVmnmBrwinuHv7OjI+NZQNnMWFB6cMYc65eRQREgE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y2g8PyEkiWSTf3eaZhvR+xUQmy7+L/GnXkQ4WS7lIykduq13EP7HqfQ+5bdt6KS6lHZThyohrYp2QVAZPtRKmaziOZRf8kYbeLmxi7j+PFhEEnJHzoRpi0Mh9czTTC+pRitbukDWZxYVhLnHGuoJ98d+oBcp9dldLtlq4RQjTPk= 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=X3v5EWDA; 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="X3v5EWDA" Received: from mail-il1-f200.google.com (mail-il1-f200.google.com [209.85.166.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 A6BA23F767 for ; Wed, 4 Dec 2024 05:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733288891; bh=jXyAuQfUujhNr4ebdBlKeTENPgCp2kxqJe5b1p/AGHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X3v5EWDAa0MwCpdWfDi+A14OMjFHEtYsPBMZYwZk6Z7wSHLeMiXIjUqkV3fjJtXlp WAqcouuL4a9ScOFitUbx6dLEVI8dZFv8uqiMCws4WaSqvAP4TQhEP1gvdqMU4AJIUk VOsA3RmQVAXqC56VJEqBFs/+3Ef1h4/Ju/Yb4uUlab/+Rq44tlnWzrRV3XhLRsx4Lp 1mhYrXymkWtWATfI7PgxtcqrcwkgWXW0itp0KZ8SxstwlOFsKrjJYQTbKrGOgdznrj sh7PwdbJhvzQK4uBS6VH9u3Eg0rrjlGZJfvv3SNo+w4JPIFur+As7DcQ4rgzOxGP0x ffFmjDDhWktCw== Received: by mail-il1-f200.google.com with SMTP id e9e14a558f8ab-3a778ce76fbso68473325ab.1 for ; Tue, 03 Dec 2024 21:08:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733288890; x=1733893690; 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=jXyAuQfUujhNr4ebdBlKeTENPgCp2kxqJe5b1p/AGHc=; b=B3QNF3n1TCBidahXf0a0dD1JMiZu/vcbFLMW/Onijk2VCUGfVzUVjhw9Qg11DtKujj 4ru0l+H81AHjYfylhW2rdzlIAvN+YdY9KJPLDZxG2WPvVLJBF6GT6preRWNcUUX7guS4 KzEsoOn3XIMhx4vvWcV/8POjuE0g7u90QCsqnvy4bA0PjpNDqDHMgcQdwUks9ac6dsGx 4MIxKBBJqDjUyrXSCzv9+p3wPuK+XTF0BDKMUzGSafomnvw3/fF5Y44d60t2z2mhAwgJ Zj4RPl03Wjqb33ZPkZDXyiQ+XFvsdd4gbAGdDO0GOhr+pOtSBrsMiE9eXoj6gcTyOESM Mvdg== X-Forwarded-Encrypted: i=1; AJvYcCUVFkseNOX4IFNcIOXdjP0SJsAimIoEUlic6gLT9K70BqG4ufXdH/Otv+UzH50MTrA+KqUBCd0ybyufHLw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxn7nHgdOGkx05+tFi01hBafOq8Azd6jZ/REwW+DDIOd6yLL4Zz m0yHI5X/VIrdFwMagvH9SVXdoAkbQuX8HNeyLhs88n7YTrkTEErVJ1W7F1AKYuHNOe1eXS6Wwb+ iBWky1zfBzXy69MK6+tnjiL0wiuD/AanczpUyePxv6qepEAY9xqR5DaFD8o/4SuYrpb7hYhKKwA VTgQ== X-Gm-Gg: ASbGncsLfJg2rLdCLbsQ+J2IUPc1PJo7g+t5SXN9wT/Et27rTDbndD/mSo3vAUcUFmQ 9cj40+RchOtYOfTjz7TyfXQx3tbN5Ydm5brTZLsAaOoEp5ORXkosc4RhxPlWFEj3WX5J8/pZEdY c5NV4c351r3fawAgiM4FXGjzpRi0+Vd5o6YVhX/m/F69W1e3fiubZGxt0ARAZEeYyIyQKZfyRrN XzJTFOx8KvRyuweJo9Hk5xtnLd/IN6Wc/uX2FAgE3CqaSvmGqnzCCjFxama9weSQKQ5 X-Received: by 2002:a05:6e02:1a0f:b0:3a7:e147:812f with SMTP id e9e14a558f8ab-3a7f9a4df8fmr55453125ab.12.1733288890461; Tue, 03 Dec 2024 21:08:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSreo3edKtytlX2/z1lj+Ztcj1hPgmrTHi1doqfmXw3O4HnfIfLBPg3ea8ZceTG86gSX4Msg== X-Received: by 2002:a05:6e02:1a0f:b0:3a7:e147:812f with SMTP id e9e14a558f8ab-3a7f9a4df8fmr55453005ab.12.1733288890200; Tue, 03 Dec 2024 21:08:10 -0800 (PST) Received: from localhost.localdomain ([240f:74:7be:1:9c88:3d14:cbea:e537]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd0a0682d6sm145466a12.10.2024.12.03.21.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 21:08:09 -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-next v3 4/7] virtio_ring: add a func argument 'recycle_done' to virtqueue_resize() Date: Wed, 4 Dec 2024 14:07:21 +0900 Message-ID: <20241204050724.307544-5-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204050724.307544-1-koichiro.den@canonical.com> References: <20241204050724.307544-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 --- 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 b3cbbd8052e4..2a90655cfa4f 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3332,7 +3332,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 @@ -3395,7 +3395,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 Fri Dec 19 06:37:39 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 5FC7718DF65 for ; Wed, 4 Dec 2024 05:08:17 +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=1733288899; cv=none; b=UzjELJpCWEQGvBOXcfADJywPB/mzIsoDfZvNSZiG7fVkY7U7VrdC6bBPqsqqHZj1JSZBltw+yf0HUo0CU6p7is84snSbU6QFqrKrjB6ttQNME/zqv8JYPG3+33mSwA9vC5lI9y1OkjH9BPCXvpPFN/y1XkL7LqP8oyIMghcopUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733288899; c=relaxed/simple; bh=gLYoI15BjmtBU7oAvSpTarPfyfyGSgvB72KHD0BKUnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LjcU7dj3TJFKXHF1FsYdvuFJhmlV/cMidML4B2Vug22bz3whk2B5PF2SN/oRfNt2z6QpwelS/DOg2g8yBeOJBBwlphb2E5t8DXtx9y9svZDQ0xONozWpu43lH45xbVvTG5F8AOWGZpZs7F/obsyZ5phFjiJfQM1uTKJfcS/68VA= 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=nDC+V+XV; 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="nDC+V+XV" Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 DDE6140C4B for ; Wed, 4 Dec 2024 05:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733288895; bh=ObVc7Whi17Pu6UUwsCZaDHkuVEONGWJHt7EBpIl7aAs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nDC+V+XVcAD7b1H+1pBB2uwhAywejnQ/hMRFp+/jG23uEQ8xcyCd7DNJrJB5NRwup pvzi+glCd2gAoKxP0vu813xGDVgcIFujukFGUtEpnFIZKnW7Cy0vQITQoxXgl6btHo 4Sx585rAL4o+J0zI9xb34fZHydysrUaDjQ8VywfhtJAmfOXOlLaKYo7Ynlaj6bb4el mczlFqveJECYWvEtov3SuxjDvDtmgt9NdFgRrloBTcWfYA5ey1YGTC4w5+CpsxJ+og LJps9Cvx3XxGE4mN5wyK3zv2rmUcvxGqy278oTtB0KT82YJiU8kmNmGTNBaxQdEgLA bDX+oXzAcSLOg== Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-7fbbb61a67cso3790706a12.3 for ; Tue, 03 Dec 2024 21:08:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733288894; x=1733893694; 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=ObVc7Whi17Pu6UUwsCZaDHkuVEONGWJHt7EBpIl7aAs=; b=QSlEhCkTlBy77ve24iy5PWCyQuILtsgV7AbRAH4ZQ8ydWfFTNOOaWlBHpGb2ATwDiX nAxh2gcTDQHMwoChdrKHQx1GjssQrF0w+x7nIZk6eI8ktnlv1T52m1xNRCF8YP/INn5w u337N+B9/Vyt1y5IFVv+/xNr2nbuGRFtJJbY9FiC1tNMVRpVhEmYtBu8Luxiv5gqJpvZ ubCtS/lgaxI1rcfQ8U5JinT+YkVzU2fFyf+JrZGsTtcanUqZeVMolFF1T2niR/OjAyZt Ds0DRt47AYroiOBRHdB4nvrNuNvJq1JFK1MfG7TVZfKlUhI03/+gIQTj8CwBzZOFvzCf j06A== X-Forwarded-Encrypted: i=1; AJvYcCU3ELU0uwdZXcaGJYO2ElsEOzB3igoXg4nTimUtk+2JvFT5iVICO9jhUvIACACmeMZjpQddwPGa4uzkHnM=@vger.kernel.org X-Gm-Message-State: AOJu0YwVi7a2znk7WRknZpJ3702SbMfmkoZbDCcNhCsaCQ1Mg5LuU6QE bRkZakDMkXZ4hbgj6cTdc4HXfynWcgfxxz6Jp1SdRGFb/Lo+1Jw9ruNuSR3wG0obPmvendSqYgh WqDvpHF1cEWLPUgj+TdozhlxEBF8kj7TgT4o+pumRKpbFmE9A3XM+bgRgI839wW7KWx/gkoPwO+ k4VA== X-Gm-Gg: ASbGncvXtmTL3cr+1HyG4e7OzPdC0jSVEj48ptMRCQbLGrZaw6cXnPZGIXl0OlSGf8w HAetoS14zyW/LCpCLeUVCsYUbW28qKWcuPJnPDpjoQI0/O/p15XpOD3bfQcWRqgEqFzlCfS6mCg 2aPwWOJAwz1H0qL8+ltp1O872ZYXLQ4lOWQh4S0HlNFu68UVTS9DN/4mUSdhPYv3urvT2f7rQsB K+5C/y1QPokQ2bIHQLcJ6vmUU+e4+rgJ4RiLWeY83b8spiHZH9WszQNXNvF5UTW9t5A X-Received: by 2002:a05:6a20:3948:b0:1e0:c7cf:bc2d with SMTP id adf61e73a8af0-1e16bdd328amr5699742637.3.1733288894411; Tue, 03 Dec 2024 21:08:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFj+uUlyY1C0BsWmALoxtojbbY8sLNjryjJ+hUDmswkw3F7P+vqgijj+KJpqRsQ36IWx1WReA== X-Received: by 2002:a05:6a20:3948:b0:1e0:c7cf:bc2d with SMTP id adf61e73a8af0-1e16bdd328amr5699705637.3.1733288894118; Tue, 03 Dec 2024 21:08:14 -0800 (PST) Received: from localhost.localdomain ([240f:74:7be:1:9c88:3d14:cbea:e537]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd0a0682d6sm145466a12.10.2024.12.03.21.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 21:08:13 -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-next v3 5/7] virtio_net: ensure netdev_tx_reset_queue is called on tx ring resize Date: Wed, 4 Dec 2024 14:07:22 +0900 Message-ID: <20241204050724.307544-6-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204050724.307544-1-koichiro.den@canonical.com> References: <20241204050724.307544-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 --- 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 2a90655cfa4f..d0cf29fd8255 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3395,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 --=20 2.43.0 From nobody Fri Dec 19 06:37:39 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 326F318F2EF for ; Wed, 4 Dec 2024 05:08:20 +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=1733288902; cv=none; b=mnAajQQdsVRc3lxyPj8IlZ09wpXyTOz5VIijm2X2pW2txLhhF98PBJiGpIxEtU+vRwqZRyW9KznlRTzAZQa0PbR0ouiNk/aIzd7GazcdO1p5IKC7ooneYnKigi1rwJ7YJySkf0P802gTRtIm342cDgn4oVGhdoveoOm4Hq3uE5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733288902; c=relaxed/simple; bh=/hxsPKXVZNwPj0FSFmTo2DxSrpBL+nEcvnadMx1VMr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iU9UxEi8zp6fj4rmsJKE+jb+HMwBTSEfsFuVTcDUQc/aXllg387Qnd5v8t6AiNOkdetPD2lxYrv7E5N/1psQ5tiNSvyC+YlTgMxzkQZ8210gaVzwFpL/QfU2Oc9sjJjQPqFBvoFsQVUhPec1iLrahEeuhaQYHQqebgnwqa/pJK0= 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=e+Z/auLe; 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="e+Z/auLe" Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (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 C44883F1CE for ; Wed, 4 Dec 2024 05:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733288899; bh=cMQ1mn6QkKh++9sVefHm/YQARbeGOPYVwGZmbPvclzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e+Z/auLe4VrP/HY06rKtp4J1/jkJ7IlDoYUNgfe9m6hcDPyfvAqUkpUh1MApIMp1x B/xbSuhQvt5tDzT2mfCU1UzZ8vWgOukWp/G3D9C31OP5jf25txTbADO0R3R67EL4H0 kgveLAt9mbzvRdFWnVOvXH+RsDakydwksvuu75NjQaZOeyoFnPyWfTwy9vCMaTnB4c dwJxaZmcxQqHEaJ9nmTnW16BrBvSVe/APU3EfiJyS6h8N7U0axEjJQCqSQ3nFisLrX XPRWdT7QVUr6ggUahYlKmAXXMix0L8WwSNDhsG1K05bJg126qBncDQYAKQ5apNe13z /ck584pR0Nkhw== Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-7251d37eac5so7164408b3a.0 for ; Tue, 03 Dec 2024 21:08:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733288898; x=1733893698; 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=cMQ1mn6QkKh++9sVefHm/YQARbeGOPYVwGZmbPvclzE=; b=PY1V11eXd/mnG9dPJPT+nfnaZudlNhOY3NGCw3FOaMQ6WX2TBg58waFFbwpnVkFxqV E69rUeK7vdX1N4SraqeTg+R5KdTb65YqiHX6EUqnH9wTwBYyK5cM1lzo7tPzYCbL+MOm +OBMexvSLJODn29Keq/zLawJ9is+IObe1Xf7TJhudBcuS1+U+PZGGi+3o/gfBSrPbKHo ArJ9Yz+Ak7HERPKX97HPUmCWVTcqwOU4V+EKLT1AmTSv3J9PNoKaSs1n5WW4ZcXeLhtI Wj9V6WSXxiAnI56aXSwWvc67DttmS0rqO6Zhr6BcZfH1yBkBepfzRc9tK7Ad0Cwd2f46 klfw== X-Forwarded-Encrypted: i=1; AJvYcCXGlr1/nvMJMbfKy2Kyei/q2wH7Mp8XGDYNGz9lKtMUB+cytqTr6Ut4wkaXca0eHaNOLGoTsB98y3BDu0g=@vger.kernel.org X-Gm-Message-State: AOJu0YywyetisR3iVlnJhcEVbJKRfPle2WoEG7XXDDvaYZfEXUTxbaPa rQBxc0/rb1e6JaTLq22v0lw/gNX9vnuXhW1MrnIRsXyb2Jy9Qn1N5yWof1I8zTqyQ/286m25SVK KySBZFH5xB06QjETxsMTjT+W4S8QW7rvkuXzFHdFQbdkCTcvc/NcsJjtkefT43pWQ67xvf5zTsy Qrxw== X-Gm-Gg: ASbGncvi9HzJp5HkS3mOxjLZLQfW5wmUvmDZZP9f26/xWOGHwvQCv5/Ho8byPansQLO B62T7oBThPyKo46M/tdf3qPSyaJNuw9UKwHFvxdB0C5WzcTd198pokpfN6TD2nVIVrfSUjomr10 uLcBsX2a8wr+WTMZrgYYXfDz7cti2iOWOLSmC7YZxCZKDt2m8L09zioDEpTQWJBCsTPocphhydw GZzhojgGbwIHV4iCB489kfHhAcqY7YHImV3iLGAiPymOV34XQA0+qQg1uLmZFkS1DOS X-Received: by 2002:a05:6a00:3c8a:b0:71e:5fa1:d3e4 with SMTP id d2e1a72fcca58-7257fa45248mr6730698b3a.2.1733288898384; Tue, 03 Dec 2024 21:08:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzK4BK1oktH3ckDZBRjHOokufY6SEBLhJ5DJ7e1vYZicOqoakq+cqHgepP7ZCNIOpN0Nx7ew== X-Received: by 2002:a05:6a00:3c8a:b0:71e:5fa1:d3e4 with SMTP id d2e1a72fcca58-7257fa45248mr6730677b3a.2.1733288898066; Tue, 03 Dec 2024 21:08:18 -0800 (PST) Received: from localhost.localdomain ([240f:74:7be:1:9c88:3d14:cbea:e537]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd0a0682d6sm145466a12.10.2024.12.03.21.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 21:08:17 -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-next v3 6/7] virtio_ring: add a func argument 'recycle_done' to virtqueue_reset() Date: Wed, 4 Dec 2024 14:07:23 +0900 Message-ID: <20241204050724.307544-7-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204050724.307544-1-koichiro.den@canonical.com> References: <20241204050724.307544-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 --- 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 d0cf29fd8255..5eaa7a2884d5 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 Fri Dec 19 06:37:39 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 D091217F4F6 for ; Wed, 4 Dec 2024 05:08:25 +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=1733288908; cv=none; b=iU1Tjj5L4MqAJ7iRwVTWThIIYmXsrXAld2xDe36AtPr+fySaucPrgLQVs9GdT4XnRanJskE/ejOt5tq61ZXlwFMhhRvIS3c7btdUQLKE2kTsCLzrpRLUP5mot7dSZTp/FQkguhClIwRxry8DErtDUJ9QiAUmhCq9pRxPzDHzcjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733288908; c=relaxed/simple; bh=pJkC/sg81thrf+L+DBV2A5EohoZuMx0x87sK8yW3WmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BDSULIkH4qEbmU5xHoaqIMiyM1e1B3cZOBNvlWhMUiRVwRLouCB3cRxo4gNTY1C6RiNmfdHJf8W1czhqs1AcFxoR5enYbzDbrrg1Vvy94IIgntWhAQKcLT45RiORGWQYChFJU5t8HEFtyLLazwpMauY8FW0jB2atsQWYfsQxPf0= 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=RNb3nZ/D; 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="RNb3nZ/D" Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.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 165E93F767 for ; Wed, 4 Dec 2024 05:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1733288904; bh=9uM+qY4J1GQbqjmyDa0r1OVtoI70UH7O4H6kctiyohw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RNb3nZ/Dju3MXmIt9xCp+I4QFIndzYDkC/bRwMxnumYQWyT/B6V4YBglTrwW+2Fk5 Bu53TcRURs+UlO1BUyrU33SvY94U87Yv/JG+N4aHh5QoaJ9hLrQ9un5y+qDxiBGDd9 x8M5gikXmBqbddu96hCLd85ieoaox0EaWlm3nAEr51ZX3zWBHGF5PnUKQl4oqPnvZ0 Ynme3mGq51tb4QNoFGntWjJJjApoX+ZgaMXvEL5IMcNWYdQmzeC2FSnYlm45QNmCpO 8EdM1iVOI2xsk2jS7aDN0Eo0KXVARkoqugQhxQWNMIis+nGYigoXb9boBpTLDazFnA MPFKjfCLsCShQ== Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-7eaa7b24162so6144187a12.1 for ; Tue, 03 Dec 2024 21:08:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733288902; x=1733893702; 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=9uM+qY4J1GQbqjmyDa0r1OVtoI70UH7O4H6kctiyohw=; b=maM2Lx8gtdZWNF8Bf/zgn/DgH9EB30SrxD9/2YythDrLz3WPKyEG+jZgYi/RNPxgpU SUxuuNoM4vk/Nov+ns3T8co+UIS0qFFORYvM7h901oY+ghr9CCTETeeSDC2yTe57SRKo /Pb2L7pEbBk7FFqn2HO6Ki4YgGsPO4pvyYK2jRWxOcosR0HKTiX2IiQO0K3h2v+f/u+J fqa9rkyKqPlH/h5ZIbBOWjQWrtaxYWsGB0QQRjEjj5yFvWvQMlyaDVuBa4I2k8acTSWK I8Qlb7FBwsdMR6aGxvOsvhtfX0WinyCfdwtskS41Ob/Pd4UYDdZ5y/8wmBNOdYwwUhkA eeNQ== X-Forwarded-Encrypted: i=1; AJvYcCXeapLe7Sw4ip/ty9VbU4PGouDhOgDj4qjjXYWAx8av48IHUIGM6l+nCtIAgC9qLA9tSBzQ+jrBivbsVZE=@vger.kernel.org X-Gm-Message-State: AOJu0YwrmUseU/5TL5EjG90QXw3rjQPgCQ6E9g0lLS1hU7ZYI1ujQIXX qNC0DGoabZpyG7yPPq7vIRscZjgrfHO26057RyNVALRiIwI+PuLKyoGXML36HVpvBOxatHaFW8A XmRAFsYcOgbYkZ+wwD/1OYpvxjGtb03Qc/WIMs6EkWKAKsP0EP5BWMlb3ezD2sGdvrfzmHpiCvt 5cKw== X-Gm-Gg: ASbGnctTwtULvxKD98Ac90qpotnAD5y1FBmsEvAPKrFEsShcJvugeJ3TLgcELJP+JN0 ZGNS+93Aol5c78j1Mn37T/12hYyKUUrw3hFv3VS0vg49/eq1bu/rZEV67zCNqU7iCkLfzhThA+Q 40uh65TfiYRmgBuSn0X+OtLYzM9Oz/Kq8vv5ToPJoa+gmbzKKa+cN+pKDIYTlqetKUVDiJG0M9D WL4QVnoeVs/7z9W+hCugllEXcjnf7F//fuQJirtRXnnsFm8xTB/GDiOIA05rdjcS9UU X-Received: by 2002:a05:6a20:9144:b0:1e0:d796:b079 with SMTP id adf61e73a8af0-1e1653bb99dmr8288069637.17.1733288902450; Tue, 03 Dec 2024 21:08:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtD8y79hadaHZvvNeugnEdk8crgadqfqLkx2GLITOJPtd6W8UtDItN+uiyqRlDo7jPSUc/FA== X-Received: by 2002:a05:6a20:9144:b0:1e0:d796:b079 with SMTP id adf61e73a8af0-1e1653bb99dmr8288032637.17.1733288902122; Tue, 03 Dec 2024 21:08:22 -0800 (PST) Received: from localhost.localdomain ([240f:74:7be:1:9c88:3d14:cbea:e537]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd0a0682d6sm145466a12.10.2024.12.03.21.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 21:08:21 -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-next v3 7/7] virtio_net: ensure netdev_tx_reset_queue is called on bind xsk for tx Date: Wed, 4 Dec 2024 14:07:24 +0900 Message-ID: <20241204050724.307544-8-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204050724.307544-1-koichiro.den@canonical.com> References: <20241204050724.307544-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 --- 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 5eaa7a2884d5..177705a56812 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