GithubHelp home page GithubHelp logo

idlatest's Introduction

Idle Latency Estimator

This tool attempts to estimate linux CPU idle wakeup latency based on tracepoints. It can be used to measure cpuidle_state.exit_latency in a CPU and SOC-independent way using the tracepoint infrastructure offered by linux.

It does not require hardware instrumentation of the target system (such as probing voltages) and can be combined with arbitrary workloads.

This tool analyzes tracepoint data and reports a histogram of observed wakeup latencies. The real exit_latency values are noticeable as "spikes" in the data.

General approach

The exit_latency is defined as the interval between when a wakeup signal is received and when the CPU can start executing code again. This is done by examining all power:cpu_idle exit events and attempting to find the wakeup source and a timestamp for it.

Wakeup sources do not generally have timestamps attached, but some do. In particular:

  • IPIs are sent by software running on another core and timestamp is automatically associated to the ipi:ipi_raise event. This is currently only available on arm/arm64.
  • When the kernel goes to sleep it arms timers through a generic clock_event_device.set_next_event callback which takes wakeup time as a parameter. A tracepoint can be added for this.

In theory timestamps from various peripherals could be used (for example PTP) but luckly IPIs and clock_events are very common.

Limitations

Wakeups that come from sources without timestamps will confound the data.

Coupled states

It is common for idle states to be "coupled" and multiple CPUs, this is generally implemented by having all cpus in a cluster enter a shallow state and only moving to the deep state with the last CPU.

Drivers for cpuidle can report this (the return value from enter func) however:

  • This result value is not exposed via tracepoints
  • Many SOC-specific drivers don't do this (it's hard)
  • The generic ARM PSCI driver can't do this (PSCI limitation)

In practice this means the latency histogram for deeper states will include values for shallower states.

Python requirements

  • numpy
  • pandas
  • matplotlib
  • jupyter notebook

These can be installed in many ways.

Installing with debian packages for python2:

# apt-get install python-matplotlib python-pandas python-notebook
$ python2 -m notebook --notebook-dir "CHECKOUT_DIR"

Installing with debian packages for python3:

# apt install python3-pandas python3-matplotlib jupyter-notebook
$ jupyter-notebook --notebook-dir "CHECKOUT_DIR"

Installing with pip

Using pip instead of distro packages should be very portable.

Running inside a virtualenv avoid contaminating your environment:

# apt-get install virtualenv
$ virtualenv venv
$ . ./venv/bin/activate
$ pip install notebook pandas matplotlib
$ jupyter-notebook --notebook-dir "CHECKOUT_DIR"

Kernel requirements

Following config options are required:

  • CONFIG_FTRACE=y
  • CONFIG_TRACER_SNAPSHOT=y
  • CONFIG_ENABLE_DEFAULT_TRACERS=y

Tracepoints for clock_event_device are out-of-tree, you need this patch:

https://bitbucket.sw.nxp.com/users/nxf25340/repos/linux-imx/commits/3f9c1254a197679d6e2675a611be758e1e0e13dc

Tracepoints for ipi_raise/ipi_enter/ipi_exit are only available on arm and arm64.

How to run

Both the host system (running the notebook) and the target need to have trace-cmd installed. The trace.dat format is mostly compatible so default versions from debian/ubuntu or yocto should work fine.

TODO

  • Include sample data
  • Run on non-imx and non-arm systems
  • Upstream additional tracepoints

Author

Leonard Crestez

Feel free to contact with questions or git send-email patches.

idlatest's People

Contributors

cdleonard avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.