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


Groups > linux.kernel > #1619802

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

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg()
Date 2017-04-10 12:50 +0200
Message-ID <tuF3s-7X5-11@gated-at.bofh.it> (permalink)
References (5 earlier) <tqGr8-5AE-3@gated-at.bofh.it> <tqHdw-69w-15@gated-at.bofh.it> <tqJ5D-7vN-11@gated-at.bofh.it> <tr2rE-3x5-21@gated-at.bofh.it> <tr3e2-45U-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 comments to fully eradicate the whole +1 business.


Something like so; which also makes it obvious p == 0 is not 'right'.


--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2777,18 +2777,18 @@ static u32 __accumulate_pelt_segments(u6
 	u32 c1, c2, c3 = d3; /* y^0 == 1 */
 
 	/*
-	 * c1 = d1 y^(p+1)
+	 * c1 = d1 y^p
 	 */
 	c1 = decay_load((u64)d1, periods);
 
 	/*
-	 *             p
+	 *            p-1
 	 * c2 = 1024 \Sum y^n
 	 *            n=1
 	 *
 	 *              inf        inf
 	 *    = 1024 ( \Sum y^n - \Sum y^n - y^0 )
-	 *              n=0        n=p+1
+	 *              n=0        n=p
 	 */
 	c2 = LOAD_AVG_MAX - decay_load(LOAD_AVG_MAX, periods) - 1024;
 
@@ -2808,15 +2808,15 @@ static u32 __accumulate_pelt_segments(u6
  *         |<->|<----------------->|<--->|
  * ... |---x---|------| ... |------|-----x (now)
  *
- *                                p
- * u' = (u + d1) y^(p+1) + 1024 \Sum y^n + d3 y^0
- *                               n=1
+ *                           p-1
+ * u' = (u + d1) y^p + 1024 \Sum y^n + d3 y^0
+ *                           n=1
  *
- *    = u y^(p+1) +				(Step 1)
+ *    = u y^p +					(Step 1)
  *
- *                          p
- *      d1 y^(p+1) + 1024 \Sum y^n + d3 y^0	(Step 2)
- *                         n=1
+ *                     p-1
+ *      d1 y^p + 1024 \Sum y^n + d3 y^0		(Step 2)
+ *                     n=1
  */
 static __always_inline u32
 accumulate_sum(u64 delta, int cpu, struct sched_avg *sa,


> > I computed all the values vs true value that the old/new computations
> > result in, and it's very close.  Absolutely it's approximately 2x off
> > the previous computation, e.g. if the old value was -15 (relative to
> > true value) than the new computation is -30.
> > 
> > This is definitely more than good enough.  If we want more precision,
> > then the correction factor of:
> >   +clamp(periods, 0, 45)
> 
> Can you do a patch with coherent comment explaining where that
> correction term comes from?

ping?

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


Thread

Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-28 16:50 +0200
  Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Yuyang Du <yuyang.du@intel.com> - 2017-03-29 10:20 +0200
    Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-29 12:50 +0200
      Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Yuyang Du <yuyang.du@intel.com> - 2017-03-30 04:50 +0200
      Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Paul Turner <pjt@google.com> - 2017-03-30 13:30 +0200
        Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-30 14:20 +0200
          Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-30 15:50 +0200
            Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Yuyang Du <yuyang.du@intel.com> - 2017-03-31 05:00 +0200
          Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-30 16:20 +0200
            Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Paul Turner <pjt@google.com> - 2017-03-31 00:10 +0200
              Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-31 09:10 +0200
                Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Paul Turner <pjt@google.com> - 2017-03-31 12:00 +0200
                Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-31 13:30 +0200
                Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Dietmar Eggemann <dietmar.eggemann@arm.com> - 2017-04-10 09:40 +0200
                Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-04-10 10:50 +0200
                Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-31 13:40 +0200
            Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Yuyang Du <yuyang.du@intel.com> - 2017-03-31 05:20 +0200
              Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Yuyang Du <yuyang.du@intel.com> - 2017-03-31 05:50 +0200
                Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-31 09:20 +0200
            Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Paul Turner <pjt@google.com> - 2017-03-31 13:00 +0200
              Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-03-31 13:50 +0200
                Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Peter Zijlstra <peterz@infradead.org> - 2017-04-10 12:50 +0200
        Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() Yuyang Du <yuyang.du@intel.com> - 2017-03-31 04:50 +0200

csiph-web