Skip to content

Commit

Permalink
[hrtimer] Change resolution storage to ktime_t format
Browse files Browse the repository at this point in the history
Change the storage format of the per base resolution to ktime_t to
make it easier accessible in the hrtimers code.

Change the resolution from (NSEC_PER_SEC/HZ) to TICK_NSEC as Roman
pointed out. TICK_NSEC is closer to the real resolution.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed Jan 12, 2006
1 parent 288867e commit e278763
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/linux/hrtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct hrtimer_base {
spinlock_t lock;
struct rb_root active;
struct rb_node *first;
unsigned long resolution;
ktime_t resolution;
ktime_t (*get_time)(void);
struct hrtimer *curr_timer;
};
Expand Down
4 changes: 2 additions & 2 deletions include/linux/ktime.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ static inline u64 ktime_to_ns(const ktime_t kt)
* idea of the (in)accuracy of timers. Timer values are rounded up to
* this resolution values.
*/
#define KTIME_REALTIME_RES (NSEC_PER_SEC/HZ)
#define KTIME_MONOTONIC_RES (NSEC_PER_SEC/HZ)
#define KTIME_REALTIME_RES (ktime_t){ .tv64 = TICK_NSEC }
#define KTIME_MONOTONIC_RES (ktime_t){ .tv64 = TICK_NSEC }

/* Get the monotonic time in timespec format: */
extern void ktime_get_ts(struct timespec *ts);
Expand Down
3 changes: 1 addition & 2 deletions kernel/hrtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,8 @@ int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
{
struct hrtimer_base *bases;

tp->tv_sec = 0;
bases = per_cpu(hrtimer_bases, raw_smp_processor_id());
tp->tv_nsec = bases[which_clock].resolution;
*tp = ktime_to_timespec(bases[which_clock].resolution);

return 0;
}
Expand Down

0 comments on commit e278763

Please sign in to comment.