From patchwork Thu Mar 30 21:01:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 96333 Delivered-To: patches@linaro.org Received: by 10.140.89.233 with SMTP id v96csp425871qgd; Thu, 30 Mar 2017 14:01:45 -0700 (PDT) X-Received: by 10.99.50.70 with SMTP id y67mr1096205pgy.109.1490907705841; Thu, 30 Mar 2017 14:01:45 -0700 (PDT) Return-Path: Received: from mail-pg0-x22b.google.com (mail-pg0-x22b.google.com. [2607:f8b0:400e:c05::22b]) by mx.google.com with ESMTPS id f70si2958269pfa.18.2017.03.30.14.01.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 14:01:45 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22b as permitted sender) client-ip=2607:f8b0:400e:c05::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22b as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22b.google.com with SMTP id 21so50290761pgg.1 for ; Thu, 30 Mar 2017 14:01:45 -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=JFz4S9Tk0ZYKF/pw2llgqF+rHMmar8hSLOpN7bi+tFY=; b=KTMQ0TQefFMGAkSffT2WUQFnayKWjFWoV/i4Npw0Ma3y9qmUWznLIPDhdhKMbpVGJW N0I1izDwVvlSmlY6uaWk0sK1zyloK4ifJU3mfeS6ot0mxbkxtxelcPzK3t7uUKsCS0O4 TyuG7kFMiVhh28yrNwWYLaE2GrzSyK6njLvo4= 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=JFz4S9Tk0ZYKF/pw2llgqF+rHMmar8hSLOpN7bi+tFY=; b=t2vQcu4RHQtktIzKY416sH2j0hmfslWAuFxXBBLjAzcibbeIrPFBiA9v+oWxEFzvfQ 1W7nfkBNNiS8fUBqstFbQGqCR0CBgc5G/EfLAKXQ44Z1vdvqRQxnzUpEQcidKavEXfTZ 56E2llz55YnjaC/eq+kTPnkTA873jWncckOVaP8NETdPUe/sXCCQS9h4pajBzBwvN8uP ZjjdsuX/XknRh+XwrkOcSIj07jtXve/Dp8OIL1+YDusVnlPvgpP3dZ2PUz/WI55oh/Xu X8Qq6mtb/E0DTITHgj8QNdwMvmmZQCRK8+wrY1Kcq3F1jLdtof12BC5a5M2dUFmYQXXk MjBw== X-Gm-Message-State: AFeK/H2CfLyTg4JRxfwSRE90vbkYOdVKS7e3lz0S0Q9FJEhrjlKxWynAR73uewoWvwb0alirmLc= X-Received: by 10.99.39.71 with SMTP id n68mr1137438pgn.85.1490907705576; Thu, 30 Mar 2017 14:01:45 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id y7sm6162626pfk.93.2017.03.30.14.01.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Mar 2017 14:01:44 -0700 (PDT) From: John Stultz To: lkml Cc: David Engraf , Ingo Molnar , Thomas Gleixner , Daniel Lezcano , Richard Cochran , Prarit Bhargava , Stephen Boyd , John Stultz Subject: [PATCH 8/9] timers, sched_clock: Update timeout for clock wrap Date: Thu, 30 Mar 2017 14:01:23 -0700 Message-Id: <1490907684-11186-9-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490907684-11186-1-git-send-email-john.stultz@linaro.org> References: <1490907684-11186-1-git-send-email-john.stultz@linaro.org> From: David Engraf The scheduler clock framework may not use the correct timeout for the clock wrap. This happens when a new clock driver calls sched_clock_register() after the kernel called sched_clock_postinit(). In this case the clock wrap timeout is too long thus sched_clock_poll() is called too late and the clock already wrapped. On my ARM system the scheduler was no longer scheduling any other task than the idle task because the sched_clock() wrapped. Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Richard Cochran Cc: Prarit Bhargava Cc: Stephen Boyd Signed-off-by: David Engraf Signed-off-by: John Stultz --- kernel/time/sched_clock.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index ea6b610..2d8f05a 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -206,6 +206,11 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) update_clock_read_data(&rd); + if (sched_clock_timer.function != NULL) { + /* update timeout for clock wrap */ + hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); + } + r = rate; if (r >= 4000000) { r /= 1000000;