On Sun, Jun 18, 2023 at 07:32:56PM +0200, Mark Kettenis wrote: > > Date: Sun, 18 Jun 2023 12:27:17 -0500 > > From: Scott Cheloha <scottchel...@gmail.com> > > > > The intent here is to update the load averages every five seconds. > > However: > > > > 1. Measuring elapsed time with the UTC clock is unreliable because of > > settimeofday(2). > > > > 2. "Call uvm_loadav() no more than once every five seconds", is not > > equivalent to "call uvm_loadav() if the current second is equal > > to zero, modulo five". > > > > Not hard to imagine edge cases where timeouts are delayed and > > the load averages are not updated. > > > > So, (1) use the monotonic clock, and (2) keep the next uvm_loadav() > > call time in a static value. > > > > ok? > > I really don't see why the calculatin of something vague like the load > average warrants complicating the code like this.
Aren't load averages used to make decisions about thread placement in the scheduler? Regardless, the code is still wrong. At minimum you should use getuptime(9).