* [PATCH] fs: tidy up do_sys_openat2() with likely/unlikely
@ 2025-03-20 9:23 Mateusz Guzik
2025-03-20 9:42 ` Christian Brauner
2025-03-20 10:49 ` Jan Kara
0 siblings, 2 replies; 3+ messages in thread
From: Mateusz Guzik @ 2025-03-20 9:23 UTC (permalink / raw)
To: brauner; +Cc: viro, jack, linux-kernel, linux-fsdevel, Mateusz Guzik
Otherwise gcc 13 generates conditional forward jumps (aka branch
mispredict by default) for build_open_flags() being succesfull.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] fs: tidy up do_sys_openat2() with likely/unlikely
2025-03-20 9:23 [PATCH] fs: tidy up do_sys_openat2() with likely/unlikely Mateusz Guzik
@ 2025-03-20 9:42 ` Christian Brauner
2025-03-20 10:49 ` Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2025-03-20 9:42 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: Christian Brauner, viro, jack, linux-kernel, linux-fsdevel
On Thu, 20 Mar 2025 10:23:31 +0100, Mateusz Guzik wrote:
> Otherwise gcc 13 generates conditional forward jumps (aka branch
> mispredict by default) for build_open_flags() being succesfull.
>
>
Applied to the vfs-6.15.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.15.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.15.misc
[1/1] fs: tidy up do_sys_openat2() with likely/unlikely
https://git.kernel.org/vfs/vfs/c/d5a05a5a44a9
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] fs: tidy up do_sys_openat2() with likely/unlikely
2025-03-20 9:23 [PATCH] fs: tidy up do_sys_openat2() with likely/unlikely Mateusz Guzik
2025-03-20 9:42 ` Christian Brauner
@ 2025-03-20 10:49 ` Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2025-03-20 10:49 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: brauner, viro, jack, linux-kernel, linux-fsdevel
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@gmail.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.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@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-20 10:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-20 9:23 [PATCH] fs: tidy up do_sys_openat2() with likely/unlikely Mateusz Guzik
2025-03-20 9:42 ` Christian Brauner
2025-03-20 10:49 ` Jan Kara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.