Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Sep 2017 18:23:45 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324127 - head/sys/fs/tmpfs
Message-ID:  <201709301823.v8UINjDY082911@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sat Sep 30 18:23:45 2017
New Revision: 324127
URL: https://svnweb.freebsd.org/changeset/base/324127

Log:
  tmpfs: skip zero-sized page count updates
  
  Such updates consisted of vast majority of modificiations, especially
  in tmpfs_reg_resize.
  
  For the case where page count did no change and the size grew we only
  need to update tn_size. Use this fact to avoid vm object lock/relock.
  
  MFC after:	1 week

Modified:
  head/sys/fs/tmpfs/tmpfs_subr.c

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_subr.c	Sat Sep 30 18:07:46 2017	(r324126)
+++ head/sys/fs/tmpfs/tmpfs_subr.c	Sat Sep 30 18:23:45 2017	(r324127)
@@ -350,7 +350,8 @@ tmpfs_free_node_locked(struct tmpfs_mount *tmp, struct
 	case VREG:
 		uobj = node->tn_reg.tn_aobj;
 		if (uobj != NULL) {
-			atomic_subtract_long(&tmp->tm_pages_used, uobj->size);
+			if (uobj->size != 0)
+				atomic_subtract_long(&tmp->tm_pages_used, uobj->size);
 			KASSERT((uobj->flags & OBJ_TMPFS) == 0,
 			    ("leaked OBJ_TMPFS node %p vm_obj %p", node, uobj));
 			vm_object_deallocate(uobj);
@@ -1375,6 +1376,12 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, bool
 	oldpages = OFF_TO_IDX(oldsize + PAGE_MASK);
 	MPASS(oldpages == uobj->size);
 	newpages = OFF_TO_IDX(newsize + PAGE_MASK);
+
+	if (__predict_true(newpages == oldpages && newsize >= oldsize)) {
+		node->tn_size = newsize;
+		return (0);
+	}
+
 	if (newpages > oldpages &&
 	    tmpfs_pages_check_avail(tmp, newpages - oldpages) == 0)
 		return (ENOSPC);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709301823.v8UINjDY082911>