Skip to content

Idle timekeeping #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Idle timekeeping #2

wants to merge 3 commits into from

Conversation

randombtree
Copy link
Owner

Fix bug where all idle CPUs are treated as timekeeping CPUS, thus resulting in more wakeups from idle.

Contains

  • Fix
  • Debug aid (new event for tracing)
  • A cleanuo

There are a few things preventing a CPU from going for long sleeps. This patch
adds a new trace event, tick_next_event, that helps debug the underlying cause
for kernel insomnia.

Signed-off-by: Roger Blomgren <[email protected]>
There are three different cases here:
- There is no next event timeout: cancel the tick.
- There is an upcoming event and we are in hr-mode: arm hr-tick.
- Not in hr-mode but have upcoming event, arm tick.

The patch also avoids adding a hrtimer with expiry KTIME_MAX on an
idle CPU, saving the uneccecary dance of rb-tree addition and removal
in that case.

Signed-off-by: Roger Blomgren <[email protected]>
The timer updating CPU (tick_do_timer_cpu) is an awake CPU responsible for
updating the time. This abstraction, however, has been used to select witch CPU
to sleep a shorter while to guarantee a proper time keeping advancement
e.g. avoiding time keeping counter wrap-overs. In a mostly idle system, where
at most one CPU is awake, the awake CPU will become the next time keeping CPU
even though the previously awake CPU is sleeping a shorter while. This
basically translates into all idle CPUs being ultimately selected as time
keeping CPUs, thus not allowed to sleep the full time otherwise allowed by
timer deadlines.

This patch introduces tick_timekeeping_cpu, which is hold at most by one CPU.
The time keeeping CPU will wake up regularly as dictated by
timekeeping_max_deferment() allowing other CPUs to sleep longer. The
timekeeping CPU will also change once in a while, gravitating towards more
"active" CPUs, again, allowing longer CPU sleeps in general.

Signed-off-by: Roger Blomgren <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant