nohz: make updating sleep stats local, add seqcount
Subsystems (2)
PATCH 1/1 nohz: make updating sleep stats local, add seqcount
Since update_ts_time_stats() has no exclusive control while it can be called from both of local cpu and remote cpu, sleep stats will go wrong if updates conflict, and stats can be referred while update is going on. It will cause bloat and/or hiccup (jump and turn back) of idle/iowait values appeared in /proc/stats.
- Stop updating from get_cpu_{idle,iowait}_time_us():
It is hard to get reasonable performance with having exclusive locking for multiple writers. To limit the update areas to local, remove update functionality from these functions. It makes time stats to be updated by woken cpu only, so there are only one writer now.
- Adds seqcount:
It should be the minimum implementation to avoid possible races between multiple readers vs. single writer. This lock protects:
idle_active, idle_entrytime, idle_sleeptime, iowait_sleeptime.
Minor cleanups included:
- Rename last_update_time to wall:
Now these function do not perform update. Change arg name and comments to fit new behavior.
- Now there is no other way to reach update_ts_time_stats(), fold this static routine into tick_nohz_stop_idle().
v5: rebased onto v3.16-rc2.
update patch description, separate from following changes. (patch body does not changed from 1/2 of v4)
v1-4: https://lkml.org/lkml/2014/4/17/120
--- include/linux/tick.h | 5 ++- kernel/time/tick-sched.c | 75 ++++++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 41 deletions(-)
include/linux/tick.h +3 -2
@@ -62,6 +62,7 @@ struct tick_sched {unsigned long idle_calls;unsigned long idle_sleeps;int idle_active; +seqcount_t idle_sleeptime_seq;ktime_t idle_entrytime;ktime_t idle_waketime;ktime_t idle_exittime;
@@ -137,8 +138,8 @@ extern void tick_nohz_idle_enter(void);extern void tick_nohz_idle_exit (void );extern void tick_nohz_irq_exit (void );extern ktime_t tick_nohz_get_sleep_length (void ); -extern u64 get_cpu_idle_time_us (int cpu,u64 *last_update_time); -extern u64 get_cpu_iowait_time_us (int cpu,u64 *last_update_time); +extern u64 get_cpu_idle_time_us (int cpu,u64 *wall); +extern u64 get_cpu_iowait_time_us (int cpu,u64 *wall);# else /* !CONFIG_NO_HZ_COMMON */ static inline int tick_nohz_tick_stopped (void )
kernel/time/tick-sched.c +36 -39
149 lines not on this page · raw message
Signature · 1 line
1.7.1