Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1454439

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

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH 4.4 043/146] sched/fair: Fix cfs_rq avg tracking underflow
Date 2016-08-02 15:50 +0200
Message-ID <s1If1-589-61@gated-at.bofh.it> (permalink)
References <rYV8K-Pn-13@gated-at.bofh.it> <rYV8L-Pn-57@gated-at.bofh.it> <rYWob-1Z8-65@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jul 25, 2016 at 03:12:24PM -0700, bsegall@google.com 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.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH 4.4 043/146] sched/fair: Fix cfs_rq avg tracking underflow bsegall@google.com - 2016-07-26 00:20 +0200
  Re: [PATCH 4.4 043/146] sched/fair: Fix cfs_rq avg tracking underflow Peter Zijlstra <peterz@infradead.org> - 2016-08-02 15:50 +0200

csiph-web