From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751981AbcGMHuL (ORCPT ); Wed, 13 Jul 2016 03:50:11 -0400 Received: from merlin.infradead.org ([205.233.59.134]:43250 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751220AbcGMHuD (ORCPT ); Wed, 13 Jul 2016 03:50:03 -0400 Date: Wed, 13 Jul 2016 09:49:37 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: Anton Blanchard , LKML , Ingo Molnar , rt@linutronix.de, Michael Ellerman , Vaidyanathan Srinivasan , shreyas@linux.vnet.ibm.com Subject: Re: [patch 10/15] sched/migration: Move calc_load_migrate() into CPU_DYING Message-ID: <20160713074937.GP30154@twins.programming.kicks-ass.net> References: <20160310115406.940706476@linutronix.de> <20160310120025.328739226@linutronix.de> <20160712143745.430733e7@kryten> 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 Tue, Jul 12, 2016 at 06:33:56PM +0200, Thomas Gleixner wrote: > Subject: sched/migration: Correct off by one in load migration > From: Thomas Gleixner > > The move of calc_load_migrate() from CPU_DEAD to CPU_DYING did not take into > account that the function is now called from a thread running on the outgoing > CPU. As a result a cpu unplug leakes a load of 1 into the global load > accounting mechanism. > > Fix it by adjusting for the currently running thread which calls > calc_load_migrate(). > > Fixes: e9cd8fa4fcfd: "sched/migration: Move calc_load_migrate() into CPU_DYING" > Reported-by: Anton Blanchard > Signed-off-by: Thomas Gleixner > +++ b/kernel/sched/loadavg.c > @@ -78,11 +78,11 @@ void get_avenrun(unsigned long *loads, unsigned long offset, int shift) > loads[2] = (avenrun[2] + offset) << shift; > } > > -long calc_load_fold_active(struct rq *this_rq) > +long calc_load_fold_active(struct rq *this_rq, long adjust) > { > long nr_active, delta = 0; > > - nr_active = this_rq->nr_running; > + nr_active = this_rq->nr_running - adjust; > nr_active += (long)this_rq->nr_uninterruptible; > > if (nr_active != this_rq->calc_load_active) { Yeah, I think this is the only sensible approach. How do you want to route this?