Re: [PATCH 4.4 043/146] sched/fair: Fix cfs_rq avg tracking underflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 25, 2016 at 03:12:24PM -0700, bsegall@xxxxxxxxxx wrote:
> > @@ -2690,15 +2707,15 @@ static inline int update_cfs_rq_load_avg
> >  
> >  	if (atomic_long_read(&cfs_rq->removed_load_avg)) {
> >  		s64 r = atomic_long_xchg(&cfs_rq->removed_load_avg, 0);
> > -		sa->load_avg = max_t(long, sa->load_avg - r, 0);
> > -		sa->load_sum = max_t(s64, sa->load_sum - r * LOAD_AVG_MAX, 0);
> > +		sub_positive(&sa->load_avg, r);
> > +		sub_positive(&sa->load_sum, r * LOAD_AVG_MAX);
> >  		removed = 1;
> >  	}
> >  
> >  	if (atomic_long_read(&cfs_rq->removed_util_avg)) {
> >  		long r = atomic_long_xchg(&cfs_rq->removed_util_avg, 0);
> > -		sa->util_avg = max_t(long, sa->util_avg - r, 0);
> > -		sa->util_sum = max_t(s32, sa->util_sum - r * LOAD_AVG_MAX, 0);
> > +		sub_positive(&sa->util_avg, r);
> > +		sub_positive(&sa->util_sum, r * LOAD_AVG_MAX);
> >  	}
> >  
> >  	decayed = __update_load_avg(now, cpu_of(rq_of(cfs_rq)), sa,

> I missed this the first time around, and I have no problem with this
> backport, but it's not remotely obvious that update_cfs_rq_h_load() is
> intended to be something approaching racing-safe when not under
> rq->lock. (And given only somewhat-adversarial compilers I agree that it
> probably won't do any worse than skip updates, though I certainly won't
> swear to it)

Right, this is somewhat 'new' because we now use the avg load value for
the load-balancer, which is entirely unserialized.


--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]