From patchwork Fri Sep 27 10:52:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 20656 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 41F9425E77 for ; Fri, 27 Sep 2013 10:52:55 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id g17sf2164790vbg.2 for ; Fri, 27 Sep 2013 03:52:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=5HghOxmsgmN2zOLQN/LeKnT9OGoGLqZkiq3ja2nVgHc=; b=m1v8o6b5lTg5dPiWBzvd/DcnLpzK4QP/deXwGZ6Lis06mz9giIxp+Jxec6q0sK2apb 1zMHhxqzLaRWLH760ReCs/8Od6J8kbFX3y0j4WyDLqpk5pk96YYNuTt+3R4FUOVV3ZGA 3194xZG6PpWpjYz5ZVMur3M5irbzTpsFDPvpYBsOkEdu2TjA/oEi2jiEMNCU9LSIasjh JG+ZSFoJGrn7tL+j0VmTJOBEiZrsoJDvSj86ZmG1GYSZZCrR241y1w6nHy2zHmaHvmPx ZG6cgOL/ZzBT2smF3BazMJj8IU2l9ZHIlak6YbImQXQvjJ95qF/0plVWPRdFcUyds0/q 79CA== X-Gm-Message-State: ALoCoQlYomaBrBAS8fumF5rjciRZ7+SSwuP2T+lqPezDlm9tzFTTVoDX/rBanGiSB8G4og5do3mF X-Received: by 10.236.90.67 with SMTP id d43mr1043913yhf.36.1380279174635; Fri, 27 Sep 2013 03:52:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.144 with SMTP id u16ls1302802qef.84.gmail; Fri, 27 Sep 2013 03:52:54 -0700 (PDT) X-Received: by 10.220.174.200 with SMTP id u8mr5791348vcz.6.1380279174547; Fri, 27 Sep 2013 03:52:54 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id m10si1686584veh.6.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Sep 2013 03:52:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id oy12so1849080veb.41 for ; Fri, 27 Sep 2013 03:52:24 -0700 (PDT) X-Received: by 10.220.88.13 with SMTP id y13mr5857185vcl.20.1380279144232; Fri, 27 Sep 2013 03:52:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp420810vcz; Fri, 27 Sep 2013 03:52:23 -0700 (PDT) X-Received: by 10.194.93.105 with SMTP id ct9mr5289045wjb.6.1380279143198; Fri, 27 Sep 2013 03:52:23 -0700 (PDT) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by mx.google.com with ESMTPS id fr4si8003261wic.30.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Sep 2013 03:52:23 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.171 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.212.171; Received: by mail-wi0-f171.google.com with SMTP id hm2so614566wib.16 for ; Fri, 27 Sep 2013 03:52:22 -0700 (PDT) X-Received: by 10.180.20.13 with SMTP id j13mr2121017wie.6.1380279142767; Fri, 27 Sep 2013 03:52:22 -0700 (PDT) Received: from mai.home (AToulouse-654-1-326-179.w86-199.abo.wanadoo.fr. [86.199.213.179]) by mx.google.com with ESMTPSA id iz19sm12731611wic.9.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Sep 2013 03:52:22 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org Subject: [PATCH] tick: make sleep length calculation more accurate Date: Fri, 27 Sep 2013 12:52:20 +0200 Message-Id: <1380279140-27728-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The sleep_length is computed in the tick_nohz_stop_sched_tick function but it is used later in the code with in between the local irq enabled. cpu_idle_loop tick_nohz_idle_enter [ exits with local irq enabled ] __tick_nohz_idle_enter tick_nohz_stop_sched_tick ... arch_cpu_idle menu_select [ uses here 'sleep_length' ] ... Between the computation of the sleep length and its usage, some interrupts can occur, making the sleep length shorter than actually it is. This patch fixes that by moving the sleep_length computation in the tick_nohz_get_sleep_length function and store the next_event for the device instead of the sleep_length. Signed-off-by: Daniel Lezcano --- include/linux/tick.h | 2 +- kernel/time/tick-sched.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/tick.h b/include/linux/tick.h index 5128d33..4932004 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -67,7 +67,7 @@ struct tick_sched { ktime_t idle_exittime; ktime_t idle_sleeptime; ktime_t iowait_sleeptime; - ktime_t sleep_length; + ktime_t next_event; unsigned long last_jiffies; unsigned long next_jiffies; ktime_t idle_expires; diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 3612fc7..2007a7f 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -673,7 +673,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, out: ts->next_jiffies = next_jiffies; ts->last_jiffies = last_jiffies; - ts->sleep_length = ktime_sub(dev->next_event, now); + ts->next_event = dev->next_event; return ret; } @@ -837,8 +837,9 @@ void tick_nohz_irq_exit(void) ktime_t tick_nohz_get_sleep_length(void) { struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched); + ktime_t now = ktime_get(); - return ts->sleep_length; + return ktime_sub(ts->next_event, now); } static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)