lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 18 Jan 2020 09:34:38 -0700
From:   Jens Axboe <axboe@...nel.dk>
To:     Pavel Begunkov <asml.silence@...il.com>, io-uring@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] io_uring: optimise sqe-to-req flags translation

On 1/18/20 3:24 AM, Pavel Begunkov wrote:
> For each IOSQE_* flag there is a corresponding REQ_F_* flag. And there
> is a repetitive pattern of their translation:
> e.g. if (sqe->flags & SQE_FLAG*) req->flags |= REQ_F_FLAG*
> 
> Use the same numerical values/bits for them, and copy them instead of
> manual handling.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
> ---
> 
> v2: enum to generate bits (Jens Axboe)
>     Comments cross 80 chars, but IMHO more visually appealing
> 
> Crosses 
> 
>  fs/io_uring.c                 | 75 +++++++++++++++++++++--------------
>  include/uapi/linux/io_uring.h | 26 +++++++++---
>  2 files changed, 67 insertions(+), 34 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index ed1adeda370e..e3e2438a7480 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -452,6 +452,49 @@ struct io_async_ctx {
>  	};
>  };
>  
> +enum {
> +	REQ_F_FIXED_FILE_BIT	= IOSQE_FIXED_FILE_BIT,
> +	REQ_F_IO_DRAIN_BIT	= IOSQE_IO_DRAIN_BIT,
> +	REQ_F_LINK_BIT		= IOSQE_IO_LINK_BIT,
> +	REQ_F_HARDLINK_BIT	= IOSQE_IO_HARDLINK_BIT,
> +	REQ_F_FORCE_ASYNC_BIT	= IOSQE_ASYNC_BIT,
> +
> +	REQ_F_LINK_NEXT_BIT,
> +	REQ_F_FAIL_LINK_BIT,
> +	REQ_F_INFLIGHT_BIT,
> +	REQ_F_CUR_POS_BIT,
> +	REQ_F_NOWAIT_BIT,
> +	REQ_F_IOPOLL_COMPLETED_BIT,
> +	REQ_F_LINK_TIMEOUT_BIT,
> +	REQ_F_TIMEOUT_BIT,
> +	REQ_F_ISREG_BIT,
> +	REQ_F_MUST_PUNT_BIT,
> +	REQ_F_TIMEOUT_NOSEQ_BIT,
> +	REQ_F_COMP_LOCKED_BIT,
> +};

Perfect

> +enum {
> +	/* correspond one-to-one to IOSQE_IO_* flags*/
> +	REQ_F_FIXED_FILE	= BIT(REQ_F_FIXED_FILE_BIT),	/* ctx owns file */

I'd put the comment on top of the line instead, these lines are way too
long.

> diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
> index 955fd477e530..cee59996b23a 100644
> --- a/include/uapi/linux/io_uring.h
> +++ b/include/uapi/linux/io_uring.h
> @@ -10,6 +10,7 @@
>  
>  #include <linux/fs.h>
>  #include <linux/types.h>
> +#include <linux/bits.h>
>  
>  /*
>   * IO submission data structure (Submission Queue Entry)
> @@ -45,14 +46,29 @@ struct io_uring_sqe {
>  	};
>  };
>  
> +enum {
> +	IOSQE_FIXED_FILE_BIT,
> +	IOSQE_IO_DRAIN_BIT,
> +	IOSQE_IO_LINK_BIT,
> +	IOSQE_IO_HARDLINK_BIT,
> +	IOSQE_ASYNC_BIT,
> +};
> +
>  /*
>   * sqe->flags
>   */
> -#define IOSQE_FIXED_FILE	(1U << 0)	/* use fixed fileset */
> -#define IOSQE_IO_DRAIN		(1U << 1)	/* issue after inflight IO */
> -#define IOSQE_IO_LINK		(1U << 2)	/* links next sqe */
> -#define IOSQE_IO_HARDLINK	(1U << 3)	/* like LINK, but stronger */
> -#define IOSQE_ASYNC		(1U << 4)	/* always go async */
> +enum {
> +	/* use fixed fileset */
> +	IOSQE_FIXED_FILE	= BIT(IOSQE_FIXED_FILE_BIT),

Let's please not use BIT() for the user visible part, though. And I'd
leave these as defines, sometimes apps do things ala:

#ifndef IOSQE_IO_LINK
#define IOSQE_IO_LINK ...
#endif

to make it easier to co-exist with old and new headers.

-- 
Jens Axboe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ