Skip to content

Commit 66f7b0c

Browse files
committed
timerfd: Provide timerfd_resume()
Resuming timekeeping is a clock-was-set event and uses the clock-was-set notification mechanism. This is in the way of making the clock-was-set update for hrtimers selective so unnecessary IPIs are avoided when a CPU base does not have timers queued which are affected by the clock setting. Provide a seperate timerfd_resume() interface so the resume logic and the clock-was-set mechanism can be distangled in the core code. Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e71a415 commit 66f7b0c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

fs/timerfd.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,22 @@ void timerfd_clock_was_set(void)
115115
rcu_read_unlock();
116116
}
117117

118+
static void timerfd_resume_work(struct work_struct *work)
119+
{
120+
timerfd_clock_was_set();
121+
}
122+
123+
static DECLARE_WORK(timerfd_work, timerfd_resume_work);
124+
125+
/*
126+
* Invoked from timekeeping_resume(). Defer the actual update to work so
127+
* timerfd_clock_was_set() runs in task context.
128+
*/
129+
void timerfd_resume(void)
130+
{
131+
schedule_work(&timerfd_work);
132+
}
133+
118134
static void __timerfd_remove_cancel(struct timerfd_ctx *ctx)
119135
{
120136
if (ctx->might_cancel) {

include/linux/hrtimer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,10 @@ hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
349349

350350
#ifdef CONFIG_TIMERFD
351351
extern void timerfd_clock_was_set(void);
352+
extern void timerfd_resume(void);
352353
#else
353354
static inline void timerfd_clock_was_set(void) { }
355+
static inline void timerfd_resume(void) { }
354356
#endif
355357
extern void hrtimers_resume(void);
356358

0 commit comments

Comments
 (0)