From patchwork Tue May 23 00:58:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 100345 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp93864qge; Mon, 22 May 2017 17:58:45 -0700 (PDT) X-Received: by 10.84.228.207 with SMTP id y15mr32299710pli.172.1495501125122; Mon, 22 May 2017 17:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495501125; cv=none; d=google.com; s=arc-20160816; b=ye4H4yMbPyjlVBGbBoUaLphK/AhQmDbm6J/+d4oBZ5hy6knJTwn9qDE8tAz1Q49Eop nwcx7K/q/6OmLUP/rKF+8i2xWkIWR35GKReo/D9uuzvvfxHZE5S6XTQ0K+9zPwWjG76M zGk7Z07XgW+56NnwC+B56KKgANp0jxak+wFOedCE1YJ4DtUSS7Pde8U8DY9B1cc84hYg ZDwhW2o/syRW0Szb+VLsjKpP2hgkhvCihOEEDrRq/Pj0QLOrT4bdTnIWekspZvcQFd7w Jx58J+XLGOsWKQEd2SDJ1o3Vb769C4066dKrKRwFHCPkmSBwAks9mmH3nL0DhORjp3aK Vfzw== 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=f5h36Dvxjwq7VrdAweDbOVj2s4quyfGo2gjG+w5HQ2w=; b=IDDCrrMkJs13T1tnQdfq84nUX1K9wWqsWyZJHGFRPGxIEnOGzJo5/cSg/B2iyshSzt Q2hIS0/hCrUR71qBmiQYdwDIFq4k2zgHjxNxkNXG74XVQoO3m3bmKzk2Q/snw/jqp4v4 AD7TDJ4HVKUaOQSK1p2uaaqKmHmRCq3Tcrv5qUyishV1FijCOzBscjSP528/j34B8Z3M Ic+dY5oADT70+Com2JRnku4+H6YaJuLNHZoVbRxcmjyGgsw2rbYjm5/Nj4C58viv9O2P FEoxtOajwga01K75k/zXXh3eqj6QU7N2OCzOzGU+kg7pmx66Mq3YLzyHGJlLnsFW1hZY QmiQ== 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 x11si18857483pfk.187.2017.05.22.17.58.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 17:58:45 -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 9so97617033pfj.1 for ; Mon, 22 May 2017 17:58:44 -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=f5h36Dvxjwq7VrdAweDbOVj2s4quyfGo2gjG+w5HQ2w=; b=fjlc1KzmMhmMHmyBeyXqwtDjN9rHnve9TcJ2SsgIneHN5aNQSBRlBNQcZSzlKT4zR9 xqYoUAI/x7g6kDESyQXIA3oatxnwoab1vfEbXYzSYmeWhKC3sq1zVcZH7MSJVUEjLtak XHeKonkz+2g2+LnOQEtpzfDf1WDsrmHhUfJO4= 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=f5h36Dvxjwq7VrdAweDbOVj2s4quyfGo2gjG+w5HQ2w=; b=MbmTTXpJ3+DBm0b5WqMSfJ0dUaeia77mQ+G3FwBoZlKPA/RObYMe3nXHjpGkfNMZSn OQvup1beY/iYEpEqUjS6x6FqLblMFniXkvq3LOiZYOenQq12wSiZojeY0Jhr6mKkADqf ysBxt0oGazcoJi/Yx2h5lzVxOoD8HfnJePlFajhYStxfcy+H7EP6/xMXII3uaLzZvIFq /zYt6gb2A+7wJ4ZNpxVEiQ/0o2D85eKqjAAhHJnN7HiBJQvXZ92PGWMxH5pB65bBSKE+ J95Cvm2ZZz863+y7GcIAcoAheRXgHCT6R++JxmO2wifolUYmgGSnBidMLF93u9yZjEOa 35OQ== X-Gm-Message-State: AODbwcAf7Vs9xfMH86xCjhHtqQHsL/G9PSPgNmNvmv0t+DFfDpYJ4gOH SZt+NGfoTvZN51iOlFY= X-Received: by 10.98.80.152 with SMTP id g24mr27984661pfj.222.1495501124496; Mon, 22 May 2017 17:58:44 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id t17sm33543918pfj.61.2017.05.22.17.58.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 May 2017 17:58:43 -0700 (PDT) From: John Stultz To: Cc: John Stultz , Kevin Brodsky , Will Deacon Subject: [DRAFT v2][PATCH 1/2] time: Fix CLOCK_MONOTONIC_RAW sub-nanosecond accounting Date: Mon, 22 May 2017 17:58:28 -0700 Message-Id: <1495501109-32346-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 Due to how the MONOTONIC_RAW accumulation logic was handled, there is the potential for a 1ns discontinuity when we do accumulations. This small discontinuity has for the most part gone un-noticed, but since ARM64 enabled CLOCK_MONOTONIC_RAW in their vDSO clock_gettime implementation, we've seen failures with the inconsistency-check test in kselftest. This patch addresses the issue by using the same sub-ns accumulation handling that CLOCK_MONOTONIC uses, which avoids the issue for in-kernel users. Since the ARM64 vDSO implementation has its own clock_gettime calculation logic, this patch reduces the frequency of errors, but failures are still seen. The ARM64 vDSO will need to be updated to include the sub-nanosecond xtime_nsec values in its calculation for this issue to be completely fixed. NOTE: Ideally we'd have a fix for the ARM64 vDSO after this patch. Cc: Kevin Brodsky Cc: Will Deacon Signed-off-by: John Stultz --- include/linux/timekeeper_internal.h | 4 ++-- kernel/time/timekeeping.c | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h index 110f453..528cc86 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h @@ -58,7 +58,7 @@ struct tk_read_base { * interval. * @xtime_remainder: Shifted nano seconds left over when rounding * @cycle_interval - * @raw_interval: Raw nano seconds accumulated per NTP interval. + * @raw_interval: Shifted raw nano seconds accumulated per NTP interval. * @ntp_error: Difference between accumulated time and NTP time in ntp * shifted nano seconds. * @ntp_error_shift: Shift conversion between clock shifted nano seconds and @@ -100,7 +100,7 @@ struct timekeeper { u64 cycle_interval; u64 xtime_interval; s64 xtime_remainder; - u32 raw_interval; + u64 raw_interval; /* The ntp_tick_length() value currently being used. * This cached copy ensures we consistently apply the tick * length for an entire tick, as ntp_tick_length may change diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 501a173..75d1bf1 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -282,7 +282,7 @@ static void tk_setup_internals(struct timekeeper *tk, struct clocksource *clock) /* Go back from cycles -> shifted ns */ tk->xtime_interval = interval * clock->mult; tk->xtime_remainder = ntpinterval - tk->xtime_interval; - tk->raw_interval = (interval * clock->mult) >> clock->shift; + tk->raw_interval = interval * clock->mult; /* if changing clocks, convert xtime_nsec shift units */ if (old_clock) { @@ -1995,7 +1995,7 @@ static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset, u32 shift, unsigned int *clock_set) { u64 interval = tk->cycle_interval << shift; - u64 raw_nsecs; + u64 nsecps; /* If the offset is smaller than a shifted interval, do nothing */ if (offset < interval) @@ -2010,14 +2010,15 @@ static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset, *clock_set |= accumulate_nsecs_to_secs(tk); /* Accumulate raw time */ - raw_nsecs = (u64)tk->raw_interval << shift; - raw_nsecs += tk->raw_time.tv_nsec; - if (raw_nsecs >= NSEC_PER_SEC) { - u64 raw_secs = raw_nsecs; - raw_nsecs = do_div(raw_secs, NSEC_PER_SEC); - tk->raw_time.tv_sec += raw_secs; + tk->tkr_raw.xtime_nsec += (u64)tk->raw_time.tv_nsec << tk->tkr_raw.shift; + tk->tkr_raw.xtime_nsec += tk->raw_interval << shift; + nsecps = (u64)NSEC_PER_SEC << tk->tkr_raw.shift; + while (tk->tkr_raw.xtime_nsec >= nsecps) { + tk->tkr_raw.xtime_nsec -= nsecps; + tk->raw_time.tv_sec++; } - tk->raw_time.tv_nsec = raw_nsecs; + tk->raw_time.tv_nsec = tk->tkr_raw.xtime_nsec >> tk->tkr_raw.shift; + tk->tkr_raw.xtime_nsec -= (u64)tk->raw_time.tv_nsec << tk->tkr_raw.shift; /* Accumulate error between NTP and clock interval */ tk->ntp_error += tk->ntp_tick << shift; From patchwork Tue May 23 00:58:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 100346 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp93891qge; Mon, 22 May 2017 17:58:50 -0700 (PDT) X-Received: by 10.98.217.5 with SMTP id s5mr28228390pfg.42.1495501130179; Mon, 22 May 2017 17:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495501130; cv=none; d=google.com; s=arc-20160816; b=VPRMXf27NevIxf4TvS+kXbkyitTns+15UGX4Mrgsde8Ve51yUGU8nVZLF93/VYcOYa 4FSTlxBsv/z2Noyop/6FIWRoZg8+RZ5wXCQNxQTvEPF3/UYFgN/kriVL8JyHa/Hpjfe0 QbFptge1KCWiQIuLEaNHtMqZglPGXf7NkPZ/0GH+6QLfPcY4e/rzYMKrK57yZNhWahVp /o/YmoH+0U6VqbYxICAtq/XH3cVC7wvvsob2TiNLkO3XBs9nmm6sEDIFhDkQZV6cAqcn UyKbed2N9r+BWfrDpwNtTXRWO4Lu+tS+UpztmxaxOreqUmO/aoE4yrTF+ietMT3mIq/D AGJA== 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=v9ph2V73kEqdB3IjNr6TKRgRqh6CX9AFiTQz21YmkUI=; b=Cpmu/JlyDELIqoMgGc9RDqPdKLI+SgB3zPczR3mGPkQJPuwIybxP4gLIMSXylnu3P7 LJp5cjVDBetj1e5SoLnxiXLjPSpwnfl7yOP0GxKZv6k8vpyWsze1BxN+noKeiNfzX1X5 VHY18/VzKCalnml2PsWfGkV9r8R8LktTiH4OgfT0dFzph+KrTPd89L/ktDWDl1aKOIav vbYoFt34sBWYSfQVfvyoaEpLocKvC0dXMZb5XblwM5zTpwFqXGprCz+AznqIJjrD9/9N 33ZmMa1Uxmg8pzVHC+E9yej9h9wW7URVTFG7EOMv8Q/GGa+JF1uDh+1zJIs9PEgiUPvp SbsQ== 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 s2si19091930pgc.176.2017.05.22.17.58.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 17:58:50 -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 m17so97657215pfg.3 for ; Mon, 22 May 2017 17:58:50 -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=v9ph2V73kEqdB3IjNr6TKRgRqh6CX9AFiTQz21YmkUI=; b=jrMyUdc/53L6fFjVCxJPgDY61ZlqoxKOJ9t0dxujbpHKBpkLy4MYNndgHZe06Puxm/ h65SGoLV3Sep1S6jXV3rvB8z7CcehrCqptabJaT13EmGyWA1j9s+2RY+lg3LG9aH0bSx aaZfOLKDUDF5YGC3LGGzhhUOJEHbJQj9XmXBs= 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=v9ph2V73kEqdB3IjNr6TKRgRqh6CX9AFiTQz21YmkUI=; b=UZgv6gQsgXBV6qjXOd4k0QBkK/7PdVGR2Q/5jKRd5/tJJIKvYGDi743m4JH9RhklfI jkD6BwFkDabSrNLqkRsxfKXwXnPcv83uGqGEsmDe36o5F+7F1GrLP7T5+7m2OjNggiVJ kOzZz+COTbDXr7U646cgYOtKm1/sxsXdIGkJD8QMPkb8aoZ7oS3zuud7+HW7qSoA3pXF 1iZzhVxAWHB0FkGkornPw8K0Ac3Mscfn3VZ4lnh7ERP8AoKuOZWIu5jU/qeAKkE8HHII Ojsojcg91zvjxZjZLzllmTgn7BuO5cwsObOXuwS/aEhOpYKRyvslAfnLIKtEcmbyFAYw 7cBQ== X-Gm-Message-State: AODbwcDbQN0Tnt0NO0lUOx0xWkRSOYVj2KnCA6iTPpzqE5sVz3h8dw5J eykNnfGO8JDOBQ+VSc9UcNIg X-Received: by 10.99.113.11 with SMTP id m11mr28461421pgc.45.1495501129757; Mon, 22 May 2017 17:58:49 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id t17sm33543918pfj.61.2017.05.22.17.58.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 May 2017 17:58:48 -0700 (PDT) From: John Stultz To: Cc: John Stultz , Kevin Brodsky , Will Deacon Subject: [DRAFT v2][PATCH 2/2] time: Clean up CLOCK_MONOTONIC_RAW time handling Date: Mon, 22 May 2017 17:58:29 -0700 Message-Id: <1495501109-32346-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495501109-32346-1-git-send-email-john.stultz@linaro.org> References: <1495501109-32346-1-git-send-email-john.stultz@linaro.org> Now that we fixed the sub-ns handling for CLOCK_MONOTONIC_RAW, remove the duplicitive tk->raw_time.tv_nsec, which can be stored in tk->tkr_raw.xtime_nsec (similarly to how its handled for monotonic time). NOTE: Ideally we'd have a fix for the ARM64 vDSO inbetween the previous patch and this patch. Cc: Kevin Brodsky Cc: Will Deacon Signed-off-by: John Stultz --- arch/arm64/kernel/vdso.c | 6 +++--- include/linux/timekeeper_internal.h | 4 ++-- kernel/time/timekeeping.c | 37 ++++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 41b6e31..6150d67 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -220,11 +220,11 @@ void update_vsyscall(struct timekeeper *tk) if (!use_syscall) { /* 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; + /* XXX The asm needs to be updated before we make this change */ + vdso_data->raw_time_sec = tk->raw_sec; + vdso_data->raw_time_nsec = 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/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h index 528cc86..8abf6df 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h @@ -52,7 +52,7 @@ struct tk_read_base { * @clock_was_set_seq: The sequence number of clock was set events * @cs_was_changed_seq: The sequence number of clocksource change events * @next_leap_ktime: CLOCK_MONOTONIC time value of a pending leap-second - * @raw_time: Monotonic raw base time in timespec64 format + * @raw_sec: CLOCK_MONOTONIC_RAW time in seconds * @cycle_interval: Number of clock cycles in one NTP interval * @xtime_interval: Number of clock shifted nano seconds in one NTP * interval. @@ -94,7 +94,7 @@ struct timekeeper { unsigned int clock_was_set_seq; u8 cs_was_changed_seq; ktime_t next_leap_ktime; - struct timespec64 raw_time; + u64 raw_sec; /* The following members are for timekeeping internal use */ u64 cycle_interval; diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 75d1bf1..2291e92 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -72,6 +72,10 @@ static inline void tk_normalize_xtime(struct timekeeper *tk) tk->tkr_mono.xtime_nsec -= (u64)NSEC_PER_SEC << tk->tkr_mono.shift; tk->xtime_sec++; } + while (tk->tkr_raw.xtime_nsec >= ((u64)NSEC_PER_SEC << tk->tkr_raw.shift)) { + tk->tkr_raw.xtime_nsec -= (u64)NSEC_PER_SEC << tk->tkr_raw.shift; + tk->raw_sec++; + } } static inline struct timespec64 tk_xtime(struct timekeeper *tk) @@ -618,9 +622,6 @@ static inline void tk_update_ktime_data(struct timekeeper *tk) nsec = (u32) tk->wall_to_monotonic.tv_nsec; tk->tkr_mono.base = ns_to_ktime(seconds * NSEC_PER_SEC + nsec); - /* Update the monotonic raw base */ - tk->tkr_raw.base = timespec64_to_ktime(tk->raw_time); - /* * The sum of the nanoseconds portions of xtime and * wall_to_monotonic can be greater/equal one second. Take @@ -630,6 +631,11 @@ static inline void tk_update_ktime_data(struct timekeeper *tk) if (nsec >= NSEC_PER_SEC) seconds++; tk->ktime_sec = seconds; + + /* Update the monotonic raw base */ + seconds = tk->raw_sec; + nsec = (u32)(tk->tkr_raw.xtime_nsec >> tk->tkr_raw.shift); + tk->tkr_raw.base = ns_to_ktime(seconds * NSEC_PER_SEC + nsec); } /* must hold timekeeper_lock */ @@ -671,7 +677,6 @@ static void timekeeping_update(struct timekeeper *tk, unsigned int action) static void timekeeping_forward_now(struct timekeeper *tk) { u64 cycle_now, delta; - u64 nsec; cycle_now = tk_clock_read(&tk->tkr_mono); delta = clocksource_delta(cycle_now, tk->tkr_mono.cycle_last, tk->tkr_mono.mask); @@ -683,10 +688,13 @@ static void timekeeping_forward_now(struct timekeeper *tk) /* If arch requires, add in get_arch_timeoffset() */ tk->tkr_mono.xtime_nsec += (u64)arch_gettimeoffset() << tk->tkr_mono.shift; - tk_normalize_xtime(tk); - nsec = clocksource_cyc2ns(delta, tk->tkr_raw.mult, tk->tkr_raw.shift); - timespec64_add_ns(&tk->raw_time, nsec); + tk->tkr_raw.xtime_nsec += delta * tk->tkr_raw.mult; + + /* If arch requires, add in get_arch_timeoffset() */ + tk->tkr_raw.xtime_nsec += (u64)arch_gettimeoffset() << tk->tkr_raw.shift; + + tk_normalize_xtime(tk); } /** @@ -1372,19 +1380,18 @@ int timekeeping_notify(struct clocksource *clock) void getrawmonotonic64(struct timespec64 *ts) { struct timekeeper *tk = &tk_core.timekeeper; - struct timespec64 ts64; unsigned long seq; u64 nsecs; do { seq = read_seqcount_begin(&tk_core.seq); + ts->tv_sec = tk->raw_sec; nsecs = timekeeping_get_ns(&tk->tkr_raw); - ts64 = tk->raw_time; } while (read_seqcount_retry(&tk_core.seq, seq)); - timespec64_add_ns(&ts64, nsecs); - *ts = ts64; + ts->tv_nsec = 0; + timespec64_add_ns(ts, nsecs); } EXPORT_SYMBOL(getrawmonotonic64); @@ -1508,8 +1515,7 @@ void __init timekeeping_init(void) tk_setup_internals(tk, clock); tk_set_xtime(tk, &now); - tk->raw_time.tv_sec = 0; - tk->raw_time.tv_nsec = 0; + tk->raw_sec = 0; if (boot.tv_sec == 0 && boot.tv_nsec == 0) boot = tk_xtime(tk); @@ -2010,15 +2016,12 @@ static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset, *clock_set |= accumulate_nsecs_to_secs(tk); /* Accumulate raw time */ - tk->tkr_raw.xtime_nsec += (u64)tk->raw_time.tv_nsec << tk->tkr_raw.shift; tk->tkr_raw.xtime_nsec += tk->raw_interval << shift; nsecps = (u64)NSEC_PER_SEC << tk->tkr_raw.shift; while (tk->tkr_raw.xtime_nsec >= nsecps) { tk->tkr_raw.xtime_nsec -= nsecps; - tk->raw_time.tv_sec++; + tk->raw_sec++; } - tk->raw_time.tv_nsec = tk->tkr_raw.xtime_nsec >> tk->tkr_raw.shift; - tk->tkr_raw.xtime_nsec -= (u64)tk->raw_time.tv_nsec << tk->tkr_raw.shift; /* Accumulate error between NTP and clock interval */ tk->ntp_error += tk->ntp_tick << shift;