DPDK usage discussions
 help / color / mirror / Atom feed
From: ······ <1104121601@qq.com>
To: users <users@dpdk.org>
Subject: Virtio PMD Issue: Packed Queue desc_event_flags Causing Testpmd Crash
Date: Sat, 11 Oct 2025 15:37:14 +0800	[thread overview]
Message-ID: <tencent_7F0BE9436613A0C9DAD8CD35EF6D4BF47D06@qq.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 4785 bytes --]

Dear DPDK Community/Maintainers.


I am writing to consult about a technical issue with the Virtio network driver (located in driver/net/virtio). During our testing of the packed queue&nbsp;feature with desc_event_flags&nbsp;enabled, Testpmd consistently crashes after running for a short period. Below is a detailed description of the scenario, observation, root cause analysis, and a proposed fix—we hope to get clarification on whether this is a usage error or a potential driver issue.

1. Scenario

Test Environment: Running Testpmd with the Virtio PMD (librte_pmd_virtio.so).

Test Focus: Validating the desc_event_flags&nbsp;functionality of Virtio packed queue&nbsp;mode.

2. Observation
After Testpmd runs for several minutes, it crashes unexpectedly. Debugging shows that the content of vq_descx&nbsp;(within struct virtqueue) is being modified unexpectedly—likely due to address mismatches in the queue memory layout.

3. Command Used to Reproduce
testpmd -c 0xff -n 4 --huge-dir=/mnt/huge_dpdk --socket-mem=1024 --socket-limit=1024 -w 0000:15:00.1 --file-prefix=test3 -d /usr/lib64/librte_pmd_virtio.so \
&nbsp; &nbsp; &nbsp; &nbsp; -- --total-num-mbufs=115200 --rxq=4 --txq=4 --forward-mode=txonly --nb-cores=4 --stats-period 1 --burst=512 --rxd=512 --txd=512 --eth-peer=0,10:70:fd:2a:60:39




4. Suspected Root Cause
The Virtio driver uses inconsistent address calculation logic&nbsp;for two critical steps:

When informing the hardware (via the modern_setup_queue&nbsp;interface) of the physical addresses for the driver&nbsp;and device&nbsp;regions of the packed queue.

When calculating the virtual addresses of the driver&nbsp;and device&nbsp;regions for the driver’s own use (via vring_init_packed).
This mismatch leads to the hardware and the driver referencing different memory regions for the device&nbsp;queue, causing unintended overwrites of vq_descx.

5. Detailed Analysis

5.1 Address Calculation in modern_setup_queue&nbsp;(Hardware-facing)
The modern_setup_queue&nbsp;function configures the queue addresses and passes them to the hardware. For packed queues, it calculates desc_addr, avail_addr&nbsp;(driver region), and used_addr&nbsp;(device region) as follows:






Key parameters for our test:

vq_nentries = 0x1000&nbsp;(4096 entries)

sizeof(struct vring_desc) = 16&nbsp;(0x10 in hex)

offsetof(struct vring_avail, ring[vq-&gt;vq_nentries]) = 4 + (0x1000 * 2)&nbsp;(base offset 4 + 2 bytes per ring entry)

Alignment requirement: VIRTIO_PCI_VRING_ALIGN = 4096&nbsp;(0x1000 in hex)
Example calculation (assuming desc_addr = 0x0):

avail_addr = 0x0 + (0x1000 * 0x10) = 0x10000&nbsp;(driver region address passed to hardware)

used_addr = RTE_ALIGN_CEIL(0x10000 + 4 + (0x1000 * 2), 0x1000) = RTE_ALIGN_CEIL(0x12004, 0x1000) = 0x13000&nbsp;(device region address passed to hardware)

5.2 Address Calculation in vring_init_packed&nbsp;(Driver-internal)
The vring_init_packed&nbsp;function calculates the driver-internal virtual addresses for the packed queue’s driver&nbsp;and device&nbsp;regions:




Example calculation (same desc_addr = 0x0, p = 0x0):

vr-&gt;driver = 0x0 + (0x1000 * 0x10) = 0x10000&nbsp;(matches avail_addr&nbsp;from modern_setup_queue)

vr-&gt;device = RTE_ALIGN_CEIL(0x10000 + sizeof(struct vring_packed_desc_event), 0x1000)

Assuming sizeof(struct vring_packed_desc_event) = 4&nbsp;(standard definition), this becomes RTE_ALIGN_CEIL(0x10004, 0x1000) = 0x11000&nbsp;(driver-internal device region address)

5.3 Critical Mismatch

Hardware uses 0x13000&nbsp;as the device&nbsp;region address.

Driver uses 0x11000&nbsp;as the device&nbsp;region address.

6. Modification Applied to Fix the Issue
We modified modern_setup_queue&nbsp;to use the same address logic as vring_init_packed&nbsp;for packed queues. After this change, Testpmd runs stably without crashes:




7. Reference from Virtio-User/Vhost-User
We noticed that the virtio-user&nbsp;and vhost-user&nbsp;drivers already use the same logic as our modified modern_setup_queue&nbsp;for packed queues. For example, in virtio_user_setup_queue_packed:





8. Question for Clarification
Both the higher and lower dpdk versions exhibit this behavior.


Therefore, for packed queues, why do modern_setup_queue&nbsp;and vring_init_packed&nbsp;use different logic to calculate the device region address?


Is this inconsistency due to incorrect usage on my part, or are there special considerations specific to packed queue mode&nbsp;(e.g., hardware compatibility, protocol requirements)?
We would greatly appreciate your help in clarifying this confusion. Thank you!


Best regards.


[A DPDK user and developer].






······
1104121601@qq.com

&nbsp;

[-- Attachment #1.2: Type: text/html, Size: 40297 bytes --]

[-- Attachment #2: 6469B6FC@56D5E327.2B09EA6800000000.png --]
[-- Type: application/octet-stream, Size: 165609 bytes --]

[-- Attachment #3: E765370F@BAFD665D.2B09EA6800000000.png --]
[-- Type: application/octet-stream, Size: 146645 bytes --]

[-- Attachment #4: D42E8FFF@3A4B3104.2B09EA6800000000.png --]
[-- Type: application/octet-stream, Size: 47772 bytes --]

[-- Attachment #5: 8D32FC0D@E5A1E632.2B09EA6800000000.png --]
[-- Type: application/octet-stream, Size: 92459 bytes --]

             reply	other threads:[~2025-10-14  7:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-11  7:37 ······ [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-10-10  7:34 =?gb18030?B?oaShpKGkoaShpKGk?=

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_7F0BE9436613A0C9DAD8CD35EF6D4BF47D06@qq.com \
    --to=1104121601@qq.com \
    --cc=users@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).