From patchwork Tue Feb 26 14:54:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 159219 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3303992jad; Tue, 26 Feb 2019 06:54:38 -0800 (PST) X-Received: by 2002:a2e:9105:: with SMTP id m5mr13903696ljg.100.1551192877911; Tue, 26 Feb 2019 06:54:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551192877; cv=none; d=google.com; s=arc-20160816; b=naZg9OiU+kBI5rwdAMh4A4xF0O5xBv+EN7jyna6KMNFx5fA9XBRJFWhFLUDucoRZ/H 5ZLRbVbLjCJRo+K0qkEamqzx+4nW7gNAoYRCodmbW6zk+psMJr0UF0fzgEcydcDgVHwj z9j4CHVGYzbQ9msnPSKQHmJsifZ/2rEegvzqdOOe/XEsNBFDaKrf3AjDI/+2Zq9b7qba ajhQyXy4GP8qd55HcGBRqnQkg2YbPkmWoN8tcx7euNian6XNdOZHgd2hNs7Oxhz5u/Fg LuhqFc/Bx3EzhLWqEqsuux55FqQ8rvLBY8aHV76M+Lnfoz74jmWst9MA0bymKMAWuK7H nvRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CizRMe2YmHoMDQUcJ8913XbNFEFzGgJHDQtzao5WKiM=; b=Qbd84DNJFfehpCmDNtoflDJS/VKxAApu7I1eve2NUNLTmLzmw9Yo6Kt4rPNJIplFAo smQ/Rm6SbHVryjLYmvBIPU55PPilVrs1f7MT9CPFdx8+wlW/lCq6zHQj6nJipBrj61B5 OcZ3RNDuYseSVqSDO0qdkCI0nPfuahSQlvt2ickt4qRWStvsFNy/Lj6ikJz3U+R3Y3XO byVFJU3/N8Fg1CtQ7stB/c/q9CZCzduOu6ZTMCkwff7VzNgIW3gUMHZauTOUGixs6ln9 9l9leEae0DInM3V3C8bn7Zhws72q2qRXwa8NQgygq7rVfnRLVlsWg1veGlBNcoIfxIex +efw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kfhQSPA9; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n4sor244395lfl.57.2019.02.26.06.54.37 for (Google Transport Security); Tue, 26 Feb 2019 06:54:37 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kfhQSPA9; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org 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=CizRMe2YmHoMDQUcJ8913XbNFEFzGgJHDQtzao5WKiM=; b=kfhQSPA9AMik5mPi+zuWznWRU+Lb20kx5Yl1pd6vQyrPRfnG2ZYWVm4Hs9i5AjRK0b GnRrB3iYlXym2YsokbhWJCIunemOZzuO9vuqHFOLcbCrDm3wSn0ZApSiB3kPmMZT4ZVe dmDlZ3gGNBUQRE0rvOZn3OW2DWmlz6edcGX8vVCXxzAE2yqcdM3MZffJJb7PJBdYLj5l 5oQcGO+AlfUyq47Vsk9LJnj3r6W/fZpU73n4kFJDER7GNwbFFwflAQ8+q7a+UCe6ax7Z 8ZJPmf7ugZk/AuUGSuMdngYkcUPATcadWzlgy7bJo/HoChaXuWSMnkbwXRIT90W6tXrv Rugg== 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=CizRMe2YmHoMDQUcJ8913XbNFEFzGgJHDQtzao5WKiM=; b=KuF8UFMpndsmW/I+S7TYK+g+6IIoDNBeM1aRkodFJbLys40sVTeIgB/QQpdX7TYayz 7GE4b9leKjJTDeSvkeqaKbG6fFiYYuCzw8bgk6/rBs2enVEjLKdpg6n2iIggduyRo27G L7m/e3JxwhyXKWw2AfV5cOJVxufsnqSF4aNwkhtXOlIOz4E+xjCliHqpMpoPr3rAFhBI PtwYMdmXb01J2xpOX6ggLBry23Ue2JZXMedSm6kMdtX2wJAcDh/H62GrUpXPb3M+vuqq +EUMPwaQy1d1U4hK1zlEXkXtxbdxjpVjYQySZ0qnsHQwTl216ek3wAZT05KWAX/oOXxF EETg== X-Gm-Message-State: AHQUAuZp/F8ikxlzNWT1xYdILEXg4jzBPt/bu0zteVtstqpBmQCNjYGE 6mm5CCk/4+IjRbHLyCx6d9y59VkI X-Google-Smtp-Source: AHgI3Iaxn87jYxFUqbmB5XhLkCIJqJ/F1RTwFyjp9WrstSdbqh+lc5QmyHlpoFkyjdolp9R2+2X54Q== X-Received: by 2002:ac2:4154:: with SMTP id c20mr1623972lfi.74.1551192877411; Tue, 26 Feb 2019 06:54:37 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t11sm2206554ljj.92.2019.02.26.06.54.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 06:54:36 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Frederic Weisbecker , Thomas Gleixner , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 4/8] cpuidle: menu: Convert to tick_nohz_get_next_timer|hrtimer() Date: Tue, 26 Feb 2019 15:54:11 +0100 Message-Id: <20190226145415.19411-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190226145415.19411-1-ulf.hansson@linaro.org> References: <20190226145415.19411-1-ulf.hansson@linaro.org> From: Daniel Lezcano Rather than using tick_nohz_get_sleep_length(), let's convert to use the more flexible tick_nohz_get_next_timer|hrtimer() APIs. This should have no functional change, but allows following changes to later drop the tick_nohz_get_sleep_length() API. Signed-off-by: Daniel Lezcano [Ulf: Clarified information in changelog] Signed-off-by: Ulf Hansson --- Changes in v11: - New patch. --- drivers/cpuidle/governors/menu.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index 61316fc51548..95e9122d6047 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -286,14 +286,26 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, unsigned int predicted_us; unsigned long nr_iowaiters; ktime_t delta_next; + ktime_t now = ktime_get(); + ktime_t next_hrtimer = tick_nohz_get_next_hrtimer(); + ktime_t next_timer = tick_nohz_get_next_timer(); if (data->needs_update) { menu_update(drv, dev); data->needs_update = 0; } - /* determine the expected residency time, round up */ - data->next_timer_us = ktime_to_us(tick_nohz_get_sleep_length(&delta_next)); + /* + * Compute the duration before the next timer, whatever the origin + */ + delta_next = ktime_sub(next_timer, now); + data->next_timer_us = ktime_to_us(delta_next); + + /* + * Compute the duration before next hrtimer which is the tick + * or an earliest hrtimer + */ + delta_next = ktime_sub(next_hrtimer, now); nr_iowaiters = nr_iowait_cpu(dev->cpu); data->bucket = which_bucket(data->next_timer_us, nr_iowaiters);