diff options
| author | riastradh <riastradh@NetBSD.org> | 2020-02-01 02:23:03 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2020-02-01 02:23:03 +0000 |
| commit | fcee5fe3ac44ab4e0eb6bc72b68b761c44cd1c1a (patch) | |
| tree | f3eb971f7ca56e68d49a763b1d4374195b9b26b4 /sys/miscfs | |
| parent | 1f6c4f3fb46a5e746b9ad2ad8c2dfc8a3216bdd9 (diff) | |
Load struct filedesc::fd_dt with atomic_load_consume.
Exceptions: when fd_refcnt <= 1, or when holding fd_lock.
While here:
- Restore KASSERT(mutex_owned(&fdp->fd_lock)) in fd_unused.
=> This is used only in fd_close and fd_abort, where it holds.
- Move bounds check assertion in fd_putfile to where it matters.
- Store fd_dt with atomic_store_release.
- Move load of fd_dt under lock in knote_fdclose.
- Omit membar_consumer in fdesc_readdir.
=> atomic_load_consume serves the same purpose now.
=> Was needed only on alpha anyway.
Diffstat (limited to 'sys/miscfs')
| -rw-r--r-- | sys/miscfs/fdesc/fdesc_vnops.c | 9 | ||||
| -rw-r--r-- | sys/miscfs/procfs/procfs_vnops.c | 7 |
2 files changed, 8 insertions, 8 deletions
diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c index dd4780057cd..fd590029e96 100644 --- a/sys/miscfs/fdesc/fdesc_vnops.c +++ b/sys/miscfs/fdesc/fdesc_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdesc_vnops.c,v 1.131 2020/01/02 15:42:27 thorpej Exp $ */ +/* $NetBSD: fdesc_vnops.c,v 1.132 2020/02/01 02:23:04 riastradh Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.131 2020/01/02 15:42:27 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.132 2020/02/01 02:23:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -206,7 +206,7 @@ fdesc_lookup(void *v) int error, ix = -1; fdtab_t *dt; - dt = curlwp->l_fd->fd_dt; + dt = atomic_load_consume(&curlwp->l_fd->fd_dt); if (cnp->cn_namelen == 1 && *pname == '.') { *vpp = dvp; @@ -567,7 +567,7 @@ fdesc_readdir(void *v) break; } - dt = curlwp->l_fd->fd_dt; + dt = atomic_load_consume(&curlwp->l_fd->fd_dt); if (uio->uio_resid < UIO_MX) return EINVAL; @@ -629,7 +629,6 @@ fdesc_readdir(void *v) *cookies++ = i + 1; } } else { - membar_consumer(); if (ap->a_ncookies) { ncookies = uimin(ncookies, dt->dt_nfiles + 2); cookies = malloc(ncookies * sizeof(off_t), diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index 31632ed078c..61c46ba4e5a 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_vnops.c,v 1.207 2019/08/29 06:43:13 hannken Exp $ */ +/* $NetBSD: procfs_vnops.c,v 1.208 2020/02/01 02:23:04 riastradh Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -105,9 +105,10 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.207 2019/08/29 06:43:13 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.208 2020/02/01 02:23:04 riastradh Exp $"); #include <sys/param.h> +#include <sys/atomic.h> #include <sys/systm.h> #include <sys/time.h> #include <sys/kernel.h> @@ -1387,7 +1388,7 @@ procfs_readdir(void *v) return ESRCH; } - nfd = p->p_fd->fd_dt->dt_nfiles; + nfd = atomic_load_consume(&p->p_fd->fd_dt)->dt_nfiles; lim = uimin((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles); if (i >= lim) { |
