From patchwork Sat Sep 15 01:05:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11452 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id EE37E24049 for ; Sat, 15 Sep 2012 01:06:10 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 336D4A3C036 for ; Sat, 15 Sep 2012 01:06:10 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id j25so3708685iaf.11 for ; Fri, 14 Sep 2012 18:06:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references:x-cbid :x-gm-message-state; bh=ZPZvDM84wKDgehUo0CVGpPoJ9ukJsnpZUPqhmWlXQIo=; b=nTw9RH3iUdcT1UcpwQNuF5egwuC40Xpm1ZdALwaSbsZZq4rdPwWq7vjCX0B++JXkE5 sDlz28wHzBPFllskqXSVic5MDJ0EPdOkYevxQlXkIHR2FpdAVTcRlkYPBA9VmTWjHeGi Q8KFQDLMHec9/jXMlO4BA+Es+HwmDl1oabZO6gpFJnFieEmGLvbW3VNnFcSNUYd0p5Qw P7PJ02WdAASRfI+O6wnlggHRy4YipNK2mCrBGBydsvGourT8AMCrs8RaiMrO5dzg1Ldw Q1HUZjtzB1TT1yxBJe3XiItwAZCDXwBghOFYB/JHuw3Maj+25tHa1/km90lr8bgyHsKR Q6YQ== Received: by 10.50.207.106 with SMTP id lv10mr292281igc.0.1347671169819; Fri, 14 Sep 2012 18:06:09 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp221037igc; Fri, 14 Sep 2012 18:06:09 -0700 (PDT) Received: by 10.236.201.195 with SMTP id b43mr6204019yho.27.1347671169077; Fri, 14 Sep 2012 18:06:09 -0700 (PDT) Received: from e6.ny.us.ibm.com (e6.ny.us.ibm.com. [32.97.182.146]) by mx.google.com with ESMTPS id h6si3681817yhk.21.2012.09.14.18.06.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Sep 2012 18:06:09 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.182.146 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.182.146; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.182.146 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: from /spool/local by e6.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Sep 2012 21:06:08 -0400 Received: from d01relay05.pok.ibm.com (9.56.227.237) by e6.ny.us.ibm.com (192.168.1.106) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 14 Sep 2012 21:06:00 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8F15xNi158040; Fri, 14 Sep 2012 21:05:59 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8F15xF9009830; Fri, 14 Sep 2012 22:05:59 -0300 Received: from kernel-pok.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q8F15rLw008890; Fri, 14 Sep 2012 22:05:58 -0300 From: John Stultz To: linux-kernel@vger.kernel.org Cc: John Stultz , Catalin Marinas , Arnd Bergmann , Richard Cochran , Prarit Bhargava , Thomas Gleixner Subject: [PATCH 2/3] jiffies: Remove compile time assumptions about CLOCK_TICK_RATE Date: Fri, 14 Sep 2012 21:05:29 -0400 Message-Id: <1347671130-22095-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347671130-22095-1-git-send-email-john.stultz@linaro.org> References: <1347671130-22095-1-git-send-email-john.stultz@linaro.org> x-cbid: 12091501-1976-0000-0000-00001158F485 X-Gm-Message-State: ALoCoQnE/bIRG9f4k0QcFfkryRWvxQOcIjuwKz4S5jg1Omd5i/AO3Yr0UWI8i+ELT4jJTGP2uhVy CLOCK_TICK_RATE is used to accurately caclulate exactly how a tick will be at a given HZ. This is useful, because while we'd expect NSEC_PER_SEC/HZ, the underlying hardware will have some granularity limit, so we won't be able to have exactly HZ ticks per second. This slight error can cause timekeeping quality problems when using the jiffies or other jiffies driven clocksources. Thus we currently use compile time CLOCK_TICK_RATE value to generate SHIFTED_HZ and NSEC_PER_JIFFIES, which we then use to adjust the jiffies clocksource to correct this error. Unfortunately though, since CLOCK_TICK_RATE is a compile time value, and the jiffies clocksource is registered very early during boot, there are a number of cases where there are different possible hardware timers that have different tick rates. This causes problems in cases like ARM where there are numerous different types of hardware, each having their own compile-time CLOCK_TICK_RATE, making it hard to accurately support different hardware with a single kernel. For the most part, this doesn't matter all that much, as not too many systems actually utilize the jiffies or jiffies driven clocksource. Usually there are other highres clocksources who's granularity error is negligable. Even so, we have some complicated calcualtions that we do everywhere to handle these edge cases. This patch removes the compile time SHIFTED_HZ value, and introduces a register_refined_jiffies() function. This results in the default jiffies clock as being assumed a perfect HZ freq, and allows archtectures that care about jiffies accuracy to call register_refined_jiffies() with the tick rate, specified dynamically at boot. This allows us, where necessary, to not have a compile time CLOCK_TICK_RATE constant, simplifies the jiffies code, and still provides a way to have an accurate jiffies clock. NOTE: Since this patch does not add register_refinied_jiffies() calls for every arch, it may cause time quality regressions in some cases. Its likely these will not be noticable, but if they are an issue, adding the following to the end of setup_arch() should resolve the regression: register_refinied_jiffies(CLOCK_TICK_RATE) Cc: Catalin Marinas Cc: Arnd Bergmann Cc: Richard Cochran Cc: Prarit Bhargava Cc: Thomas Gleixner Signed-off-by: John Stultz --- arch/x86/kernel/setup.c | 3 +++ include/linux/jiffies.h | 15 ++------------- kernel/time/jiffies.c | 32 +++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f4b9b80..4062f15 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -68,6 +68,7 @@ #include #include #include +#include #include