[Devel] [PATCH 1/5] make steal time's to-tick routine generic

Glauber Costa glommer at parallels.com
Thu Feb 2 06:19:28 PST 2012


In this patchset, I am exposing other data as ticks as well,
that are originally nanoseconds. Whether or not I should do it,
it is open for debate, and I am happy to drop this patch if we
decide not to. But right now this exists to support the
further patch that uses it.

Signed-off-by: Glauber Costa <glommer at parallels.com>
---
 kernel/sched/core.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b9be4ba..455810f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -850,13 +850,18 @@ EXPORT_SYMBOL_GPL(account_system_vtime);
 
 #endif /* CONFIG_IRQ_TIME_ACCOUNTING */
 
+static inline u64 nsec_to_tick(u64 nsec)
+{
+	if (unlikely(nsec > NSEC_PER_SEC))
+		return div_u64(nsec, TICK_NSEC);
+
+	return __iter_div_u64_rem(nsec, TICK_NSEC, &nsec);
+}
+
 #ifdef CONFIG_PARAVIRT
 static inline u64 steal_ticks(u64 steal)
 {
-	if (unlikely(steal > NSEC_PER_SEC))
-		return div_u64(steal, TICK_NSEC);
-
-	return __iter_div_u64_rem(steal, TICK_NSEC, &steal);
+	return nsec_to_tick(steal);
 }
 #endif
 
-- 
1.7.7.4




More information about the Devel mailing list