Let’s take a look at the dynamics of cpu hotplugging on a Nexus 5 running Maru. Keep an eye on the right two panes, which show CPU utilization on the top and cpu states and cpuset limits on the bottom.
When the system is idle, note how all cores except cpu0 are offline. This is thanks to a hotplugging daemon called mpdecision that is found on Android devices running Qualcomm chipsets.
When we add load, mpdecision will start turning on cores. When the load drops off, mpdecision will start shutting off cores until only cpu0 is on. This is a great optimization for battery life.
Now, on Maru, the desktop is isolated within an LXC container, and (unknown to me when I built this…) is by default placed in a cpuset (a kernel resource controller for managing task scheduling across cores). Normally, this would be fine since LXC will just copy over the root cpuset configuration (all available cpus), but with hotplugging it is always throttled down to just cpu0 due to the fact that cpuset subgroups must be subsets of it’s parents. That is, all child cpusets shrink as the parent shrinks, but never grows as the parent grows. That means we always end up with the container cpuset being just cpu0!
To fix this temporarily, we can poke the cpuset sysfs tree and configure LXC and it’s children to access all cores…
…but after we idle again we end up in the same state as before with the LXC cpuset dropping to just 0.
To fix this permanently, we need to tell LXC to not use cpusets at all, which requires a build-time change, which I am committing shortly!
Cool, huh?
More context and info here: https://github.com/maruos/maruos/issues/58
Share this recording
Link
Append ?t=30
to start the playback at 30s, ?t=3:20
to start the playback at 3m 20s.
Embed image link
Use snippets below to display a screenshot linking to this recording.
Useful in places where scripts are not allowed (e.g. in a project's README file).
HTML:
Markdown:
Embed the player
If you're embedding on your own page or on a site which permits script tags, you can use the full player widget:
Paste the above script tag where you want the player to be displayed on your page.
See embedding docs for additional options.
Download this recording
You can download this recording in asciicast v2 format, as a .cast file.
DownloadReplay in terminal
You can replay the downloaded recording in your terminal using the
asciinema play
command:
asciinema play 124345.cast
If you don't have asciinema CLI installed then see installation instructions.
Use with stand-alone player on your website
Download asciinema player from
the releases page
(you only need .js
and .css
file), then use it like this:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="asciinema-player.css" />
</head>
<body>
<div id="player"></div>
<script src="asciinema-player.min.js"></script>
<script>
AsciinemaPlayer.create(
'/assets/124345.cast',
document.getElementById('player'),
{ cols: 211, rows: 54 }
);
</script>
</body>
</html>
See asciinema player quick-start guide for full usage instructions.
Generate GIF from this recording
While this site doesn't provide GIF conversion at the moment, you can still do it yourself with the help of asciinema GIF generator utility - agg.
Once you have it installed, generate a GIF with the following command:
agg https://asciinema.org/a/124345 demo.gif
Or, if you already downloaded the recording file:
agg demo.cast demo.gif
Check agg --help
for all available options. You can change font
family and size, select color theme, adjust speed and more.
See agg manual for full usage instructions.