public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Ammar Faizi <[email protected]>,
	Pavel Begunkov <[email protected]>
Cc: io-uring Mailing List <[email protected]>,
	Bedirhan KURT <[email protected]>,
	Louvian Lyndal <[email protected]>
Subject: Re: [PATCH v4 RFC liburing 3/3] Wrap all syscalls in a kernel style return value
Date: Sun, 3 Oct 2021 07:17:56 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

> diff --git a/src/register.c b/src/register.c
> index cb09dea..fec144d 100644
> --- a/src/register.c
> +++ b/src/register.c
> @@ -6,7 +6,6 @@
>  #include <sys/mman.h>
>  #include <sys/resource.h>
>  #include <unistd.h>
> -#include <errno.h>
>  #include <string.h>
>  
>  #include "liburing/compat.h"
> @@ -104,13 +103,16 @@ int io_uring_register_files_update(struct io_uring *ring, unsigned off,
>  
>  static int increase_rlimit_nofile(unsigned nr)
>  {
> +	int ret;
>  	struct rlimit rlim;
>  
> -	if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
> -		return -errno;
> +	ret = uring_getrlimit(RLIMIT_NOFILE, &rlim);
> +	if (ret < 0)
> +		return ret;
> +
>  	if (rlim.rlim_cur < nr) {
>  		rlim.rlim_cur += nr;
> -		setrlimit(RLIMIT_NOFILE, &rlim);
> +		return uring_setrlimit(RLIMIT_NOFILE, &rlim);
>  	}

This isn't a functionally equivalent transformation, and it's
purposefully not returning failure to increase. It may still succeed if
we fail here, relying on failure later for the actual operation that
needs an increase in files.

> diff --git a/src/syscall.h b/src/syscall.h
> index f7f63aa..3e964ed 100644
> --- a/src/syscall.h
> +++ b/src/syscall.h
> @@ -4,11 +4,15 @@
>  
>  #include <errno.h>
>  #include <signal.h>
> +#include <stdint.h>
>  #include <unistd.h>
> +#include <stdbool.h>
>  #include <sys/mman.h>
>  #include <sys/syscall.h>
>  #include <sys/resource.h>
>  
> +#include <liburing.h>
> +
>  #ifdef __alpha__
>  /*
>   * alpha and mips are exception, other architectures have
> @@ -60,6 +64,21 @@ int __sys_io_uring_register(int fd, unsigned int opcode, const void *arg,
>  			    unsigned int nr_args);
>  
>  
> +static inline void *ERR_PTR(intptr_t n)
> +{
> +	return (void *) n;
> +}
> +
> +

Extra newline here.

Apart from those two, starting to look pretty reasonable.

-- 
Jens Axboe


  reply	other threads:[~2021-10-03 13:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-03 10:17 [PATCHSET v4 RFC liburing 0/4] Implement the kernel style return value Ammar Faizi
2021-10-03 10:17 ` [PATCH v4 RFC liburing 1/3] src/syscall: Wrap `errno` for `__sys_io_uring_{register,setup,enter{2,}}` Ammar Faizi
2021-10-03 10:17 ` [PATCH v4 RFC liburing 2/3] src/{queue,register,setup}: Don't use `__sys_io_uring*` Ammar Faizi
2021-10-03 10:17 ` [PATCH v4 RFC liburing 3/3] Wrap all syscalls in a kernel style return value Ammar Faizi
2021-10-03 13:17   ` Jens Axboe [this message]
2021-10-03 15:13     ` Ammar Faizi
2021-10-03 10:43 ` [PATCHSET v4 RFC liburing 0/4] Implement the " 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 \
    [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