From patchwork Thu Jun 1 03:07:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 100810 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp612348qge; Wed, 31 May 2017 20:08:02 -0700 (PDT) X-Received: by 10.99.101.135 with SMTP id z129mr35968946pgb.66.1496286481953; Wed, 31 May 2017 20:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496286481; cv=none; d=google.com; s=arc-20160816; b=hmrZSDnkKUbW92SQiDK0ZZWhFbYLwf2Sino8G/eEfhLwonDj5v+x5qC2akkdFJR+x/ o/Bbkecc6LVRt4nKvhz4utGNYmcPp84v1hQY04BTbZIAUWmGm6rtV+LLA8ek7h+4gCu/ txCP1nEgS1+DL+cI4dcfwqmravZJLo/+71uemxiainxeHDb1m3gtQkbgN6Dd7K+OBwCR EVESBP0m9cHulPuh/uvXgZfypmdkYDUxt8OVPvsmdqwjflEJETEjYszxBgkowFoW7z80 Rz11Ggu4rQ0rxnrPCvv56O0PDjy/yK+3dwAgVwRlZ06uLe2tFgSSqkJit59SbAnteJt3 vY9A== 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=Qat27Sgie6oK3/TlkLwpmsze5bNB9yU/n1A8SwSCGeg=; b=F78YVD6oJBMz17DURnx+Xsm/vVt6UjYvtj+HqdO0QuAsnZqpWN4isreea3lJzu74HG bntRI3QlKKjmdsfglHPGnasbNjEdY5wG7YVjXwKS+eT4znSgCKTNBaJUv0powWdTF7oo MSAuRC6TaXge556dWe+Q2O/Ot1r969nYX5bwGeEJiiu+JpKH403qw0CoZ8/indc4tvWV sSgCy4otmxzwcKLKSHsgl4Gj7+lL6KvOFd4voA9BL92djS1ohI6rOj3XgRwIf0maOAz6 MR2j9B0bCBPVco45Qd2HRSxW6Lw7d53LH87+x/0Ovc1/7oKMRMsfXs576qeN+sOEDvqC AIzA== 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::22f 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-x22f.google.com (mail-pf0-x22f.google.com. [2607:f8b0:400e:c00::22f]) by mx.google.com with ESMTPS id f7si18179072pfa.150.2017.05.31.20.08.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 May 2017 20:08:01 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22f as permitted sender) client-ip=2607:f8b0:400e:c00::22f; 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::22f 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-x22f.google.com with SMTP id m17so24584532pfg.3 for ; Wed, 31 May 2017 20:08:01 -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=Qat27Sgie6oK3/TlkLwpmsze5bNB9yU/n1A8SwSCGeg=; b=ADFEomAu3pIpiBZOVLuqcaILktUfNEe/YZtv5JHPBcY4dzmD3VVgwcalkesKpM1JNZ 7FzeBjvRlrtguOHnMi51bNxIf5vZxXBrT05UsmYMG/tv7PFilwLeTDcBm/Y5I3m3WKrP Is5eKdpDCp6y+NYq5nXO+5P+B42h520UcNqnQ= 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=Qat27Sgie6oK3/TlkLwpmsze5bNB9yU/n1A8SwSCGeg=; b=YBHviTE1jp7iKtVBhrE91HiHuMWJiXVtlv5yu69yecD/rKQ6vBpxRQ/fx2LvQAn1DX vbAtNYcw3lv+9ripkv2MVB4ENBFJRELBI2F8/qsLTvRGHdiNGDXYfgtNlZ3WHlGI/Q6b 3beodaIqMXfNUXFLM/lZvgtg4OQg4jpz82j2uozGLBfyMXgVlnYBKS3xjk4kzhrAhesn NNj7osOzvMLtMD9bPmHRHvlNNl9H55A4ugmnOjwYuGGoLBZ/PkZv8qt6cz6kllLJV5i9 5X9mHCwqVSh1GXDmYgfg+6Q5RGSSwMfn8EKyO3xK767xC/BzCAChzYLGKjBzhoiwYtQt lqfg== X-Gm-Message-State: AODbwcCVrC6kpThci2v2+FQT4hdaMaTX0t9g24SYcFWcln6GrQw/CQux 5H0zeAiTpiL1u9G4Z2Y= X-Received: by 10.98.138.150 with SMTP id o22mr33972619pfk.120.1496286481498; Wed, 31 May 2017 20:08:01 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id s68sm29137756pgc.5.2017.05.31.20.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 20:08:00 -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: [PATCH 0/3 v2] Fixes for two recently found timekeeping bugs Date: Wed, 31 May 2017 20:07:55 -0700 Message-Id: <1496286478-13584-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. As always feedback would be appreciated! thanks -john v2: * Addressed style/phrasing feedback from Ingo * Dropped the final cleanup patch, since it can wait for 4.13-rc Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Miroslav Lichvar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Stephen Boyd Cc: Daniel Mentz John Stultz (2): time: Fix clock->read(clock) race around clocksource changes time: Fix CLOCK_MONOTONIC_RAW sub-nanosecond accounting 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 | 4 +-- kernel/time/timekeeping.c | 59 +++++++++++++++++++++++------------ 4 files changed, 44 insertions(+), 25 deletions(-) -- 2.7.4