Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2220968imm; Sun, 12 Aug 2018 09:11:48 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzS1FIznmrsks6hq2gtk5gdPAb+1LqOqkQTz/L9L8GyITgltgmXQxEX1QNkwuQ57KYemWML X-Received: by 2002:a63:4811:: with SMTP id v17-v6mr13582537pga.379.1534090308024; Sun, 12 Aug 2018 09:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534090307; cv=none; d=google.com; s=arc-20160816; b=Mq8hnffZ6SapiMM6qvhLap0k7gflN+Ye8xT3sVmVCN6zC61RI5O0rLBisiblYngEl+ RIDDZGKUPNSUo2qZFGzEGRL0ibG3pOkeB/drK4rmu6wsfW6OaOkyRjgNr3o5M7FM8hOH eEuXWX1ZvmTaXc8C+EehjnHAw1dsAGRDMWncolhkZPUTBICZ7+vUuLXdUlotqhmftJSO xQZMkyNtyk2nX3cEDwv72Jt2S34awnxXMqRQrhhIakQUUUQPnNBGMHdYq0LQhE86Gpnr hqtXYeA00WD/OFLZwbbVXOwqyTTKoiUAV2O+Iqbwi+P03750aY83YSURrUlRFhtKkYWc DOhg== 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=V18Yg/vtevZ0nWVd2TxyiDMrqJoQAluOHbayWFvQXps=; b=GQ5nAYIF3qJ8cTWRKVsjcUAl2ZXxPjbwz4r7meDZnebeQqwivGn6esCzblhrt4zxOU 9T2Y+Aq5zx55V5acWmsBPYSehKE+lSCob8v7MwB76G5lNfDhd4D1JysSIwZjDOa7usxS gJiTbzh4vWW/3rdkHZ21TqiZXWYj5cXXR/gORTUnfvQxk3FQwflp71rfuQMHwmPjF+Gb WrlHXhKN7RbogL8Z6H5IK4dJZUZPYcYI8eYiqpNE6XR7KodTZjuHxAfZ6wtXBEhSWZbh eL9B9YByPSwMgB26uzJJKo7LJm050W+HuJ1AK9fyPzmM/1usn3PAFAWcrnKpAyQKw4eb NeYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OSxffkp8; 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 x1-v6si13722071pge.521.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=OSxffkp8; 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 S1728279AbeHLSsb (ORCPT + 99 others); Sun, 12 Aug 2018 14:48:31 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41839 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727564AbeHLSsb (ORCPT ); Sun, 12 Aug 2018 14:48:31 -0400 Received: by mail-wr1-f65.google.com with SMTP id j5-v6so12208866wrr.8 for ; Sun, 12 Aug 2018 09:10:00 -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=V18Yg/vtevZ0nWVd2TxyiDMrqJoQAluOHbayWFvQXps=; b=OSxffkp8NwJyPYpiwF1fIiewerSpTUDVO903chrUq34Ei11KpkKTlPdZubWBo51/Q7 GbrHWJSKaJBzEnXyCV+jI7+Nrezo1178q/h9F6MM14Cop3As8v5NX8aezc3DOGnsm8xo xrYwzUbUVOBGD9k9dvoB0LKsbG5Sxb1gTh22o= 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=V18Yg/vtevZ0nWVd2TxyiDMrqJoQAluOHbayWFvQXps=; b=DsYrSHTohqjLpdk7NqHoNzKCbf2uf+PDc9QtmLLI/lr/DIZFbSlBblLXojUvDW1LW9 kJ3xanrzLaj/VzlkorqPRChEXb14LMU4Y+rGYwtLLS0BESagB6XBh0GI6Ov6/t8hXczW 3Y7b6VOozS+anF2ANuU1vUwWEqIHCVTgc56XD2UrawZqv2u/lsD+DeRHCxXuv+UdF5Lk 81oYFr4+5Lx6HAKODsiYcpfiXmW0liEIpPfqPPE9HtJdrkK1/FL9wfZNSN97xzM60yez Emp4Va4DhMnteGMVeoD7TJWk7s4bC1vGV0/6Ypne+HhfkfAEMPKEDlPvhuHGTg09iCE6 4gbA== X-Gm-Message-State: AOUpUlEZKQaJ03wPZSwYZKJ2MstjU+lex8HDElVwZXU3L3yIgUdLeIjM jyUnaWB+Mr16VqJuqS+DpbUJWA== X-Received: by 2002:a5d:458b:: with SMTP id p11-v6mr8555372wrq.122.1534090199872; Sun, 12 Aug 2018 09:09:59 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Aug 2018 09:09:58 -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 2/5] cpuidle: menu: Record tick delta value in struct menu_device Date: Mon, 13 Aug 2018 00:09:28 +0800 Message-Id: <1534090171-14464-3-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 Since the tick delta is used in multiple places in menu_select(), it's better to use single one variable to record this value; furthermore, for more readable we can refactor the code to split a separate function to making decision for stopping tick, which also needs to use tick delta value as one metric for consideration. To achieve these purposes, this patch adds a new item 'tick_delta_us' in struct menu_device to record tick delta value. This patch also is a preparation for optimization stopping tick in sequential patches. Signed-off-by: Leo Yan --- drivers/cpuidle/governors/menu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index b972db1..83618ab 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -124,6 +124,7 @@ struct menu_device { int tick_wakeup; unsigned int next_timer_us; + unsigned int tick_delta_us; unsigned int predicted_us; unsigned int bucket; unsigned int correction_factor[BUCKETS]; @@ -305,6 +306,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, /* determine the expected residency time, round up */ data->next_timer_us = ktime_to_us(tick_nohz_get_sleep_length(&delta_next)); + data->tick_delta_us = ktime_to_us(delta_next); get_iowait_load(&nr_iowaiters, &cpu_load); data->bucket = which_bucket(data->next_timer_us, nr_iowaiters); @@ -317,7 +319,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, * timer event for the idle state selection. */ if (tick_nohz_tick_stopped()) { - data->predicted_us = ktime_to_us(delta_next); + data->predicted_us = data->tick_delta_us; goto select; } @@ -400,11 +402,11 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, */ if (((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) || data->predicted_us < TICK_USEC) && !tick_nohz_tick_stopped()) { - unsigned int delta_next_us = ktime_to_us(delta_next); *stop_tick = false; - if (idx > 0 && drv->states[idx].target_residency > delta_next_us) { + if (idx > 0 && + drv->states[idx].target_residency > data->tick_delta_us) { /* * The tick is not going to be stopped and the target * residency of the state to be returned is not within @@ -417,7 +419,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, continue; idx = i; - if (drv->states[i].target_residency <= delta_next_us) + if (drv->states[i].target_residency <= + data->tick_delta_us) break; } } -- 2.7.4