Author: mjg Date: Thu Dec 10 17:17:22 2020 New Revision: 368516 URL: https://svnweb.freebsd.org/changeset/base/368516
Log: fd: make serialization in fdescfree_fds conditional on hold count p_fd nullification in fdescfree serializes against new threads transitioning the count 1 -> 2, meaning that fdescfree_fds observing the count of 1 can safely assume there is nobody else using the table. Losing the race and observing > 1 is harmless. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D27522 Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Thu Dec 10 13:32:51 2020 (r368515) +++ head/sys/kern/kern_descrip.c Thu Dec 10 17:17:22 2020 (r368516) @@ -2466,9 +2466,13 @@ fdescfree_fds(struct thread *td, struct filedesc *fdp, KASSERT(refcount_load(&fdp->fd_refcnt) == 0, ("%s: fd table %p carries references", __func__, fdp)); - /* Serialize with threads iterating over the table. */ - FILEDESC_XLOCK(fdp); - FILEDESC_XUNLOCK(fdp); + /* + * Serialize with threads iterating over the table, if any. + */ + if (refcount_load(&fdp->fd_holdcnt) > 1) { + FILEDESC_XLOCK(fdp); + FILEDESC_XUNLOCK(fdp); + } lastfile = fdlastfile_single(fdp); for (i = 0; i <= lastfile; i++) { _______________________________________________ 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"