From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966712AbcHBNou (ORCPT ); Tue, 2 Aug 2016 09:44:50 -0400 Received: from merlin.infradead.org ([205.233.59.134]:45151 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966624AbcHBNlh (ORCPT ); Tue, 2 Aug 2016 09:41:37 -0400 Date: Tue, 2 Aug 2016 13:24:17 +0200 From: Peter Zijlstra To: bsegall@google.com Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Andrey Ryabinin , Chris Wilson , Linus Torvalds , Mike Galbraith , Thomas Gleixner , Yuyang Du , kernel@kyup.com, morten.rasmussen@arm.com, pjt@google.com, steve.muckle@linaro.org, Ingo Molnar , Greg Kroah-Hartman Subject: Re: [PATCH 4.4 043/146] sched/fair: Fix cfs_rq avg tracking underflow Message-ID: <20160802112417.GH6862@twins.programming.kicks-ass.net> References: <20160725203521.340401316@linuxfoundation.org> <20160725203523.152875464@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.