Skip to content

Higher CPU utilization with io_uring based design for Rx Packet processing via AF_PACKET RAW socket #1506

@anandkv1980

Description

@anandkv1980

For Packet processing Use case, I tried the following multishot model - replacing the legacy recvmmsg() based packet processing flow.
For the rate of 5-6 Gbps traffic rate, I hardly see any difference in throughput between io_uring and legacy design.
But the overall CPU utilization is on the higher side with io_uring based implementation. I have added details of the implementatio

Do you have any suggestions on what can be tuned further to bring down the overall CPU utilization and achieve better throughput with io_uring ?

RX Side (socket_uring_rx.c)

io_uring APIs:

  • io_uring_get_sqe() - Get submission queue entry for new operations
  • io_uring_prep_recvmsg_multishot() - Prepare multishot receive operation
  • io_uring_sqe_set_data() - Attach user data to SQE
  • io_uring_submit() - Submit operations to kernel
  • io_uring_cqe_get_data() - Retrieve user data from completion
  • io_uring_peek_cqe() - Non-blocking check for completions
  • io_uring_cqe_seen() - Mark completion as processed
  • io_uring_buf_ring_add() - Add buffer to provided buffer ring
  • io_uring_buf_ring_advance() - Commit buffers to ring
  • io_uring_enable_rings() - Enable ring operations

io_uring Flags:

  • IOSQE_BUFFER_SELECT - Enable buffer selection from provided buffer ring
  • IORING_CQE_F_MORE - Multishot operation continues
  • IORING_SETUP_COOP_TASKRUN - Cooperative task running
  • IORING_SETUP_DEFER_TASKRUN - Defer task work
  • IORING_SETUP_SINGLE_ISSUER - Single-threaded submission optimization
  • IORING_SETUP_R_DISABLED - Initialize ring in disabled state

Architecture:

  • Separate RX/TX rings to avoid contention
  • RX: multishot receive with provided buffer ring
  • TX: writev operations (sendmsg unsupported for AF_PACKET)
  • Both rings use SINGLE_ISSUER + R_DISABLED for single-threaded optimization

RX Path:

  • Multishot operations reduce submission overhead
  • Provided buffer ring enables zero-copy reception
  • Per-socket multishot for multiple sockets
  • Automatic multishot resubmission when F_MORE flag absent
  • Buffer recycling via buf_ring_add/advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions