Skip to contentSkip to conversation

time keeping add cycle_raw for actual incrementation

PATCH In review Steven Rostedt 1 participant 1 message Aug 24, 2007 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 time keeping add cycle_raw for actual incrementation

The get_monotonic_cycles needs to produce a monotonic counter as output. Currently it uses cycles_last as the base to add the delta too. cycles_last only is the counter that was last measured and is cyclic in nature (not monotonic).

This patch adds a cycle_raw to produce an accumulative counter. Unfortunately there is already an cycle_accumulate variable, but that is used to avoid clock source overflow and can also be decremented (probably that name should be changed and we should use that for this patch).

From: John Stultz <[email protected]>

include/linux/clocksource.h +2 -1
Index: linux-2.6-rt/include/linux/clocksource.h
===================================================================
@@ -77,7 +77,7 @@ struct clocksource {
 	void (*resume)(void);
 
 	/* timekeeping specific data, ignore */
-	cycle_t cycle_accumulated, cycle_interval;
+	cycle_t cycle_accumulated, cycle_interval, cycle_raw;
 	u64	xtime_interval;
 	/*
 	 * Second part is written at each timer interrupt
@@ -198,6 +198,7 @@ static inline void clocksource_accumulat
 	cycle_t offset = (now - cs->cycle_last) & cs->mask;
 	cs->cycle_last = now;
 	cs->cycle_accumulated += offset;
+	cs->cycle_raw += offset;
 }
 
 /**
kernel/time/timekeeping.c +1 -1
Index: linux-2.6-rt/kernel/time/timekeeping.c
===================================================================
@@ -75,7 +75,7 @@ cycle_t notrace get_monotonic_cycles(voi
 	/* calculate the delta since the last update_wall_time: */
 	cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
 
-	return clock->cycle_last + cycle_delta;
+	return clock->cycle_raw + cycle_delta;
 }
 
 unsigned long notrace cycles_to_usecs(cycle_t cycles)