From patchwork Sat May 27 03:33:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 100584 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp536069qge; Fri, 26 May 2017 20:34:00 -0700 (PDT) X-Received: by 10.98.23.74 with SMTP id 71mr6007116pfx.30.1495856040618; Fri, 26 May 2017 20:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495856040; cv=none; d=google.com; s=arc-20160816; b=JfYRzH+a293U0kXPErrX1RXX6Evkd2b60S/Oc1VpSbVfNvxmP64ZzxEqgouFJLjf6t Mq1fsf0uXUfC4k2rJKPmu+0pLBrGQE87YoPe+DpzCyzYzu/2qLbt0IHdhig3e9zZFQLn qrSDE2QnkUwUaUzP4/VbfVY1HuyZLIFGgDo5HdG9m1JB0XhmIWdjYG+a5G7xAFKPh5zk x66w/4TegkVkygDA06UXsO3/IdgHPsUaMqjo6xLxBfjXbyNjsEC0cQbV9x44BfiTIBcD g/HUcKvld86RQNZBDh4pOtrwB3lEeTvieRZ/E5jDNk8QCdxc5jmD4AkNImH+wYRgOdHU eWJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=XCc0Ho5zp5zD5Mx/vIOm/8QUN0YymOSMJR2iPprebRE=; b=Ufolc2XFlrbPFDPRANRL/uX5KdZc8I+8NTcZt/tMPDs+DGuohc4gnEAEjIS+R7xX6S 3MFIg3crKFTNqX3xikd5tFTDBpNpQrpsh5RscKphRzAdLmKp/T/ni2kj/dY9xTcH50Qs GoXTlfyplQ1PNwlxeGVxjPgcDOb9VyOwXvxkEQZjrfG+XbcbufwsP0wZanGhU0cGIU2I nl5J1j0Q0U+uT8ng66warRffEzG+RNdk+9guXg8Us9nmOnQ89wqWg8QTlA2RZsl6U7VP U6jT2zyMUdhzSDqPUUwgr5JgyUFSMk9kMCFXQNSX1Rwh2GStu6e3bpjmxLcawyxQzglK nIvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::233 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-pf0-x233.google.com (mail-pf0-x233.google.com. [2607:f8b0:400e:c00::233]) by mx.google.com with ESMTPS id z1si2929866pfg.120.2017.05.26.20.34.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 May 2017 20:34:00 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::233 as permitted sender) client-ip=2607:f8b0:400e:c00::233; 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:c00::233 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x233.google.com with SMTP id 9so25093369pfj.1 for ; Fri, 26 May 2017 20:34:00 -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; bh=XCc0Ho5zp5zD5Mx/vIOm/8QUN0YymOSMJR2iPprebRE=; b=grA8gnOwyP7Y/UuyXxo4DW//AK1bhdwc9P2bBZLFGqkgAygiw6R1/USo/oms7R8477 Fui6A9DLTUBMqCJzyrT4vYXB9SMDA5RmN+9WLYGdsWfABGCybkbQ2ycsWzMdVRbp1Pny /6lI2sRnXPaM+45DK4U5OxBek3/0Ae78BMz7E= 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; bh=XCc0Ho5zp5zD5Mx/vIOm/8QUN0YymOSMJR2iPprebRE=; b=ATQYJHwkx2ELTbkOgnCABktbfH8eaQG7rXE2f7VsQrYGGqY82O7qlfBflbAubZw5PI gHZ/o1eOKEw6x0WM8TJKLCogWP7FEajT+5vhLua8OoGjNOUQ3y80TmjSwBhClXoQhknY 1lNaKh6pmWr5CeIsg5yM+NIl/w5Id/RCSOfd+IdQiVLnKL52mT92Ytqqy2wRuCffAKhl A+MXErsPRfCrF0uHDsSH/XnrJJgv3D1bG6G7BSJf/0k3WUxeRlu05sa4J+eAjpzM+Xz2 plIrX84cCxcXSlBoQSOy3LsJOx6CCY76mEpCmJvsjAszwVj4Rj2XDKK9rO5YMy8HJvxQ 6cpA== X-Gm-Message-State: AODbwcBL62RImSvSKaeBTyVFGjrEBeNqaDskyJH86CGw2vMW1fvk33H6 BBdH7ZFmtU7I68uA86w= X-Received: by 10.84.217.218 with SMTP id d26mr63201893plj.47.1495856040244; Fri, 26 May 2017 20:34:00 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id d185sm3413255pgc.39.2017.05.26.20.33.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 May 2017 20:33:58 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Ingo Molnar , Miroslav Lichvar , Richard Cochran , Prarit Bhargava , Stephen Boyd , Daniel Mentz Subject: [RFC][PATCH 0/4] Fixes for two recently found timekeeping bugs Date: Fri, 26 May 2017 20:33:51 -0700 Message-Id: <1495856035-6622-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 As part of the Linaro Linux Kernel Functional Test (LKFT) effort, test failures from kselftest/timer's inconsistency-check were reported connected to CLOCK_MONOTONIC_RAW, on the HiKey platform. Digging in I found that an old issue with how sub-ns accounting is handled with the RAW time which was fixed long ago with the CLOCK_MONOTONIC/REALTIME ids, but missed with RAW time, was present. Additionally, running further tests, I uncovered an issue with how the clocksource read function is handled when clocksources are changed, which can cause crashes. Both of these issues have not been uncovered in x86 based testing due to x86 not using vDSO to accelerate CLOCK_MONOTONIC_RAW, combined with the HiKey's arch_timer clocksource being fast to access but incrementing slowly enough to get multiple reads using the same counter value (which helps uncover time handing issues), along with the fact that none of the x86 clocksources making use of the clocksource argument passed to the read function. This patchset addresses these two issues. Thanks so much to help from Will Deacon in getting the needed adjustments to the arm64 vDSO in place. Also thanks to Daniel Mentz who also properly diagnosed the MONOTONIC_RAW issue in parallel while I was woking on this patchset. I wanted to send these out for some initial review. I'm unfortunately still chasing a third issue (related to inconsistencies triggered during extreme freq adjustments) I've uncovered on HiKey, which doesn't seem to be related to the previous two. As always feedback would be appreciated! thanks -john Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Miroslav Lichvar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Stephen Boyd Cc: Daniel Mentz John Stultz (3): time: Fix clock->read(clock) race around clocksource changes time: Fix CLOCK_MONOTONIC_RAW sub-nanosecond accounting time: Clean up CLOCK_MONOTONIC_RAW time handling Will Deacon (1): arm64: vdso: Fix nsec handling for CLOCK_MONOTONIC_RAW arch/arm64/kernel/vdso.c | 5 +- arch/arm64/kernel/vdso/gettimeofday.S | 1 - include/linux/timekeeper_internal.h | 8 +-- kernel/time/timekeeping.c | 96 ++++++++++++++++++++++------------- 4 files changed, 66 insertions(+), 44 deletions(-) -- 2.7.4 Tested-by: Daniel Mentz