From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755732AbcECItR (ORCPT ); Tue, 3 May 2016 04:49:17 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:37183 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755557AbcECItH (ORCPT ); Tue, 3 May 2016 04:49:07 -0400 Date: Tue, 3 May 2016 10:49:01 +0200 From: Peter Zijlstra To: Yuyang Du Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, bsegall@google.com, pjt@google.com, morten.rasmussen@arm.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, juri.lelli@arm.com Subject: Re: [PATCH v2 05/12] sched/fair: Optimize __update_sched_avg() Message-ID: <20160503084901.GI3430@twins.programming.kicks-ass.net> References: <1462226078-31904-1-git-send-email-yuyang.du@intel.com> <1462226078-31904-6-git-send-email-yuyang.du@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1462226078-31904-6-git-send-email-yuyang.du@intel.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 03, 2016 at 05:54:31AM +0800, Yuyang Du wrote: > __update_sched_avg() has these steps: > 1. add the left of the last incomplete period > 2. decay old sum > 3. accumulate new sum since last_update_time > 4. add the current incomplete period > 5. update averages > > Previously, we separately computed steps 1, 3, and 4, leading to > each one of them ugly in codes and costly in overhead. But actually > they all do the same thing, so we combine them together. The result > will be much cleaner codes and less CPU cycles. I would very much like to see an explanation of how we can fold all that here. Without me having to untangle the code first. That also helps me to verify if the code does indeed implement what you meant it to, etc..