From e98538b60126e9b45f983d0a5cc33a6c9eb94840 Mon Sep 17 00:00:00 2001 From: mjg Date: Sun, 2 Feb 2020 09:38:40 +0000 Subject: [PATCH] fd: sprinkle some predits around fget clang inlines fget -> _fget into kern_fstat and eliminates several checkes, but prior to this change it would assume fget_unlocked was likely to fail and consequently avoidable jumps got generated. --- sys/kern/kern_descrip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 1edbed989fdf..b81f7b0eef5d 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1437,7 +1437,7 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp) AUDIT_ARG_FD(fd); error = fget(td, fd, &cap_fstat_rights, &fp); - if (error != 0) + if (__predict_false(error != 0)) return (error); AUDIT_ARG_FILE(td->td_proc, fp); @@ -2792,9 +2792,9 @@ _fget(struct thread *td, int fd, struct file **fpp, int flags, *fpp = NULL; fdp = td->td_proc->p_fd; error = fget_unlocked(fdp, fd, needrightsp, &fp, seqp); - if (error != 0) + if (__predict_false(error != 0)) return (error); - if (fp->f_ops == &badfileops) { + if (__predict_false(fp->f_ops == &badfileops)) { fdrop(fp, td); return (EBADF); }