From patchwork Wed Aug 14 16:02:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tuukka.tikkanen@linaro.org X-Patchwork-Id: 2844651 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 62E689F239 for ; Wed, 14 Aug 2013 16:19:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E9E8205AF for ; Wed, 14 Aug 2013 16:19:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92A91205A1 for ; Wed, 14 Aug 2013 16:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932640Ab3HNQSt (ORCPT ); Wed, 14 Aug 2013 12:18:49 -0400 Received: from mx.mmd.net ([80.83.0.3]:57318 "EHLO mx.mmd.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760042Ab3HNQRo (ORCPT ); Wed, 14 Aug 2013 12:17:44 -0400 Received: from t73174b.tic0.net (pc.h.tic0.net [80.83.5.114]) by mx.mmd.net (Postfix) with ESMTP id A434CF99; Wed, 14 Aug 2013 19:01:13 +0300 (EEST) From: tuukka.tikkanen@linaro.org To: rjw@sisk.pl, daniel.lezcano@linaro.org, linux-pm@vger.kernel.org Cc: private-pmwg@linaro.org, linux-kernel@vger.kernel.org, Tuukka Tikkanen Subject: [PATCH 2/8] Cpuidle: Rearrange code and comments in get_typical_interval() Date: Wed, 14 Aug 2013 19:02:35 +0300 Message-Id: <859fb6805a5d7364c179be3b9180a58b7d8a51e0.1376493949.git.tuukka.tikkanen@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tuukka Tikkanen This patch rearranges a if-return-elsif-goto-fi-return sequence into if-return-fi-if-return-fi-goto sequence. The functionality remains the same. Also, a lengthy comment that did not describe the functionality in the order it occurs is split into half and top half is moved closer to actual implementation it describes. Signed-off-by: Tuukka Tikkanen --- drivers/cpuidle/governors/menu.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index c8ab1c5..b13d57c 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -228,14 +228,6 @@ again: do_div(stddev, divisor); stddev = int_sqrt(stddev); /* - * If we have outliers to the upside in our distribution, discard - * those by setting the threshold to exclude these outliers, then - * calculate the average and standard deviation again. Once we get - * down to the bottom 3/4 of our samples, stop excluding samples. - * - * This can deal with workloads that have long pauses interspersed - * with sporadic activity with a bunch of short pauses. - * * The typical interval is obtained when standard deviation is small * or standard deviation is small compared to the average interval. * @@ -246,12 +238,22 @@ again: if (data->expected_us > avg) data->predicted_us = avg; return; - - } else if ((divisor * 4) > INTERVALS * 3) { - /* Exclude the max interval */ - thresh = max - 1; - goto again; } + + /* + * If we have outliers to the upside in our distribution, discard + * those by setting the threshold to exclude these outliers, then + * calculate the average and standard deviation again. Once we get + * down to the bottom 3/4 of our samples, stop excluding samples. + * + * This can deal with workloads that have long pauses interspersed + * with sporadic activity with a bunch of short pauses. + */ + if ((divisor * 4) <= INTERVALS * 3) + return; + + thresh = max - 1; + goto again; } /**