From patchwork Thu Jul 24 04:03:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 34189 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1EB632AFC1 for ; Thu, 24 Jul 2014 04:04:05 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hq11sf6680762vcb.7 for ; Wed, 23 Jul 2014 21:04:04 -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=LZQXMIc2SqtMtUem2Km7wiKT/kyt7yPdIl+wKRwM68I=; b=cUBPHPG0QQq6kPevdssp8Hk5KNy17mOGef8WpOnmLuJkUlulminLdIOloO14TihrBM cYZeCgi8st7vNZyZjyFRaHqn7c+CEB7xrMtPIxfqGq+eXW3L0ZOXpfJ0kAep7VF2Xc3m eDPlaGqoIVcRkmvRX0e8NqrGvv38VB33q6bfneBBCAG+U5j388bnktictoGyYeB2DLdq 2RDFMKLoXfgfFAimERGBiNKbtdQZBbw37wfC4YFqxxZVpuBthw93wUq4RUtPFL4jA/rX BiCZCXz76JtbtxNFsBgGkEQoJmytmZJ0+LIH1/of5AzHHWXu1lx8dgNckYq5HlROgYaC hmwQ== X-Gm-Message-State: ALoCoQnyk3+s53DejYYqh48ETL+U3v94aWhQMNsjZstJBFC0SldWf//aZfchUq71lwvPpWVWBFRm X-Received: by 10.224.2.193 with SMTP id 1mr2924917qak.9.1406174644849; Wed, 23 Jul 2014 21:04:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.228 with SMTP id j91ls662851qgf.31.gmail; Wed, 23 Jul 2014 21:04:04 -0700 (PDT) X-Received: by 10.52.190.196 with SMTP id gs4mr6856722vdc.50.1406174644760; Wed, 23 Jul 2014 21:04:04 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id cx1si4184761vec.38.2014.07.23.21.04.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 21:04:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hq11so4028335vcb.10 for ; Wed, 23 Jul 2014 21:04:04 -0700 (PDT) X-Received: by 10.52.99.106 with SMTP id ep10mr6553444vdb.73.1406174644668; Wed, 23 Jul 2014 21:04:04 -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.221.37.5 with SMTP id tc5csp332915vcb; Wed, 23 Jul 2014 21:04:04 -0700 (PDT) X-Received: by 10.66.221.66 with SMTP id qc2mr6987375pac.123.1406174643574; Wed, 23 Jul 2014 21:04:03 -0700 (PDT) Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by mx.google.com with ESMTPS id ks7si4543513pab.173.2014.07.23.21.04.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 21:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Received: by mail-pa0-f41.google.com with SMTP id rd3so3069418pab.0 for ; Wed, 23 Jul 2014 21:04:03 -0700 (PDT) X-Received: by 10.70.96.38 with SMTP id dp6mr7086266pdb.136.1406174643110; Wed, 23 Jul 2014 21:04:03 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id z4sm5418259pdb.18.2014.07.23.21.04.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Jul 2014 21:04:02 -0700 (PDT) From: John Stultz To: LKML Cc: Stephen Boyd , Thomas Gleixner , Ingo Molnar , stable , John Stultz Subject: [PATCH] sched_clock: Avoid corrupting hrtimer tree during suspend Date: Wed, 23 Jul 2014 21:03:50 -0700 Message-Id: <1406174630-23458-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) 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: , From: Stephen Boyd During suspend we call sched_clock_poll() to update the epoch and accumulated time and reprogram the sched_clock_timer to fire before the next wrap-around time. Unfortunately, sched_clock_poll() doesn't restart the timer, instead it relies on the hrtimer layer to do that and during suspend we aren't calling that function from the hrtimer layer. Instead, we're reprogramming the expires time while the hrtimer is enqueued, which can cause the hrtimer tree to be corrupted. Furthermore, we restart the timer during suspend but we update the epoch during resume which seems counter-intuitive. Let's fix this by saving the accumulated state and canceling the timer during suspend. On resume we can update the epoch and restart the timer similar to what we would do if we were starting the clock for the first time. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: stable Fixes: a08ca5d1089d "sched_clock: Use an hrtimer instead of timer" Signed-off-by: Stephen Boyd Signed-off-by: John Stultz --- Ingo/Thomas: Here's a fix for tip/timers/urgent for 3.16 and -stable. Let me know if you have any objections. thanks -john kernel/time/sched_clock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 445106d..01d2d15 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -191,7 +191,8 @@ void __init sched_clock_postinit(void) static int sched_clock_suspend(void) { - sched_clock_poll(&sched_clock_timer); + update_sched_clock(); + hrtimer_cancel(&sched_clock_timer); cd.suspended = true; return 0; } @@ -199,6 +200,7 @@ static int sched_clock_suspend(void) static void sched_clock_resume(void) { cd.epoch_cyc = read_sched_clock(); + hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); cd.suspended = false; }