StagingBuff: support both Mlock & IOUring pin; Use in IoUAssmEngn

We use io_uring_register_buffers() for IoUringAssemblyEngine instead
of using mlock(). This __appears__ to have reduced CPU utilization on
the Dell laptop. Could also be that we recently upgraded total RAM
from 8GiB to 32GiB.
This commit is contained in:
2026-04-02 03:51:22 -04:00
parent 26dd686ebf
commit 1d64ce0c7e
11 changed files with 257 additions and 61 deletions
@@ -27,8 +27,6 @@
#include "pcloudStimulusProducer.h"
#include "livoxGen1.h"
// #define REGISTER_IOURING_BUFFERS
namespace smo {
namespace stim_buff {
@@ -116,10 +114,6 @@ bool IoUringAssemblyEngine::setup()
assembledSlotsTracker[i].ioVec.iov_len = slot.nBytes;
}
// Declare iovec early to avoid goto crossing initialization
#ifdef REGISTER_IOURING_BUFFERS
struct iovec iov;
#endif
int ret;
/** EXPLANATION:
@@ -134,23 +128,27 @@ bool IoUringAssemblyEngine::setup()
if (ret < 0)
{ goto cleanup; }
#ifdef REGISTER_IOURING_BUFFERS
// Register staging buffer with io_uring for DMA-apt I/O
iov = parent.assemblyBuffer.getIoUringRegisterIoVec();
ret = io_uring_register_buffers(&ring, &iov, 1);
if (ret < 0)
{ goto cleanup_ring; }
#endif
try
{
if (assemblyBufferIoUringPinner)
{
throw std::runtime_error(std::string(__func__)
+ ": assemblyBufferIoUringPinner already exists");
}
assemblyBufferIoUringPinner =
parent.assemblyBuffer.makeIoUringPinner(&ring);
}
catch (const std::exception&)
{
goto cleanup_ring;
}
// Create eventfd for CQE notifications (used with boost's unified loop)
eventfdFd = eventfd(0, EFD_NONBLOCK);
if (eventfdFd < 0)
{
#ifdef REGISTER_IOURING_BUFFERS
goto cleanup_buffers;
#else
goto cleanup_ring;
#endif
}
// Register eventfd with io_uring
@@ -164,11 +162,8 @@ bool IoUringAssemblyEngine::setup()
cleanup_eventfd:
close(eventfdFd);
eventfdFd = -1;
#ifdef REGISTER_IOURING_BUFFERS
cleanup_buffers:
io_uring_unregister_buffers(&ring);
#endif
cleanup_ring:
assemblyBufferIoUringPinner.reset();
io_uring_queue_exit(&ring);
cleanup:
return false;
@@ -217,9 +212,7 @@ void IoUringAssemblyEngine::finalize()
if (wasAcceptingRequests)
{
#ifdef REGISTER_IOURING_BUFFERS
io_uring_unregister_buffers(&ring);
#endif
assemblyBufferIoUringPinner.reset();
io_uring_queue_exit(&ring);
}