Author: mjg
Date: Tue Dec 11 11:58:44 2018
New Revision: 341817
URL: https://svnweb.freebsd.org/changeset/base/341817

Log:
  fd: tidy up closing a fd
  
  - avoid a call to knote_close in the common case
  - annotate mqueue as unlikely
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c        Tue Dec 11 11:57:12 2018        
(r341816)
+++ head/sys/kern/kern_descrip.c        Tue Dec 11 11:58:44 2018        
(r341817)
@@ -1186,12 +1186,13 @@ closefp(struct filedesc *fdp, int fd, struct file *fp,
         * knote_fdclose to prevent a race of the fd getting opened, a knote
         * added, and deleteing a knote for the new fd.
         */
-       knote_fdclose(td, fd);
+       if (__predict_false(!TAILQ_EMPTY(&fdp->fd_kqlist)))
+               knote_fdclose(td, fd);
 
        /*
         * We need to notify mqueue if the object is of type mqueue.
         */
-       if (fp->f_type == DTYPE_MQUEUE)
+       if (__predict_false(fp->f_type == DTYPE_MQUEUE))
                mq_fdclose(td, fd, fp);
        FILEDESC_XUNLOCK(fdp);
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to