git: ef89b78bb1f6 - main - vfs: stabilize freevnodes_old
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 16 Sep 2023 15:54:37 UTC
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ef89b78bb1f60484cc743fa590d623ad896ca8e9 commit ef89b78bb1f60484cc743fa590d623ad896ca8e9 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2023-09-16 15:41:12 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2023-09-16 15:54:09 +0000 vfs: stabilize freevnodes_old In face of parallel callers. --- sys/kern/vfs_subr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 9d5b1b7e472e..11cdea5a7dc1 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1528,21 +1528,22 @@ vfs_freevnodes_dec(void) static u_long vnlru_read_freevnodes(void) { - long slop, rfreevnodes; + long slop, rfreevnodes, rfreevnodes_old; int cpu; rfreevnodes = atomic_load_long(&freevnodes); + rfreevnodes_old = atomic_load_long(&freevnodes_old); - if (rfreevnodes > freevnodes_old) - slop = rfreevnodes - freevnodes_old; + if (rfreevnodes > rfreevnodes_old) + slop = rfreevnodes - rfreevnodes_old; else - slop = freevnodes_old - rfreevnodes; + slop = rfreevnodes_old - rfreevnodes; if (slop < VNLRU_FREEVNODES_SLOP) return (rfreevnodes >= 0 ? rfreevnodes : 0); - freevnodes_old = rfreevnodes; CPU_FOREACH(cpu) { - freevnodes_old += cpuid_to_pcpu[cpu]->pc_vfs_freevnodes; + rfreevnodes += cpuid_to_pcpu[cpu]->pc_vfs_freevnodes; } + atomic_store_long(&freevnodes_old, rfreevnodes); return (freevnodes_old >= 0 ? freevnodes_old : 0); }