Skip to content

Commit d5a05a5

Browse files
mjguzikbrauner
authored andcommitted
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 <mjguzik@gmail.com> Link: https://lore.kernel.org/r/20250320092331.1921700-1-mjguzik@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 9ae7e5a commit d5a05a5

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

fs/open.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,18 +1412,19 @@ static int do_sys_openat2(int dfd, const char __user *filename,
14121412
struct open_how *how)
14131413
{
14141414
struct open_flags op;
1415-
int fd = build_open_flags(how, &op);
14161415
struct filename *tmp;
1416+
int err, fd;
14171417

1418-
if (fd)
1419-
return fd;
1418+
err = build_open_flags(how, &op);
1419+
if (unlikely(err))
1420+
return err;
14201421

14211422
tmp = getname(filename);
14221423
if (IS_ERR(tmp))
14231424
return PTR_ERR(tmp);
14241425

14251426
fd = get_unused_fd_flags(how->flags);
1426-
if (fd >= 0) {
1427+
if (likely(fd >= 0)) {
14271428
struct file *f = do_filp_open(dfd, tmp, &op);
14281429
if (IS_ERR(f)) {
14291430
put_unused_fd(fd);

0 commit comments

Comments
 (0)