Skip to content

Comments

libublk: add IO buffer memory locking feature#25

Merged
ming1 merged 1 commit intomainfrom
mlock-io-buffer
Aug 27, 2025
Merged

libublk: add IO buffer memory locking feature#25
ming1 merged 1 commit intomainfrom
mlock-io-buffer

Conversation

@ming1
Copy link
Collaborator

@ming1 ming1 commented Aug 27, 2025

Add new UBLK_DEV_F_MLOCK_IO_BUFFER flag to lock IO buffer pages in memory, preventing them from being swapped to disk for predictable IO latency.

Key changes:

  • Add UBLK_DEV_F_MLOCK_IO_BUFFER flag to UblkFlags
  • Enhance IoBuf with mlock/munlock support via new_with_mlock()
  • Add feature compatibility validation (incompatible with USER_COPY, AUTO_BUF_REG, and SUPPORT_ZERO_COPY)
  • Integrate mlock support in UblkDev::alloc_queue_io_bufs()
  • Add comprehensive test coverage for mlock functionality
  • Don't discard io buffer pages in case of UBLK_DEV_F_MLOCK_IO_BUFFER
  • Update loop example with --mlock-io-buffer command line option
  • Document CAP_IPC_LOCK capability requirement

The feature requires CAP_IPC_LOCK capability and can be granted with: sudo setcap cap_ipc_lock=eip $UBLK_EXECUTABLE

Add new UBLK_DEV_F_MLOCK_IO_BUFFER flag to lock IO buffer pages in memory,
preventing them from being swapped to disk for predictable IO latency.

Key changes:
- Add UBLK_DEV_F_MLOCK_IO_BUFFER flag to UblkFlags
- Enhance IoBuf with mlock/munlock support via new_with_mlock()
- Add feature compatibility validation (incompatible with USER_COPY,
  AUTO_BUF_REG, and SUPPORT_ZERO_COPY)
- Integrate mlock support in UblkDev::alloc_queue_io_bufs()
- Add comprehensive test coverage for mlock functionality
- Don't discard io buffer pages in case of UBLK_DEV_F_MLOCK_IO_BUFFER
- Update loop example with --mlock-io-buffer command line option
- Document CAP_IPC_LOCK capability requirement

The feature requires CAP_IPC_LOCK capability and can be granted with:
sudo setcap cap_ipc_lock=eip $UBLK_EXECUTABLE

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
@ming1 ming1 merged commit 38e4ef1 into main Aug 27, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant