public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH v5 liburing 0/3] Implement the kernel style return value
@ 2021-10-03 15:34 Ammar Faizi
  2021-10-03 15:34 ` [PATCH v5 liburing 1/3] src/syscall: Wrap `errno` for `__sys_io_uring_{register,setup,enter{2,}}` Ammar Faizi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ammar Faizi @ 2021-10-03 15:34 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov
  Cc: io-uring Mailing List, Bedirhan KURT, Louvian Lyndal

Hi Jens,

This is the v5 of the kernel style return value implementation for
liburing.

The main purpose of these changes is to make it possible to remove
the dependency of `errno` variable in the liburing C sources. If we
can land this on liburing, we will start working on adding support
build liburing without libc.

Currently, we expose these functions to userland:
  1) `__sys_io_uring_register`
  2) `__sys_io_uring_setup`
  3) `__sys_io_uring_enter2`
  4) `__sys_io_uring_enter`

The tests in `test/io_uring_{enter,register,setup}.c` are the examples
of it. Since the userland needs to check the `errno` value to use them
properly, this means those functions always depend on libc. So we
cannot change their behavior. Don't touch them all, this ensures the
changes only affect liburing internal and no visible functionality
changes for the users.

Then we introduce new functions with the same name (with extra
underscore as prefix, 4 underscores):
  1) `____sys_io_uring_register`
  2) `____sys_io_uring_setup`
  3) `____sys_io_uring_enter2`
  4) `____sys_io_uring_enter`

These functions do not use `errno` variable *on the caller*, they use
the kernel style return value (return a negative value of error code
when errors).

These functions are defined as `static inline` in `src/syscall.h`.
They are just a wrapper to make sure liburing internal sources do not
touch `errno` variable from C files directly. We need to make C files
not to touch the `errno` variable to support build without libc.

To completely remove the `errno` variable dependency from liburing C
files. We wrap all syscalls in a kernel style return value as well.

Currently we have 5 other syscalls in liburing. We wrapped all of
them as these 5 functions:
  1) `uring_mmap`
  2) `uring_munmap`
  3) `uring_madvise`
  4) `uring_getrlimit`
  5) `uring_setrlimit`

All of them are `static inline` and will return a negative value of
error code in case error happens.

Extra new helpers:
  1) `ERR_PTR()`
  2) `PTR_ERR()`
  3) `IS_ERR()`

These helpers are used to deal with syscalls that return a pointer.
Currently only `uring_mmap()` that depends on these.

----------------------------------------------------------------

If you want view a git repository, you can take a look at:

  https://github.com/ammarfaizi2/liburing/tree/kernel-style-retval-v5

If you want a git tag, you can pull. The following changes since
commit ce10538688b93dafd257ebfed7faf18844e0052d:

  test: Fix endianess issue on `bind()` and `connect()` (2021-09-27 07:45:03 -0600)

are available in the Git repository at:

  git://github.com/ammarfaizi2/liburing.git tags/kernel-style-retval-v5

for you to fetch changes up to 0c210dbae26a80ee82dbc7430828ab6fd7012548:

  Wrap all syscalls in a kernel style return value (2021-10-03 21:37:25 +0700)

----------------------------------------------------------------
Changes from v1 to v2:
- Make all wrapper functions be `static inline`, so they don't pollute
  the global scope.
- Reduce the number of patches. Now we only have 4 patches (it was 6).

Changes from v2 to v3:
- Remove duplicate Signed-off-by.

Changes from v3 to v4:
- Fix unintentional logic change [1].
- Don't take the kernel header file to have extra helpers (ERR_PTR,
  PTR_ERR, IS_ERR). Write our own helpers with the same principles [2].
- Change the wrapper prefix, it was
  `liburing_{mmap,munmap,madvise,{get,set}rlimit}`, now we use
  `uring_{mmap,munmap,madvise,{get,set}rlimit}` to make it more
  compact and consistent (as we already have `uring_{{un,}likely})`.
- Reduce the number of patches. Now we only have 3 patches (it was 4).

Changes from v4 to v5 (this thread):
- Fix wrong functionality transformation of setrlimit() call [3].
- Fix code style, remove extra new line [3].

Link: [GH Issue] https://github.com/axboe/liburing/issues/443
Link: [v1] https://lore.kernel.org/io-uring/[email protected]/T/
Link: [v2] https://lore.kernel.org/io-uring/[email protected]/T/
Link: [v3] https://lore.kernel.org/io-uring/[email protected]/T/
Link: [v4] https://lore.kernel.org/io-uring/[email protected]/T/

#Ref
Link: [1] https://lore.kernel.org/io-uring/[email protected]/
Link: [2] https://github.com/axboe/liburing/issues/446
Link: [3] https://lore.kernel.org/io-uring/[email protected]/
----------------------------------------------------------------
Ammar Faizi (3):
      src/syscall: Wrap `errno` for `__sys_io_uring_{register,setup,enter{2,}}`
      src/{queue,register,setup}: Don't use `__sys_io_uring*`
      Wrap all syscalls in a kernel style return value

 src/queue.c    |  28 +++----
 src/register.c | 197 +++++++++++++++--------------------------------
 src/setup.c    |  57 +++++++-------
 src/syscall.c  |  43 +----------
 src/syscall.h  | 139 +++++++++++++++++++++++++++++++++
 5 files changed, 245 insertions(+), 219 deletions(-)

-- 
Ammar Faizi



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

end of thread, other threads:[~2021-10-03 15:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-03 15:34 [PATCH v5 liburing 0/3] Implement the kernel style return value Ammar Faizi
2021-10-03 15:34 ` [PATCH v5 liburing 1/3] src/syscall: Wrap `errno` for `__sys_io_uring_{register,setup,enter{2,}}` Ammar Faizi
2021-10-03 15:34 ` [PATCH v5 liburing 2/3] src/{queue,register,setup}: Don't use `__sys_io_uring*` Ammar Faizi
2021-10-03 15:34 ` [PATCH v5 liburing 3/3] Wrap all syscalls in a kernel style return value Ammar Faizi
2021-10-03 15:59 ` [PATCH v5 liburing 0/3] Implement the " Jens Axboe

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