public inbox for [email protected]
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/5] Ensure io_uring data structure consistentcy in liburing
@ 2022-06-06  6:12 Ammar Faizi
  2022-06-06  6:12 ` [RFC PATCH v1 1/5] lib: Don't indent in `#ifdef -> #define -> #endif` block Ammar Faizi
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Ammar Faizi @ 2022-06-06  6:12 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Pavel Begunkov, Fernanda Ma'rouf, Hao Xu,
	Alviro Iskandar Setiawan, io-uring Mailing List,
	GNU/Weeb Mailing List


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.


Signed-off-by: Ammar Faizi <[email protected]>
---

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
-- 
Ammar Faizi


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-06 11:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-06  6:12 [RFC PATCH v1 0/5] Ensure io_uring data structure consistentcy in liburing Ammar Faizi
2022-06-06  6:12 ` [RFC PATCH v1 1/5] lib: Don't indent in `#ifdef -> #define -> #endif` block Ammar Faizi
2022-06-06  6:12 ` [RFC PATCH v1 2/5] lib: Add `BUILD_BUG_ON()` macro Ammar Faizi
2022-06-06  6:12 ` [RFC PATCH v1 3/5] lib: Add `sizeof_field()` macro Ammar Faizi
2022-06-06  6:12 ` [RFC PATCH v1 4/5] Avoid macro redefinition warnings Ammar Faizi
2022-06-06  6:12 ` [RFC PATCH v1 5/5] Add io_uring data structure build assertion Ammar Faizi
2022-06-06 11:51   ` Pavel Begunkov
2022-06-06  8:03 ` [RFC PATCH v1 0/5] Ensure io_uring data structure consistentcy in liburing Hao Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox