From eae96dbbc9d50a028e454de7f11704bd923b693c Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 30 Sep 2017 11:06:49 -0700 Subject: [PATCH] tmpfs - Conditionalize atomic adds on mount structure * Conditionalize tracking of the total pages allocated to avoid the atomic op when the delta change is 0. Suggested-by: mjg_ --- sys/vfs/tmpfs/tmpfs_subr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/vfs/tmpfs/tmpfs_subr.c b/sys/vfs/tmpfs/tmpfs_subr.c index 5542da5612..16627dee88 100644 --- a/sys/vfs/tmpfs/tmpfs_subr.c +++ b/sys/vfs/tmpfs/tmpfs_subr.c @@ -277,7 +277,8 @@ tmpfs_free_node(struct tmpfs_mount *tmp, struct tmpfs_node *node) objcache_put(tmp->tm_node_pool, node); /* node is now invalid */ - atomic_add_long(&tmp->tm_pages_used, -(long)pages); + if (pages) + atomic_add_long(&tmp->tm_pages_used, -(long)pages); } /* --------------------------------------------------------------------- */ @@ -952,7 +953,8 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, int trivial) node->tn_reg.tn_aobj_pages = newpages; node->tn_size = newsize; - atomic_add_long(&tmp->tm_pages_used, (newpages - oldpages)); + if (newpages != oldpages) + atomic_add_long(&tmp->tm_pages_used, (newpages - oldpages)); /* * When adjusting the vnode filesize and its VM object we must -- 2.11.4.GIT