Fix a ticks comparison in sched_pctcpu_update().
We may fail to reset the %CPU tracking window if a thread does not run for over half of the ticks rollover period, resulting in a bogus %CPU value for the thread until ticks fully rolls over. Handle this by comparing the unsigned difference ticks - ts_ltick with SCHED_TICK_TARG instead. Reviewed by: cem, jeff MFC after: 1 week Sponsored by: Dell EMC Isilon
This commit is contained in:
parent
a0bbf9e0e3
commit
7813302434
@ -1662,7 +1662,11 @@ sched_pctcpu_update(struct td_sched *ts, int run)
|
||||
{
|
||||
int t = ticks;
|
||||
|
||||
if (t - ts->ts_ltick >= SCHED_TICK_TARG) {
|
||||
/*
|
||||
* The signed difference may be negative if the thread hasn't run for
|
||||
* over half of the ticks rollover period.
|
||||
*/
|
||||
if ((u_int)(t - ts->ts_ltick) >= SCHED_TICK_TARG) {
|
||||
ts->ts_ticks = 0;
|
||||
ts->ts_ftick = t - SCHED_TICK_TARG;
|
||||
} else if (t - ts->ts_ftick >= SCHED_TICK_MAX) {
|
||||
|
Loading…
Reference in New Issue
Block a user