Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-04-10 Thread Peter Zijlstra
On Fri, Mar 31, 2017 at 01:38:55PM +0200, Peter Zijlstra wrote: > So here, @periods == p+1, see also c1. Yes, this is confusing [*]. > [*] hysterically p used to be off by 1, which is where the p+1 came > from, but now periods includes it. I was thinking of doing a patch > correcting all the comme

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-04-10 Thread Peter Zijlstra
On Mon, Apr 10, 2017 at 08:39:10AM +0100, Dietmar Eggemann wrote: > Are you planning to get rid of scale_load_down() for weight because of > the correctness problems of the signal mentioned by Paul in this thread? Yes; it would be good to (again) use all 20 bits of weight for the load_avg things.

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-04-10 Thread Dietmar Eggemann
On 31/03/17 12:23, Peter Zijlstra wrote: > On Fri, Mar 31, 2017 at 02:58:57AM -0700, Paul Turner wrote: >>> So lets pull it out again -- but I don't think we need to undo all of >>> yuyang's patches for that. So please, look at the patch I proposed for >>> the problem you spotted. Lets fix the cu

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-31 Thread Peter Zijlstra
On Fri, Mar 31, 2017 at 03:55:40AM -0700, Paul Turner wrote: > > 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 > > > > infinf > >

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-31 Thread Peter Zijlstra
On Fri, Mar 31, 2017 at 02:58:57AM -0700, Paul Turner wrote: > I agree, but it's not correct relative to the numerical > interpretations we actually want to use. We examine these values for > forward-looking decisions, e.g. if we move this thread, how much load > are we moving and vruntime calcul

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-31 Thread Peter Zijlstra
On Fri, Mar 31, 2017 at 02:58:57AM -0700, Paul Turner wrote: > > So lets pull it out again -- but I don't think we need to undo all of > > yuyang's patches for that. So please, look at the patch I proposed for > > the problem you spotted. Lets fix the current state and take it from > > there, ok? >

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-31 Thread Paul Turner
On Thu, Mar 30, 2017 at 7:14 AM, 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; >

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-31 Thread Paul Turner
On Fri, Mar 31, 2017 at 12:01 AM, Peter Zijlstra wrote: > On Thu, Mar 30, 2017 at 03:02:47PM -0700, Paul Turner wrote: >> On Thu, Mar 30, 2017 at 7:14 AM, 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, Pau

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-31 Thread Peter Zijlstra
On Fri, Mar 31, 2017 at 03:41:18AM +0800, Yuyang Du wrote: > > > > > > p > > > c2 = 1024 \Sum y^n > > > n=1 > > > > > > infinf > > > = 1024 ( \Sum y^n - \Sum y^n - y^0 ) > > > n=0n=p > > > > It looks surprisingly kinda w

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-31 Thread Peter Zijlstra
On Thu, Mar 30, 2017 at 03:02:47PM -0700, Paul Turner wrote: > On Thu, Mar 30, 2017 at 7:14 AM, 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(p

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Yuyang Du
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 (

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Yuyang Du
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 LOA

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Yuyang Du
On Thu, Mar 30, 2017 at 03:46:58PM +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: > > > > - The naming here is really ambiguous: > > > "__accumulate_sum" -> "__accumulate_pelt_segme

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Yuyang Du
Hi Paul, On Thu, Mar 30, 2017 at 04:21:08AM -0700, Paul Turner wrote: > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -2767,7 +2767,7 @@ static const u32 __accumulated_sum_N32[] > > * Approximate: > > * val * y^n,where y^32 ~= 0.5 (~1 scheduling period) > > */ > > -s

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Paul Turner
On Thu, Mar 30, 2017 at 7:14 AM, 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; >

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Peter Zijlstra
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_

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Peter Zijlstra
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: > > - The naming here is really ambiguous: > > "__accumulate_sum" -> "__accumulate_pelt_segments"? > > OK, I did struggle with that a bit too but failed to improve, I

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Peter Zijlstra
On Thu, Mar 30, 2017 at 04:21:08AM -0700, Paul Turner wrote: > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -2767,7 +2767,7 @@ static const u32 __accumulated_sum_N32[] > > * Approximate: > > * val * y^n,where y^32 ~= 0.5 (~1 scheduling period) > > */ > > -static __al

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-30 Thread Paul Turner
> --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -2767,7 +2767,7 @@ static const u32 __accumulated_sum_N32[] > * Approximate: > * val * y^n,where y^32 ~= 0.5 (~1 scheduling period) > */ > -static __always_inline u64 decay_load(u64 val, u64 n) > +static u64 decay_load(u64 val

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-29 Thread Yuyang Du
Hi Peter, On Wed, Mar 29, 2017 at 12:41:26PM +0200, Peter Zijlstra wrote: > On Wed, Mar 29, 2017 at 08:04:42AM +0800, Yuyang Du wrote: > > Yes, you need to, and let me do it too and learn how you will rewrite > > it. > > I've meanwhile written this. Does that work for you? It works. You sort it

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-29 Thread Peter Zijlstra
On Wed, Mar 29, 2017 at 08:04:42AM +0800, Yuyang Du wrote: > Yes, you need to, and let me do it too and learn how you will rewrite > it. I've meanwhile written this. Does that work for you? --- Subject: sched/fair: Optimize ___update_sched_avg() From: Yuyang Du Date: Mon, 13 Feb 2017 05:44:23 +0

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-29 Thread Yuyang Du
Hi Peter, On Tue, Mar 28, 2017 at 04:46:25PM +0200, Peter Zijlstra wrote: > On Mon, Feb 13, 2017 at 05:44:23AM +0800, Yuyang Du wrote: > > __update_load_avg() has the following steps: > > > > 1. add the remainder of the last incomplete period > > 2. decay old sum > > 3. accumulate new sum i

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-29 Thread Yuyang Du
On Tue, Mar 28, 2017 at 02:50:22PM +0200, Peter Zijlstra wrote: > This Changelog being so impenetrable is what makes me skip over it; > I'll put it on the 'look-at-later' pile, and that just never happens :/ Very understandable, but thank you. I hope I can write the changelog better. :)

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-28 Thread Peter Zijlstra
On Mon, Feb 13, 2017 at 05:44:23AM +0800, Yuyang Du wrote: > __update_load_avg() has the following steps: > > 1. add the remainder of the last incomplete period > 2. decay old sum > 3. accumulate new sum in full periods since last_update_time > 4. accumulate the current incomplete period >

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-03-28 Thread Peter Zijlstra
This Changelog being so impenetrable is what makes me skip over it; I'll put it on the 'look-at-later' pile, and that just never happens :/ On Mon, Feb 13, 2017 at 05:44:23AM +0800, Yuyang Du wrote: > __update_load_avg() has the following steps: > > 1. add the remainder of the last incomplete p

[RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()

2017-02-12 Thread Yuyang Du
__update_load_avg() has the following steps: 1. add the remainder of the last incomplete period 2. decay old sum 3. accumulate new sum in full periods since last_update_time 4. accumulate the current incomplete period 5. update averages However, there is no need to separately compute st