Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932904AbdCaDqK (ORCPT ); Thu, 30 Mar 2017 23:46:10 -0400 Received: from mga09.intel.com ([134.134.136.24]:4842 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932618AbdCaDqJ (ORCPT ); Thu, 30 Mar 2017 23:46:09 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,250,1486454400"; d="scan'208";a="840265112" Date: Fri, 31 Mar 2017 03:41:18 +0800 From: Yuyang Du To: Peter Zijlstra Cc: Paul Turner , Ingo Molnar , LKML , Benjamin Segall , Morten Rasmussen , Vincent Guittot , Dietmar Eggemann , Matt Fleming , umgwanakikbuti@gmail.com Subject: Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Message-ID: <20170330194118.GE16440@ydu19desktop> References: <1486935863-25251-1-git-send-email-yuyang.du@intel.com> <1486935863-25251-3-git-send-email-yuyang.du@intel.com> <20170328144625.GX3093@worktop> <20170329000442.GC2459@ydu19desktop> <20170329104126.lg6ismevfbqywpcj@hirez.programming.kicks-ass.net> <20170330121658.6mo7datma4ssw7st@hirez.programming.kicks-ass.net> <20170330141428.deiduft5btwid6ov@hirez.programming.kicks-ass.net> <20170330191355.GD16440@ydu19desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170330191355.GD16440@ydu19desktop> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1872 Lines: 52 On Fri, Mar 31, 2017 at 03:13:55AM +0800, Yuyang Du wrote: > On Thu, Mar 30, 2017 at 04:14:28PM +0200, Peter Zijlstra wrote: > > On Thu, Mar 30, 2017 at 02:16:58PM +0200, Peter Zijlstra wrote: > > > On Thu, Mar 30, 2017 at 04:21:08AM -0700, Paul Turner wrote: > > > > > > > + > > > > > + if (unlikely(periods >= LOAD_AVG_MAX_N)) > > > > > return LOAD_AVG_MAX; > > > > > > > > > > Is this correct in the iterated periods > LOAD_AVG_MAX_N case? > > > > I don't think the decay above is guaranteed to return these to zero. > > > > > > Ah! > > > > > > Indeed, so decay_load() needs LOAD_AVG_PERIOD * 63 before it truncates > > > to 0, because every LOAD_AVG_PERIOD we half the value; loose 1 bit; so > > > 63 of those and we're 0. > > > > > > But __accumulate_sum() OTOH returns LOAD_AVG_MAX after only > > > LOAD_AVG_MAX_N, which < LOAD_AVG_PERIOD * 63. > > > > > > So yes, combined we exceed LOAD_AVG_MAX, which is bad. Let me think what > > > to do about that. > > > > > > So at the very least it should be decay_load(LOAD_AVG_MAX, 1) (aka > > LOAD_AVG_MAX - 1024), but that still doesn't account for the !0 > > decay_load() of the first segment. > > > > I'm thinking that we can compute the middle segment, by taking the max > > value and chopping off the ends, like: > > > > > > p > > c2 = 1024 \Sum y^n > > n=1 > > > > inf inf > > = 1024 ( \Sum y^n - \Sum y^n - y^0 ) > > n=0 n=p > > It looks surprisingly kinda works :) > > > + c2 = LOAD_AVG_MAX - decay_load(LOAD_AVG_MAX, periods) - 1024; > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > But, I'm not sure this is what you want (just assume p==0). > Oh, what I meant is when p != 0, actually p>=1. And thinking about it for a while, it's really what you want, brilliant :)