From owner-svn-src-all@freebsd.org Wed Dec 9 14:04:55 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2526C47DE9A; Wed, 9 Dec 2020 14:04:55 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Crf1z0Ynnz3D7V; Wed, 9 Dec 2020 14:04:55 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 01776274C2; Wed, 9 Dec 2020 14:04:55 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0B9E4s3d050511; Wed, 9 Dec 2020 14:04:54 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0B9E4sTq050510; Wed, 9 Dec 2020 14:04:54 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202012091404.0B9E4sTq050510@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 9 Dec 2020 14:04:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368485 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 368485 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Dec 2020 14:04:55 -0000 Author: markj Date: Wed Dec 9 14:04:54 2020 New Revision: 368485 URL: https://svnweb.freebsd.org/changeset/base/368485 Log: Use refcount_load(9) to load fd table reference counts No functional change intended. Reviewed by: kib, mjg Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27512 Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Wed Dec 9 09:53:21 2020 (r368484) +++ head/sys/kern/kern_descrip.c Wed Dec 9 14:04:54 2020 (r368485) @@ -1830,7 +1830,8 @@ fdgrowtable(struct filedesc *fdp, int nfd) * which must not be freed. */ if (onfiles > NDFILE) { - if (curproc->p_numthreads == 1 && fdp->fd_refcnt == 1) + if (curproc->p_numthreads == 1 && + refcount_load(&fdp->fd_refcnt) == 1) free(otable, M_FILEDESC); else { ft = (struct freetable *)&otable->fdt_ofiles[onfiles]; @@ -2160,7 +2161,7 @@ static void fddrop(struct filedesc *fdp) { - if (fdp->fd_holdcnt > 1) { + if (refcount_load(&fdp->fd_holdcnt) > 1) { if (refcount_release(&fdp->fd_holdcnt) == 0) return; } @@ -2221,7 +2222,7 @@ fdunshare(struct thread *td) struct filedesc *tmp; struct proc *p = td->td_proc; - if (p->p_fd->fd_refcnt == 1) + if (refcount_load(&p->p_fd->fd_refcnt) == 1) return; tmp = fdcopy(p->p_fd); @@ -2570,7 +2571,8 @@ fdsetugidsafety(struct thread *td) int i; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(&fdp->fd_refcnt) == 1, + ("the fdtable should not be shared")); MPASS(fdp->fd_nfiles >= 3); for (i = 0; i <= 2; i++) { fp = fdp->fd_ofiles[i].fde_file; @@ -2621,7 +2623,8 @@ fdcloseexec(struct thread *td) int i, lastfile; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(&fdp->fd_refcnt) == 1, + ("the fdtable should not be shared")); lastfile = fdlastfile_single(fdp); for (i = 0; i <= lastfile; i++) { fde = &fdp->fd_ofiles[i]; @@ -2651,7 +2654,8 @@ fdcheckstd(struct thread *td) int i, error, devnull; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(&fdp->fd_refcnt) == 1, + ("the fdtable should not be shared")); MPASS(fdp->fd_nfiles >= 3); devnull = -1; for (i = 0; i <= 2; i++) { @@ -3974,7 +3978,8 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS) continue; FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (n = 0; fdp->fd_refcnt > 0 && n <= lastfile; ++n) { + for (n = 0; refcount_load(&fdp->fd_refcnt) > 0 && n <= lastfile; + n++) { if ((fp = fdp->fd_ofiles[n].fde_file) == NULL) continue; xf.xf_fd = n; @@ -4245,7 +4250,7 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *s pwd_drop(pwd); FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (i = 0; fdp->fd_refcnt > 0 && i <= lastfile; i++) { + for (i = 0; refcount_load(&fdp->fd_refcnt) > 0 && i <= lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) continue; #ifdef CAPABILITIES @@ -4400,7 +4405,7 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS) pwd_drop(pwd); FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (i = 0; fdp->fd_refcnt > 0 && i <= lastfile; i++) { + for (i = 0; refcount_load(&fdp->fd_refcnt) > 0 && i <= lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) continue; export_file_to_kinfo(fp, i, NULL, kif, fdp,