public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>, Pavel Begunkov <[email protected]>
Cc: Ammar Faizi <[email protected]>,
	io-uring Mailing List <[email protected]>,
	Bedirhan KURT <[email protected]>,
	Louvian Lyndal <[email protected]>
Subject: [PATCHSET v2 RFC liburing 0/4] Implement the kernel style return value
Date: Sat,  2 Oct 2021 08:28:13 +0700	[thread overview]
Message-ID: <[email protected]> (raw)

Hi everyone,

This is the v2 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).

Link: https://github.com/axboe/liburing/issues/443
Link: [v1] https://lore.kernel.org/io-uring/[email protected]/
----------------------------------------------------------------
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



             reply	other threads:[~2021-10-02  1:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-02  1:28 Ammar Faizi [this message]
2021-10-02  1:28 ` [PATCH v2 RFC liburing 1/4] src/syscall: Implement the kernel style return value Ammar Faizi
2021-10-02  1:28 ` [PATCH v2 RFC liburing 2/4] src/{queue,register,setup}: Don't use `__sys_io_uring*` Ammar Faizi
2021-10-02  1:28 ` [PATCH v2 RFC liburing 3/4] Wrap all syscalls in a kernel style return value Ammar Faizi
2021-10-02  1:28 ` [PATCH v2 RFC liburing 4/4] src/{queue,register,setup}: Remove `#include <errno.h>` Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211002012817.107517-1-ammar.faizi@students.amikom.ac.id \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox