From patchwork Fri Jul 27 18:48:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 10342 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 7EE0A23F08 for ; Fri, 27 Jul 2012 18:51:49 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 21154A19199 for ; Fri, 27 Jul 2012 18:51:49 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3541392yhp.11 for ; Fri, 27 Jul 2012 11:51:48 -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-content-scanned:x-cbid:x-gm-message-state; bh=7yMmmZxkI5D/XN/bsHKR2L9p0DqUmFC8S00uGMiG1GI=; b=clVTCJl0TpXvwib79/YUb6nP6+0D+pCyq5i1dWdM9X/78X4NKbSOCs6aQhx70VHmwW x6t8cV1QChvx2RRhaxIempAhekPvXyilwE7VknhPkO1zIvsPsTCMxGHsEBGUo39HNWya NtZiGKjkTKy2JtKykOtRjdt9C1ufCKnGaj5DpknUQDMPGat3BSqRtOQ/mwFrJHJqv8SI 1vQLmpchqqlm3jLsMT1fg+IcEnWwiRZpeu1JoVKkDYamQoekjOGn4CsjdXMuYHytyOZw hXD+ocdzsy7rw809b5bKxAmFudKV/So2d+bzQNwvzCYw9QtBviwfk8El5BaewaYeD7hZ ASag== Received: by 10.50.242.73 with SMTP id wo9mr3025612igc.1.1343415108452; Fri, 27 Jul 2012 11:51:48 -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.43.93.3 with SMTP id bs3csp46714icc; Fri, 27 Jul 2012 11:51:47 -0700 (PDT) Received: by 10.236.191.131 with SMTP id g3mr3267690yhn.59.1343415107627; Fri, 27 Jul 2012 11:51:47 -0700 (PDT) Received: from e2.ny.us.ibm.com (e2.ny.us.ibm.com. [32.97.182.142]) by mx.google.com with ESMTPS id h6si2859491yhk.34.2012.07.27.11.51.47 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 11:51:47 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.182.142 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.182.142; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.182.142 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 e2.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Jul 2012 14:48:37 -0400 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e2.ny.us.ibm.com (192.168.1.102) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 27 Jul 2012 14:48:36 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 1E19A38C804A; Fri, 27 Jul 2012 14:48:35 -0400 (EDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6RImVs354591618; Fri, 27 Jul 2012 14:48:31 -0400 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6RInZEr010716; Fri, 27 Jul 2012 12:49:35 -0600 Received: from kernel-pok.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6RInUqv010520; Fri, 27 Jul 2012 12:49:34 -0600 From: John Stultz To: lkml Cc: Catalin Marinas , Andrew Morton , Ingo Molnar , Richard Cochran , Prarit Bhargava , Thomas Gleixner , John Stultz Subject: [PATCH 1/5] jiffies: Allow CLOCK_TICK_RATE to be undefined Date: Fri, 27 Jul 2012 14:48:09 -0400 Message-Id: <1343414893-45779-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343414893-45779-1-git-send-email-john.stultz@linaro.org> References: <1343414893-45779-1-git-send-email-john.stultz@linaro.org> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12072718-5112-0000-0000-00000A76634F X-Gm-Message-State: ALoCoQn+Ak52Mr1mL+/WS/vPDhV7FPOZo6oE+5uvGoKNMEt8IqSD7xIvJD4A6u09EqNr3azqEqwL From: Catalin Marinas CLOCK_TICK_RATE is a legacy constant that defines the timer device's granularity. On hardware with particularly coarse granularity, this constant is used to reduce accumulated time error when using jiffies as a clocksource, by calculating the hardware's actual tick length rather then just assuming it is 1sec/HZ. However, for the most part this is unnecessary, as most modern systems don't use jiffies for their clocksource, and their tick device is sufficiently fine grained to avoid major error. Thus, this patch allows an architecture to not define CLOCK_TICK_RATE, in which case ACTHZ defaults to (HZ << 8). Signed-off-by: Catalin Marinas Acked-by: Arnd Bergmann Cc: Andrew Morton Cc: Ingo Molnar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Thomas Gleixner [jstultz: commit log & intention tweaks] Signed-off-by: John Stultz --- include/linux/jiffies.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 265e2c3..7d24466 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -39,9 +39,6 @@ # error Invalid value of HZ. #endif -/* LATCH is used in the interval timer and ftape setup. */ -#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ - /* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can * improve accuracy by shifting LSH bits, hence calculating: * (NOM << LSH) / DEN @@ -54,8 +51,15 @@ #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) +#ifdef CLOCK_TICK_RATE +/* LATCH is used in the interval timer and ftape setup. */ +# define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ + /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ -#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) +# define ACTHZ (SH_DIV(CLOCK_TICK_RATE, LATCH, 8)) +#else +# define ACTHZ (HZ << 8) +#endif /* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */ #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))