From patchwork Mon Feb 24 06:29:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuukka Tikkanen X-Patchwork-Id: 25175 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3DAA22066C for ; Mon, 24 Feb 2014 08:13:23 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id v10sf16408837pde.1 for ; Mon, 24 Feb 2014 00:13:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=qht6jiWEt2e8CTt88Y/fUpQjMRh5Kn7KFHrv7LPHfps=; b=MLpds2/Ecc6ruSxcVp6BkWfBi55nBIYvmPOaNREgGEiV4uRd0SYj6qQYic88ip/SAw Er3pvKhbOW+fUa899nN4xnCI9Z4B91/KpU6+K5tOBV9EHoFZrJI8P6FDSuJ1dgK+Lv+b qLe7XudjapFwWE6ineWt9eO8UcPB2wMIzBYNeEdaLTDy3YRON8LeIGIeJPZBN2V/GPVU JqyjCCmAomFeLIWoin1pmm71VhXdIf1IO6lhbSeatsEfzgy1vtTFcDeYB1xwlFTXRjO/ 5B1fZj8VdadTNUM8pQNuct8bBCdQ+5QaoeVPXMxaXRWx+UGbRhwtJp/Tw2thXbFIG6GX 4t9Q== X-Gm-Message-State: ALoCoQmk5BMhy7IWbldt/+63xR6AXum2+jjpBeKm7zKShkPZ3T9CNxLyQj1IPqulBQjuUtcu+ICo X-Received: by 10.68.216.230 with SMTP id ot6mr10281832pbc.3.1393229602456; Mon, 24 Feb 2014 00:13:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.149 with SMTP id c21ls1931225qgd.52.gmail; Mon, 24 Feb 2014 00:13:22 -0800 (PST) X-Received: by 10.220.95.139 with SMTP id d11mr11638355vcn.21.1393229602314; Mon, 24 Feb 2014 00:13:22 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id u1si5648912vek.67.2014.02.24.00.13.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Feb 2014 00:13:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id pa12so114430veb.21 for ; Mon, 24 Feb 2014 00:13:22 -0800 (PST) X-Received: by 10.220.191.134 with SMTP id dm6mr11820833vcb.16.1393229602242; Mon, 24 Feb 2014 00:13:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp44709vcz; Mon, 24 Feb 2014 00:13:21 -0800 (PST) X-Received: by 10.68.180.37 with SMTP id dl5mr23394922pbc.111.1393229601412; Mon, 24 Feb 2014 00:13:21 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tk9si15928254pac.151.2014.02.24.00.13.20; Mon, 24 Feb 2014 00:13:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753437AbaBXINL (ORCPT + 26 others); Mon, 24 Feb 2014 03:13:11 -0500 Received: from mx.mmd.net ([80.83.0.3]:55412 "EHLO mx.mmd.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752473AbaBXINC (ORCPT ); Mon, 24 Feb 2014 03:13:02 -0500 Received: from istutuskone.tic0.net (verkonrikkoja.tic0.net [80.83.5.104]) by mx.mmd.net (Postfix) with ESMTP id D9F2EF82; Mon, 24 Feb 2014 09:26:33 +0200 (EET) From: Tuukka Tikkanen To: linux-pm@vger.kernel.org, rjw@rjwysocki.net Cc: daniel.lezcano@linaro.org, tuukka.tikkanen@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] Cpuidle: Move perf multiplier calculation out of the selection loop Date: Mon, 24 Feb 2014 08:29:35 +0200 Message-Id: <1393223377-5744-6-git-send-email-tuukka.tikkanen@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1393223377-5744-1-git-send-email-tuukka.tikkanen@linaro.org> References: <1393223377-5744-1-git-send-email-tuukka.tikkanen@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tuukka.tikkanen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The menu governor performance multiplier defines a minimum predicted idle duration to latency ratio. Instead of checking this separately in every iteration of the state selection loop, adjust the overall latency restriction for the whole loop if this restriction is tighter than what is set by the QoS subsystem. The original test s->exit_latency * multiplier > data->predicted_us becomes s->exit_latency > data->predicted_us / multiplier by dividing both sides of the comparison by "multiplier". While division is likely to be several times slower than multiplication, the minor performance hit allows making a generic sleep state selection function based on (sleep duration, maximum latency) tuple. Signed-off-by: Tuukka Tikkanen --- drivers/cpuidle/governors/menu.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index b347c10..71b5232 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -288,7 +288,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) struct menu_device *data = &__get_cpu_var(menu_devices); int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); int i; - int multiplier; + unsigned int interactivity_req; struct timespec t; if (data->needs_update) { @@ -310,8 +310,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) data->bucket = which_bucket(data->next_timer_us); - multiplier = performance_multiplier(); - /* * if the correction factor is 0 (eg first time init or cpu hotplug * etc), we actually want to start out with a unity factor. @@ -331,6 +329,15 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) get_typical_interval(data); /* + * Performance multiplier defines a minimum predicted idle + * duration / latency ratio. Adjust the latency limit if + * necessary. + */ + interactivity_req = data->predicted_us / performance_multiplier(); + if (latency_req > interactivity_req) + latency_req = interactivity_req; + + /* * We want to default to C1 (hlt), not to busy polling * unless the timer is happening really really soon. */ @@ -353,8 +360,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) continue; if (s->exit_latency > latency_req) continue; - if (s->exit_latency * multiplier > data->predicted_us) - continue; data->last_state_idx = i; }