From: Mateusz Guzik Date: Thu, 20 Mar 2025 09:23:31 +0000 (+0100) Subject: fs: tidy up do_sys_openat2() with likely/unlikely X-Git-Tag: v6.15-rc1~254^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5a05a5a44a983ead5c57673af2c5bcfd2f0d3e9;p=thirdparty%2Flinux.git fs: tidy up do_sys_openat2() with likely/unlikely Otherwise gcc 13 generates conditional forward jumps (aka branch mispredict by default) for build_open_flags() being succesfull. Signed-off-by: Mateusz Guzik Link: https://lore.kernel.org/r/20250320092331.1921700-1-mjguzik@gmail.com Signed-off-by: Christian Brauner --- diff --git a/fs/open.c b/fs/open.c index 634fdca6501aa..df140788077bf 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1412,18 +1412,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);