Skip to content

RFC Ensure io_uring data structure consistentcy in liburing

Ammar Faizi io-uring 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5lib: Don't indent in `#ifdef -> #define -> #endif` blocksrc/lib.h+5 -50 replies
2/5lib: Add `BUILD_BUG_ON()` macrosrc/lib.h+4 -00 replies
3/5lib: Add `sizeof_field()` macrosrc/lib.h+4 -00 replies
4/5Avoid macro redefinition warningssrc/queue.c src/register.c src/setup.c +1 more+8 -00 replies
5/5Add io_uring data structure build assertionsrc/Makefile src/build_assert.h+59 -11 reply

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchHao Xu
SeriesA-b
1/5
2/5
3/5
4/5
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH v1 0/5] Ensure io_uring data structure consistentcy in liburing

Hi,

This is an RFC for liburing-2.3.

## Introduction:
This series adds compile time assertions for liburing. They are taken from the io_uring source in the kernel tree. The point of this series is to make sure the shared struct is consistent between the kernel space and user space.

## Implementation detail:
We use static_assert() macro from <assert.h> that can yield compile error if the expression given to it evaluates to false. This way we can create a BUILD_BUG_ON() macro that we usually use inside the kernel. The assertions are placed inside a header file named build_assert.h, this header is included via compile flag -include when compiling the core liburing sources.

## How to maintain this?
This is pretty much easy to maintain, we just need to sync the BUILD_BUG_ON() macro calls that check the shared struct from io_uring. See patch #5 for detail.

## Patches summary:

- Patch 1 is just a small code style cleanup.
- Patch 2 is to add BUILD_BUG_ON() macro.
- Patch 3 is to add sizeof_field() macro.
- Patch 4 is to avoid macro redefinition warnings.
- Patch 5 is the main part, it adds io_uring data structure assertions.

---

Ammar Faizi (5):
lib: Don't indent in #ifdef -> #define -> #endif block
lib: Add BUILD_BUG_ON() macro
lib: Add sizeof_field() macro
Avoid macro redefinition warnings
Add io_uring data structure build assertion

 src/Makefile       |  3 ++-
 src/build_assert.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++
 src/lib.h          | 18 +++++++++++----
 src/queue.c        |  2 ++
 src/register.c     |  2 ++
 src/setup.c        |  2 ++
 src/syscall.c      |  2 ++
 7 files changed, 80 insertions(+), 6 deletions(-)
 create mode 100644 src/build_assert.h

base-commit: 4633a2d0fe9bd1f3dbb5b6d2788a08a264803146

Signature · 1 line
Ammar Faizi