Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2220966imm; Sun, 12 Aug 2018 09:11:48 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzE5AJMVYaXmUi9BZSgOx7D3k/ygdDMTThwQZTlFSLKYEglrMRoYrTcIKLjcQiw6GY7MLIQ X-Received: by 2002:a17:902:b70f:: with SMTP id d15-v6mr5710191pls.53.1534090308026; Sun, 12 Aug 2018 09:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534090308; cv=none; d=google.com; s=arc-20160816; b=a/NzHXjx7NkRbSDs/iRM2R+5HhwyqnsMZcOopq5gX9tHlsGORxre41UJf/DmMHCQuI c70zJ5N0ZO7cLipYn1pUT5YJXlHGHBzM2Ab+zjO/bp32tP4OjvAfeBfLJ/ZqmBcho0G1 d+rIMFXqqNhJ6X6Yeoi/Qb+w1x1euOV1khqTo/S2fLafxAGyOevk9chDvcEURM9fUheK LblRtY9CFjLTMaGxs47l2UWYtFGDqVyQpW4TMqLKeHiC9dpQ7U9lAf3R5CXQ8OvC6nFJ nZCl9nFWpHiLoXcdS0yRZ8tWnGUtjxn2XoA7k1o30W7vzBNpFCnYPlbXIXk3TmSh+iL3 UBYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7syOievGKU1gnJa8oh05y8DUlQgWF5NjJ3xt3wLMcp0=; b=csx8l7lZ5CCDGR5y7JI0pskRFQtoj090Z03YD3veXEQJ0UhRcDb1lGmCJre62eV3da 3XrzZxKxwfpSWhKSYCDbm/Aj0FdTHPmp7YOnNdsHOPv3L5/s1T8qjF1SyzsjRIiAfccb BWvVYfTOFds3No61F7BWiJWMwPjRZDIXY2iAPomd2NrbCKqLuStTePsulxtV5OE+JmX4 i28T7ocQswKcZSpwi0KMdyw1Mcck+4lS0Z8ej1/n12/ma6Jo28ffsVawcN8Bv7kHQCAW W8RtaH5aOJuIy4GcjoHjvMDGTVdl2w1yatogwFopcEhDvYRymIQVaKRr4JYMLiO3mPXC 8JNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Aqw4vA0x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11-v6si17751997pfc.340.2018.08.12.09.11.18; Sun, 12 Aug 2018 09:11:47 -0700 (PDT) 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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Aqw4vA0x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728244AbeHLSs2 (ORCPT + 99 others); Sun, 12 Aug 2018 14:48:28 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:53849 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727699AbeHLSs1 (ORCPT ); Sun, 12 Aug 2018 14:48:27 -0400 Received: by mail-wm0-f67.google.com with SMTP id s9-v6so6473898wmh.3 for ; Sun, 12 Aug 2018 09:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7syOievGKU1gnJa8oh05y8DUlQgWF5NjJ3xt3wLMcp0=; b=Aqw4vA0xT3WxMfTUxnd2mwPWd8CNO/XKIvCXki9jTDnHbOsEpUGb8lNr5DxnTeREod RtqC2bdKn0+llD37F45FFVZkE3+SCLiR5wyX/knNX9M8hLOei8vErZgtXqz8CuzNhE1W OtoVDdXcF8fJUARQ4SjmDJL1uS57JPBz+gdfk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7syOievGKU1gnJa8oh05y8DUlQgWF5NjJ3xt3wLMcp0=; b=GfMFuxMZ2VLWTqK3ZFcWjHVWqWwimw/gTaqSDnLuK6kqt0krRbu8tyNSRbee6IyVY9 TtDUNqMgSLAjdRANYqMUaDyUh0Ka3fakKZG5KQ4jClBacVWcOIaGSNd6gyKnF1qPN02G 3vHO8CwFukgsQHufYBL0nj1OErP0zCoGPcgkvQPhiwDMPxTS1rfY8gty/HhhqsGCXzNp U3UJD+88lA4mK4aTTRYUf7pKQUxk5Hhe9rZLYeItmHU/zppnifltWV0X/okoxygKmvOb A5es1nrASyQFcSlLl5K35ERRrBn7wklEK7y3ixIoTluN9sOs5fDqYblbg595hW85XF+j k3uA== X-Gm-Message-State: AOUpUlG2b4Z7J3Sb18GTCpe0LspnbU12EBuMfkm3hKdxzP8zSvBa5u+x 38jC68VZr4npmqJUPVg5EY/XWg== X-Received: by 2002:a1c:28c2:: with SMTP id o185-v6mr6159731wmo.40.1534090195777; Sun, 12 Aug 2018 09:09:55 -0700 (PDT) Received: from localhost.localdomain ([45.76.138.171]) by smtp.gmail.com with ESMTPSA id t6-v6sm7437369wmf.8.2018.08.12.09.09.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Aug 2018 09:09:55 -0700 (PDT) From: Leo Yan To: "Rafael J. Wysocki" , "Peter Zijlstra (Intel)" , Daniel Lezcano , Vincent Guittot , Ramesh Thomas , linux-kernel@vger.kernel.org, Linux PM Cc: Leo Yan Subject: [PATCH v1 1/5] cpuidle: menu: Clean up variables usage in menu_select() Date: Mon, 13 Aug 2018 00:09:27 +0800 Message-Id: <1534090171-14464-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534090171-14464-1-git-send-email-leo.yan@linaro.org> References: <1534090171-14464-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The usage for two variables 'data->predicted_us' and 'expected_interval' in menu_select() are confused, especially these two variables are assigned with each other: firstly 'data->predicted_us' is assigned to the minimum value between 'data->predicted_us' and 'expected_interval', so it presents the prediction period for taking account different factors and include consideration for expected interval; but later 'data->predicted_us' is assigned back to 'expected_interval' and from then on the function uses 'expected_interval' to select idle state; this results in 'expected_interval' has two different semantics between the top half and the bottom half of the same function. This patch is to clean up the usage of these two variables, we always use 'data->predicted_us' to present the idle duration predictions and it can be used to compare with idle state target residency or tick boundary for choosing idle state; we purely use 'expected_interval' to record the expected interval value, which is mainly for interval interrupt estimation. Signed-off-by: Leo Yan --- drivers/cpuidle/governors/menu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index 5eb7d6f..b972db1 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -363,7 +363,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, latency_req = interactivity_req; select: - expected_interval = data->predicted_us; /* * Find the idle state with the lowest power while satisfying * our constraints. @@ -386,7 +385,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, * expected idle duration so that the tick is retained * as long as that target residency is low enough. */ - expected_interval = drv->states[idx].target_residency; + data->predicted_us = drv->states[idx].target_residency; break; } idx = i; @@ -400,7 +399,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, * expected idle duration is shorter than the tick period length. */ if (((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) || - expected_interval < TICK_USEC) && !tick_nohz_tick_stopped()) { + data->predicted_us < TICK_USEC) && !tick_nohz_tick_stopped()) { unsigned int delta_next_us = ktime_to_us(delta_next); *stop_tick = false; -- 2.7.4