Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _TICK_SCHED_H
0003 #define _TICK_SCHED_H
0004 
0005 #include <linux/hrtimer.h>
0006 
0007 enum tick_device_mode {
0008     TICKDEV_MODE_PERIODIC,
0009     TICKDEV_MODE_ONESHOT,
0010 };
0011 
0012 struct tick_device {
0013     struct clock_event_device *evtdev;
0014     enum tick_device_mode mode;
0015 };
0016 
0017 enum tick_nohz_mode {
0018     NOHZ_MODE_INACTIVE,
0019     NOHZ_MODE_LOWRES,
0020     NOHZ_MODE_HIGHRES,
0021 };
0022 
0023 /**
0024  * struct tick_sched - sched tick emulation and no idle tick control/stats
0025  * @sched_timer:    hrtimer to schedule the periodic tick in high
0026  *          resolution mode
0027  * @check_clocks:   Notification mechanism about clocksource changes
0028  * @nohz_mode:      Mode - one state of tick_nohz_mode
0029  * @inidle:     Indicator that the CPU is in the tick idle mode
0030  * @tick_stopped:   Indicator that the idle tick has been stopped
0031  * @idle_active:    Indicator that the CPU is actively in the tick idle mode;
0032  *          it is reset during irq handling phases.
0033  * @do_timer_lst:   CPU was the last one doing do_timer before going idle
0034  * @got_idle_tick:  Tick timer function has run with @inidle set
0035  * @last_tick:      Store the last tick expiry time when the tick
0036  *          timer is modified for nohz sleeps. This is necessary
0037  *          to resume the tick timer operation in the timeline
0038  *          when the CPU returns from nohz sleep.
0039  * @next_tick:      Next tick to be fired when in dynticks mode.
0040  * @idle_jiffies:   jiffies at the entry to idle for idle time accounting
0041  * @idle_calls:     Total number of idle calls
0042  * @idle_sleeps:    Number of idle calls, where the sched tick was stopped
0043  * @idle_entrytime: Time when the idle call was entered
0044  * @idle_waketime:  Time when the idle was interrupted
0045  * @idle_exittime:  Time when the idle state was left
0046  * @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
0047  * @iowait_sleeptime:   Sum of the time slept in idle with sched tick stopped, with IO outstanding
0048  * @timer_expires:  Anticipated timer expiration time (in case sched tick is stopped)
0049  * @timer_expires_base: Base time clock monotonic for @timer_expires
0050  * @next_timer:     Expiry time of next expiring timer for debugging purpose only
0051  * @tick_dep_mask:  Tick dependency mask - is set, if someone needs the tick
0052  * @last_tick_jiffies:  Value of jiffies seen on last tick
0053  * @stalled_jiffies:    Number of stalled jiffies detected across ticks
0054  */
0055 struct tick_sched {
0056     struct hrtimer          sched_timer;
0057     unsigned long           check_clocks;
0058     enum tick_nohz_mode     nohz_mode;
0059 
0060     unsigned int            inidle      : 1;
0061     unsigned int            tick_stopped    : 1;
0062     unsigned int            idle_active : 1;
0063     unsigned int            do_timer_last   : 1;
0064     unsigned int            got_idle_tick   : 1;
0065 
0066     ktime_t             last_tick;
0067     ktime_t             next_tick;
0068     unsigned long           idle_jiffies;
0069     unsigned long           idle_calls;
0070     unsigned long           idle_sleeps;
0071     ktime_t             idle_entrytime;
0072     ktime_t             idle_waketime;
0073     ktime_t             idle_exittime;
0074     ktime_t             idle_sleeptime;
0075     ktime_t             iowait_sleeptime;
0076     unsigned long           last_jiffies;
0077     u64             timer_expires;
0078     u64             timer_expires_base;
0079     u64             next_timer;
0080     ktime_t             idle_expires;
0081     atomic_t            tick_dep_mask;
0082     unsigned long           last_tick_jiffies;
0083     unsigned int            stalled_jiffies;
0084 };
0085 
0086 extern struct tick_sched *tick_get_tick_sched(int cpu);
0087 
0088 extern void tick_setup_sched_timer(void);
0089 #if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
0090 extern void tick_cancel_sched_timer(int cpu);
0091 #else
0092 static inline void tick_cancel_sched_timer(int cpu) { }
0093 #endif
0094 
0095 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
0096 extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
0097 #else
0098 static inline int
0099 __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
0100 {
0101     return -EBUSY;
0102 }
0103 #endif
0104 
0105 #endif