Skip to content

Commit fbf920f

Browse files
covanamKAGA-KOKO
authored andcommitted
hrtimers: Add missing hrtimer_init() trace points
hrtimer_init*_on_stack() is not covered by tracing when CONFIG_DEBUG_OBJECTS_TIMERS=y. Rework the functions similar to hrtimer_init() and hrtimer_init_sleeper() so that the hrtimer_init() tracepoint is unconditionally available. The rework makes hrtimer_init_sleeper() unused. Delete it. Signed-off-by: Nam Cao <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/74528e8abf2bb96e8bee85ffacbf14e15cf89f0d.1730386209.git.namcao@linutronix.de
1 parent 2634303 commit fbf920f

File tree

2 files changed

+37
-47
lines changed

2 files changed

+37
-47
lines changed

include/linux/hrtimer.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,32 +228,15 @@ static inline void hrtimer_cancel_wait_running(struct hrtimer *timer)
228228
/* Initialize timers: */
229229
extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
230230
enum hrtimer_mode mode);
231-
extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clock_id,
232-
enum hrtimer_mode mode);
233-
234-
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
235231
extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
236232
enum hrtimer_mode mode);
237233
extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
238234
clockid_t clock_id,
239235
enum hrtimer_mode mode);
240236

237+
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
241238
extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
242239
#else
243-
static inline void hrtimer_init_on_stack(struct hrtimer *timer,
244-
clockid_t which_clock,
245-
enum hrtimer_mode mode)
246-
{
247-
hrtimer_init(timer, which_clock, mode);
248-
}
249-
250-
static inline void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
251-
clockid_t clock_id,
252-
enum hrtimer_mode mode)
253-
{
254-
hrtimer_init_sleeper(sl, clock_id, mode);
255-
}
256-
257240
static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
258241
#endif
259242

kernel/time/hrtimer.c

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,11 @@ static inline void debug_hrtimer_init(struct hrtimer *timer)
417417
debug_object_init(timer, &hrtimer_debug_descr);
418418
}
419419

420+
static inline void debug_hrtimer_init_on_stack(struct hrtimer *timer)
421+
{
422+
debug_object_init_on_stack(timer, &hrtimer_debug_descr);
423+
}
424+
420425
static inline void debug_hrtimer_activate(struct hrtimer *timer,
421426
enum hrtimer_mode mode)
422427
{
@@ -428,28 +433,6 @@ static inline void debug_hrtimer_deactivate(struct hrtimer *timer)
428433
debug_object_deactivate(timer, &hrtimer_debug_descr);
429434
}
430435

431-
static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
432-
enum hrtimer_mode mode);
433-
434-
void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id,
435-
enum hrtimer_mode mode)
436-
{
437-
debug_object_init_on_stack(timer, &hrtimer_debug_descr);
438-
__hrtimer_init(timer, clock_id, mode);
439-
}
440-
EXPORT_SYMBOL_GPL(hrtimer_init_on_stack);
441-
442-
static void __hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
443-
clockid_t clock_id, enum hrtimer_mode mode);
444-
445-
void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
446-
clockid_t clock_id, enum hrtimer_mode mode)
447-
{
448-
debug_object_init_on_stack(&sl->timer, &hrtimer_debug_descr);
449-
__hrtimer_init_sleeper(sl, clock_id, mode);
450-
}
451-
EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack);
452-
453436
void destroy_hrtimer_on_stack(struct hrtimer *timer)
454437
{
455438
debug_object_free(timer, &hrtimer_debug_descr);
@@ -459,6 +442,7 @@ EXPORT_SYMBOL_GPL(destroy_hrtimer_on_stack);
459442
#else
460443

461444
static inline void debug_hrtimer_init(struct hrtimer *timer) { }
445+
static inline void debug_hrtimer_init_on_stack(struct hrtimer *timer) { }
462446
static inline void debug_hrtimer_activate(struct hrtimer *timer,
463447
enum hrtimer_mode mode) { }
464448
static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { }
@@ -472,6 +456,13 @@ debug_init(struct hrtimer *timer, clockid_t clockid,
472456
trace_hrtimer_init(timer, clockid, mode);
473457
}
474458

459+
static inline void debug_init_on_stack(struct hrtimer *timer, clockid_t clockid,
460+
enum hrtimer_mode mode)
461+
{
462+
debug_hrtimer_init_on_stack(timer);
463+
trace_hrtimer_init(timer, clockid, mode);
464+
}
465+
475466
static inline void debug_activate(struct hrtimer *timer,
476467
enum hrtimer_mode mode)
477468
{
@@ -1600,6 +1591,23 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
16001591
}
16011592
EXPORT_SYMBOL_GPL(hrtimer_init);
16021593

1594+
/**
1595+
* hrtimer_init_on_stack - initialize a timer in stack memory
1596+
* @timer: The timer to be initialized
1597+
* @clock_id: The clock to be used
1598+
* @mode: The timer mode
1599+
*
1600+
* Similar to hrtimer_init(), except that this one must be used if struct hrtimer is in stack
1601+
* memory.
1602+
*/
1603+
void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id,
1604+
enum hrtimer_mode mode)
1605+
{
1606+
debug_init_on_stack(timer, clock_id, mode);
1607+
__hrtimer_init(timer, clock_id, mode);
1608+
}
1609+
EXPORT_SYMBOL_GPL(hrtimer_init_on_stack);
1610+
16031611
/*
16041612
* A timer is active, when it is enqueued into the rbtree or the
16051613
* callback function is running or it's in the state of being migrated
@@ -1944,7 +1952,7 @@ void hrtimer_sleeper_start_expires(struct hrtimer_sleeper *sl,
19441952
* Make the enqueue delivery mode check work on RT. If the sleeper
19451953
* was initialized for hard interrupt delivery, force the mode bit.
19461954
* This is a special case for hrtimer_sleepers because
1947-
* hrtimer_init_sleeper() determines the delivery mode on RT so the
1955+
* __hrtimer_init_sleeper() determines the delivery mode on RT so the
19481956
* fiddling with this decision is avoided at the call sites.
19491957
*/
19501958
if (IS_ENABLED(CONFIG_PREEMPT_RT) && sl->timer.is_hard)
@@ -1987,19 +1995,18 @@ static void __hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
19871995
}
19881996

19891997
/**
1990-
* hrtimer_init_sleeper - initialize sleeper to the given clock
1998+
* hrtimer_init_sleeper_on_stack - initialize a sleeper in stack memory
19911999
* @sl: sleeper to be initialized
19922000
* @clock_id: the clock to be used
19932001
* @mode: timer mode abs/rel
19942002
*/
1995-
void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clock_id,
1996-
enum hrtimer_mode mode)
2003+
void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
2004+
clockid_t clock_id, enum hrtimer_mode mode)
19972005
{
1998-
debug_init(&sl->timer, clock_id, mode);
2006+
debug_init_on_stack(&sl->timer, clock_id, mode);
19992007
__hrtimer_init_sleeper(sl, clock_id, mode);
2000-
20012008
}
2002-
EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
2009+
EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack);
20032010

20042011
int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
20052012
{

0 commit comments

Comments
 (0)