From patchwork Sat Jan 28 00:59:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 92742 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp498860qgi; Fri, 27 Jan 2017 16:59:39 -0800 (PST) X-Received: by 10.99.101.199 with SMTP id z190mr12096722pgb.219.1485565179337; Fri, 27 Jan 2017 16:59:39 -0800 (PST) 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 35si3144734pgx.238.2017.01.27.16.59.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2017 16:59:39 -0800 (PST) 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 204so85353673pge.0 for ; Fri, 27 Jan 2017 16:59:39 -0800 (PST) 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=wwu3mZYr/RVdPOpHEPwOoGrFvM/OfyLATa9ThbM1wzk=; b=ECjgoDPhkkSRosXn0TFzhuokgsMhOfJOz6zknFhPQmEkiqVejvOBqruUpJmWjpr73B J+3qdpOBnKpkip5r2Bf71MLbFGny8D38xXQwpFpbK7hhfYptxnRW0ipzLrczQxqDSIKQ 4SZQhcweF599HUExAtUufS9jBgR3SH0G3WgXc= 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=wwu3mZYr/RVdPOpHEPwOoGrFvM/OfyLATa9ThbM1wzk=; b=J9dwgzeoeS1DT1WIZzPPjIzlDcVuDDk2gbjob4PESlnqjcirZM5BPQDtKwZKJcqEOS +O7c96RHBpkM6mY6eAK/nTrMnO/S3Difb7Syyb57uMAda1sQGH9EObClFfQ+xNLcOri5 YAw6HPdGaudxPxRMnefENS9YbQRccB4U0n1NRfqJ8IUqjxIlhcpSghMLElzoAyZtHrTq J7VU1wd+tU18G0gQrsRABEqyrUDZIPYyxULSnWJmGyDo2gvzvFw7jLeiqXgVbC1HJT+Y fqa5FbwhcUsM6SXhsCo6FO5SvZppKhEvifNfFtJpyRHG9ClzMmLeIL4nPq8s/zeEwRDD 0Gbw== X-Gm-Message-State: AIkVDXLUPdbgpCR1TVGcHZT09D7L5SQymT1gpYVMBKPGV7woe36QlnP+t711lPrq18kC6WsU4k4= X-Received: by 10.98.133.11 with SMTP id u11mr12065168pfd.132.1485565179029; Fri, 27 Jan 2017 16:59:39 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l25sm14025441pfb.24.2017.01.27.16.59.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jan 2017 16:59:38 -0800 (PST) From: John Stultz To: lkml Cc: Russell King , David Riley , Thomas Gleixner , Richard Cochran , Prarit Bhargava , Ingo Molnar , John Stultz Subject: [PATCH 2/3] delay: Add explanation of udelay() inaccuracy Date: Fri, 27 Jan 2017 16:59:30 -0800 Message-Id: <1485565171-21223-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485565171-21223-1-git-send-email-john.stultz@linaro.org> References: <1485565171-21223-1-git-send-email-john.stultz@linaro.org> From: Russell King There seems to be some misunderstanding that udelay() and friends will always guarantee the specified delay. This is a false understanding. When udelay() is based on CPU cycles, it can return early for many reasons which are detailed by Linus' reply to me in a thread in 2011: http://lists.openwall.net/linux-kernel/2011/01/12/372 However, a udelay test module was created in 2014 which allows udelay() to only be 0.5% fast, which is outside of the CPU-cycles udelay() results I measured back in 2011, which were deemed to be in the "we don't care" region. test_udelay() should be fixed to reflect the real allowable tolerance on udelay(), rather than 0.5%. Cc: David Riley Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Cc: Ingo Molnar Signed-off-by: Russell King Signed-off-by: John Stultz --- include/linux/delay.h | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.7.4 diff --git a/include/linux/delay.h b/include/linux/delay.h index a6ecb34..2ecb3c4 100644 --- a/include/linux/delay.h +++ b/include/linux/delay.h @@ -5,6 +5,17 @@ * Copyright (C) 1993 Linus Torvalds * * Delay routines, using a pre-computed "loops_per_jiffy" value. + * + * Please note that ndelay(), udelay() and mdelay() may return early for + * several reasons: + * 1. computed loops_per_jiffy too low (due to the time taken to + * execute the timer interrupt.) + * 2. cache behaviour affecting the time it takes to execute the + * loop function. + * 3. CPU clock rate changes. + * + * Please see this thread: + * http://lists.openwall.net/linux-kernel/2011/01/09/56 */ #include