blob: 72faaa2f3902ec1f8eea41c58450fd46a61413e0 [file] [log] [blame]
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tutorial goal"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This tutorial aims to show how to **configure** a **test environment** using\n",
"the **TestEnv module** provided by LISA."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Configure logging"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import logging\n",
"from conf import LisaLogging\n",
"LisaLogging.setup()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Execute this cell to enabled devlib debugging statements\n",
"logging.getLogger('ssh').setLevel(logging.DEBUG)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Other python modules required by this notebook\n",
"import json\n",
"import time\n",
"import os"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test environment setup"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Do you have custom scripts to deploy and use on target?"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[01;34m../../tools\u001b[00m\r\n",
"├── \u001b[01;34marm64\u001b[00m\r\n",
"│   ├── \u001b[01;32mperf\u001b[00m\r\n",
"│   ├── \u001b[01;32mrt-app\u001b[00m\r\n",
"│   ├── \u001b[01;32mtaskset\u001b[00m\r\n",
"│   └── \u001b[01;32mtrace-cmd\u001b[00m\r\n",
"├── \u001b[01;34marmeabi\u001b[00m\r\n",
"│   ├── \u001b[01;32mbusybox\u001b[00m\r\n",
"│   ├── \u001b[01;32mdaemonize\u001b[00m\r\n",
"│   ├── htop\r\n",
"│   ├── htop.armv7\r\n",
"│   ├── \u001b[01;32mperf\u001b[00m\r\n",
"│   ├── \u001b[01;32mrt-app\u001b[00m\r\n",
"│   ├── \u001b[01;32msysbench\u001b[00m\r\n",
"│   ├── \u001b[01;32mtaskset\u001b[00m\r\n",
"│   ├── \u001b[01;31mterminfo.tar.bz2\u001b[00m\r\n",
"│   └── \u001b[01;32mtrace-cmd\u001b[00m\r\n",
"├── LICENSE.busybox\r\n",
"├── LICENSE.perf\r\n",
"├── LICENSE.rt-app\r\n",
"├── LICENSE.taskset\r\n",
"├── LICENSE.trace-cmd\r\n",
"├── \u001b[01;32mplots.py\u001b[00m\r\n",
"├── \u001b[01;32mreport.py\u001b[00m\r\n",
"├── report.pyc\r\n",
"├── \u001b[01;34mscripts\u001b[00m\r\n",
"│   ├── \u001b[01;32mcgroup_run_into.sh\u001b[00m\r\n",
"│   ├── \u001b[01;32mcgroup_tasks_move.sh\u001b[00m\r\n",
"│   ├── \u001b[01;32mcpuidle_sampling.sh\u001b[00m\r\n",
"│   ├── \u001b[01;32modroid_sampler.py\u001b[00m\r\n",
"│   ├── \u001b[01;32modroid_sampler.sh\u001b[00m\r\n",
"│   ├── \u001b[01;32mtrace_frequencies.sh\u001b[00m\r\n",
"│   └── \u001b[01;32mtraceview_extract.awk\u001b[00m\r\n",
"├── \u001b[01;34mx86\u001b[00m\r\n",
"│   ├── \u001b[01;32mbusybox\u001b[00m\r\n",
"│   └── \u001b[01;32mchrt\u001b[00m\r\n",
"└── \u001b[01;34mx86_64\u001b[00m\r\n",
" ├── \u001b[01;32mbusybox\u001b[00m\r\n",
" ├── \u001b[01;32mchrt\u001b[00m\r\n",
" ├── \u001b[01;32mperf\u001b[00m\r\n",
" ├── \u001b[01;32mrt-app\u001b[00m\r\n",
" ├── \u001b[01;32mtaskset\u001b[00m\r\n",
" ├── \u001b[01;32mtrace-cmd\u001b[00m\r\n",
" └── \u001b[01;32mwlg\u001b[00m\r\n",
"\r\n",
"5 directories, 38 files\r\n"
]
}
],
"source": [
"# Custom scrips must be deployed under $LISA_HOME/tools\n",
"!tree ../../tools"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#!/bin/bash\r\n",
"\r\n",
"# CPU to monitor\r\n",
"CPU=${1:-0}\r\n",
"# Sampling time\r\n",
"SLEEP=${2:-1}\r\n",
"# Samples to collect\r\n",
"COUNT=${3:-3}\r\n",
"\r\n",
"# Enter CPU's sysfs\r\n",
"cd /sys/devices/system/cpu\r\n",
"\r\n",
"# Initial C-State residencies counter\r\n",
"ISC=$(find cpu0/cpuidle -name \"state*\" | wc -l)\r\n",
"for I in $(seq 0 $((ISC-1))); do\r\n",
"\tLCS[$I]=`cat cpu$CPU/cpuidle/state$I/usage`\r\n",
"done\r\n",
"\r\n",
"# Dump header\r\n",
"printf \"#%13s \" \"Time\"\r\n",
"for I in $(seq 0 $((ISC-1))); do\r\n",
" printf \"%14s \" \"idle$I\"\r\n",
"done\r\n",
"echo\r\n",
"\r\n",
"# Sampling loop\r\n",
"for I in $(seq $COUNT); do\r\n",
"\r\n",
"\tsleep $SLEEP\r\n",
"\r\n",
"\t# Dump CPU C-State residencies\r\n",
"\tnow=$(date +%s)\r\n",
"\tprintf \"%14d \" $now\r\n",
"\tfor I in $(seq 0 $((ISC-1))); do\r\n",
"\t\tU=`cat cpu$CPU/cpuidle/state$I/usage`\r\n",
"\t\tCCS=$(($U - ${LCS[$I]}))\r\n",
"\t\tprintf \"%14d \" $CCS\r\n",
"\t\tLCS[$I]=$U\r\n",
"\tdone\r\n",
"\techo\r\n",
"\r\n",
"\r\n",
"done\r\n",
"\r\n",
"# vim: ts=2\r\n"
]
}
],
"source": [
"# This is the (not so fancy) script we want to deploy\n",
"!cat ../../tools/scripts/cpuidle_sampling.sh"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Which devlib modules you need for your experiments?"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:34:06 INFO : Devlib provided modules are found under:\n",
"04:34:06 INFO : $LISA_HOME/libs/devlib/devlib/module/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" thermal.py\r\n",
" vexpress.py\r\n",
" cooling.py\r\n",
" android.py\r\n",
" biglittle.py\r\n",
" cpuidle.py\r\n",
" hotplug.py\r\n",
" cpufreq.py\r\n",
" hwmon.py\r\n",
" cgroups.py\r\n"
]
}
],
"source": [
"# You can have a look at the devlib supported modules by lising the\n",
"devlib_modules_folder = 'libs/devlib/devlib/module/'\n",
"\n",
"logging.info(\"Devlib provided modules are found under:\")\n",
"logging.info(\" $LISA_HOME/{}\".format(devlib_modules_folder))\n",
"!cd ../../ ; find {devlib_modules_folder} -name \"*.py\" | sed 's|libs/devlib/devlib/module/| |' | grep -v __init__ "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup you TestEnv confguration"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Setup a target configuration\n",
"conf = {\n",
"\n",
" # Define the kind of target platform to use for the experiments\n",
" \"platform\" : 'linux', # platform type, valid other options are:\n",
" # android - access via ADB\n",
" # linux - access via SSH\n",
" # host - direct access\n",
" \n",
" # Preload settings for a specific target\n",
" \"board\" : 'juno', # board type, valid options are:\n",
" # - juno - JUNO Development Board\n",
" # - tc2 - TC2 Development Board\n",
"\n",
" # Login credentials\n",
" \"host\" : \"192.168.0.1\",\n",
" \"username\" : \"root\",\n",
" \"password\" : \"\",\n",
"\n",
" # Custom tools to deploy on target, they must be placed under:\n",
" # $LISA_HOME/tools/(ARCH|scripts)\n",
" \"tools\" : [ \"cpuidle_sampling.sh\" ],\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",
" # Devlib module required (or not required)\n",
" 'modules' : [ \"cpufreq\", \"cgroups\" ],\n",
" #\"exclude_modules\" : [ \"hwmon\" ],\n",
" \n",
" # Local installation path used for kernel/dtb installation on target\n",
" # The specified path MUST be accessible from the board, e.g.\n",
" # - JUNO/TC2: it can be the mount path of the VMESD disk image\n",
" # - Other board: it can be a TFTP server path used by the board bootloader\n",
" \"tftp\" : {\n",
" \"folder\" : \"/var/lib/tftpboot\",\n",
" \"kernel\" : \"kern.bin\",\n",
" \"dtb\" : \"dtb.bin\",\n",
" },\n",
"\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:34:08 INFO : Target - Using base path: /home/derkling/Code/lisa\n",
"04:34:08 INFO : Target - Loading custom (inline) target configuration\n",
"04:34:08 DEBUG : Target - Target configuration {'username': 'root', 'platform': 'linux', 'host': '192.168.0.1', 'ftrace': {'buffsize': 10240, 'events': ['cpu_idle', 'sched_switch']}, 'board': 'juno', 'modules': ['cpufreq', 'cgroups'], 'tftp': {'kernel': 'kern.bin', 'folder': '/var/lib/tftpboot', 'dtb': 'dtb.bin'}, 'password': '', 'tools': ['cpuidle_sampling.sh'], 'results_dir': 'TestEnvExample'}\n",
"04:34:08 INFO : Target - Devlib modules to load: ['bl', 'cpufreq', 'cgroups', 'hwmon']\n",
"04:34:08 INFO : Target - Connecting linux target:\n",
"04:34:08 INFO : Target - username : root\n",
"04:34:08 INFO : Target - host : 192.168.0.1\n",
"04:34:08 INFO : Target - password : \n",
"04:34:08 DEBUG : Target - Setup LINUX target...\n",
"04:34:08 DEBUG : Installing module vexpress-u-boot\n",
"04:34:08 DEBUG : Installing module vexpress-dtr\n",
"04:34:08 DEBUG : Installing module vexpress-vemsd\n",
"04:34:08 DEBUG : Logging in root@192.168.0.1\n",
"04:34:09 DEBUG : id\n",
"04:34:09 DEBUG : if [ -e '/root/devlib-target/bin' ]; then echo 1; else echo 0; fi\n",
"04:34:10 DEBUG : ls -1 /root/devlib-target/bin\n",
"04:34:10 DEBUG : cat /proc/cpuinfo\n",
"04:34:10 DEBUG : sudo -- sh -c 'dmidecode -s system-version'\n",
"04:34:11 DEBUG : Installing module bl\n",
"04:34:11 DEBUG : /root/devlib-target/bin/busybox uname -m\n",
"04:34:11 DEBUG : if [ -e '/sys/devices/system/cpu/cpufreq' ]; then echo 1; else echo 0; fi\n",
"04:34:12 DEBUG : Installing module cpufreq\n",
"04:34:12 DEBUG : zcat /proc/config.gz\n",
"04:34:12 DEBUG : Installing module cgroups\n",
"04:34:12 DEBUG : mount\n",
"04:34:12 DEBUG : cgroup_root already mounted at /sys/fs/cgroup\n",
"04:34:13 DEBUG : /root/devlib-target/bin/busybox cat /proc/cgroups\n",
"04:34:13 DEBUG : Available controllers: ['cpuset', 'cpu', 'schedtune', 'memory', 'devices', 'freezer', 'perf_event', 'hugetlb', 'pids']\n",
"04:34:13 DEBUG : Init cpuset controller...\n",
"04:34:13 DEBUG : /root/devlib-target/bin/busybox grep cpuset /proc/cgroups\n",
"04:34:13 DEBUG : mount\n",
"04:34:14 DEBUG : Controller cpuset mounted under: /sys/fs/cgroup/devlib_cpuset\n",
"04:34:14 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_cpuset\n",
"04:34:14 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_cpuset ] || mkdir -p /sys/fs/cgroup/devlib_cpuset'\n",
"04:34:14 DEBUG : Controller cpuset enabled\n",
"04:34:14 DEBUG : Init cpu controller...\n",
"04:34:14 DEBUG : /root/devlib-target/bin/busybox grep cpu /proc/cgroups\n",
"04:34:15 DEBUG : mount\n",
"04:34:15 DEBUG : Controller cpu mounted under: /sys/fs/cgroup/devlib_cpu\n",
"04:34:15 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_cpu\n",
"04:34:15 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_cpu ] || mkdir -p /sys/fs/cgroup/devlib_cpu'\n",
"04:34:15 DEBUG : Controller cpu enabled\n",
"04:34:15 DEBUG : Init schedtune controller...\n",
"04:34:15 DEBUG : /root/devlib-target/bin/busybox grep schedtune /proc/cgroups\n",
"04:34:16 DEBUG : mount\n",
"04:34:16 DEBUG : Controller schedtune mounted under: /sys/fs/cgroup/devlib_schedtune\n",
"04:34:16 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_schedtune\n",
"04:34:16 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_schedtune ] || mkdir -p /sys/fs/cgroup/devlib_schedtune'\n",
"04:34:17 DEBUG : Controller schedtune enabled\n",
"04:34:17 DEBUG : Init memory controller...\n",
"04:34:17 DEBUG : /root/devlib-target/bin/busybox grep memory /proc/cgroups\n",
"04:34:17 DEBUG : mount\n",
"04:34:17 DEBUG : Controller memory mounted under: /sys/fs/cgroup/devlib_memory\n",
"04:34:17 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_memory\n",
"04:34:18 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_memory ] || mkdir -p /sys/fs/cgroup/devlib_memory'\n",
"04:34:18 DEBUG : Controller memory enabled\n",
"04:34:18 DEBUG : Init devices controller...\n",
"04:34:18 DEBUG : /root/devlib-target/bin/busybox grep devices /proc/cgroups\n",
"04:34:18 DEBUG : mount\n",
"04:34:19 DEBUG : Controller devices mounted under: /sys/fs/cgroup/devlib_devices\n",
"04:34:19 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_devices\n",
"04:34:19 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_devices ] || mkdir -p /sys/fs/cgroup/devlib_devices'\n",
"04:34:19 DEBUG : Controller devices enabled\n",
"04:34:19 DEBUG : Init freezer controller...\n",
"04:34:19 DEBUG : /root/devlib-target/bin/busybox grep freezer /proc/cgroups\n",
"04:34:20 DEBUG : mount\n",
"04:34:20 DEBUG : Controller freezer mounted under: /sys/fs/cgroup/devlib_freezer\n",
"04:34:20 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_freezer\n",
"04:34:20 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_freezer ] || mkdir -p /sys/fs/cgroup/devlib_freezer'\n",
"04:34:20 DEBUG : Controller freezer enabled\n",
"04:34:20 DEBUG : Init perf_event controller...\n",
"04:34:20 DEBUG : /root/devlib-target/bin/busybox grep perf_event /proc/cgroups\n",
"04:34:21 DEBUG : mount\n",
"04:34:21 DEBUG : Controller perf_event mounted under: /sys/fs/cgroup/devlib_perf_event\n",
"04:34:21 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_perf_event\n",
"04:34:21 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_perf_event ] || mkdir -p /sys/fs/cgroup/devlib_perf_event'\n",
"04:34:22 DEBUG : Controller perf_event enabled\n",
"04:34:22 DEBUG : Init hugetlb controller...\n",
"04:34:22 DEBUG : /root/devlib-target/bin/busybox grep hugetlb /proc/cgroups\n",
"04:34:22 DEBUG : mount\n",
"04:34:22 DEBUG : Controller hugetlb mounted under: /sys/fs/cgroup/devlib_hugetlb\n",
"04:34:22 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_hugetlb\n",
"04:34:22 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_hugetlb ] || mkdir -p /sys/fs/cgroup/devlib_hugetlb'\n",
"04:34:23 DEBUG : Controller hugetlb enabled\n",
"04:34:23 DEBUG : Init pids controller...\n",
"04:34:23 DEBUG : /root/devlib-target/bin/busybox grep pids /proc/cgroups\n",
"04:34:23 DEBUG : mount\n",
"04:34:24 DEBUG : Controller pids mounted under: /sys/fs/cgroup/devlib_pids\n",
"04:34:24 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_pids\n",
"04:34:24 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_pids ] || mkdir -p /sys/fs/cgroup/devlib_pids'\n",
"04:34:24 DEBUG : Controller pids enabled\n",
"04:34:24 DEBUG : if [ -e '/sys/class/hwmon' ]; then echo 1; else echo 0; fi\n",
"04:34:24 DEBUG : Installing module hwmon\n",
"04:34:25 DEBUG : ls -1 /sys/class/hwmon\n",
"04:34:25 DEBUG : if [ -e '/sys/class/hwmon/hwmon0/name' ]; then echo 1; else echo 0; fi\n",
"04:34:25 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon0/name'\\'''\n",
"04:34:26 DEBUG : ls -1 /sys/class/hwmon/hwmon0/\n",
"04:34:26 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon0/curr1_label'\\'''\n",
"04:34:27 DEBUG : if [ -e '/sys/class/hwmon/hwmon1/name' ]; then echo 1; else echo 0; fi\n",
"04:34:27 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon1/name'\\'''\n",
"04:34:27 DEBUG : ls -1 /sys/class/hwmon/hwmon1/\n",
"04:34:28 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon1/curr1_label'\\'''\n",
"04:34:28 DEBUG : if [ -e '/sys/class/hwmon/hwmon10/name' ]; then echo 1; else echo 0; fi\n",
"04:34:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon10/name'\\'''\n",
"04:34:29 DEBUG : ls -1 /sys/class/hwmon/hwmon10/\n",
"04:34:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon10/power1_label'\\'''\n",
"04:34:30 DEBUG : if [ -e '/sys/class/hwmon/hwmon11/name' ]; then echo 1; else echo 0; fi\n",
"04:34:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon11/name'\\'''\n",
"04:34:31 DEBUG : ls -1 /sys/class/hwmon/hwmon11/\n",
"04:34:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon11/power1_label'\\'''\n",
"04:34:32 DEBUG : if [ -e '/sys/class/hwmon/hwmon12/name' ]; then echo 1; else echo 0; fi\n",
"04:34:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon12/name'\\'''\n",
"04:34:32 DEBUG : ls -1 /sys/class/hwmon/hwmon12/\n",
"04:34:33 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon12/energy1_label'\\'''\n",
"04:34:33 DEBUG : if [ -e '/sys/class/hwmon/hwmon13/name' ]; then echo 1; else echo 0; fi\n",
"04:34:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/name'\\'''\n",
"04:34:34 DEBUG : ls -1 /sys/class/hwmon/hwmon13/\n",
"04:34:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_label'\\'''\n",
"04:34:35 DEBUG : if [ -e '/sys/class/hwmon/hwmon14/name' ]; then echo 1; else echo 0; fi\n",
"04:34:35 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/name'\\'''\n",
"04:34:36 DEBUG : ls -1 /sys/class/hwmon/hwmon14/\n",
"04:34:36 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_label'\\'''\n",
"04:34:37 DEBUG : if [ -e '/sys/class/hwmon/hwmon15/name' ]; then echo 1; else echo 0; fi\n",
"04:34:37 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon15/name'\\'''\n",
"04:34:37 DEBUG : ls -1 /sys/class/hwmon/hwmon15/\n",
"04:34:38 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon15/energy1_label'\\'''\n",
"04:34:38 DEBUG : if [ -e '/sys/class/hwmon/hwmon16/name' ]; then echo 1; else echo 0; fi\n",
"04:34:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/name'\\'''\n",
"04:34:39 DEBUG : ls -1 /sys/class/hwmon/hwmon16/\n",
"04:34:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in0_label'\\'''\n",
"04:34:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in1_label'\\'''\n",
"04:34:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in2_label'\\'''\n",
"04:34:41 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in3_label'\\'''\n",
"04:34:41 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in4_label'\\'''\n",
"04:34:42 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in5_label'\\'''\n",
"04:34:42 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in6_label'\\'''\n",
"04:34:42 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/temp1_label'\\'''\n",
"04:34:43 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/temp2_label'\\'''\n",
"04:34:43 DEBUG : if [ -e '/sys/class/hwmon/hwmon2/name' ]; then echo 1; else echo 0; fi\n",
"04:34:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon2/name'\\'''\n",
"04:34:44 DEBUG : ls -1 /sys/class/hwmon/hwmon2/\n",
"04:34:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon2/curr1_label'\\'''\n",
"04:34:45 DEBUG : if [ -e '/sys/class/hwmon/hwmon3/name' ]; then echo 1; else echo 0; fi\n",
"04:34:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon3/name'\\'''\n",
"04:34:46 DEBUG : ls -1 /sys/class/hwmon/hwmon3/\n",
"04:34:46 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon3/curr1_label'\\'''\n",
"04:34:47 DEBUG : if [ -e '/sys/class/hwmon/hwmon4/name' ]; then echo 1; else echo 0; fi\n",
"04:34:47 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon4/name'\\'''\n",
"04:34:47 DEBUG : ls -1 /sys/class/hwmon/hwmon4/\n",
"04:34:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon4/in1_label'\\'''\n",
"04:34:48 DEBUG : if [ -e '/sys/class/hwmon/hwmon5/name' ]; then echo 1; else echo 0; fi\n",
"04:34:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon5/name'\\'''\n",
"04:34:49 DEBUG : ls -1 /sys/class/hwmon/hwmon5/\n",
"04:34:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon5/in1_label'\\'''\n",
"04:34:50 DEBUG : if [ -e '/sys/class/hwmon/hwmon6/name' ]; then echo 1; else echo 0; fi\n",
"04:34:50 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon6/name'\\'''\n",
"04:34:51 DEBUG : ls -1 /sys/class/hwmon/hwmon6/\n",
"04:34:51 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon6/in1_label'\\'''\n",
"04:34:52 DEBUG : if [ -e '/sys/class/hwmon/hwmon7/name' ]; then echo 1; else echo 0; fi\n",
"04:34:52 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon7/name'\\'''\n",
"04:34:52 DEBUG : ls -1 /sys/class/hwmon/hwmon7/\n",
"04:34:53 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon7/in1_label'\\'''\n",
"04:34:53 DEBUG : if [ -e '/sys/class/hwmon/hwmon8/name' ]; then echo 1; else echo 0; fi\n",
"04:34:54 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon8/name'\\'''\n",
"04:34:54 DEBUG : ls -1 /sys/class/hwmon/hwmon8/\n",
"04:34:54 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon8/power1_label'\\'''\n",
"04:34:55 DEBUG : if [ -e '/sys/class/hwmon/hwmon9/name' ]; then echo 1; else echo 0; fi\n",
"04:34:55 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon9/name'\\'''\n",
"04:34:56 DEBUG : ls -1 /sys/class/hwmon/hwmon9/\n",
"04:34:56 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon9/power1_label'\\'''\n",
"04:34:56 DEBUG : Target - Checking target connection...\n",
"04:34:56 DEBUG : Target - Target info:\n",
"04:34:56 DEBUG : Target - ABI: arm64\n",
"04:34:56 DEBUG : Target - CPUs: CpuInfo(['A53', 'A57', 'A57', 'A53', 'A53', 'A53'])\n",
"04:34:56 DEBUG : Target - Clusters: [0, 1, 1, 0, 0, 0]\n",
"04:34:57 DEBUG : sudo -- sh -c 'mount -o remount,rw /'\n",
"04:34:57 INFO : Target - Initializing target workdir:\n",
"04:34:57 INFO : Target - /root/devlib-target\n",
"04:34:57 DEBUG : mkdir -p /root/devlib-target\n",
"04:34:57 DEBUG : mkdir -p /root/devlib-target/bin\n",
"04:34:58 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",
"04:34:58 DEBUG : chmod a+x /root/devlib-target/bin/busybox\n",
"04:34:58 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",
"04:34:58 DEBUG : chmod a+x /root/devlib-target/bin/shutils\n",
"04:34:59 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/scripts/cpuidle_sampling.sh root@192.168.0.1:/root/devlib-target/bin/cpuidle_sampling.sh\n",
"04:34:59 DEBUG : chmod a+x /root/devlib-target/bin/cpuidle_sampling.sh\n",
"04:34:59 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",
"04:34:59 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n",
"04:35:00 DEBUG : Target - Check for module [bl]...\n",
"04:35:00 DEBUG : Target - Check for module [cpufreq]...\n",
"04:35:00 DEBUG : Target - Check for module [cgroups]...\n",
"04:35:00 DEBUG : Target - Check for module [hwmon]...\n",
"04:35:00 INFO : Target - Topology:\n",
"04:35:00 INFO : Target - [[0, 3, 4, 5], [1, 2]]\n",
"04:35:00 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"04:35:00 DEBUG : cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n",
"04:35:01 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"04:35:01 DEBUG : cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies\n",
"04:35:01 DEBUG : Platform - Trying to load default EM from /home/derkling/Code/lisa/libs/utils/platforms/juno.json\n",
"04:35:01 INFO : Platform - Loading default EM:\n",
"04:35:01 INFO : Platform - /home/derkling/Code/lisa/libs/utils/platforms/juno.json\n",
"04:35:01 DEBUG : loading JSON...\n",
"04:35:01 DEBUG : Loaded JSON configuration:\n",
"{u'nrg_model': {u'big': {u'cluster': {u'nrg_max': 64}, u'cpu': {u'cap_max': 1024, u'nrg_max': 616}}, u'little': {u'cluster': {u'nrg_max': 57}, u'cpu': {u'cap_max': 447, u'nrg_max': 93}}}}\n",
"04:35:01 DEBUG : Platform - Platform descriptor initialized\n",
"{'nrg_model': {u'big': {u'cluster': {u'nrg_max': 64}, u'cpu': {u'cap_max': 1024, u'nrg_max': 616}}, u'little': {u'cluster': {u'nrg_max': 57}, u'cpu': {u'cap_max': 447, u'nrg_max': 93}}}, 'clusters': {'big': [1, 2], 'little': [0, 3, 4, 5]}, 'cpus_count': 6, 'freqs': {'big': [450000, 625000, 800000, 950000, 1100000], 'little': [450000, 575000, 700000, 775000, 850000]}, 'topology': [[0, 3, 4, 5], [1, 2]]}\n",
"04:35:01 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",
"04:35:02 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n",
"04:35:02 DEBUG : cat /sys/kernel/debug/tracing/available_events\n",
"04:35:02 INFO : FTrace - Enabled tracepoints:\n",
"04:35:02 INFO : FTrace - cpu_idle\n",
"04:35:02 INFO : FTrace - sched_switch\n",
"04:35:02 DEBUG : EnergyMeter - using default energy meter for [juno]\n",
"04:35:02 INFO : EnergyMeter - Scanning for HWMON channels, may take some time...\n",
"04:35:02 DEBUG : Discovering available HWMON sensors...\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_amp/curr1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_amp/curr1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_power/power1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_power/power1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_energy/energy1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_energy/energy1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_energy/energy1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_energy/energy1\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/temp1\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/temp2\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/in0\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/in1\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/in2\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/in3\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/in4\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/in5\n",
"04:35:02 DEBUG : \tAdding sensor scpi_sensors/in6\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_amp/curr1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_amp/curr1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_volt/in1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_volt/in1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_volt/in1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_volt/in1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_power/power1\n",
"04:35:02 DEBUG : \tAdding sensor v2m_juno_power/power1\n",
"04:35:02 DEBUG : EnergyMeter - Enabling channels {'kinds': ['energy'], 'sites': ['a53', 'a57']}\n",
"04:35:02 INFO : EnergyMeter - Channels selected for energy sampling:\n",
"04:35:02 INFO : EnergyMeter - a57_energy\n",
"04:35:03 INFO : EnergyMeter - a53_energy\n",
"04:35:03 DEBUG : No RT-App workloads, skipping calibration\n",
"04:35:03 WARNING : TestEnv - Wipe previous contents of the results folder:\n",
"04:35:03 WARNING : TestEnv - /home/derkling/Code/lisa/results/TestEnvExample\n",
"04:35:03 INFO : TestEnv - Set results folder to:\n",
"04:35:03 INFO : TestEnv - /home/derkling/Code/lisa/results/TestEnvExample\n",
"04:35:03 INFO : TestEnv - Experiment results available also in:\n",
"04:35:03 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": 9,
"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",
" \"host\": \"192.168.0.1\", \n",
" \"password\": \"\", \n",
" \"tools\": [\n",
" \"cpuidle_sampling.sh\", \n",
" \"trace-cmd\"\n",
" ], \n",
" \"modules\": [\n",
" \"cpufreq\", \n",
" \"cgroups\"\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": 10,
"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": 11,
"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": 12,
"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": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'/home/derkling/Code/lisa/results/TestEnvExample'"
]
},
"execution_count": 13,
"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": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'/data/local/schedtest'"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# The working directory on the target\n",
"te.workdir"
]
},
{
"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": 15,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:27:32 DEBUG : No RT-App workloads, skipping calibration\n"
]
}
],
"source": [
"# Calibrate RT-App (if required) and get the most updated calibration value\n",
"te.calibration()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:27:32 DEBUG : Platform - Dump platform descriptor in [/tmp/platform.json]\n"
]
},
{
"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": 16,
"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": 17,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [],
"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": 18,
"metadata": {
"collapsed": false
},
"outputs": [],
"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": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:27:33 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": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 12\r\n",
"drwxrwxrwx 2 root nogroup 4096 Feb 22 17:34 .\r\n",
"drwxr-xr-x 79 root root 4096 Feb 26 15:17 ..\r\n",
"-rw-r--r-- 1 derkling derkling 1168 Mar 2 16:27 group\r\n"
]
}
],
"source": [
"!ls -la /var/lib/tftpboot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Access to the devlib API"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A special TestEnv attribute is <b>target</b>, which represents a <b>devlib instance</b>.\n",
"Using the target attribute we can access to the full set of devlib provided\n",
"functionalities. Which are summarized in the following sections."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Remotes commands execution"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:27:34 DEBUG : echo -n 'Hello Test Environment'\n"
]
},
{
"data": {
"text/plain": [
"'Hello Test Environment'"
]
},
"execution_count": 22,
"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": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:27:34 INFO : Spawn a task which will run for a while...\n",
"04:27:35 DEBUG : sudo -- sh -c 'sh -c \"sleep 10\" 1>/dev/null 2>/dev/null &'\n"
]
}
],
"source": [
"# Spawn a command in background on the target\n",
"logging.info(\"Spawn a task which will run for a while...\")\n",
"process = te.target.kick_off(\"sleep 10\", as_root=True)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:27:35 DEBUG : ps\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" PID TTY TIME CMD\n",
" 6097 pts/0 00:00:00 sh\n",
" 6270 pts/0 00:00:00 sleep\n",
" 6271 pts/0 00:00:00 ps\n"
]
}
],
"source": [
"output = te.target.execute(\"ps\")\n",
"print '\\n'.join(output.splitlines())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notice that _the Shell PID is always the same_ for all commands we execute.<br>\n",
"This is due to devlib ensuring to keep a **persistent connection** with the target device."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Running custom scripts"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:28:18 DEBUG : if [ -e '/root/devlib-target/bin' ]; then echo 1; else echo 0; fi\n",
"04:28:18 DEBUG : ls -1 /root/devlib-target/bin\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"/root/devlib-target/bin/cpuidle_sampling.sh\n"
]
}
],
"source": [
"my_script = te.target.get_installed(\"cpuidle_sampling.sh\")\n",
"print my_script"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:28:19 DEBUG : sudo -- sh -c '/root/devlib-target/bin/cpuidle_sampling.sh'\n"
]
},
{
"data": {
"text/plain": [
"['# Time idle0 idle1 idle2 ',\n",
" ' 1456934283 0 11 19 ',\n",
" ' 1456934284 0 5 17 ',\n",
" ' 1456934285 0 5 19 ']"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"output = te.target.execute(my_script, as_root=True)\n",
"output.splitlines()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notice that the output is returned as a **list of lines**. This provides a useful base for post-processing the output of that command."
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"code_folding": [],
"collapsed": false
},
"outputs": [],
"source": [
"# We can also use \"notebook embedded\" scripts\n",
"# my_script = \" \\\n",
"# for I in $(seq 3); do \\\n",
"# grep '' /sys/devices/system/cpu/cpu*/cpufreq/stats/time_in_stats | \\\n",
"# sed -e 's|/sys/devices/system/cpu/cpu||' -e 's|/cpufreq/scaling_governor:| |' \\\n",
"# sleep 1 \\\n",
"# done \\\n",
"# \""
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# print te.target.execute(my_script)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Access to target specific attributes"
]
},
{
"cell_type": "code",
"execution_count": 9,
"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": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:35:03 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"04:35: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": [
"04:35:04 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n",
"04:35: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": [
"## Modules usage example: CPUFreq"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:36:33 DEBUG : sudo -- sh -c '/root/devlib-target/bin/shutils cpufreq_get_all_governors'\n"
]
},
{
"data": {
"text/plain": [
"{'0': 'performance',\n",
" '1': 'performance',\n",
" '2': 'performance',\n",
" '3': 'performance',\n",
" '4': 'performance',\n",
" '5': 'performance'}"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# You can use autocompletion to have a look at the supported method for a\n",
"# specific module\n",
"te.target.cpufreq #.get_all_governors()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:39:00 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors'\\'''\n"
]
},
{
"data": {
"text/plain": [
"['conservative', 'ondemand', 'userspace', 'powersave', 'performance', 'sched']"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get goverors available for CPU0\n",
"te.target.cpufreq.list_governors(0)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:40:04 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors'\\'''\n",
"04:40:04 DEBUG : sudo -- sh -c 'echo ondemand > '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:40:05 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:40:05 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:40:06 DEBUG : ls -1 /sys/devices/system/cpu/cpu0/cpufreq/ondemand\n"
]
}
],
"source": [
"# Set the \"ondemand\" governor\n",
"te.target.cpufreq.set_governor(0, 'ondemand')"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:40:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:40:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:40:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load'\\'''\n",
"04:40:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/io_is_busy'\\'''\n",
"04:40:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias'\\'''\n",
"04:40:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_down_factor'\\'''\n",
"04:40:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'\\'''\n",
"04:40:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate_min'\\'''\n",
"04:40:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold'\\'''\n"
]
},
{
"data": {
"text/plain": [
"{'ignore_nice_load': '0',\n",
" 'io_is_busy': '0',\n",
" 'powersave_bias': '0',\n",
" 'sampling_down_factor': '1',\n",
" 'sampling_rate': '1200000',\n",
" 'sampling_rate_min': '24000',\n",
" 'up_threshold': '95'}"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Check governor tunables\n",
"te.target.cpufreq.get_governor_tunables(0)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:41:46 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:41:46 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:41:47 DEBUG : sudo -- sh -c 'echo 2000000 > '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'\\'''\n",
"04:41:47 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'\\'''\n",
"04:41:47 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:41:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n",
"04:41:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load'\\'''\n",
"04:41:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/io_is_busy'\\'''\n",
"04:41:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias'\\'''\n",
"04:41:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_down_factor'\\'''\n",
"04:41:50 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'\\'''\n",
"04:41:50 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate_min'\\'''\n",
"04:41:51 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold'\\'''\n"
]
},
{
"data": {
"text/plain": [
"{'ignore_nice_load': '0',\n",
" 'io_is_busy': '0',\n",
" 'powersave_bias': '0',\n",
" 'sampling_down_factor': '1',\n",
" 'sampling_rate': '2000000',\n",
" 'sampling_rate_min': '24000',\n",
" 'up_threshold': '95'}"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Update governor tunables\n",
"te.target.cpufreq.set_governor_tunables(0, sampling_rate=2000000)\n",
"te.target.cpufreq.get_governor_tunables(0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Modules usage example: CGroups"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:51:18 INFO : CGroup - Available controllers:\n",
"04:51:18 DEBUG : /root/devlib-target/bin/busybox cat /proc/cgroups\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cpuset (hierarchy id: 1) has 2 cgroups\n",
"cpu (hierarchy id: 2) has 1 cgroups\n",
"schedtune (hierarchy id: 3) has 1 cgroups\n",
"memory (hierarchy id: 4) has 1 cgroups\n",
"devices (hierarchy id: 5) has 1 cgroups\n",
"freezer (hierarchy id: 6) has 1 cgroups\n",
"perf_event (hierarchy id: 7) has 1 cgroups\n",
"hugetlb (hierarchy id: 8) has 1 cgroups\n",
"pids (hierarchy id: 9) has 1 cgroups\n"
]
}
],
"source": [
"logging.info('%14s - Available controllers:', 'CGroup')\n",
"ssys = target.cgroups.list_subsystems()\n",
"for (n,h,g,e) in ssys:\n",
" print '{:10} (hierarchy id: {:d}) has {} cgroups'.format(n, h, g)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Get a reference to the CPUSet controller\n",
"cpuset = target.cgroups.controller('cpuset')"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:51:42 DEBUG : Listing groups for cpuset controller\n",
"04:51:43 DEBUG : /root/devlib-target/bin/busybox find /sys/fs/cgroup/devlib_cpuset -type d\n",
"04:51:43 DEBUG : Populate cpuset cgroup: /\n",
"04:51:43 DEBUG : Populate cpuset cgroup: /LITTLE\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Existing CGropups:\n",
" /\n",
" /LITTLE\n"
]
}
],
"source": [
"# Get the list of current configured CGroups for that controller\n",
"cgroups = cpuset.list_all()\n",
"print 'Existing CGropups:'\n",
"for cg in cgroups:\n",
" print \" \", cg"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:45:15 DEBUG : Reading cpuset attributes from:\n",
"04:45:15 DEBUG : /sys/fs/cgroup/devlib_cpuset/LITTLE\n",
"04:45:15 DEBUG : /root/devlib-target/bin/shutils cgroups_get_attributes /sys/fs/cgroup/devlib_cpuset/LITTLE cpuset\n"
]
},
{
"data": {
"text/plain": [
"{'cpu_exclusive': '0',\n",
" 'cpus': '',\n",
" 'effective_cpus': '',\n",
" 'effective_mems': '',\n",
" 'mem_exclusive': '0',\n",
" 'mem_hardwall': '0',\n",
" 'memory_migrate': '0',\n",
" 'memory_pressure': '0',\n",
" 'memory_spread_page': '0',\n",
" 'memory_spread_slab': '0',\n",
" 'mems': '',\n",
" 'sched_load_balance': '1',\n",
" 'sched_relax_domain_level': '-1'}"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create a LITTLE partition and check which tunables we have\n",
"cpuset_littles = cpuset.cgroup('/LITTLE')\n",
"cpuset_littles.get()"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:47:33 DEBUG : Set attribute [/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.cpus] to: 0,3-5\"\n",
"04:47:33 DEBUG : sudo -- sh -c 'echo 0,3-5 > '\\''/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.cpus'\\'''\n",
"04:47:33 DEBUG : sudo -- sh -c 'cat '\\''/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.cpus'\\'''\n",
"04:47:34 DEBUG : Set attribute [/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.mems] to: 0\"\n",
"04:47:34 DEBUG : sudo -- sh -c 'echo 0 > '\\''/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.mems'\\'''\n",
"04:47:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.mems'\\'''\n"
]
}
],
"source": [
"# Setup CPUs and MEMORY nodes for the LITTLE partition\n",
"cpuset_littles.set(cpus=te.target.bl.littles, mems=0)"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:52:55 DEBUG : Reading cpuset attributes from:\n",
"04:52:55 DEBUG : /sys/fs/cgroup/devlib_cpuset\n",
"04:52:55 DEBUG : /root/devlib-target/bin/shutils cgroups_get_attributes /sys/fs/cgroup/devlib_cpuset cpuset\n",
"04:52:55 DEBUG : Reading cpuset attributes from:\n",
"04:52:55 DEBUG : /sys/fs/cgroup/devlib_cpuset/LITTLE\n",
"04:52:55 DEBUG : /root/devlib-target/bin/shutils cgroups_get_attributes /sys/fs/cgroup/devlib_cpuset/LITTLE cpuset\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cpuset:/ cpus: 0-5\n",
"cpuset:/LITTLE cpus: 0,3-5\n"
]
}
],
"source": [
"# Dump the configuraiton of each controller\n",
"for cgname in cgroups:\n",
" cgroup = cpuset.cgroup(cgname)\n",
" attrs = cgroup.get()\n",
" cpus = attrs['cpus']\n",
" print '{}:{:<15} cpus: {}'.format(cpuset.kind, cgroup.name, cpus)"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Methods exists to move tasks in/out and in between groups\n",
"# cpuset_littles.add_task()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sample energy from the target"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"03:02:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"03:02:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"03:02:39 DEBUG : SAMPLE: {'a53': {'total': 10.111351999999897, 'last': 1335.646094, 'delta': 9.059672999999975}, 'a57': {'total': 15.980763000000024, 'last': 2052.693486, 'delta': 13.449973000000227}}\n",
"03:02:39 DEBUG : RESET: {'a53': {'total': 0, 'last': 1335.646094, 'delta': 0}, 'a57': {'total': 0, 'last': 2052.693486, 'delta': 0}}\n",
"03:02:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"03:02:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"03:02:40 DEBUG : SAMPLE: {'a53': {'total': 0.3706250000000182, 'last': 1336.016719, 'delta': 0.3706250000000182}, 'a57': {'total': 0.49970399999983783, 'last': 2053.19319, 'delta': 0.49970399999983783}}\n",
"03:02:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"03:02:41 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"03:02:41 DEBUG : SAMPLE: {'a53': {'total': 0.7240460000000439, 'last': 1336.37014, 'delta': 0.35342100000002574}, 'a57': {'total': 0.9984340000000884, 'last': 2053.69192, 'delta': 0.4987300000002506}}\n",
"03:02:43 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"03:02:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"03:02:44 DEBUG : SAMPLE: {'a53': {'total': 1.2472549999999956, 'last': 1336.893349, 'delta': 0.5232089999999516}, 'a57': {'total': 1.9705329999997048, 'last': 2054.664019, 'delta': 0.9720989999996164}}\n",
"03:02:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n",
"03:02:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n",
"03:02:45 DEBUG : SAMPLE: {'a53': {'total': 1.4408379999999852, 'last': 1337.086932, 'delta': 0.19358299999998962}, 'a57': {'total': 2.4585919999999533, 'last': 2055.152078, 'delta': 0.4880590000002485}}\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"First read: {\n",
" \"a53\": {\n",
" \"total\": 0.7240460000000439, \n",
" \"last\": 1336.37014, \n",
" \"delta\": 0.35342100000002574\n",
" }, \n",
" \"a57\": {\n",
" \"total\": 0.9984340000000884, \n",
" \"last\": 2053.69192, \n",
" \"delta\": 0.4987300000002506\n",
" }\n",
"}\n",
"Second read: {\n",
" \"a53\": {\n",
" \"total\": 1.4408379999999852, \n",
" \"last\": 1337.086932, \n",
" \"delta\": 0.19358299999998962\n",
" }, \n",
" \"a57\": {\n",
" \"total\": 2.4585919999999533, \n",
" \"last\": 2055.152078, \n",
" \"delta\": 0.4880590000002485\n",
" }\n",
"}\n"
]
}
],
"source": [
"# Reset and sample energy counters\n",
"te.emeter.reset()\n",
"\n",
"# Sleep some time\n",
"time.sleep(2)\n",
"\n",
"# Sample energy consumption since last reset\n",
"nrg = te.emeter.sample()\n",
"nrg = json.dumps(te.emeter.sample(), indent=4)\n",
"print \"First read: \", nrg\n",
"\n",
"# Sleep some more time\n",
"time.sleep(2)\n",
"\n",
"# Sample again\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": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"02:59:43 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",
"02:59:44 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n",
"02:59:44 DEBUG : cat /sys/kernel/debug/tracing/available_events\n",
"02:59:44 INFO : FTrace - Enabled tracepoints:\n",
"02:59:44 INFO : FTrace - cpu_idle\n",
"02:59:44 INFO : FTrace - cpu_capacity\n",
"02:59:44 INFO : FTrace - cpu_frequency\n",
"02:59:44 INFO : FTrace - sched_switch\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": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"02:59:45 DEBUG : sudo -- sh -c 'echo 10240 > '\\''/sys/kernel/debug/tracing/buffer_size_kb'\\'''\n",
"02:59:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/kernel/debug/tracing/buffer_size_kb'\\'''\n",
"02:59:45 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd reset'\n",
"02:59:46 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd start -e cpu_idle -e cpu_capacity -e cpu_frequency -e sched_switch'\n",
"02:59:48 DEBUG : sudo -- sh -c 'echo TRACE_MARKER_START > '\\''/sys/kernel/debug/tracing/trace_marker'\\'''\n",
"02:59:48 DEBUG : Trace CPUFreq frequencies\n",
"02:59:48 DEBUG : sudo -- sh -c '/root/devlib-target/bin/shutils cpufreq_trace_all_frequencies'\n",
"02:59:48 DEBUG : uname -a\n",
"02:59:49 DEBUG : Trace CPUFreq frequencies\n",
"02:59:49 DEBUG : sudo -- sh -c '/root/devlib-target/bin/shutils cpufreq_trace_all_frequencies'\n",
"02:59:49 DEBUG : sudo -- sh -c 'echo TRACE_MARKER_STOP > '\\''/sys/kernel/debug/tracing/trace_marker'\\'''\n",
"02:59:49 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": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"02:59:50 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd extract -o /root/devlib-target/trace.dat'\n",
"02:59:51 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
}