Modernize geom_stats_snapshot_get

* A logically useless memset() is used to fault in some memory pages.
  Change it to explicit_bzero so the compiler won't eliminate it.

* Eliminate the second memset.  It made sense in the days of the Big
  Kernel Lock, but not in the days of fine-grained SMP and especially
  not in the days of VDSO.

Sponsored by:	Axcient
Reviewed by:	phk
Differential Revision:	https://reviews.freebsd.org/D29047

(cherry picked from commit f05b724ecb)
This commit is contained in:
Alan Somers 2021-03-03 13:06:38 -07:00
parent 438e52f814
commit 774abe650b

View file

@ -136,9 +136,8 @@ geom_stats_snapshot_get(void)
free(sp);
return (NULL);
}
memset(sp->ptr, 0, pagesize * npages); /* page in, cache */
explicit_bzero(sp->ptr, pagesize * npages); /* page in, cache */
clock_gettime(CLOCK_REALTIME, &sp->time);
memset(sp->ptr, 0, pagesize * npages); /* page in, cache */
memcpy(sp->ptr, statp, pagesize * npages);
sp->pages = npages;
sp->perpage = spp;