Skip to content

Commit

Permalink
hrtimer: Make hrtimer_forward() private to core timer code
Browse files Browse the repository at this point in the history
hrtimer_forward() invites to be used in the wrong way and there is no real
requirement to have it outside of the timers core code.

All users outside of the timer core code have been converted to
hrtimer_forward_now() which provides all what the non-core code usage
needs.

Export hrtimer_forward_now() instead and move the prototype to a timer core
header.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed Sep 20, 2021
1 parent fc66ea9 commit 9ad8708
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
26 changes: 1 addition & 25 deletions include/linux/hrtimer.h
Expand Up @@ -480,31 +480,7 @@ static inline int hrtimer_callback_running(struct hrtimer *timer)
return timer->base->running == timer;
}

/* Forward a hrtimer so it expires after now: */
extern u64
hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);

/**
* hrtimer_forward_now - forward the timer expiry so it expires after now
* @timer: hrtimer to forward
* @interval: the interval to forward
*
* Forward the timer expiry so it will expire after the current time
* of the hrtimer clock base. Returns the number of overruns.
*
* Can be safely called from the callback function of @timer. If
* called from other contexts @timer must neither be enqueued nor
* running the callback and the caller needs to take care of
* serialization.
*
* Note: This only updates the timer expiry value and does not requeue
* the timer.
*/
static inline u64 hrtimer_forward_now(struct hrtimer *timer,
ktime_t interval)
{
return hrtimer_forward(timer, timer->base->get_time(), interval);
}
extern u64 hrtimer_forward_now(struct hrtimer *timer, ktime_t interval);

/* Precise sleep: */

Expand Down
23 changes: 22 additions & 1 deletion kernel/time/hrtimer.c
Expand Up @@ -1067,7 +1067,28 @@ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)

return orun;
}
EXPORT_SYMBOL_GPL(hrtimer_forward);

/**
* hrtimer_forward_now - forward the timer expiry so it expires after now
* @timer: hrtimer to forward
* @interval: the interval to forward
*
* Forward the timer expiry so it will expire after the current time
* of the hrtimer clock base. Returns the number of overruns.
*
* Can be safely called from the callback function of @timer. If
* called from other contexts @timer must neither be enqueued nor
* running the callback and the caller needs to take care of
* serialization.
*
* Note: This only updates the timer expiry value and does not requeue
* the timer.
*/
extern u64 hrtimer_forward_now(struct hrtimer *timer, ktime_t interval)
{
return hrtimer_forward(timer, timer->base->get_time(), interval);
}
EXPORT_SYMBOL_GPL(hrtimer_forward_now);

/*
* enqueue_hrtimer - internal function to (re)start a timer
Expand Down
1 change: 1 addition & 0 deletions kernel/time/posix-timers.c
Expand Up @@ -33,6 +33,7 @@
#include <linux/time_namespace.h>

#include "timekeeping.h"
#include "tick-internal.h"
#include "posix-timers.h"

/*
Expand Down
1 change: 1 addition & 0 deletions kernel/time/tick-internal.h
Expand Up @@ -177,6 +177,7 @@ void clock_was_set(unsigned int bases);
void clock_was_set_delayed(void);

void hrtimers_resume_local(void);
u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);

/* Since jiffies uses a simple TICK_NSEC multiplier
* conversion, the .shift value could be zero. However
Expand Down

0 comments on commit 9ad8708

Please sign in to comment.