svn commit: r357406 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Sun Feb 2 09:38:41 UTC 2020


Author: mjg
Date: Sun Feb  2 09:38:40 2020
New Revision: 357406
URL: https://svnweb.freebsd.org/changeset/base/357406

Log:
  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.

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Sun Feb  2 09:37:16 2020	(r357405)
+++ head/sys/kern/kern_descrip.c	Sun Feb  2 09:38:40 2020	(r357406)
@@ -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, in
 	*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);
 	}


More information about the svn-src-all mailing list