From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965689AbbJ0Rpj (ORCPT ); Tue, 27 Oct 2015 13:45:39 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:36634 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965502AbbJ0RdO (ORCPT ); Tue, 27 Oct 2015 13:33:14 -0400 From: =?UTF-8?q?B=C3=A1lint=20Czobor?= To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Minsung Kim , =?UTF-8?q?B=C3=A1lint=20Czobor?= Subject: [PATCH 49/70] cpufreq: interactive: avoid underflow on active time calculation Date: Tue, 27 Oct 2015 18:30:37 +0100 Message-Id: <1445967059-6897-49-git-send-email-czoborbalint@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1445967059-6897-1-git-send-email-czoborbalint@gmail.com> References: <1445967059-6897-1-git-send-email-czoborbalint@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Minsung Kim Check for idle time delta less than elapsed time delta, avoid underflow computing active time. Change-Id: I3e4c6ef1ad794eec49ed379c0c50fa727fd6ad28 Signed-off-by: Minsung Kim Signed-off-by: Bálint Czobor --- drivers/cpufreq/cpufreq_interactive.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index b4d12b2..7303f50 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -325,7 +325,12 @@ static u64 update_load(int cpu) now_idle = get_cpu_idle_time(cpu, &now); delta_idle = (unsigned int)(now_idle - pcpu->time_in_idle); delta_time = (unsigned int)(now - pcpu->time_in_idle_timestamp); - active_time = delta_time - delta_idle; + + if (delta_time <= delta_idle) + active_time = 0; + else + active_time = delta_time - delta_idle; + pcpu->cputime_speedadj += active_time * pcpu->policy->cur; pcpu->time_in_idle = now_idle; -- 1.7.9.5