io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET v3 RFC liburing 0/4] Implement the kernel style return value
@ 2021-10-02  1:48 Ammar Faizi
  2021-10-02  1:48 ` [PATCH v3 RFC liburing 1/4] src/syscall: " Ammar Faizi
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Ammar Faizi @ 2021-10-02  1:48 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov
  Cc: Ammar Faizi, io-uring Mailing List, Bedirhan KURT, Louvian Lyndal

Hi everyone,

Sorry, v3 just to remove duplicate Signed-off-by.

This is the v3 of RFC to implement the kernel style return value for
liburing.

The main purpose of these changes is to make it possible to remove
the dependency of `errno` variable. If we can land this on liburing,
we will start working on no libc support with raw system call written
in Assembly (no libc). These changes should not affect the user, only
affect liburing internal sources.

We do not plan to drop the libc dependency, we just want to make it
possible to build liburing without the 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. 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 `inline static` in `src/syscall.h`.
They are just a wrapper to make sure liburing internal sources do not
touch `errno` variable from C files directly.

After that, we need to deal with other syscalls. Currently we have 5
wrapper functions for all syscalls used in liburing. They are:
  1) `liburing_mmap`
  2) `liburing_munmap`
  3) `liburing_madvise`
  4) `liburing_getrlimit`
  5) `liburing_setrlimit`

Also add kernel error header `src/kernel_err.h`, this is taken from
the Linux kernel source `include/linux/err.h` with a bit modification.

The purpose of `src/kernel_err.h` file is to use `PTR_ERR()`,
`ERR_PTR()`, etc. to implement the kernel style return value for
pointer return value. Currently only `liburing_mmap()` that depends
on this kernel error header file.

If you want a git repository, you can take a look at:
    
    git://github.com/ammarfaizi2/liburing.git kernel-style-retval

Please review.
----------------------------------------------------------------
Changes since v1:
- 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 since v2:
- Remove duplicate Signed-off-by.

Link: https://github.com/axboe/liburing/issues/443
Link: [v1] https://lore.kernel.org/io-uring/20210929101606.62822-1-ammar.faizi@students.amikom.ac.id/T/
Link: [v2] https://lore.kernel.org/io-uring/20211002012817.107517-1-ammar.faizi@students.amikom.ac.id/T
----------------------------------------------------------------
Ammar Faizi (4):
      src/syscall: Implement the kernel style return value
      src/{queue,register,setup}: Don't use `__sys_io_uring*`
      Wrap all syscalls in a kernel style return value
      src/{queue,register,setup}: Remove `#include <errno.h>`

 src/kernel_err.h |  75 ++++++++++++++++++
 src/queue.c      |  28 +++----
 src/register.c   | 190 ++++++++++++++-------------------------------
 src/setup.c      |  61 ++++++++-------
 src/syscall.c    |  42 +---------
 src/syscall.h    | 130 +++++++++++++++++++++++++++++++
 6 files changed, 310 insertions(+), 216 deletions(-)
 create mode 100644 src/kernel_err.h

--
Ammar Faizi



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

end of thread, other threads:[~2021-10-02  9:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-02  1:48 [PATCHSET v3 RFC liburing 0/4] Implement the kernel style return value Ammar Faizi
2021-10-02  1:48 ` [PATCH v3 RFC liburing 1/4] src/syscall: " Ammar Faizi
2021-10-02  1:48 ` [PATCH v3 RFC liburing 2/4] src/{queue,register,setup}: Don't use `__sys_io_uring*` Ammar Faizi
2021-10-02  8:12   ` Louvian Lyndal
2021-10-02  9:04     ` Ammar Faizi
2021-10-02  1:48 ` [PATCH v3 RFC liburing 3/4] Wrap all syscalls in a kernel style return value Ammar Faizi
2021-10-02  1:48 ` [PATCH v3 RFC liburing 4/4] src/{queue,register,setup}: Remove `#include <errno.h>` Ammar Faizi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).