Subject: Culling a few calls to microtime()
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-kern
Date: 08/01/2002 11:26:55
This is a little change to reduce a few calls to microtime() based on
some other similar code in the kernel. Seem reasonable?
Simon.
--
Simon Burge <simonb@wasabisystems.com>
NetBSD Development, Support and Service: http://www.wasabisystems.com/
Index: miscfs/kernfs/kernfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/miscfs/kernfs/kernfs_vnops.c,v
retrieving revision 1.82
diff -d -p -u -r1.82 kernfs_vnops.c
--- miscfs/kernfs/kernfs_vnops.c 2002/07/19 18:35:44 1.82
+++ miscfs/kernfs/kernfs_vnops.c 2002/08/01 01:21:44
@@ -466,7 +466,6 @@ kernfs_getattr(v)
} */ *ap = v;
struct vnode *vp = ap->a_vp;
struct vattr *vap = ap->a_vap;
- struct timeval tv;
int error = 0;
char strbuf[KSTRING], *buf;
@@ -478,10 +477,11 @@ kernfs_getattr(v)
vap->va_size = 0;
vap->va_blocksize = DEV_BSIZE;
/*
- * Make all times be current TOD.
+ * Make all times be current TOD. Avoid microtime(9), it's slow.
+ * We don't guard the read from time(9) with splclock(9) since we
+ * don't actually need to be THAT sure the access is atomic.
*/
- microtime(&tv);
- TIMEVAL_TO_TIMESPEC(&tv, &vap->va_ctime);
+ TIMEVAL_TO_TIMESPEC(&time, &vap->va_ctime);
vap->va_atime = vap->va_mtime = vap->va_ctime;
vap->va_gen = 0;
vap->va_flags = 0;
Index: miscfs/portal/portal_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/miscfs/portal/portal_vnops.c,v
retrieving revision 1.42
diff -d -p -u -r1.42 portal_vnops.c
--- miscfs/portal/portal_vnops.c 2002/07/05 03:24:07 1.42
+++ miscfs/portal/portal_vnops.c 2002/08/01 01:21:44
@@ -545,7 +545,6 @@ portal_getattr(v)
} */ *ap = v;
struct vnode *vp = ap->a_vp;
struct vattr *vap = ap->a_vap;
- struct timeval tv;
memset(vap, 0, sizeof(*vap));
vattr_null(vap);
@@ -555,10 +554,12 @@ portal_getattr(v)
vap->va_size = DEV_BSIZE;
vap->va_blocksize = DEV_BSIZE;
/*
- * Make all times be current TOD.
+ * Make all times be current TOD. Avoid microtime(9), it's slow.
+ * We don't guard the read from time(9) with splclock(9) since we
+ * don't actually need to be THAT sure the access is atomic.
*/
- microtime(&tv);
- TIMEVAL_TO_TIMESPEC(&tv, &vap->va_ctime);
+ TIMEVAL_TO_TIMESPEC(&time, &vap->va_ctime);
+ vap->va_atime = vap->va_mtime = vap->va_ctime;
vap->va_atime = vap->va_mtime = vap->va_ctime;
vap->va_gen = 0;
vap->va_flags = 0;
Index: miscfs/procfs/procfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/miscfs/procfs/procfs_vnops.c,v
retrieving revision 1.89
diff -d -p -u -r1.89 procfs_vnops.c
--- miscfs/procfs/procfs_vnops.c 2002/05/09 15:44:45 1.89
+++ miscfs/procfs/procfs_vnops.c 2002/08/01 01:21:45
@@ -469,7 +469,6 @@ procfs_getattr(v)
struct pfsnode *pfs = VTOPFS(ap->a_vp);
struct vattr *vap = ap->a_vap;
struct proc *procp;
- struct timeval tv;
int error;
/* first check the process still exists */
@@ -500,15 +499,17 @@ procfs_getattr(v)
vap->va_blocksize = PAGE_SIZE;
/*
- * Make all times be current TOD.
+ * Make all times be current TOD. Avoid microtime(9), it's slow.
+ * We don't guard the read from time(9) with splclock(9) since we
+ * don't actually need to be THAT sure the access is atomic.
+ *
* It would be possible to get the process start
* time from the p_stat structure, but there's
* no "file creation" time stamp anyway, and the
* p_stat structure is not addressible if u. gets
* swapped out for that process.
*/
- microtime(&tv);
- TIMEVAL_TO_TIMESPEC(&tv, &vap->va_ctime);
+ TIMEVAL_TO_TIMESPEC(&time, &vap->va_ctime);
vap->va_atime = vap->va_mtime = vap->va_ctime;
switch (pfs->pfs_type) {