blob: cdbab0dee021568b62f8325d73a2b3a50147faef [file] [log] [blame]
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import logging\n",
"reload(logging)\n",
"logging.basicConfig(\n",
" format='%(asctime)-9s %(levelname)-8s: %(message)s',\n",
" datefmt='%I:%M:%S')\n",
"\n",
"# Enable logging at INFO level\n",
"logging.getLogger().setLevel(logging.INFO)\n",
"# Uncomment the follwing line to enabled devlib debugging statements\n",
"logging.getLogger('ssh').setLevel(logging.DEBUG)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import json\n",
"import time\n",
"import os"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test environment setup"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Setup a target configuration\n",
"conf = {\n",
"\n",
" # Platform and board to target\n",
" \"platform\" : \"linux\",\n",
" \"board\" : \"juno\",\n",
"\n",
" # Login credentials\n",
" \"host\" : \"192.168.0.1\",\n",
" \"username\" : \"root\",\n",
" \"password\" : \"\",\n",
"\n",
" # Local installation path\n",
" \"tftp\" : {\n",
" \"folder\" : \"/var/lib/tftpboot\",\n",
" \"kernel\" : \"kern.bin\",\n",
" \"dtb\" : \"dtb.bin\",\n",
" },\n",
"\n",
" # Tools to deploy\n",
" \"tools\" : [ \"rt-app\", \"taskset\" ],\n",
"\n",
" # RTApp calibration values (comment to let LISA do a calibration run)\n",
" \"rtapp-calib\" : {\n",
" \"0\": 358, \"1\": 138, \"2\": 138, \"3\": 357, \"4\": 359, \"5\": 355\n",
" },\n",
"\n",
" # FTrace configuration\n",
" \"ftrace\" : {\n",
" \"events\" : [\n",
" \"cpu_idle\",\n",
" \"sched_switch\",\n",
" ],\n",
" \"buffsize\" : 10240,\n",
" },\n",
" \n",
" # Where results are collected\n",
" \"results_dir\" : \"TestEnvExample\",\n",
" \n",
" # Tune which devlib module are required\n",
" #\"exclude_modules\" : [ \"hwmon\" ],\n",
"\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"05:59:27 INFO : Target - Using base path: /home/derkling/Code/lisa\n",
"05:59:27 INFO : Target - Loading custom (inline) target configuration\n",
"05:59:27 INFO : Target - Devlib modules to load: ['bl', 'hwmon', 'cpufreq']\n",
"05:59:27 INFO : Target - Connecting linux target with: {'username': 'root', 'host': '192.168.0.1', 'password': ''}\n",
"05:59:27 DEBUG : Logging in root@192.168.0.1\n",
"06:00:19 DEBUG : id\n",
"06:00:19 DEBUG : echo $PATH\n",
"06:00:20 DEBUG : ls -1 /usr/local/bin\n",
"06:00:20 DEBUG : cat /proc/cpuinfo\n",
"06:00:20 DEBUG : sudo -- sh -c 'dmidecode -s system-version'\n",
"06:00:21 DEBUG : if [ -e '/sys/class/hwmon' ]; then echo 1; else echo 0; fi\n",
"06:00:21 DEBUG : ls -1 /sys/class/hwmon\n",
"06:00:22 DEBUG : if [ -e '/sys/class/hwmon/hwmon0/name' ]; then echo 1; else echo 0; fi\n",
"06:00:22 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon0/name'\\'''\n",
"06:00:23 DEBUG : ls -1 /sys/class/hwmon/hwmon0/\n",
"06:00:23 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon0/curr1_label'\\'''\n",
"06:00:23 DEBUG : if [ -e '/sys/class/hwmon/hwmon1/name' ]; then echo 1; else echo 0; fi\n",
"06:00:24 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon1/name'\\'''\n",
"06:00:24 DEBUG : ls -1 /sys/class/hwmon/hwmon1/\n",
"06:00:25 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon1/curr1_label'\\'''\n",
"06:00:25 DEBUG : if [ -e '/sys/class/hwmon/hwmon10/name' ]; then echo 1; else echo 0; fi\n",
"06:00:25 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon10/name'\\'''\n",
"06:00:26 DEBUG : ls -1 /sys/class/hwmon/hwmon10/\n",
"06:00:26 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon10/power1_label'\\'''\n",
"06:00:27 DEBUG : if [ -e '/sys/class/hwmon/hwmon11/name' ]; then echo 1; else echo 0; fi\n",
"06:00:27 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon11/name'\\'''\n",
"06:00:28 DEBUG : ls -1 /sys/class/hwmon/hwmon11/\n",
"06:00:28 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon11/power1_label'\\'''\n",
"06:00:28 DEBUG : if [ -e '/sys/class/hwmon/hwmon12/name' ]; then echo 1; else echo 0; fi\n",
"06:00:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon12/name'\\'''\n",
"06:00:29 DEBUG : ls -1 /sys/class/hwmon/hwmon12/\n",
"06:00:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon12/energy1_label'\\'''\n",
"06:00:30 DEBUG : if [ -e '/sys/class/hwmon/hwmon13/name' ]; then echo 1; else echo 0; fi\n",
"06:00:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/name'\\'''\n",
"06:00:31 DEBUG : ls -1 /sys/class/hwmon/hwmon13/\n",
"06:00:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_label'\\'''\n",
"06:00:32 DEBUG : if [ -e '/sys/class/hwmon/hwmon14/name' ]; then echo 1; else echo 0; fi\n",
"06:00:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/name'\\'''\n",
"06:00:33 DEBUG : ls -1 /sys/class/hwmon/hwmon14/\n",
"06:00:33 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_label'\\'''\n",
"06:00:33 DEBUG : if [ -e '/sys/class/hwmon/hwmon15/name' ]; then echo 1; else echo 0; fi\n",
"06:00:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon15/name'\\'''\n",
"06:00:34 DEBUG : ls -1 /sys/class/hwmon/hwmon15/\n",
"06:00:35 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon15/energy1_label'\\'''\n",
"06:00:35 DEBUG : if [ -e '/sys/class/hwmon/hwmon16/name' ]; then echo 1; else echo 0; fi\n",
"06:00:35 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/name'\\'''\n",
"06:00:36 DEBUG : ls -1 /sys/class/hwmon/hwmon16/\n",
"06:00:36 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in0_label'\\'''\n",
"06:00:37 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in1_label'\\'''\n",
"06:00:37 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in2_label'\\'''\n",
"06:00:38 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in3_label'\\'''\n",
"06:00:38 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in4_label'\\'''\n",
"06:00:38 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in5_label'\\'''\n",
"06:00:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in6_label'\\'''\n",
"06:00:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/temp1_label'\\'''\n",
"06:00:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/temp2_label'\\'''\n",
"06:00:40 DEBUG : if [ -e '/sys/class/hwmon/hwmon2/name' ]; then echo 1; else echo 0; fi\n",
"06:00:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon2/name'\\'''\n",
"06:00:41 DEBUG : ls -1 /sys/class/hwmon/hwmon2/\n",
"06:00:41 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon2/curr1_label'\\'''\n",
"06:00:42 DEBUG : if [ -e '/sys/class/hwmon/hwmon3/name' ]; then echo 1; else echo 0; fi\n",
"06:00:42 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon3/name'\\'''\n",
"06:00:43 DEBUG : ls -1 /sys/class/hwmon/hwmon3/\n",
"06:00:43 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon3/curr1_label'\\'''\n",
"06:00:43 DEBUG : if [ -e '/sys/class/hwmon/hwmon4/name' ]; then echo 1; else echo 0; fi\n",
"06:00:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon4/name'\\'''\n",
"06:00:44 DEBUG : ls -1 /sys/class/hwmon/hwmon4/\n",
"06:00:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon4/in1_label'\\'''\n",
"06:00:45 DEBUG : if [ -e '/sys/class/hwmon/hwmon5/name' ]; then echo 1; else echo 0; fi\n",
"06:00:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon5/name'\\'''\n",
"06:00:46 DEBUG : ls -1 /sys/class/hwmon/hwmon5/\n",
"06:00:46 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon5/in1_label'\\'''\n",
"06:00:47 DEBUG : if [ -e '/sys/class/hwmon/hwmon6/name' ]; then echo 1; else echo 0; fi\n",
"06:00:47 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon6/name'\\'''\n",
"06:00:48 DEBUG : ls -1 /sys/class/hwmon/hwmon6/\n",
"06:00:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon6/in1_label'\\'''\n",
"06:00:48 DEBUG : if [ -e '/sys/class/hwmon/hwmon7/name' ]; then echo 1; else echo 0; fi\n",
"06:00:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon7/name'\\'''\n",
"06:00:49 DEBUG : ls -1 /sys/class/hwmon/hwmon7/\n",
"06:00:50 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon7/in1_label'\\'''\n",
"06:00:50 DEBUG : if [ -e '/sys/class/hwmon/hwmon8/name' ]; then echo 1; else echo 0; fi\n",
"06:00:50 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon8/name'\\'''\n",
"06:00:51 DEBUG : ls -1 /sys/class/hwmon/hwmon8/\n",
"06:00:51 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon8/power1_label'\\'''\n",
"06:00:52 DEBUG : if [ -e '/sys/class/hwmon/hwmon9/name' ]; then echo 1; else echo 0; fi\n",
"06:00:52 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon9/name'\\'''\n",
"06:00:52 DEBUG : ls -1 /sys/class/hwmon/hwmon9/\n",
"06:00:53 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon9/power1_label'\\'''\n",
"06:00:53 DEBUG : uname -m\n",
"06:00:54 DEBUG : if [ -e '/sys/devices/system/cpu/cpufreq' ]; then echo 1; else echo 0; fi\n",
"06:00:54 DEBUG : sudo -- sh -c 'mount -o remount,rw /'\n",
"06:00:54 INFO : Target - Initializing target workdir [/root/devlib-target]\n",
"06:00:55 DEBUG : mkdir -p /root/devlib-target\n",
"06:00:55 DEBUG : mkdir -p /root/devlib-target/bin\n",
"06:00:55 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/arm64/busybox root@192.168.0.1:/root/devlib-target/bin/busybox\n",
"06:00:56 DEBUG : chmod a+x /root/devlib-target/bin/busybox\n",
"06:00:56 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/scripts/shutils root@192.168.0.1:/root/devlib-target/bin/shutils\n",
"06:00:56 DEBUG : chmod a+x /root/devlib-target/bin/shutils\n",
"06:00:56 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/scripts/cgroup_run_into.sh root@192.168.0.1:/root/devlib-target/bin/cgroup_run_into.sh\n",
"06:00:57 DEBUG : chmod a+x /root/devlib-target/bin/cgroup_run_into.sh\n",
"06:00:57 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/perf root@192.168.0.1:/root/devlib-target/bin/perf\n",
"06:01:00 DEBUG : chmod a+x /root/devlib-target/bin/perf\n",
"06:01:00 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/taskset root@192.168.0.1:/root/devlib-target/bin/taskset\n",
"06:01:00 DEBUG : chmod a+x /root/devlib-target/bin/taskset\n",
"06:01:01 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/rt-app root@192.168.0.1:/root/devlib-target/bin/rt-app\n",
"06:01:02 DEBUG : chmod a+x /root/devlib-target/bin/rt-app\n",
"06:01:03 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/trace-cmd root@192.168.0.1:/root/devlib-target/bin/trace-cmd\n",
"06:01:03 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n",
"06:01:03 INFO : Target topology: [[0, 3, 4, 5], [1, 2]]\n",
"06:01:03 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"06:01:04 DEBUG : cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n",
"06:01:04 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"06:01:05 DEBUG : cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies\n",
"06:01:05 INFO : Platform - Loading default EM [/home/derkling/Code/lisa/libs/utils/platforms/juno.json]...\n",
"06:01:05 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/arm64/trace-cmd root@192.168.0.1:/root/devlib-target/bin/trace-cmd\n",
"06:01:05 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n",
"06:01:06 DEBUG : cat /sys/kernel/debug/tracing/available_events\n",
"06:01:06 INFO : FTrace - Enabled events:\n",
"06:01:06 INFO : FTrace - ['cpu_idle', 'sched_switch']\n",
"06:01:06 INFO : FTrace - None\n",
"06:01:06 INFO : EnergyMeter - Scanning for HWMON channels, may take some time...\n",
"06:01:06 INFO : EnergyMeter - Channels selected for energy sampling:\n",
"[CHAN(v2m_juno_energy/energy1, a57_energy), CHAN(v2m_juno_energy/energy1, a53_energy)]\n",
"06:01:06 INFO : Loading RTApp calibration from configuration file...\n",
"06:01:06 INFO : Using RT-App calibration values: {\"0\": 358, \"1\": 138, \"2\": 138, \"3\": 357, \"4\": 359, \"5\": 355}\n",
"06:01:06 INFO : TestEnv - Set results folder to:\n",
"06:01:06 INFO : TestEnv - /home/derkling/Code/lisa/results/TestEnvExample\n",
"06:01:06 INFO : TestEnv - Experiment results available also in:\n",
"06:01:06 INFO : TestEnv - /home/derkling/Code/lisa/results_latest\n"
]
}
],
"source": [
"from env import TestEnv\n",
"\n",
"# Initialize a test environment using the provided configuration\n",
"te = TestEnv(conf)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Attributes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The initialization of the test environment pre-initialize some useful<br>\n",
"environment variables which are available to write test cases.\n",
"\n",
"These are some of the information available via the TestEnv object."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"username\": \"root\", \n",
" \"ftrace\": {\n",
" \"buffsize\": 10240, \n",
" \"events\": [\n",
" \"cpu_idle\", \n",
" \"sched_switch\"\n",
" ]\n",
" }, \n",
" \"rtapp-calib\": {\n",
" \"1\": 138, \n",
" \"0\": 358, \n",
" \"3\": 357, \n",
" \"2\": 138, \n",
" \"5\": 355, \n",
" \"4\": 359\n",
" }, \n",
" \"host\": \"192.168.0.1\", \n",
" \"password\": \"\", \n",
" \"tools\": [\n",
" \"rt-app\", \n",
" \"taskset\", \n",
" \"trace-cmd\", \n",
" \"taskset\", \n",
" \"trace-cmd\", \n",
" \"perf\", \n",
" \"cgroup_run_into.sh\"\n",
" ], \n",
" \"results_dir\": \"TestEnvExample\", \n",
" \"platform\": \"linux\", \n",
" \"board\": \"juno\", \n",
" \"__features__\": [], \n",
" \"tftp\": {\n",
" \"kernel\": \"kern.bin\", \n",
" \"folder\": \"/var/lib/tftpboot\", \n",
" \"dtb\": \"dtb.bin\"\n",
" }\n",
"}\n"
]
}
],
"source": [
"# The complete configuration of the target we have configured\n",
"print json.dumps(te.conf, indent=4)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"None\n",
"None\n"
]
}
],
"source": [
"# Last configured kernel and DTB image\n",
"print te.kernel\n",
"print te.dtb"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"192.168.0.1\n",
"None\n"
]
}
],
"source": [
"# The IP and MAC address of the target\n",
"print te.ip\n",
"print te.mac"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"nrg_model\": {\n",
" \"big\": {\n",
" \"cluster\": {\n",
" \"nrg_max\": 64\n",
" }, \n",
" \"cpu\": {\n",
" \"cap_max\": 1024, \n",
" \"nrg_max\": 616\n",
" }\n",
" }, \n",
" \"little\": {\n",
" \"cluster\": {\n",
" \"nrg_max\": 57\n",
" }, \n",
" \"cpu\": {\n",
" \"cap_max\": 447, \n",
" \"nrg_max\": 93\n",
" }\n",
" }\n",
" }, \n",
" \"clusters\": {\n",
" \"big\": [\n",
" 1, \n",
" 2\n",
" ], \n",
" \"little\": [\n",
" 0, \n",
" 3, \n",
" 4, \n",
" 5\n",
" ]\n",
" }, \n",
" \"cpus_count\": 6, \n",
" \"freqs\": {\n",
" \"big\": [\n",
" 450000, \n",
" 625000, \n",
" 800000, \n",
" 950000, \n",
" 1100000\n",
" ], \n",
" \"little\": [\n",
" 450000, \n",
" 575000, \n",
" 700000, \n",
" 775000, \n",
" 850000\n",
" ]\n",
" }, \n",
" \"topology\": [\n",
" [\n",
" 0, \n",
" 3, \n",
" 4, \n",
" 5\n",
" ], \n",
" [\n",
" 1, \n",
" 2\n",
" ]\n",
" ]\n",
"}\n"
]
}
],
"source": [
"# A full platform descriptor\n",
"print json.dumps(te.platform, indent=4)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'/home/derkling/Code/lisa/results/TestEnvExample'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# A pre-created folder to host the tests results generated using this\n",
"# test environment, notice that the suite could add additional information\n",
"# in this folder, like for example a copy of the target configuration\n",
"# and other target specific collected information\n",
"te.res_dir"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'/data/local/schedtest'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# The working directory on the target\n",
"te.workdir"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"cluster [[0, 3, 4, 5], [1, 2]]\n",
"cpu [[0], [1], [2], [3], [4], [5]]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# The target topology, which can be used to build BART assertions\n",
"te.topology"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Functions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Some methods are also exposed to test developers which could be used to easy\n",
"the creation of tests.\n",
"\n",
"These are some of the methods available:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"{0: 358, 1: 138, 2: 138, 3: 357, 4: 359, 5: 355}"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Calibrate RT-App (if required) and get the most updated calibration value\n",
"te.calibration()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"({'clusters': {'big': [1, 2], 'little': [0, 3, 4, 5]},\n",
" 'cpus_count': 6,\n",
" 'freqs': {'big': [450000, 625000, 800000, 950000, 1100000],\n",
" 'little': [450000, 575000, 700000, 775000, 850000]},\n",
" 'nrg_model': {u'big': {u'cluster': {u'nrg_max': 64},\n",
" u'cpu': {u'cap_max': 1024, u'nrg_max': 616}},\n",
" u'little': {u'cluster': {u'nrg_max': 57},\n",
" u'cpu': {u'cap_max': 447, u'nrg_max': 93}}},\n",
" 'topology': [[0, 3, 4, 5], [1, 2]]},\n",
" '/tmp/platform.json')"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Generate a JSON file with the complete platform description\n",
"te.platform_dump(dest_dir='/tmp')"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:01:08 INFO : HostResolver - Target (00:02:f7:00:5a:5b) at IP address: 192.168.0.1\n",
"06:01:08 DEBUG : sudo -- sh -c 'sleep 2 && reboot -f &'\n",
"06:01:08 INFO : Reboot - Waiting up to 60[s] for target [192.168.0.1] to reboot...\n",
"06:02:13 INFO : Target - Devlib modules to load: ['bl', 'hwmon', 'cpufreq']\n",
"06:02:13 INFO : Target - Connecting linux target with: {'username': 'root', 'host': '192.168.0.1', 'password': ''}\n",
"06:02:13 DEBUG : Logging in root@192.168.0.1\n",
"06:02:14 DEBUG : id\n",
"06:02:15 DEBUG : echo $PATH\n",
"06:02:15 DEBUG : ls -1 /usr/local/bin\n",
"06:02:16 DEBUG : cat /proc/cpuinfo\n",
"06:02:16 DEBUG : sudo -- sh -c 'dmidecode -s system-version'\n",
"06:02:16 DEBUG : if [ -e '/sys/class/hwmon' ]; then echo 1; else echo 0; fi\n",
"06:02:17 DEBUG : ls -1 /sys/class/hwmon\n",
"06:02:17 DEBUG : if [ -e '/sys/class/hwmon/hwmon0/name' ]; then echo 1; else echo 0; fi\n",
"06:02:18 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon0/name'\\'''\n",
"06:02:18 DEBUG : ls -1 /sys/class/hwmon/hwmon0/\n",
"06:02:19 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon0/curr1_label'\\'''\n",
"06:02:19 DEBUG : if [ -e '/sys/class/hwmon/hwmon1/name' ]; then echo 1; else echo 0; fi\n",
"06:02:19 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon1/name'\\'''\n",
"06:02:20 DEBUG : ls -1 /sys/class/hwmon/hwmon1/\n",
"06:02:20 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon1/curr1_label'\\'''\n",
"06:02:21 DEBUG : if [ -e '/sys/class/hwmon/hwmon10/name' ]; then echo 1; else echo 0; fi\n",
"06:02:21 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon10/name'\\'''\n",
"06:02:21 DEBUG : ls -1 /sys/class/hwmon/hwmon10/\n",
"06:02:22 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon10/power1_label'\\'''\n",
"06:02:22 DEBUG : if [ -e '/sys/class/hwmon/hwmon11/name' ]; then echo 1; else echo 0; fi\n",
"06:02:23 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon11/name'\\'''\n",
"06:02:23 DEBUG : ls -1 /sys/class/hwmon/hwmon11/\n",
"06:02:23 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon11/power1_label'\\'''\n",
"06:02:24 DEBUG : if [ -e '/sys/class/hwmon/hwmon12/name' ]; then echo 1; else echo 0; fi\n",
"06:02:24 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon12/name'\\'''\n",
"06:02:25 DEBUG : ls -1 /sys/class/hwmon/hwmon12/\n",
"06:02:25 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon12/energy1_label'\\'''\n",
"06:02:26 DEBUG : if [ -e '/sys/class/hwmon/hwmon13/name' ]; then echo 1; else echo 0; fi\n",
"06:02:26 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/name'\\'''\n",
"06:02:26 DEBUG : ls -1 /sys/class/hwmon/hwmon13/\n",
"06:02:27 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_label'\\'''\n",
"06:02:27 DEBUG : if [ -e '/sys/class/hwmon/hwmon14/name' ]; then echo 1; else echo 0; fi\n",
"06:02:28 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/name'\\'''\n",
"06:02:28 DEBUG : ls -1 /sys/class/hwmon/hwmon14/\n",
"06:02:28 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_label'\\'''\n",
"06:02:29 DEBUG : if [ -e '/sys/class/hwmon/hwmon15/name' ]; then echo 1; else echo 0; fi\n",
"06:02:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon15/name'\\'''\n",
"06:02:30 DEBUG : ls -1 /sys/class/hwmon/hwmon15/\n",
"06:02:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon15/energy1_label'\\'''\n",
"06:02:31 DEBUG : if [ -e '/sys/class/hwmon/hwmon16/name' ]; then echo 1; else echo 0; fi\n",
"06:02:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/name'\\'''\n",
"06:02:31 DEBUG : ls -1 /sys/class/hwmon/hwmon16/\n",
"06:02:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in0_label'\\'''\n",
"06:02:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in1_label'\\'''\n",
"06:02:33 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in2_label'\\'''\n",
"06:02:33 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in3_label'\\'''\n",
"06:02:33 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in4_label'\\'''\n",
"06:02:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in5_label'\\'''\n",
"06:02:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in6_label'\\'''\n",
"06:02:35 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/temp1_label'\\'''\n",
"06:02:35 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/temp2_label'\\'''\n",
"06:02:36 DEBUG : if [ -e '/sys/class/hwmon/hwmon2/name' ]; then echo 1; else echo 0; fi\n",
"06:02:36 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon2/name'\\'''\n",
"06:02:36 DEBUG : ls -1 /sys/class/hwmon/hwmon2/\n",
"06:02:37 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon2/curr1_label'\\'''\n",
"06:02:37 DEBUG : if [ -e '/sys/class/hwmon/hwmon3/name' ]; then echo 1; else echo 0; fi\n",
"06:02:38 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon3/name'\\'''\n",
"06:02:38 DEBUG : ls -1 /sys/class/hwmon/hwmon3/\n",
"06:02:38 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon3/curr1_label'\\'''\n",
"06:02:39 DEBUG : if [ -e '/sys/class/hwmon/hwmon4/name' ]; then echo 1; else echo 0; fi\n",
"06:02:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon4/name'\\'''\n",
"06:02:40 DEBUG : ls -1 /sys/class/hwmon/hwmon4/\n",
"06:02:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon4/in1_label'\\'''\n",
"06:02:41 DEBUG : if [ -e '/sys/class/hwmon/hwmon5/name' ]; then echo 1; else echo 0; fi\n",
"06:02:41 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon5/name'\\'''\n",
"06:02:41 DEBUG : ls -1 /sys/class/hwmon/hwmon5/\n",
"06:02:42 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon5/in1_label'\\'''\n",
"06:02:42 DEBUG : if [ -e '/sys/class/hwmon/hwmon6/name' ]; then echo 1; else echo 0; fi\n",
"06:02:43 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon6/name'\\'''\n",
"06:02:43 DEBUG : ls -1 /sys/class/hwmon/hwmon6/\n",
"06:02:43 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon6/in1_label'\\'''\n",
"06:02:44 DEBUG : if [ -e '/sys/class/hwmon/hwmon7/name' ]; then echo 1; else echo 0; fi\n",
"06:02:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon7/name'\\'''\n",
"06:02:45 DEBUG : ls -1 /sys/class/hwmon/hwmon7/\n",
"06:02:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon7/in1_label'\\'''\n",
"06:02:46 DEBUG : if [ -e '/sys/class/hwmon/hwmon8/name' ]; then echo 1; else echo 0; fi\n",
"06:02:46 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon8/name'\\'''\n",
"06:02:46 DEBUG : ls -1 /sys/class/hwmon/hwmon8/\n",
"06:02:47 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon8/power1_label'\\'''\n",
"06:02:47 DEBUG : if [ -e '/sys/class/hwmon/hwmon9/name' ]; then echo 1; else echo 0; fi\n",
"06:02:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon9/name'\\'''\n",
"06:02:48 DEBUG : ls -1 /sys/class/hwmon/hwmon9/\n",
"06:02:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon9/power1_label'\\'''\n",
"06:02:49 DEBUG : uname -m\n",
"06:02:49 DEBUG : if [ -e '/sys/devices/system/cpu/cpufreq' ]; then echo 1; else echo 0; fi\n",
"06:02:50 DEBUG : sudo -- sh -c 'mount -o remount,rw /'\n",
"06:02:50 INFO : Target - Initializing target workdir [/root/devlib-target]\n",
"06:02:50 DEBUG : mkdir -p /root/devlib-target\n",
"06:02:50 DEBUG : mkdir -p /root/devlib-target/bin\n",
"06:02:51 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/arm64/busybox root@192.168.0.1:/root/devlib-target/bin/busybox\n",
"06:02:51 DEBUG : chmod a+x /root/devlib-target/bin/busybox\n",
"06:02:51 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/scripts/shutils root@192.168.0.1:/root/devlib-target/bin/shutils\n",
"06:02:52 DEBUG : chmod a+x /root/devlib-target/bin/shutils\n",
"06:02:52 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/scripts/cgroup_run_into.sh root@192.168.0.1:/root/devlib-target/bin/cgroup_run_into.sh\n",
"06:02:52 DEBUG : chmod a+x /root/devlib-target/bin/cgroup_run_into.sh\n",
"06:02:52 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/perf root@192.168.0.1:/root/devlib-target/bin/perf\n",
"06:02:55 DEBUG : chmod a+x /root/devlib-target/bin/perf\n",
"06:02:56 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/taskset root@192.168.0.1:/root/devlib-target/bin/taskset\n",
"06:02:56 DEBUG : chmod a+x /root/devlib-target/bin/taskset\n",
"06:02:56 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/rt-app root@192.168.0.1:/root/devlib-target/bin/rt-app\n",
"06:02:56 DEBUG : chmod a+x /root/devlib-target/bin/rt-app\n",
"06:02:57 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/trace-cmd root@192.168.0.1:/root/devlib-target/bin/trace-cmd\n",
"06:02:57 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n",
"06:02:57 INFO : Target topology: [[0, 3, 4, 5], [1, 2]]\n",
"06:02:57 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"06:02:58 DEBUG : cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n",
"06:02:58 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"06:02:59 DEBUG : cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies\n",
"06:02:59 INFO : Platform - Loading default EM [/home/derkling/Code/lisa/libs/utils/platforms/juno.json]...\n",
"06:02:59 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/arm64/trace-cmd root@192.168.0.1:/root/devlib-target/bin/trace-cmd\n",
"06:02:59 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n",
"06:03:00 DEBUG : cat /sys/kernel/debug/tracing/available_events\n",
"06:03:00 INFO : FTrace - Enabled events:\n",
"06:03:00 INFO : FTrace - ['cpu_idle', 'sched_switch']\n",
"06:03:00 INFO : FTrace - None\n",
"06:03:00 INFO : EnergyMeter - Scanning for HWMON channels, may take some time...\n",
"06:03:00 INFO : EnergyMeter - Channels selected for energy sampling:\n",
"[CHAN(v2m_juno_energy/energy1, a57_energy), CHAN(v2m_juno_energy/energy1, a53_energy)]\n"
]
}
],
"source": [
"# Force a reboot of the target (and wait specified [s] before reconnect)\n",
"te.reboot(reboot_time=60, ping_time=15)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:00 INFO : HostResolver - Target (00:02:F7:00:5A:5B) at IP address: 192.168.0.1\n"
]
},
{
"data": {
"text/plain": [
"('00:02:F7:00:5A:5B', '192.168.0.1')"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Resolve a MAC address into an IP address\n",
"te.resolv_host(host='00:02:F7:00:5A:5B')"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:00 INFO : TFTP - Deploy /etc/group into /var/lib/tftpboot/group\n"
]
}
],
"source": [
"# Copy the specified file into the TFTP server folder defined by configuration\n",
"te.tftp_deploy('/etc/group')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A special TestEnv attribute is <b>target</b>, which represent a <b>devlib instance</b>.<br>\n",
"Using the target attribute we can access to the full set of devlib provided<br>\n",
"functionalities. Which are summarized in the following sections."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"# Access to the devlib API"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:01 DEBUG : echo -n 'Hello Test Environment'\n"
]
},
{
"data": {
"text/plain": [
"'Hello Test Environment'"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Run a command on the target\n",
"te.target.execute(\"echo -n 'Hello Test Environment'\", as_root=False)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:02 DEBUG : sudo -- sh -c 'sh -c \"sleep 10\" 1>/dev/null 2>/dev/null &'\n"
]
},
{
"data": {
"text/plain": [
"''"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Spawn a command in background on the target\n",
"te.target.kick_off(\"sleep 10\", as_root=True)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ABI : arm64\n",
"big Core Family : A57\n",
"LITTLE Core Family : A53\n",
"CPU's Clusters IDs : [0, 1, 1, 0, 0, 0]\n",
"CPUs type : ['A53', 'A57', 'A57', 'A53', 'A53', 'A53']\n"
]
}
],
"source": [
"# Acces to many target specific information\n",
"print \"ABI : \", te.target.abi\n",
"print \"big Core Family : \", te.target.big_core\n",
"print \"LITTLE Core Family : \", te.target.little_core\n",
"print \"CPU's Clusters IDs : \", te.target.core_clusters\n",
"print \"CPUs type : \", te.target.core_names"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:02 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"06:03:03 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq'\\'''\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"big CPUs IDs : [1, 2]\n",
"LITTLE CPUs IDs : [0, 3, 4, 5]\n",
"big CPUs freqs : 1100000"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:03 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"06:03:04 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor'\\'''\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"big CPUs governor : performance\n"
]
}
],
"source": [
"# Access to big.LITTLE specific information\n",
"print \"big CPUs IDs : \", te.target.bl.bigs\n",
"print \"LITTLE CPUs IDs : \", te.target.bl.littles\n",
"print \"big CPUs freqs : {}\".format(te.target.bl.get_bigs_frequency())\n",
"print \"big CPUs governor : {}\".format(te.target.bl.get_bigs_governor())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sample energy from the target"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:04 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"06:03:05 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"06:03:05 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"06:03:05 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"06:03:06 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"06:03:06 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"06:03:09 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"06:03:09 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"06:03:10 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"06:03:10 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"First read: {\n",
" \"a53\": {\n",
" \"total\": 0.37534899999999993, \n",
" \"last\": 51.372362, \n",
" \"delta\": 0.18520200000000386\n",
" }, \n",
" \"a57\": {\n",
" \"total\": 1.0124409999999955, \n",
" \"last\": 59.688784, \n",
" \"delta\": 0.5027259999999956\n",
" }\n",
"}\n",
"Second read: {\n",
" \"a53\": {\n",
" \"total\": 1.7191619999999972, \n",
" \"last\": 52.716175, \n",
" \"delta\": 0.17561400000000305\n",
" }, \n",
" \"a57\": {\n",
" \"total\": 2.4685759999999988, \n",
" \"last\": 61.144919, \n",
" \"delta\": 0.4992990000000006\n",
" }\n",
"}\n"
]
}
],
"source": [
"# Reset and sample energy counters\n",
"te.emeter.reset()\n",
"nrg = te.emeter.sample()\n",
"nrg = json.dumps(te.emeter.sample(), indent=4)\n",
"print \"First read: \", nrg\n",
"time.sleep(2)\n",
"nrg = te.emeter.sample()\n",
"nrg = json.dumps(te.emeter.sample(), indent=4)\n",
"print \"Second read: \", nrg"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Configure FTrace for a sepcific experiment"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:10 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/arm64/trace-cmd root@192.168.0.1:/root/devlib-target/bin/trace-cmd\n",
"06:03:11 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n",
"06:03:11 DEBUG : cat /sys/kernel/debug/tracing/available_events\n",
"06:03:11 INFO : FTrace - Enabled events:\n",
"06:03:11 INFO : FTrace - ['cpu_idle', 'cpu_capacity', 'cpu_frequency', 'sched_switch']\n",
"06:03:11 INFO : FTrace - None\n"
]
}
],
"source": [
"# Configure a specific set of events to trace\n",
"te.ftrace_conf(\n",
" { \n",
" \"events\" : [ \n",
" \"cpu_idle\", \n",
" \"cpu_capacity\",\n",
" \"cpu_frequency\",\n",
" \"sched_switch\",\n",
" ], \n",
" \"buffsize\" : 10240 \n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:11 DEBUG : sudo -- sh -c 'echo 10240 > '\\''/sys/kernel/debug/tracing/buffer_size_kb'\\'''\n",
"06:03:12 DEBUG : sudo -- sh -c 'cat '\\''/sys/kernel/debug/tracing/buffer_size_kb'\\'''\n",
"06:03:12 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd reset'\n",
"06:03:13 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd start -e cpu_idle -e cpu_capacity -e cpu_frequency -e sched_switch'\n",
"06:03:14 DEBUG : sudo -- sh -c 'echo TRACE_MARKER_START > '\\''/sys/kernel/debug/tracing/trace_marker'\\'''\n",
"06:03:15 DEBUG : sudo -- sh -c '/root/devlib-target/bin/shutils cpufreq_trace_all_frequencies'\n",
"06:03:15 DEBUG : uname -a\n",
"06:03:15 DEBUG : sudo -- sh -c '/root/devlib-target/bin/shutils cpufreq_trace_all_frequencies'\n",
"06:03:16 DEBUG : sudo -- sh -c 'echo TRACE_MARKER_STOP > '\\''/sys/kernel/debug/tracing/trace_marker'\\'''\n",
"06:03:16 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd stop'\n"
]
}
],
"source": [
"# Start/Stop a FTrace session\n",
"te.ftrace.start()\n",
"te.target.execute(\"uname -a\")\n",
"te.ftrace.stop()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"06:03:17 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd extract -o /root/devlib-target/trace.dat'\n",
"06:03:18 DEBUG : /usr/bin/scp -r root@192.168.0.1:/root/devlib-target/trace.dat /home/derkling/Code/lisa/results/TestEnvExample/trace.dat\n"
]
}
],
"source": [
"# Collect and visualize the trace\n",
"trace_file = os.path.join(te.res_dir, 'trace.dat')\n",
"te.ftrace.get_trace(trace_file)\n",
"output = os.popen(\"DISPLAY=:0.0 kernelshark {}\".format(trace_file))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}