Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1269187

[PATCH 1/4] ktime: add a roundup function

From Jacob Pan <jacob.jun.pan@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH 1/4] ktime: add a roundup function
Date 2015-11-13 21:00 +0100
Message-ID <qusFQ-2eI-29@gated-at.bofh.it> (permalink)
References <qusFP-2eI-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


ktime roundup function can be used to keep timer aligned and
prevent drift for recurring timeouts.

Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
---
 include/linux/ktime.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 2b6a204..2e293fa 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -233,6 +233,16 @@ static inline ktime_t ktime_sub_us(const ktime_t kt, const u64 usec)
 
 extern ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs);
 
+static inline ktime_t ktime_roundup(ktime_t x, ktime_t y)
+{
+	u64 temp_tv64;
+
+	temp_tv64 = x.tv64 + y.tv64 - 1;
+	temp_tv64 = div64_u64(temp_tv64, y.tv64);
+	x.tv64 = temp_tv64 * y.tv64;
+
+	return x;
+}
 /**
  * ktime_to_timespec_cond - convert a ktime_t variable to timespec
  *			    format only if the variable contains data
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] CFS idle injection Jacob Pan <jacob.jun.pan@linux.intel.com> - 2015-11-13 21:00 +0100
  [PATCH 1/4] ktime: add a roundup function Jacob Pan <jacob.jun.pan@linux.intel.com> - 2015-11-13 21:00 +0100
    Re: [PATCH 1/4] ktime: add a roundup function John Stultz <john.stultz@linaro.org> - 2015-11-13 21:20 +0100
      Re: [PATCH 1/4] ktime: add a roundup function Jacob Pan <jacob.jun.pan@linux.intel.com> - 2015-11-13 23:40 +0100
    Re: [PATCH 1/4] ktime: add a roundup function Thomas Gleixner <tglx@linutronix.de> - 2015-11-13 21:20 +0100
      Re: [PATCH 1/4] ktime: add a roundup function Jacob Pan <jacob.jun.pan@linux.intel.com> - 2015-11-13 23:40 +0100

csiph-web