From patchwork Sun Aug 12 16:09:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 143995 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2183770ljj; Sun, 12 Aug 2018 09:10:05 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz+mTSUz3c8nCdW6BRFB6AwpVgBb2iTDEDriddj1hmMp9pNbOUcpDTw1rXeJ0bZBuakLKbJ X-Received: by 2002:a17:902:4124:: with SMTP id e33-v6mr13501648pld.48.1534090205329; Sun, 12 Aug 2018 09:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534090205; cv=none; d=google.com; s=arc-20160816; b=aMP2AqmDLCOdu1wzYp7kky9kQTeJuSc2A1iQJK4xuL7wUmVKZ2PgwBO328yOYadV3p CHI3SymUIKk8CQTlQ2nEMISvFNNVCYcvpFz31+9Eyw5AAFSKe5AQXzoeXv8FjM9l+tlg JkbHu0ZklEor526x3m7gzT6x6CLLCOrdI3IOcfyUKibYcGPtY5kZmPuk/REB6YjzDdUL PcLvsXVtMCYz2MBLeBsg1x5mioZRERu5TyXkdzj/8r9cnjLKSgiiuO3th9f9UsRQAtAM rVH71SLPEocMOrgItaMSwniG3iwoQ3yCyCHWS+WW5Vg9fFtHWdNTN2VSLNTl9ViTFEKS E+Wg== 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 x33-v6si12325234plb.160.2018.08.12.09.10.05; Sun, 12 Aug 2018 09:10:05 -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 S1728291AbeHLSsb (ORCPT + 31 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(-) -- 2.7.4 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; } }