svn commit: r256295 - in projects/camlock/sys: geom kern

Alexander Motin mav at FreeBSD.org
Thu Oct 10 20:03:55 UTC 2013


Author: mav
Date: Thu Oct 10 20:03:54 2013
New Revision: 256295
URL: http://svnweb.freebsd.org/changeset/base/256295

Log:
  Use the same satistics for disk and its GEOM provider.
  
  Avoiding double accounting allows to reduce CPU load on I/O, especially on
  machines with slow timecounter.  As side effect it also makes gstat show
  statistics for raw disk providers even when kern.geom.collectstats is set
  to zero, making that mode more usable.

Modified:
  projects/camlock/sys/geom/geom_disk.c
  projects/camlock/sys/geom/geom_io.c
  projects/camlock/sys/kern/subr_devstat.c

Modified: projects/camlock/sys/geom/geom_disk.c
==============================================================================
--- projects/camlock/sys/geom/geom_disk.c	Thu Oct 10 19:56:31 2013	(r256294)
+++ projects/camlock/sys/geom/geom_disk.c	Thu Oct 10 20:03:54 2013	(r256295)
@@ -554,6 +554,9 @@ g_disk_create(void *arg, int flag)
 	gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, dp->d_unit);
 	gp->softc = sc;
 	pp = g_new_providerf(gp, "%s", gp->name);
+	devstat_remove_entry(pp->stat);
+	pp->stat = NULL;
+	dp->d_devstat->id = pp;
 	pp->mediasize = dp->d_mediasize;
 	pp->sectorsize = dp->d_sectorsize;
 	pp->stripeoffset = dp->d_stripeoffset;

Modified: projects/camlock/sys/geom/geom_io.c
==============================================================================
--- projects/camlock/sys/geom/geom_io.c	Thu Oct 10 19:56:31 2013	(r256294)
+++ projects/camlock/sys/geom/geom_io.c	Thu Oct 10 20:03:54 2013	(r256295)
@@ -510,7 +510,7 @@ g_io_request(struct bio *bp, struct g_co
 
 	KASSERT(!(bp->bio_flags & BIO_ONQUEUE),
 	    ("Bio already on queue bp=%p", bp));
-	if (g_collectstats)
+	if ((g_collectstats & ~(pp->stat ? 0 : 1)) != 0)
 		binuptime(&bp->bio_t0);
 	else
 		getbinuptime(&bp->bio_t0);
@@ -647,7 +647,7 @@ g_io_deliver(struct bio *bp, int error)
 	 * can not update one instance of the statistics from more
 	 * than one thread at a time, so grab the lock first.
 	 */
-	if (g_collectstats)
+	if ((g_collectstats & ~(pp->stat ? 0 : 1)) != 0)
 		binuptime(&now);
 	mtxp = mtx_pool_find(mtxpool_sleep, cp);
 	mtx_lock(mtxp);

Modified: projects/camlock/sys/kern/subr_devstat.c
==============================================================================
--- projects/camlock/sys/kern/subr_devstat.c	Thu Oct 10 19:56:31 2013	(r256294)
+++ projects/camlock/sys/kern/subr_devstat.c	Thu Oct 10 20:03:54 2013	(r256295)
@@ -131,6 +131,7 @@ devstat_new_entry(const void *dev_name,
 	ds = devstat_alloc();
 	mtx_lock(&devstat_mutex);
 	if (unit_number == -1) {
+		ds->unit_number = unit_number;
 		ds->id = dev_name;
 		binuptime(&ds->creation_time);
 		devstat_generation++;
@@ -242,7 +243,7 @@ devstat_remove_entry(struct devstat *ds)
 
 	/* Remove this entry from the devstat queue */
 	atomic_add_acq_int(&ds->sequence1, 1);
-	if (ds->id == NULL) {
+	if (ds->unit_number != -1) {
 		devstat_num_devs--;
 		STAILQ_REMOVE(devstat_head, ds, devstat, dev_links);
 	}


More information about the svn-src-projects mailing list