From patchwork Sat May 27 03:33:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 100587 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp536084qge; Fri, 26 May 2017 20:34:05 -0700 (PDT) X-Received: by 10.98.224.1 with SMTP id f1mr6044025pfh.116.1495856045460; Fri, 26 May 2017 20:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495856045; cv=none; d=google.com; s=arc-20160816; b=F6oskR2E2ckL9Qgy0R5VVdz1jkqTUPLrJ5FHxYlNO3lEHBLffSVuH0jLBMrC/467oW X/uRIoh3P/DSK9oIbfuHBcP0zi+0oG4AGNIk5EqkGXKp4WmB+QoxGhLgHY56VhCxRpGr yD5BbLSZdgPdbvDKqf/6M27NrGEVh56U3YDrjqJKKbMqg7vB78rDY6OoFEa24z2zbzKY tE2HPGlFMnC+1NKCDkHOhnsfhtlsysJdEMyr+HdkPanGQj4wq/WSlZ6UJy/Xqi1E95Fm Si4E/G+jZM8CxubTHtvEWcAXkkvb0aZ9LcjtCjr/lVBpGQsct9T7vMZusxCDXGepeSB+ +8hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PZLGpQT7alfMqARS4XWpF1YHIS0cr9Gi5YPB8QvjAr0=; b=vA5I3gquDvdG76mc0t/EzDa4AWh8L87F9wG2QYmy4xVLV7/OMUhFLCG7xpXHY7ZJAx hUbN6eBgH7v3UldD6HFZHlJgwJwGTp4k2V9xgZIn4h3fFO405qoNoxiNuqmVyWPW8nIM I8aaHB38K0wPE+dknBQHpKolcKFJrzAE/KeKaTaTWFe1PypSLlH9mZZfzMHJE2gKlzEJ 0woEwG8tJDuePxMvEbxy+fpK2B6XHqOGnstfID/kF01QOrC5WRasML9/jpPCCmq899Ff BY0Oo2JkSYyzoS3vFCj7qL8g4g8kgYe/7vn7Tya1xNMagbfiij4hjDtA5I+BBgDd24+d 5efg== 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::22d 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-x22d.google.com (mail-pf0-x22d.google.com. [2607:f8b0:400e:c00::22d]) by mx.google.com with ESMTPS id 59si33776019pld.76.2017.05.26.20.34.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 May 2017 20:34:05 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22d as permitted sender) client-ip=2607:f8b0:400e:c00::22d; 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::22d 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-x22d.google.com with SMTP id 9so25093983pfj.1 for ; Fri, 26 May 2017 20:34:05 -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:in-reply-to:references; bh=PZLGpQT7alfMqARS4XWpF1YHIS0cr9Gi5YPB8QvjAr0=; b=SFROtI5f6gT/IBcs1qD75L+DVM8XqW414egfZver05woXTV5lp1G6qk8SgIr3mmkRa t4HKAeKjnsEDM2KQ8cISRMBgGMIec74EVlEv/r4aeRgvdUDsHAXpSQGP0QdPG+3J+jXU mW+GebsfKwYA3p6OwKRnYJpW+C0vGAS4EAJSc= 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=PZLGpQT7alfMqARS4XWpF1YHIS0cr9Gi5YPB8QvjAr0=; b=aBDgaMzuuN4Ig6L6ILCcMOmrqzrKkv/K/pwT8cHAFNnpwIR7d3Xya7BmnTYTSjSRlE LVykZb0jD12mm7UIXYKA99r/LDlO+pS+qmkRNxjHNINZu637iFoDm6dQXbeUQ39wJE/e hpiDUr5kKoueXSG7WZX4dKbolSzbwxixlCPTmBxT1PolDPX68/Qt+rFX1YNnv9dY0M7E uAnU56enXKESK83PDNNRE9kS7lk+S9s2oYqp+m4x864PPn8p3AGBoVLZLlKhG3ppuWgo Ejo+7lbWFC2RMith+T23asqrNRxp+Tl3WvjFwlUwPWzdfVY0bqhOxKC8OrJqe102oMf5 /Qxg== X-Gm-Message-State: AODbwcAwlDQoeWDH22gvdkWXe8MzPxjFsep4cG22P3Y1Z3XkxGD6c2xH 6p7Zz8w3YfGTnrJ3kxA= X-Received: by 10.84.248.73 with SMTP id e9mr62455946pln.76.1495856045188; Fri, 26 May 2017 20:34:05 -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.34.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 May 2017 20:34:04 -0700 (PDT) From: John Stultz To: lkml Cc: Will Deacon , Thomas Gleixner , Ingo Molnar , Miroslav Lichvar , Richard Cochran , Prarit Bhargava , Stephen Boyd , Kevin Brodsky , Daniel Mentz , John Stultz Subject: [RFC][PATCH 3/4] arm64: vdso: Fix nsec handling for CLOCK_MONOTONIC_RAW Date: Fri, 26 May 2017 20:33:54 -0700 Message-Id: <1495856035-6622-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495856035-6622-1-git-send-email-john.stultz@linaro.org> References: <1495856035-6622-1-git-send-email-john.stultz@linaro.org> From: Will Deacon Commit 45a7905fc48f ("arm64: vdso: defer shifting of nanosecond component of timespec") fixed sub-ns inaccuracies in our vDSO clock_gettime implementation by deferring the right-shift of the nanoseconds components until after the timespec addition, which operates on left-shifted values. That worked nicely until support for CLOCK_MONOTONIC_RAW was added in 49eea433b326 ("arm64: Add support for CLOCK_MONOTONIC_RAW in clock_gettime() vDSO"). Noticing that the core timekeeping code never set tkr_raw.xtime_nsec, the vDSO implementation didn't bother exposing it via the data page and instead took the unshifted tk->raw_time.tv_nsec value which was then immediately shifted left in the vDSO code. Now that the core code is actually setting tkr_raw.xtime_nsec, we need to take that into account in the vDSO by adding it to the shifted raw_time value. Rather than do that at each use (and expand the data page in the process), instead perform the shift/addition operation when populating the data page and remove the shift from the vDSO code entirely. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Miroslav Lichvar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Stephen Boyd Cc: Kevin Brodsky Cc: Will Deacon Cc: Daniel Mentz Reported-by: John Stultz Acked-by: Acked-by: Kevin Brodsky Signed-off-by: Will Deacon [jstultz: minor whitespace tweak] Signed-off-by: John Stultz --- arch/arm64/kernel/vdso.c | 5 +++-- arch/arm64/kernel/vdso/gettimeofday.S | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 41b6e31..d0cb007 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -221,10 +221,11 @@ void update_vsyscall(struct timekeeper *tk) /* tkr_mono.cycle_last == tkr_raw.cycle_last */ vdso_data->cs_cycle_last = tk->tkr_mono.cycle_last; vdso_data->raw_time_sec = tk->raw_time.tv_sec; - vdso_data->raw_time_nsec = tk->raw_time.tv_nsec; + vdso_data->raw_time_nsec = (tk->raw_time.tv_nsec << + tk->tkr_raw.shift) + + tk->tkr_raw.xtime_nsec; vdso_data->xtime_clock_sec = tk->xtime_sec; vdso_data->xtime_clock_nsec = tk->tkr_mono.xtime_nsec; - /* tkr_raw.xtime_nsec == 0 */ vdso_data->cs_mono_mult = tk->tkr_mono.mult; vdso_data->cs_raw_mult = tk->tkr_raw.mult; /* tkr_mono.shift == tkr_raw.shift */ diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S index e00b467..76320e9 100644 --- a/arch/arm64/kernel/vdso/gettimeofday.S +++ b/arch/arm64/kernel/vdso/gettimeofday.S @@ -256,7 +256,6 @@ monotonic_raw: seqcnt_check fail=monotonic_raw /* All computations are done with left-shifted nsecs. */ - lsl x14, x14, x12 get_nsec_per_sec res=x9 lsl x9, x9, x12