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] [day] [month] [year] [list]
Message-ID: <6w5kjzcpt7le4cz7iernbqawqgx6nfhipce4cvvu4qwssaeu2o@azv3x2c7bbkv>
Date: Thu, 20 Mar 2025 11:49:45 +0100
From: Jan Kara <jack@...e.cz>
To: Mateusz Guzik <mjguzik@...il.com>
Cc: brauner@...nel.org, viro@...iv.linux.org.uk, jack@...e.cz, 
	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] fs: tidy up do_sys_openat2() with likely/unlikely

On Thu 20-03-25 10:23:31, Mateusz Guzik wrote:
> Otherwise gcc 13 generates conditional forward jumps (aka branch
> mispredict by default) for build_open_flags() being succesfull.
> 
> Signed-off-by: Mateusz Guzik <mjguzik@...il.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
> 
> maybe i'll get around to do it a full pass instead of sending byte-sized
> patchen. someone(tm) should definitely do it.
> 
>  fs/open.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/open.c b/fs/open.c
> index bdbf03f799a1..a9063cca9911 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -1413,18 +1413,19 @@ static int do_sys_openat2(int dfd, const char __user *filename,
>  			  struct open_how *how)
>  {
>  	struct open_flags op;
> -	int fd = build_open_flags(how, &op);
>  	struct filename *tmp;
> +	int err, fd;
>  
> -	if (fd)
> -		return fd;
> +	err = build_open_flags(how, &op);
> +	if (unlikely(err))
> +		return err;
>  
>  	tmp = getname(filename);
>  	if (IS_ERR(tmp))
>  		return PTR_ERR(tmp);
>  
>  	fd = get_unused_fd_flags(how->flags);
> -	if (fd >= 0) {
> +	if (likely(fd >= 0)) {
>  		struct file *f = do_filp_open(dfd, tmp, &op);
>  		if (IS_ERR(f)) {
>  			put_unused_fd(fd);
> -- 
> 2.43.0
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ