1 { 2 "cells": [ 3 { 4 "cell_type": "markdown", 5 "metadata": {}, 6 "source": [ 7 "# Tutorial goal" 8 ] 9 }, 10 { 11 "cell_type": "markdown", 12 "metadata": {}, 13 "source": [ 14 "This tutorial aims to show how to **configure** a **test environment** using\n", 15 "the **TestEnv module** provided by LISA." 16 ] 17 }, 18 { 19 "cell_type": "markdown", 20 "metadata": {}, 21 "source": [ 22 "# Configure logging" 23 ] 24 }, 25 { 26 "cell_type": "code", 27 "execution_count": 1, 28 "metadata": { 29 "collapsed": true 30 }, 31 "outputs": [], 32 "source": [ 33 "import logging\n", 34 "from conf import LisaLogging\n", 35 "LisaLogging.setup()" 36 ] 37 }, 38 { 39 "cell_type": "code", 40 "execution_count": 2, 41 "metadata": { 42 "collapsed": true 43 }, 44 "outputs": [], 45 "source": [ 46 "# Execute this cell to enabled devlib debugging statements\n", 47 "logging.getLogger('ssh').setLevel(logging.DEBUG)" 48 ] 49 }, 50 { 51 "cell_type": "code", 52 "execution_count": 3, 53 "metadata": { 54 "collapsed": false 55 }, 56 "outputs": [], 57 "source": [ 58 "# Other python modules required by this notebook\n", 59 "import json\n", 60 "import time\n", 61 "import os" 62 ] 63 }, 64 { 65 "cell_type": "markdown", 66 "metadata": {}, 67 "source": [ 68 "# Test environment setup" 69 ] 70 }, 71 { 72 "cell_type": "markdown", 73 "metadata": {}, 74 "source": [ 75 "## Do you have custom scripts to deploy and use on target?" 76 ] 77 }, 78 { 79 "cell_type": "code", 80 "execution_count": 4, 81 "metadata": { 82 "collapsed": false 83 }, 84 "outputs": [ 85 { 86 "name": "stdout", 87 "output_type": "stream", 88 "text": [ 89 "\u001b[01;34m../../tools\u001b[00m\r\n", 90 " \u001b[01;34marm64\u001b[00m\r\n", 91 " \u001b[01;32mperf\u001b[00m\r\n", 92 " \u001b[01;32mrt-app\u001b[00m\r\n", 93 " \u001b[01;32mtaskset\u001b[00m\r\n", 94 " \u001b[01;32mtrace-cmd\u001b[00m\r\n", 95 " \u001b[01;34marmeabi\u001b[00m\r\n", 96 " \u001b[01;32mbusybox\u001b[00m\r\n", 97 " \u001b[01;32mdaemonize\u001b[00m\r\n", 98 " htop\r\n", 99 " htop.armv7\r\n", 100 " \u001b[01;32mperf\u001b[00m\r\n", 101 " \u001b[01;32mrt-app\u001b[00m\r\n", 102 " \u001b[01;32msysbench\u001b[00m\r\n", 103 " \u001b[01;32mtaskset\u001b[00m\r\n", 104 " \u001b[01;31mterminfo.tar.bz2\u001b[00m\r\n", 105 " \u001b[01;32mtrace-cmd\u001b[00m\r\n", 106 " LICENSE.busybox\r\n", 107 " LICENSE.perf\r\n", 108 " LICENSE.rt-app\r\n", 109 " LICENSE.taskset\r\n", 110 " LICENSE.trace-cmd\r\n", 111 " \u001b[01;32mplots.py\u001b[00m\r\n", 112 " \u001b[01;32mreport.py\u001b[00m\r\n", 113 " report.pyc\r\n", 114 " \u001b[01;34mscripts\u001b[00m\r\n", 115 " \u001b[01;32mcgroup_run_into.sh\u001b[00m\r\n", 116 " \u001b[01;32mcgroup_tasks_move.sh\u001b[00m\r\n", 117 " \u001b[01;32mcpuidle_sampling.sh\u001b[00m\r\n", 118 " \u001b[01;32modroid_sampler.py\u001b[00m\r\n", 119 " \u001b[01;32modroid_sampler.sh\u001b[00m\r\n", 120 " \u001b[01;32mtrace_frequencies.sh\u001b[00m\r\n", 121 " \u001b[01;32mtraceview_extract.awk\u001b[00m\r\n", 122 " \u001b[01;34mx86\u001b[00m\r\n", 123 " \u001b[01;32mbusybox\u001b[00m\r\n", 124 " \u001b[01;32mchrt\u001b[00m\r\n", 125 " \u001b[01;34mx86_64\u001b[00m\r\n", 126 " \u001b[01;32mbusybox\u001b[00m\r\n", 127 " \u001b[01;32mchrt\u001b[00m\r\n", 128 " \u001b[01;32mperf\u001b[00m\r\n", 129 " \u001b[01;32mrt-app\u001b[00m\r\n", 130 " \u001b[01;32mtaskset\u001b[00m\r\n", 131 " \u001b[01;32mtrace-cmd\u001b[00m\r\n", 132 " \u001b[01;32mwlg\u001b[00m\r\n", 133 "\r\n", 134 "5 directories, 38 files\r\n" 135 ] 136 } 137 ], 138 "source": [ 139 "# Custom scrips must be deployed under $LISA_HOME/tools\n", 140 "!tree ../../tools" 141 ] 142 }, 143 { 144 "cell_type": "code", 145 "execution_count": 5, 146 "metadata": { 147 "collapsed": false 148 }, 149 "outputs": [ 150 { 151 "name": "stdout", 152 "output_type": "stream", 153 "text": [ 154 "#!/bin/bash\r\n", 155 "\r\n", 156 "# CPU to monitor\r\n", 157 "CPU=${1:-0}\r\n", 158 "# Sampling time\r\n", 159 "SLEEP=${2:-1}\r\n", 160 "# Samples to collect\r\n", 161 "COUNT=${3:-3}\r\n", 162 "\r\n", 163 "# Enter CPU's sysfs\r\n", 164 "cd /sys/devices/system/cpu\r\n", 165 "\r\n", 166 "# Initial C-State residencies counter\r\n", 167 "ISC=$(find cpu0/cpuidle -name \"state*\" | wc -l)\r\n", 168 "for I in $(seq 0 $((ISC-1))); do\r\n", 169 "\tLCS[$I]=`cat cpu$CPU/cpuidle/state$I/usage`\r\n", 170 "done\r\n", 171 "\r\n", 172 "# Dump header\r\n", 173 "printf \"#%13s \" \"Time\"\r\n", 174 "for I in $(seq 0 $((ISC-1))); do\r\n", 175 " printf \"%14s \" \"idle$I\"\r\n", 176 "done\r\n", 177 "echo\r\n", 178 "\r\n", 179 "# Sampling loop\r\n", 180 "for I in $(seq $COUNT); do\r\n", 181 "\r\n", 182 "\tsleep $SLEEP\r\n", 183 "\r\n", 184 "\t# Dump CPU C-State residencies\r\n", 185 "\tnow=$(date +%s)\r\n", 186 "\tprintf \"%14d \" $now\r\n", 187 "\tfor I in $(seq 0 $((ISC-1))); do\r\n", 188 "\t\tU=`cat cpu$CPU/cpuidle/state$I/usage`\r\n", 189 "\t\tCCS=$(($U - ${LCS[$I]}))\r\n", 190 "\t\tprintf \"%14d \" $CCS\r\n", 191 "\t\tLCS[$I]=$U\r\n", 192 "\tdone\r\n", 193 "\techo\r\n", 194 "\r\n", 195 "\r\n", 196 "done\r\n", 197 "\r\n", 198 "# vim: ts=2\r\n" 199 ] 200 } 201 ], 202 "source": [ 203 "# This is the (not so fancy) script we want to deploy\n", 204 "!cat ../../tools/scripts/cpuidle_sampling.sh" 205 ] 206 }, 207 { 208 "cell_type": "markdown", 209 "metadata": {}, 210 "source": [ 211 "## Which devlib modules you need for your experiments?" 212 ] 213 }, 214 { 215 "cell_type": "code", 216 "execution_count": 6, 217 "metadata": { 218 "collapsed": false 219 }, 220 "outputs": [ 221 { 222 "name": "stderr", 223 "output_type": "stream", 224 "text": [ 225 "04:34:06 INFO : Devlib provided modules are found under:\n", 226 "04:34:06 INFO : $LISA_HOME/libs/devlib/devlib/module/\n" 227 ] 228 }, 229 { 230 "name": "stdout", 231 "output_type": "stream", 232 "text": [ 233 " thermal.py\r\n", 234 " vexpress.py\r\n", 235 " cooling.py\r\n", 236 " android.py\r\n", 237 " biglittle.py\r\n", 238 " cpuidle.py\r\n", 239 " hotplug.py\r\n", 240 " cpufreq.py\r\n", 241 " hwmon.py\r\n", 242 " cgroups.py\r\n" 243 ] 244 } 245 ], 246 "source": [ 247 "# You can have a look at the devlib supported modules by lising the\n", 248 "devlib_modules_folder = 'libs/devlib/devlib/module/'\n", 249 "\n", 250 "logging.info(\"Devlib provided modules are found under:\")\n", 251 "logging.info(\" $LISA_HOME/{}\".format(devlib_modules_folder))\n", 252 "!cd ../../ ; find {devlib_modules_folder} -name \"*.py\" | sed 's|libs/devlib/devlib/module/| |' | grep -v __init__ " 253 ] 254 }, 255 { 256 "cell_type": "markdown", 257 "metadata": {}, 258 "source": [ 259 "## Setup you TestEnv confguration" 260 ] 261 }, 262 { 263 "cell_type": "code", 264 "execution_count": 7, 265 "metadata": { 266 "collapsed": false 267 }, 268 "outputs": [], 269 "source": [ 270 "# Setup a target configuration\n", 271 "conf = {\n", 272 "\n", 273 " # Define the kind of target platform to use for the experiments\n", 274 " \"platform\" : 'linux', # platform type, valid other options are:\n", 275 " # android - access via ADB\n", 276 " # linux - access via SSH\n", 277 " # host - direct access\n", 278 " \n", 279 " # Preload settings for a specific target\n", 280 " \"board\" : 'juno', # board type, valid options are:\n", 281 " # - juno - JUNO Development Board\n", 282 " # - tc2 - TC2 Development Board\n", 283 "\n", 284 " # Login credentials\n", 285 " \"host\" : \"192.168.0.1\",\n", 286 " \"username\" : \"root\",\n", 287 " \"password\" : \"\",\n", 288 "\n", 289 " # Custom tools to deploy on target, they must be placed under:\n", 290 " # $LISA_HOME/tools/(ARCH|scripts)\n", 291 " \"tools\" : [ \"cpuidle_sampling.sh\" ],\n", 292 "\n", 293 " # FTrace configuration\n", 294 " \"ftrace\" : {\n", 295 " \"events\" : [\n", 296 " \"cpu_idle\",\n", 297 " \"sched_switch\",\n", 298 " ],\n", 299 " \"buffsize\" : 10240,\n", 300 " },\n", 301 " \n", 302 " # Where results are collected\n", 303 " \"results_dir\" : \"TestEnvExample\",\n", 304 " \n", 305 " # Devlib module required (or not required)\n", 306 " 'modules' : [ \"cpufreq\", \"cgroups\" ],\n", 307 " #\"exclude_modules\" : [ \"hwmon\" ],\n", 308 " \n", 309 " # Local installation path used for kernel/dtb installation on target\n", 310 " # The specified path MUST be accessible from the board, e.g.\n", 311 " # - JUNO/TC2: it can be the mount path of the VMESD disk image\n", 312 " # - Other board: it can be a TFTP server path used by the board bootloader\n", 313 " \"tftp\" : {\n", 314 " \"folder\" : \"/var/lib/tftpboot\",\n", 315 " \"kernel\" : \"kern.bin\",\n", 316 " \"dtb\" : \"dtb.bin\",\n", 317 " },\n", 318 "\n", 319 "}" 320 ] 321 }, 322 { 323 "cell_type": "code", 324 "execution_count": 8, 325 "metadata": { 326 "collapsed": false, 327 "scrolled": true 328 }, 329 "outputs": [ 330 { 331 "name": "stderr", 332 "output_type": "stream", 333 "text": [ 334 "04:34:08 INFO : Target - Using base path: /home/derkling/Code/lisa\n", 335 "04:34:08 INFO : Target - Loading custom (inline) target configuration\n", 336 "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", 337 "04:34:08 INFO : Target - Devlib modules to load: ['bl', 'cpufreq', 'cgroups', 'hwmon']\n", 338 "04:34:08 INFO : Target - Connecting linux target:\n", 339 "04:34:08 INFO : Target - username : root\n", 340 "04:34:08 INFO : Target - host : 192.168.0.1\n", 341 "04:34:08 INFO : Target - password : \n", 342 "04:34:08 DEBUG : Target - Setup LINUX target...\n", 343 "04:34:08 DEBUG : Installing module vexpress-u-boot\n", 344 "04:34:08 DEBUG : Installing module vexpress-dtr\n", 345 "04:34:08 DEBUG : Installing module vexpress-vemsd\n", 346 "04:34:08 DEBUG : Logging in root (a] 192.168.0.1\n", 347 "04:34:09 DEBUG : id\n", 348 "04:34:09 DEBUG : if [ -e '/root/devlib-target/bin' ]; then echo 1; else echo 0; fi\n", 349 "04:34:10 DEBUG : ls -1 /root/devlib-target/bin\n", 350 "04:34:10 DEBUG : cat /proc/cpuinfo\n", 351 "04:34:10 DEBUG : sudo -- sh -c 'dmidecode -s system-version'\n", 352 "04:34:11 DEBUG : Installing module bl\n", 353 "04:34:11 DEBUG : /root/devlib-target/bin/busybox uname -m\n", 354 "04:34:11 DEBUG : if [ -e '/sys/devices/system/cpu/cpufreq' ]; then echo 1; else echo 0; fi\n", 355 "04:34:12 DEBUG : Installing module cpufreq\n", 356 "04:34:12 DEBUG : zcat /proc/config.gz\n", 357 "04:34:12 DEBUG : Installing module cgroups\n", 358 "04:34:12 DEBUG : mount\n", 359 "04:34:12 DEBUG : cgroup_root already mounted at /sys/fs/cgroup\n", 360 "04:34:13 DEBUG : /root/devlib-target/bin/busybox cat /proc/cgroups\n", 361 "04:34:13 DEBUG : Available controllers: ['cpuset', 'cpu', 'schedtune', 'memory', 'devices', 'freezer', 'perf_event', 'hugetlb', 'pids']\n", 362 "04:34:13 DEBUG : Init cpuset controller...\n", 363 "04:34:13 DEBUG : /root/devlib-target/bin/busybox grep cpuset /proc/cgroups\n", 364 "04:34:13 DEBUG : mount\n", 365 "04:34:14 DEBUG : Controller cpuset mounted under: /sys/fs/cgroup/devlib_cpuset\n", 366 "04:34:14 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_cpuset\n", 367 "04:34:14 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_cpuset ] || mkdir -p /sys/fs/cgroup/devlib_cpuset'\n", 368 "04:34:14 DEBUG : Controller cpuset enabled\n", 369 "04:34:14 DEBUG : Init cpu controller...\n", 370 "04:34:14 DEBUG : /root/devlib-target/bin/busybox grep cpu /proc/cgroups\n", 371 "04:34:15 DEBUG : mount\n", 372 "04:34:15 DEBUG : Controller cpu mounted under: /sys/fs/cgroup/devlib_cpu\n", 373 "04:34:15 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_cpu\n", 374 "04:34:15 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_cpu ] || mkdir -p /sys/fs/cgroup/devlib_cpu'\n", 375 "04:34:15 DEBUG : Controller cpu enabled\n", 376 "04:34:15 DEBUG : Init schedtune controller...\n", 377 "04:34:15 DEBUG : /root/devlib-target/bin/busybox grep schedtune /proc/cgroups\n", 378 "04:34:16 DEBUG : mount\n", 379 "04:34:16 DEBUG : Controller schedtune mounted under: /sys/fs/cgroup/devlib_schedtune\n", 380 "04:34:16 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_schedtune\n", 381 "04:34:16 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_schedtune ] || mkdir -p /sys/fs/cgroup/devlib_schedtune'\n", 382 "04:34:17 DEBUG : Controller schedtune enabled\n", 383 "04:34:17 DEBUG : Init memory controller...\n", 384 "04:34:17 DEBUG : /root/devlib-target/bin/busybox grep memory /proc/cgroups\n", 385 "04:34:17 DEBUG : mount\n", 386 "04:34:17 DEBUG : Controller memory mounted under: /sys/fs/cgroup/devlib_memory\n", 387 "04:34:17 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_memory\n", 388 "04:34:18 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_memory ] || mkdir -p /sys/fs/cgroup/devlib_memory'\n", 389 "04:34:18 DEBUG : Controller memory enabled\n", 390 "04:34:18 DEBUG : Init devices controller...\n", 391 "04:34:18 DEBUG : /root/devlib-target/bin/busybox grep devices /proc/cgroups\n", 392 "04:34:18 DEBUG : mount\n", 393 "04:34:19 DEBUG : Controller devices mounted under: /sys/fs/cgroup/devlib_devices\n", 394 "04:34:19 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_devices\n", 395 "04:34:19 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_devices ] || mkdir -p /sys/fs/cgroup/devlib_devices'\n", 396 "04:34:19 DEBUG : Controller devices enabled\n", 397 "04:34:19 DEBUG : Init freezer controller...\n", 398 "04:34:19 DEBUG : /root/devlib-target/bin/busybox grep freezer /proc/cgroups\n", 399 "04:34:20 DEBUG : mount\n", 400 "04:34:20 DEBUG : Controller freezer mounted under: /sys/fs/cgroup/devlib_freezer\n", 401 "04:34:20 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_freezer\n", 402 "04:34:20 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_freezer ] || mkdir -p /sys/fs/cgroup/devlib_freezer'\n", 403 "04:34:20 DEBUG : Controller freezer enabled\n", 404 "04:34:20 DEBUG : Init perf_event controller...\n", 405 "04:34:20 DEBUG : /root/devlib-target/bin/busybox grep perf_event /proc/cgroups\n", 406 "04:34:21 DEBUG : mount\n", 407 "04:34:21 DEBUG : Controller perf_event mounted under: /sys/fs/cgroup/devlib_perf_event\n", 408 "04:34:21 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_perf_event\n", 409 "04:34:21 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_perf_event ] || mkdir -p /sys/fs/cgroup/devlib_perf_event'\n", 410 "04:34:22 DEBUG : Controller perf_event enabled\n", 411 "04:34:22 DEBUG : Init hugetlb controller...\n", 412 "04:34:22 DEBUG : /root/devlib-target/bin/busybox grep hugetlb /proc/cgroups\n", 413 "04:34:22 DEBUG : mount\n", 414 "04:34:22 DEBUG : Controller hugetlb mounted under: /sys/fs/cgroup/devlib_hugetlb\n", 415 "04:34:22 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_hugetlb\n", 416 "04:34:22 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_hugetlb ] || mkdir -p /sys/fs/cgroup/devlib_hugetlb'\n", 417 "04:34:23 DEBUG : Controller hugetlb enabled\n", 418 "04:34:23 DEBUG : Init pids controller...\n", 419 "04:34:23 DEBUG : /root/devlib-target/bin/busybox grep pids /proc/cgroups\n", 420 "04:34:23 DEBUG : mount\n", 421 "04:34:24 DEBUG : Controller pids mounted under: /sys/fs/cgroup/devlib_pids\n", 422 "04:34:24 DEBUG : Creating cgroup /sys/fs/cgroup/devlib_pids\n", 423 "04:34:24 DEBUG : sudo -- sh -c '[ -d /sys/fs/cgroup/devlib_pids ] || mkdir -p /sys/fs/cgroup/devlib_pids'\n", 424 "04:34:24 DEBUG : Controller pids enabled\n", 425 "04:34:24 DEBUG : if [ -e '/sys/class/hwmon' ]; then echo 1; else echo 0; fi\n", 426 "04:34:24 DEBUG : Installing module hwmon\n", 427 "04:34:25 DEBUG : ls -1 /sys/class/hwmon\n", 428 "04:34:25 DEBUG : if [ -e '/sys/class/hwmon/hwmon0/name' ]; then echo 1; else echo 0; fi\n", 429 "04:34:25 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon0/name'\\'''\n", 430 "04:34:26 DEBUG : ls -1 /sys/class/hwmon/hwmon0/\n", 431 "04:34:26 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon0/curr1_label'\\'''\n", 432 "04:34:27 DEBUG : if [ -e '/sys/class/hwmon/hwmon1/name' ]; then echo 1; else echo 0; fi\n", 433 "04:34:27 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon1/name'\\'''\n", 434 "04:34:27 DEBUG : ls -1 /sys/class/hwmon/hwmon1/\n", 435 "04:34:28 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon1/curr1_label'\\'''\n", 436 "04:34:28 DEBUG : if [ -e '/sys/class/hwmon/hwmon10/name' ]; then echo 1; else echo 0; fi\n", 437 "04:34:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon10/name'\\'''\n", 438 "04:34:29 DEBUG : ls -1 /sys/class/hwmon/hwmon10/\n", 439 "04:34:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon10/power1_label'\\'''\n", 440 "04:34:30 DEBUG : if [ -e '/sys/class/hwmon/hwmon11/name' ]; then echo 1; else echo 0; fi\n", 441 "04:34:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon11/name'\\'''\n", 442 "04:34:31 DEBUG : ls -1 /sys/class/hwmon/hwmon11/\n", 443 "04:34:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon11/power1_label'\\'''\n", 444 "04:34:32 DEBUG : if [ -e '/sys/class/hwmon/hwmon12/name' ]; then echo 1; else echo 0; fi\n", 445 "04:34:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon12/name'\\'''\n", 446 "04:34:32 DEBUG : ls -1 /sys/class/hwmon/hwmon12/\n", 447 "04:34:33 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon12/energy1_label'\\'''\n", 448 "04:34:33 DEBUG : if [ -e '/sys/class/hwmon/hwmon13/name' ]; then echo 1; else echo 0; fi\n", 449 "04:34:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/name'\\'''\n", 450 "04:34:34 DEBUG : ls -1 /sys/class/hwmon/hwmon13/\n", 451 "04:34:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_label'\\'''\n", 452 "04:34:35 DEBUG : if [ -e '/sys/class/hwmon/hwmon14/name' ]; then echo 1; else echo 0; fi\n", 453 "04:34:35 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/name'\\'''\n", 454 "04:34:36 DEBUG : ls -1 /sys/class/hwmon/hwmon14/\n", 455 "04:34:36 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_label'\\'''\n", 456 "04:34:37 DEBUG : if [ -e '/sys/class/hwmon/hwmon15/name' ]; then echo 1; else echo 0; fi\n", 457 "04:34:37 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon15/name'\\'''\n", 458 "04:34:37 DEBUG : ls -1 /sys/class/hwmon/hwmon15/\n", 459 "04:34:38 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon15/energy1_label'\\'''\n", 460 "04:34:38 DEBUG : if [ -e '/sys/class/hwmon/hwmon16/name' ]; then echo 1; else echo 0; fi\n", 461 "04:34:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/name'\\'''\n", 462 "04:34:39 DEBUG : ls -1 /sys/class/hwmon/hwmon16/\n", 463 "04:34:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in0_label'\\'''\n", 464 "04:34:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in1_label'\\'''\n", 465 "04:34:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in2_label'\\'''\n", 466 "04:34:41 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in3_label'\\'''\n", 467 "04:34:41 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in4_label'\\'''\n", 468 "04:34:42 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in5_label'\\'''\n", 469 "04:34:42 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/in6_label'\\'''\n", 470 "04:34:42 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/temp1_label'\\'''\n", 471 "04:34:43 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon16/temp2_label'\\'''\n", 472 "04:34:43 DEBUG : if [ -e '/sys/class/hwmon/hwmon2/name' ]; then echo 1; else echo 0; fi\n", 473 "04:34:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon2/name'\\'''\n", 474 "04:34:44 DEBUG : ls -1 /sys/class/hwmon/hwmon2/\n", 475 "04:34:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon2/curr1_label'\\'''\n", 476 "04:34:45 DEBUG : if [ -e '/sys/class/hwmon/hwmon3/name' ]; then echo 1; else echo 0; fi\n", 477 "04:34:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon3/name'\\'''\n", 478 "04:34:46 DEBUG : ls -1 /sys/class/hwmon/hwmon3/\n", 479 "04:34:46 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon3/curr1_label'\\'''\n", 480 "04:34:47 DEBUG : if [ -e '/sys/class/hwmon/hwmon4/name' ]; then echo 1; else echo 0; fi\n", 481 "04:34:47 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon4/name'\\'''\n", 482 "04:34:47 DEBUG : ls -1 /sys/class/hwmon/hwmon4/\n", 483 "04:34:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon4/in1_label'\\'''\n", 484 "04:34:48 DEBUG : if [ -e '/sys/class/hwmon/hwmon5/name' ]; then echo 1; else echo 0; fi\n", 485 "04:34:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon5/name'\\'''\n", 486 "04:34:49 DEBUG : ls -1 /sys/class/hwmon/hwmon5/\n", 487 "04:34:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon5/in1_label'\\'''\n", 488 "04:34:50 DEBUG : if [ -e '/sys/class/hwmon/hwmon6/name' ]; then echo 1; else echo 0; fi\n", 489 "04:34:50 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon6/name'\\'''\n", 490 "04:34:51 DEBUG : ls -1 /sys/class/hwmon/hwmon6/\n", 491 "04:34:51 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon6/in1_label'\\'''\n", 492 "04:34:52 DEBUG : if [ -e '/sys/class/hwmon/hwmon7/name' ]; then echo 1; else echo 0; fi\n", 493 "04:34:52 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon7/name'\\'''\n", 494 "04:34:52 DEBUG : ls -1 /sys/class/hwmon/hwmon7/\n", 495 "04:34:53 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon7/in1_label'\\'''\n", 496 "04:34:53 DEBUG : if [ -e '/sys/class/hwmon/hwmon8/name' ]; then echo 1; else echo 0; fi\n", 497 "04:34:54 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon8/name'\\'''\n", 498 "04:34:54 DEBUG : ls -1 /sys/class/hwmon/hwmon8/\n", 499 "04:34:54 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon8/power1_label'\\'''\n", 500 "04:34:55 DEBUG : if [ -e '/sys/class/hwmon/hwmon9/name' ]; then echo 1; else echo 0; fi\n", 501 "04:34:55 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon9/name'\\'''\n", 502 "04:34:56 DEBUG : ls -1 /sys/class/hwmon/hwmon9/\n", 503 "04:34:56 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon9/power1_label'\\'''\n", 504 "04:34:56 DEBUG : Target - Checking target connection...\n", 505 "04:34:56 DEBUG : Target - Target info:\n", 506 "04:34:56 DEBUG : Target - ABI: arm64\n", 507 "04:34:56 DEBUG : Target - CPUs: CpuInfo(['A53', 'A57', 'A57', 'A53', 'A53', 'A53'])\n", 508 "04:34:56 DEBUG : Target - Clusters: [0, 1, 1, 0, 0, 0]\n", 509 "04:34:57 DEBUG : sudo -- sh -c 'mount -o remount,rw /'\n", 510 "04:34:57 INFO : Target - Initializing target workdir:\n", 511 "04:34:57 INFO : Target - /root/devlib-target\n", 512 "04:34:57 DEBUG : mkdir -p /root/devlib-target\n", 513 "04:34:57 DEBUG : mkdir -p /root/devlib-target/bin\n", 514 "04:34:58 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/arm64/busybox root (a] 192.168.0.1:/root/devlib-target/bin/busybox\n", 515 "04:34:58 DEBUG : chmod a+x /root/devlib-target/bin/busybox\n", 516 "04:34:58 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/scripts/shutils root (a] 192.168.0.1:/root/devlib-target/bin/shutils\n", 517 "04:34:58 DEBUG : chmod a+x /root/devlib-target/bin/shutils\n", 518 "04:34:59 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/scripts/cpuidle_sampling.sh root (a] 192.168.0.1:/root/devlib-target/bin/cpuidle_sampling.sh\n", 519 "04:34:59 DEBUG : chmod a+x /root/devlib-target/bin/cpuidle_sampling.sh\n", 520 "04:34:59 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/tools/arm64/trace-cmd root (a] 192.168.0.1:/root/devlib-target/bin/trace-cmd\n", 521 "04:34:59 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n", 522 "04:35:00 DEBUG : Target - Check for module [bl]...\n", 523 "04:35:00 DEBUG : Target - Check for module [cpufreq]...\n", 524 "04:35:00 DEBUG : Target - Check for module [cgroups]...\n", 525 "04:35:00 DEBUG : Target - Check for module [hwmon]...\n", 526 "04:35:00 INFO : Target - Topology:\n", 527 "04:35:00 INFO : Target - [[0, 3, 4, 5], [1, 2]]\n", 528 "04:35:00 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n", 529 "04:35:00 DEBUG : cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n", 530 "04:35:01 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n", 531 "04:35:01 DEBUG : cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies\n", 532 "04:35:01 DEBUG : Platform - Trying to load default EM from /home/derkling/Code/lisa/libs/utils/platforms/juno.json\n", 533 "04:35:01 INFO : Platform - Loading default EM:\n", 534 "04:35:01 INFO : Platform - /home/derkling/Code/lisa/libs/utils/platforms/juno.json\n", 535 "04:35:01 DEBUG : loading JSON...\n", 536 "04:35:01 DEBUG : Loaded JSON configuration:\n", 537 "{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", 538 "04:35:01 DEBUG : Platform - Platform descriptor initialized\n", 539 "{'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", 540 "04:35:01 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/arm64/trace-cmd root (a] 192.168.0.1:/root/devlib-target/bin/trace-cmd\n", 541 "04:35:02 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n", 542 "04:35:02 DEBUG : cat /sys/kernel/debug/tracing/available_events\n", 543 "04:35:02 INFO : FTrace - Enabled tracepoints:\n", 544 "04:35:02 INFO : FTrace - cpu_idle\n", 545 "04:35:02 INFO : FTrace - sched_switch\n", 546 "04:35:02 DEBUG : EnergyMeter - using default energy meter for [juno]\n", 547 "04:35:02 INFO : EnergyMeter - Scanning for HWMON channels, may take some time...\n", 548 "04:35:02 DEBUG : Discovering available HWMON sensors...\n", 549 "04:35:02 DEBUG : \tAdding sensor v2m_juno_amp/curr1\n", 550 "04:35:02 DEBUG : \tAdding sensor v2m_juno_amp/curr1\n", 551 "04:35:02 DEBUG : \tAdding sensor v2m_juno_power/power1\n", 552 "04:35:02 DEBUG : \tAdding sensor v2m_juno_power/power1\n", 553 "04:35:02 DEBUG : \tAdding sensor v2m_juno_energy/energy1\n", 554 "04:35:02 DEBUG : \tAdding sensor v2m_juno_energy/energy1\n", 555 "04:35:02 DEBUG : \tAdding sensor v2m_juno_energy/energy1\n", 556 "04:35:02 DEBUG : \tAdding sensor v2m_juno_energy/energy1\n", 557 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/temp1\n", 558 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/temp2\n", 559 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/in0\n", 560 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/in1\n", 561 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/in2\n", 562 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/in3\n", 563 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/in4\n", 564 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/in5\n", 565 "04:35:02 DEBUG : \tAdding sensor scpi_sensors/in6\n", 566 "04:35:02 DEBUG : \tAdding sensor v2m_juno_amp/curr1\n", 567 "04:35:02 DEBUG : \tAdding sensor v2m_juno_amp/curr1\n", 568 "04:35:02 DEBUG : \tAdding sensor v2m_juno_volt/in1\n", 569 "04:35:02 DEBUG : \tAdding sensor v2m_juno_volt/in1\n", 570 "04:35:02 DEBUG : \tAdding sensor v2m_juno_volt/in1\n", 571 "04:35:02 DEBUG : \tAdding sensor v2m_juno_volt/in1\n", 572 "04:35:02 DEBUG : \tAdding sensor v2m_juno_power/power1\n", 573 "04:35:02 DEBUG : \tAdding sensor v2m_juno_power/power1\n", 574 "04:35:02 DEBUG : EnergyMeter - Enabling channels {'kinds': ['energy'], 'sites': ['a53', 'a57']}\n", 575 "04:35:02 INFO : EnergyMeter - Channels selected for energy sampling:\n", 576 "04:35:02 INFO : EnergyMeter - a57_energy\n", 577 "04:35:03 INFO : EnergyMeter - a53_energy\n", 578 "04:35:03 DEBUG : No RT-App workloads, skipping calibration\n", 579 "04:35:03 WARNING : TestEnv - Wipe previous contents of the results folder:\n", 580 "04:35:03 WARNING : TestEnv - /home/derkling/Code/lisa/results/TestEnvExample\n", 581 "04:35:03 INFO : TestEnv - Set results folder to:\n", 582 "04:35:03 INFO : TestEnv - /home/derkling/Code/lisa/results/TestEnvExample\n", 583 "04:35:03 INFO : TestEnv - Experiment results available also in:\n", 584 "04:35:03 INFO : TestEnv - /home/derkling/Code/lisa/results_latest\n" 585 ] 586 } 587 ], 588 "source": [ 589 "from env import TestEnv\n", 590 "\n", 591 "# Initialize a test environment using the provided configuration\n", 592 "te = TestEnv(conf)" 593 ] 594 }, 595 { 596 "cell_type": "markdown", 597 "metadata": {}, 598 "source": [ 599 "## Attributes" 600 ] 601 }, 602 { 603 "cell_type": "markdown", 604 "metadata": {}, 605 "source": [ 606 "The initialization of the test environment pre-initialize some useful<br>\n", 607 "environment variables which are available to write test cases.\n", 608 "\n", 609 "These are some of the information available via the TestEnv object." 610 ] 611 }, 612 { 613 "cell_type": "code", 614 "execution_count": 9, 615 "metadata": { 616 "collapsed": false 617 }, 618 "outputs": [ 619 { 620 "name": "stdout", 621 "output_type": "stream", 622 "text": [ 623 "{\n", 624 " \"username\": \"root\", \n", 625 " \"ftrace\": {\n", 626 " \"buffsize\": 10240, \n", 627 " \"events\": [\n", 628 " \"cpu_idle\", \n", 629 " \"sched_switch\"\n", 630 " ]\n", 631 " }, \n", 632 " \"host\": \"192.168.0.1\", \n", 633 " \"password\": \"\", \n", 634 " \"tools\": [\n", 635 " \"cpuidle_sampling.sh\", \n", 636 " \"trace-cmd\"\n", 637 " ], \n", 638 " \"modules\": [\n", 639 " \"cpufreq\", \n", 640 " \"cgroups\"\n", 641 " ], \n", 642 " \"results_dir\": \"TestEnvExample\", \n", 643 " \"platform\": \"linux\", \n", 644 " \"board\": \"juno\", \n", 645 " \"__features__\": [], \n", 646 " \"tftp\": {\n", 647 " \"kernel\": \"kern.bin\", \n", 648 " \"folder\": \"/var/lib/tftpboot\", \n", 649 " \"dtb\": \"dtb.bin\"\n", 650 " }\n", 651 "}\n" 652 ] 653 } 654 ], 655 "source": [ 656 "# The complete configuration of the target we have configured\n", 657 "print json.dumps(te.conf, indent=4)" 658 ] 659 }, 660 { 661 "cell_type": "code", 662 "execution_count": 10, 663 "metadata": { 664 "collapsed": false 665 }, 666 "outputs": [ 667 { 668 "name": "stdout", 669 "output_type": "stream", 670 "text": [ 671 "None\n", 672 "None\n" 673 ] 674 } 675 ], 676 "source": [ 677 "# Last configured kernel and DTB image\n", 678 "print te.kernel\n", 679 "print te.dtb" 680 ] 681 }, 682 { 683 "cell_type": "code", 684 "execution_count": 11, 685 "metadata": { 686 "collapsed": false 687 }, 688 "outputs": [ 689 { 690 "name": "stdout", 691 "output_type": "stream", 692 "text": [ 693 "192.168.0.1\n", 694 "None\n" 695 ] 696 } 697 ], 698 "source": [ 699 "# The IP and MAC address of the target\n", 700 "print te.ip\n", 701 "print te.mac" 702 ] 703 }, 704 { 705 "cell_type": "code", 706 "execution_count": 12, 707 "metadata": { 708 "collapsed": false 709 }, 710 "outputs": [ 711 { 712 "name": "stdout", 713 "output_type": "stream", 714 "text": [ 715 "{\n", 716 " \"nrg_model\": {\n", 717 " \"big\": {\n", 718 " \"cluster\": {\n", 719 " \"nrg_max\": 64\n", 720 " }, \n", 721 " \"cpu\": {\n", 722 " \"cap_max\": 1024, \n", 723 " \"nrg_max\": 616\n", 724 " }\n", 725 " }, \n", 726 " \"little\": {\n", 727 " \"cluster\": {\n", 728 " \"nrg_max\": 57\n", 729 " }, \n", 730 " \"cpu\": {\n", 731 " \"cap_max\": 447, \n", 732 " \"nrg_max\": 93\n", 733 " }\n", 734 " }\n", 735 " }, \n", 736 " \"clusters\": {\n", 737 " \"big\": [\n", 738 " 1, \n", 739 " 2\n", 740 " ], \n", 741 " \"little\": [\n", 742 " 0, \n", 743 " 3, \n", 744 " 4, \n", 745 " 5\n", 746 " ]\n", 747 " }, \n", 748 " \"cpus_count\": 6, \n", 749 " \"freqs\": {\n", 750 " \"big\": [\n", 751 " 450000, \n", 752 " 625000, \n", 753 " 800000, \n", 754 " 950000, \n", 755 " 1100000\n", 756 " ], \n", 757 " \"little\": [\n", 758 " 450000, \n", 759 " 575000, \n", 760 " 700000, \n", 761 " 775000, \n", 762 " 850000\n", 763 " ]\n", 764 " }, \n", 765 " \"topology\": [\n", 766 " [\n", 767 " 0, \n", 768 " 3, \n", 769 " 4, \n", 770 " 5\n", 771 " ], \n", 772 " [\n", 773 " 1, \n", 774 " 2\n", 775 " ]\n", 776 " ]\n", 777 "}\n" 778 ] 779 } 780 ], 781 "source": [ 782 "# A full platform descriptor\n", 783 "print json.dumps(te.platform, indent=4)" 784 ] 785 }, 786 { 787 "cell_type": "code", 788 "execution_count": 13, 789 "metadata": { 790 "collapsed": false 791 }, 792 "outputs": [ 793 { 794 "data": { 795 "text/plain": [ 796 "'/home/derkling/Code/lisa/results/TestEnvExample'" 797 ] 798 }, 799 "execution_count": 13, 800 "metadata": {}, 801 "output_type": "execute_result" 802 } 803 ], 804 "source": [ 805 "# A pre-created folder to host the tests results generated using this\n", 806 "# test environment, notice that the suite could add additional information\n", 807 "# in this folder, like for example a copy of the target configuration\n", 808 "# and other target specific collected information\n", 809 "te.res_dir" 810 ] 811 }, 812 { 813 "cell_type": "code", 814 "execution_count": 14, 815 "metadata": { 816 "collapsed": false 817 }, 818 "outputs": [ 819 { 820 "data": { 821 "text/plain": [ 822 "'/data/local/schedtest'" 823 ] 824 }, 825 "execution_count": 14, 826 "metadata": {}, 827 "output_type": "execute_result" 828 } 829 ], 830 "source": [ 831 "# The working directory on the target\n", 832 "te.workdir" 833 ] 834 }, 835 { 836 "cell_type": "markdown", 837 "metadata": {}, 838 "source": [ 839 "## Functions" 840 ] 841 }, 842 { 843 "cell_type": "markdown", 844 "metadata": {}, 845 "source": [ 846 "Some methods are also exposed to test developers which could be used to easy\n", 847 "the creation of tests.\n", 848 "\n", 849 "These are some of the methods available:" 850 ] 851 }, 852 { 853 "cell_type": "code", 854 "execution_count": 15, 855 "metadata": { 856 "collapsed": false, 857 "scrolled": true 858 }, 859 "outputs": [ 860 { 861 "name": "stderr", 862 "output_type": "stream", 863 "text": [ 864 "04:27:32 DEBUG : No RT-App workloads, skipping calibration\n" 865 ] 866 } 867 ], 868 "source": [ 869 "# Calibrate RT-App (if required) and get the most updated calibration value\n", 870 "te.calibration()" 871 ] 872 }, 873 { 874 "cell_type": "code", 875 "execution_count": 16, 876 "metadata": { 877 "collapsed": false 878 }, 879 "outputs": [ 880 { 881 "name": "stderr", 882 "output_type": "stream", 883 "text": [ 884 "04:27:32 DEBUG : Platform - Dump platform descriptor in [/tmp/platform.json]\n" 885 ] 886 }, 887 { 888 "data": { 889 "text/plain": [ 890 "({'clusters': {'big': [1, 2], 'little': [0, 3, 4, 5]},\n", 891 " 'cpus_count': 6,\n", 892 " 'freqs': {'big': [450000, 625000, 800000, 950000, 1100000],\n", 893 " 'little': [450000, 575000, 700000, 775000, 850000]},\n", 894 " 'nrg_model': {u'big': {u'cluster': {u'nrg_max': 64},\n", 895 " u'cpu': {u'cap_max': 1024, u'nrg_max': 616}},\n", 896 " u'little': {u'cluster': {u'nrg_max': 57},\n", 897 " u'cpu': {u'cap_max': 447, u'nrg_max': 93}}},\n", 898 " 'topology': [[0, 3, 4, 5], [1, 2]]},\n", 899 " '/tmp/platform.json')" 900 ] 901 }, 902 "execution_count": 16, 903 "metadata": {}, 904 "output_type": "execute_result" 905 } 906 ], 907 "source": [ 908 "# Generate a JSON file with the complete platform description\n", 909 "te.platform_dump(dest_dir='/tmp')" 910 ] 911 }, 912 { 913 "cell_type": "code", 914 "execution_count": 17, 915 "metadata": { 916 "collapsed": false, 917 "scrolled": true 918 }, 919 "outputs": [], 920 "source": [ 921 "# Force a reboot of the target (and wait specified [s] before reconnect)\n", 922 "# te.reboot(reboot_time=60, ping_time=15)" 923 ] 924 }, 925 { 926 "cell_type": "code", 927 "execution_count": 18, 928 "metadata": { 929 "collapsed": false 930 }, 931 "outputs": [], 932 "source": [ 933 "# Resolve a MAC address into an IP address\n", 934 "# te.resolv_host(host='00:02:F7:00:5A:5B')" 935 ] 936 }, 937 { 938 "cell_type": "code", 939 "execution_count": 19, 940 "metadata": { 941 "collapsed": false 942 }, 943 "outputs": [ 944 { 945 "name": "stderr", 946 "output_type": "stream", 947 "text": [ 948 "04:27:33 INFO : TFTP - Deploy /etc/group into /var/lib/tftpboot/group\n" 949 ] 950 } 951 ], 952 "source": [ 953 "# Copy the specified file into the TFTP server folder defined by configuration\n", 954 "te.tftp_deploy('/etc/group')" 955 ] 956 }, 957 { 958 "cell_type": "code", 959 "execution_count": 20, 960 "metadata": { 961 "collapsed": false 962 }, 963 "outputs": [ 964 { 965 "name": "stdout", 966 "output_type": "stream", 967 "text": [ 968 "total 12\r\n", 969 "drwxrwxrwx 2 root nogroup 4096 Feb 22 17:34 .\r\n", 970 "drwxr-xr-x 79 root root 4096 Feb 26 15:17 ..\r\n", 971 "-rw-r--r-- 1 derkling derkling 1168 Mar 2 16:27 group\r\n" 972 ] 973 } 974 ], 975 "source": [ 976 "!ls -la /var/lib/tftpboot" 977 ] 978 }, 979 { 980 "cell_type": "markdown", 981 "metadata": {}, 982 "source": [ 983 "# Access to the devlib API" 984 ] 985 }, 986 { 987 "cell_type": "markdown", 988 "metadata": {}, 989 "source": [ 990 "A special TestEnv attribute is <b>target</b>, which represents a <b>devlib instance</b>.\n", 991 "Using the target attribute we can access to the full set of devlib provided\n", 992 "functionalities. Which are summarized in the following sections." 993 ] 994 }, 995 { 996 "cell_type": "markdown", 997 "metadata": {}, 998 "source": [ 999 "## Remotes commands execution" 1000 ] 1001 }, 1002 { 1003 "cell_type": "code", 1004 "execution_count": 22, 1005 "metadata": { 1006 "collapsed": false 1007 }, 1008 "outputs": [ 1009 { 1010 "name": "stderr", 1011 "output_type": "stream", 1012 "text": [ 1013 "04:27:34 DEBUG : echo -n 'Hello Test Environment'\n" 1014 ] 1015 }, 1016 { 1017 "data": { 1018 "text/plain": [ 1019 "'Hello Test Environment'" 1020 ] 1021 }, 1022 "execution_count": 22, 1023 "metadata": {}, 1024 "output_type": "execute_result" 1025 } 1026 ], 1027 "source": [ 1028 "# Run a command on the target\n", 1029 "te.target.execute(\"echo -n 'Hello Test Environment'\", as_root=False)" 1030 ] 1031 }, 1032 { 1033 "cell_type": "code", 1034 "execution_count": 23, 1035 "metadata": { 1036 "collapsed": false 1037 }, 1038 "outputs": [ 1039 { 1040 "name": "stderr", 1041 "output_type": "stream", 1042 "text": [ 1043 "04:27:34 INFO : Spawn a task which will run for a while...\n", 1044 "04:27:35 DEBUG : sudo -- sh -c 'sh -c \"sleep 10\" 1>/dev/null 2>/dev/null &'\n" 1045 ] 1046 } 1047 ], 1048 "source": [ 1049 "# Spawn a command in background on the target\n", 1050 "logging.info(\"Spawn a task which will run for a while...\")\n", 1051 "process = te.target.kick_off(\"sleep 10\", as_root=True)" 1052 ] 1053 }, 1054 { 1055 "cell_type": "code", 1056 "execution_count": 24, 1057 "metadata": { 1058 "collapsed": false 1059 }, 1060 "outputs": [ 1061 { 1062 "name": "stderr", 1063 "output_type": "stream", 1064 "text": [ 1065 "04:27:35 DEBUG : ps\n" 1066 ] 1067 }, 1068 { 1069 "name": "stdout", 1070 "output_type": "stream", 1071 "text": [ 1072 " PID TTY TIME CMD\n", 1073 " 6097 pts/0 00:00:00 sh\n", 1074 " 6270 pts/0 00:00:00 sleep\n", 1075 " 6271 pts/0 00:00:00 ps\n" 1076 ] 1077 } 1078 ], 1079 "source": [ 1080 "output = te.target.execute(\"ps\")\n", 1081 "print '\\n'.join(output.splitlines())" 1082 ] 1083 }, 1084 { 1085 "cell_type": "markdown", 1086 "metadata": {}, 1087 "source": [ 1088 "Notice that _the Shell PID is always the same_ for all commands we execute.<br>\n", 1089 "This is due to devlib ensuring to keep a **persistent connection** with the target device." 1090 ] 1091 }, 1092 { 1093 "cell_type": "markdown", 1094 "metadata": {}, 1095 "source": [ 1096 "## Running custom scripts" 1097 ] 1098 }, 1099 { 1100 "cell_type": "code", 1101 "execution_count": 27, 1102 "metadata": { 1103 "collapsed": false 1104 }, 1105 "outputs": [ 1106 { 1107 "name": "stderr", 1108 "output_type": "stream", 1109 "text": [ 1110 "04:28:18 DEBUG : if [ -e '/root/devlib-target/bin' ]; then echo 1; else echo 0; fi\n", 1111 "04:28:18 DEBUG : ls -1 /root/devlib-target/bin\n" 1112 ] 1113 }, 1114 { 1115 "name": "stdout", 1116 "output_type": "stream", 1117 "text": [ 1118 "/root/devlib-target/bin/cpuidle_sampling.sh\n" 1119 ] 1120 } 1121 ], 1122 "source": [ 1123 "my_script = te.target.get_installed(\"cpuidle_sampling.sh\")\n", 1124 "print my_script" 1125 ] 1126 }, 1127 { 1128 "cell_type": "code", 1129 "execution_count": 28, 1130 "metadata": { 1131 "collapsed": false 1132 }, 1133 "outputs": [ 1134 { 1135 "name": "stderr", 1136 "output_type": "stream", 1137 "text": [ 1138 "04:28:19 DEBUG : sudo -- sh -c '/root/devlib-target/bin/cpuidle_sampling.sh'\n" 1139 ] 1140 }, 1141 { 1142 "data": { 1143 "text/plain": [ 1144 "['# Time idle0 idle1 idle2 ',\n", 1145 " ' 1456934283 0 11 19 ',\n", 1146 " ' 1456934284 0 5 17 ',\n", 1147 " ' 1456934285 0 5 19 ']" 1148 ] 1149 }, 1150 "execution_count": 28, 1151 "metadata": {}, 1152 "output_type": "execute_result" 1153 } 1154 ], 1155 "source": [ 1156 "output = te.target.execute(my_script, as_root=True)\n", 1157 "output.splitlines()" 1158 ] 1159 }, 1160 { 1161 "cell_type": "markdown", 1162 "metadata": {}, 1163 "source": [ 1164 "Notice that the output is returned as a **list of lines**. This provides a useful base for post-processing the output of that command." 1165 ] 1166 }, 1167 { 1168 "cell_type": "code", 1169 "execution_count": 35, 1170 "metadata": { 1171 "code_folding": [], 1172 "collapsed": false 1173 }, 1174 "outputs": [], 1175 "source": [ 1176 "# We can also use \"notebook embedded\" scripts\n", 1177 "# my_script = \" \\\n", 1178 "# for I in $(seq 3); do \\\n", 1179 "# grep '' /sys/devices/system/cpu/cpu*/cpufreq/stats/time_in_stats | \\\n", 1180 "# sed -e 's|/sys/devices/system/cpu/cpu||' -e 's|/cpufreq/scaling_governor:| |' \\\n", 1181 "# sleep 1 \\\n", 1182 "# done \\\n", 1183 "# \"" 1184 ] 1185 }, 1186 { 1187 "cell_type": "code", 1188 "execution_count": 34, 1189 "metadata": { 1190 "collapsed": false 1191 }, 1192 "outputs": [], 1193 "source": [ 1194 "# print te.target.execute(my_script)" 1195 ] 1196 }, 1197 { 1198 "cell_type": "markdown", 1199 "metadata": {}, 1200 "source": [ 1201 "## Access to target specific attributes" 1202 ] 1203 }, 1204 { 1205 "cell_type": "code", 1206 "execution_count": 9, 1207 "metadata": { 1208 "collapsed": false 1209 }, 1210 "outputs": [ 1211 { 1212 "name": "stdout", 1213 "output_type": "stream", 1214 "text": [ 1215 "ABI : arm64\n", 1216 "big Core Family : A57\n", 1217 "LITTLE Core Family : A53\n", 1218 "CPU's Clusters IDs : [0, 1, 1, 0, 0, 0]\n", 1219 "CPUs type : ['A53', 'A57', 'A57', 'A53', 'A53', 'A53']\n" 1220 ] 1221 } 1222 ], 1223 "source": [ 1224 "# Acces to many target specific information\n", 1225 "print \"ABI : \", te.target.abi\n", 1226 "print \"big Core Family : \", te.target.big_core\n", 1227 "print \"LITTLE Core Family : \", te.target.little_core\n", 1228 "print \"CPU's Clusters IDs : \", te.target.core_clusters\n", 1229 "print \"CPUs type : \", te.target.core_names" 1230 ] 1231 }, 1232 { 1233 "cell_type": "code", 1234 "execution_count": 10, 1235 "metadata": { 1236 "collapsed": false 1237 }, 1238 "outputs": [ 1239 { 1240 "name": "stderr", 1241 "output_type": "stream", 1242 "text": [ 1243 "04:35:03 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n", 1244 "04:35:03 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq'\\'''\n" 1245 ] 1246 }, 1247 { 1248 "name": "stdout", 1249 "output_type": "stream", 1250 "text": [ 1251 "big CPUs IDs : [1, 2]\n", 1252 "LITTLE CPUs IDs : [0, 3, 4, 5]\n", 1253 "big CPUs freqs : 1100000" 1254 ] 1255 }, 1256 { 1257 "name": "stderr", 1258 "output_type": "stream", 1259 "text": [ 1260 "04:35:04 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/online'\\'''\n", 1261 "04:35:04 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor'\\'''\n" 1262 ] 1263 }, 1264 { 1265 "name": "stdout", 1266 "output_type": "stream", 1267 "text": [ 1268 "\n", 1269 "big CPUs governor : performance\n" 1270 ] 1271 } 1272 ], 1273 "source": [ 1274 "# Access to big.LITTLE specific information\n", 1275 "print \"big CPUs IDs : \", te.target.bl.bigs\n", 1276 "print \"LITTLE CPUs IDs : \", te.target.bl.littles\n", 1277 "print \"big CPUs freqs : {}\".format(te.target.bl.get_bigs_frequency())\n", 1278 "print \"big CPUs governor : {}\".format(te.target.bl.get_bigs_governor())" 1279 ] 1280 }, 1281 { 1282 "cell_type": "markdown", 1283 "metadata": {}, 1284 "source": [ 1285 "## Modules usage example: CPUFreq" 1286 ] 1287 }, 1288 { 1289 "cell_type": "code", 1290 "execution_count": 11, 1291 "metadata": { 1292 "collapsed": false 1293 }, 1294 "outputs": [ 1295 { 1296 "name": "stderr", 1297 "output_type": "stream", 1298 "text": [ 1299 "04:36:33 DEBUG : sudo -- sh -c '/root/devlib-target/bin/shutils cpufreq_get_all_governors'\n" 1300 ] 1301 }, 1302 { 1303 "data": { 1304 "text/plain": [ 1305 "{'0': 'performance',\n", 1306 " '1': 'performance',\n", 1307 " '2': 'performance',\n", 1308 " '3': 'performance',\n", 1309 " '4': 'performance',\n", 1310 " '5': 'performance'}" 1311 ] 1312 }, 1313 "execution_count": 11, 1314 "metadata": {}, 1315 "output_type": "execute_result" 1316 } 1317 ], 1318 "source": [ 1319 "# You can use autocompletion to have a look at the supported method for a\n", 1320 "# specific module\n", 1321 "te.target.cpufreq #.get_all_governors()" 1322 ] 1323 }, 1324 { 1325 "cell_type": "code", 1326 "execution_count": 16, 1327 "metadata": { 1328 "collapsed": false 1329 }, 1330 "outputs": [ 1331 { 1332 "name": "stderr", 1333 "output_type": "stream", 1334 "text": [ 1335 "04:39:00 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors'\\'''\n" 1336 ] 1337 }, 1338 { 1339 "data": { 1340 "text/plain": [ 1341 "['conservative', 'ondemand', 'userspace', 'powersave', 'performance', 'sched']" 1342 ] 1343 }, 1344 "execution_count": 16, 1345 "metadata": {}, 1346 "output_type": "execute_result" 1347 } 1348 ], 1349 "source": [ 1350 "# Get goverors available for CPU0\n", 1351 "te.target.cpufreq.list_governors(0)" 1352 ] 1353 }, 1354 { 1355 "cell_type": "code", 1356 "execution_count": 17, 1357 "metadata": { 1358 "collapsed": false 1359 }, 1360 "outputs": [ 1361 { 1362 "name": "stderr", 1363 "output_type": "stream", 1364 "text": [ 1365 "04:40:04 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors'\\'''\n", 1366 "04:40:04 DEBUG : sudo -- sh -c 'echo ondemand > '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1367 "04:40:05 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1368 "04:40:05 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1369 "04:40:06 DEBUG : ls -1 /sys/devices/system/cpu/cpu0/cpufreq/ondemand\n" 1370 ] 1371 } 1372 ], 1373 "source": [ 1374 "# Set the \"ondemand\" governor\n", 1375 "te.target.cpufreq.set_governor(0, 'ondemand')" 1376 ] 1377 }, 1378 { 1379 "cell_type": "code", 1380 "execution_count": 19, 1381 "metadata": { 1382 "collapsed": false 1383 }, 1384 "outputs": [ 1385 { 1386 "name": "stderr", 1387 "output_type": "stream", 1388 "text": [ 1389 "04:40:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1390 "04:40:29 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1391 "04:40:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load'\\'''\n", 1392 "04:40:30 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/io_is_busy'\\'''\n", 1393 "04:40:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias'\\'''\n", 1394 "04:40:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_down_factor'\\'''\n", 1395 "04:40:31 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'\\'''\n", 1396 "04:40:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate_min'\\'''\n", 1397 "04:40:32 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold'\\'''\n" 1398 ] 1399 }, 1400 { 1401 "data": { 1402 "text/plain": [ 1403 "{'ignore_nice_load': '0',\n", 1404 " 'io_is_busy': '0',\n", 1405 " 'powersave_bias': '0',\n", 1406 " 'sampling_down_factor': '1',\n", 1407 " 'sampling_rate': '1200000',\n", 1408 " 'sampling_rate_min': '24000',\n", 1409 " 'up_threshold': '95'}" 1410 ] 1411 }, 1412 "execution_count": 19, 1413 "metadata": {}, 1414 "output_type": "execute_result" 1415 } 1416 ], 1417 "source": [ 1418 "# Check governor tunables\n", 1419 "te.target.cpufreq.get_governor_tunables(0)" 1420 ] 1421 }, 1422 { 1423 "cell_type": "code", 1424 "execution_count": 22, 1425 "metadata": { 1426 "collapsed": false 1427 }, 1428 "outputs": [ 1429 { 1430 "name": "stderr", 1431 "output_type": "stream", 1432 "text": [ 1433 "04:41:46 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1434 "04:41:46 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1435 "04:41:47 DEBUG : sudo -- sh -c 'echo 2000000 > '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'\\'''\n", 1436 "04:41:47 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'\\'''\n", 1437 "04:41:47 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1438 "04:41:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'\\'''\n", 1439 "04:41:48 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load'\\'''\n", 1440 "04:41:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/io_is_busy'\\'''\n", 1441 "04:41:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias'\\'''\n", 1442 "04:41:49 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_down_factor'\\'''\n", 1443 "04:41:50 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'\\'''\n", 1444 "04:41:50 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate_min'\\'''\n", 1445 "04:41:51 DEBUG : sudo -- sh -c 'cat '\\''/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold'\\'''\n" 1446 ] 1447 }, 1448 { 1449 "data": { 1450 "text/plain": [ 1451 "{'ignore_nice_load': '0',\n", 1452 " 'io_is_busy': '0',\n", 1453 " 'powersave_bias': '0',\n", 1454 " 'sampling_down_factor': '1',\n", 1455 " 'sampling_rate': '2000000',\n", 1456 " 'sampling_rate_min': '24000',\n", 1457 " 'up_threshold': '95'}" 1458 ] 1459 }, 1460 "execution_count": 22, 1461 "metadata": {}, 1462 "output_type": "execute_result" 1463 } 1464 ], 1465 "source": [ 1466 "# Update governor tunables\n", 1467 "te.target.cpufreq.set_governor_tunables(0, sampling_rate=2000000)\n", 1468 "te.target.cpufreq.get_governor_tunables(0)" 1469 ] 1470 }, 1471 { 1472 "cell_type": "markdown", 1473 "metadata": {}, 1474 "source": [ 1475 "## Modules usage example: CGroups" 1476 ] 1477 }, 1478 { 1479 "cell_type": "code", 1480 "execution_count": 44, 1481 "metadata": { 1482 "collapsed": false 1483 }, 1484 "outputs": [ 1485 { 1486 "name": "stderr", 1487 "output_type": "stream", 1488 "text": [ 1489 "04:51:18 INFO : CGroup - Available controllers:\n", 1490 "04:51:18 DEBUG : /root/devlib-target/bin/busybox cat /proc/cgroups\n" 1491 ] 1492 }, 1493 { 1494 "name": "stdout", 1495 "output_type": "stream", 1496 "text": [ 1497 "cpuset (hierarchy id: 1) has 2 cgroups\n", 1498 "cpu (hierarchy id: 2) has 1 cgroups\n", 1499 "schedtune (hierarchy id: 3) has 1 cgroups\n", 1500 "memory (hierarchy id: 4) has 1 cgroups\n", 1501 "devices (hierarchy id: 5) has 1 cgroups\n", 1502 "freezer (hierarchy id: 6) has 1 cgroups\n", 1503 "perf_event (hierarchy id: 7) has 1 cgroups\n", 1504 "hugetlb (hierarchy id: 8) has 1 cgroups\n", 1505 "pids (hierarchy id: 9) has 1 cgroups\n" 1506 ] 1507 } 1508 ], 1509 "source": [ 1510 "logging.info('%14s - Available controllers:', 'CGroup')\n", 1511 "ssys = target.cgroups.list_subsystems()\n", 1512 "for (n,h,g,e) in ssys:\n", 1513 " print '{:10} (hierarchy id: {:d}) has {} cgroups'.format(n, h, g)" 1514 ] 1515 }, 1516 { 1517 "cell_type": "code", 1518 "execution_count": 23, 1519 "metadata": { 1520 "collapsed": true 1521 }, 1522 "outputs": [], 1523 "source": [ 1524 "# Get a reference to the CPUSet controller\n", 1525 "cpuset = target.cgroups.controller('cpuset')" 1526 ] 1527 }, 1528 { 1529 "cell_type": "code", 1530 "execution_count": 47, 1531 "metadata": { 1532 "collapsed": false 1533 }, 1534 "outputs": [ 1535 { 1536 "name": "stderr", 1537 "output_type": "stream", 1538 "text": [ 1539 "04:51:42 DEBUG : Listing groups for cpuset controller\n", 1540 "04:51:43 DEBUG : /root/devlib-target/bin/busybox find /sys/fs/cgroup/devlib_cpuset -type d\n", 1541 "04:51:43 DEBUG : Populate cpuset cgroup: /\n", 1542 "04:51:43 DEBUG : Populate cpuset cgroup: /LITTLE\n" 1543 ] 1544 }, 1545 { 1546 "name": "stdout", 1547 "output_type": "stream", 1548 "text": [ 1549 "Existing CGropups:\n", 1550 " /\n", 1551 " /LITTLE\n" 1552 ] 1553 } 1554 ], 1555 "source": [ 1556 "# Get the list of current configured CGroups for that controller\n", 1557 "cgroups = cpuset.list_all()\n", 1558 "print 'Existing CGropups:'\n", 1559 "for cg in cgroups:\n", 1560 " print \" \", cg" 1561 ] 1562 }, 1563 { 1564 "cell_type": "code", 1565 "execution_count": 29, 1566 "metadata": { 1567 "collapsed": false 1568 }, 1569 "outputs": [ 1570 { 1571 "name": "stderr", 1572 "output_type": "stream", 1573 "text": [ 1574 "04:45:15 DEBUG : Reading cpuset attributes from:\n", 1575 "04:45:15 DEBUG : /sys/fs/cgroup/devlib_cpuset/LITTLE\n", 1576 "04:45:15 DEBUG : /root/devlib-target/bin/shutils cgroups_get_attributes /sys/fs/cgroup/devlib_cpuset/LITTLE cpuset\n" 1577 ] 1578 }, 1579 { 1580 "data": { 1581 "text/plain": [ 1582 "{'cpu_exclusive': '0',\n", 1583 " 'cpus': '',\n", 1584 " 'effective_cpus': '',\n", 1585 " 'effective_mems': '',\n", 1586 " 'mem_exclusive': '0',\n", 1587 " 'mem_hardwall': '0',\n", 1588 " 'memory_migrate': '0',\n", 1589 " 'memory_pressure': '0',\n", 1590 " 'memory_spread_page': '0',\n", 1591 " 'memory_spread_slab': '0',\n", 1592 " 'mems': '',\n", 1593 " 'sched_load_balance': '1',\n", 1594 " 'sched_relax_domain_level': '-1'}" 1595 ] 1596 }, 1597 "execution_count": 29, 1598 "metadata": {}, 1599 "output_type": "execute_result" 1600 } 1601 ], 1602 "source": [ 1603 "# Create a LITTLE partition and check which tunables we have\n", 1604 "cpuset_littles = cpuset.cgroup('/LITTLE')\n", 1605 "cpuset_littles.get()" 1606 ] 1607 }, 1608 { 1609 "cell_type": "code", 1610 "execution_count": 33, 1611 "metadata": { 1612 "collapsed": false 1613 }, 1614 "outputs": [ 1615 { 1616 "name": "stderr", 1617 "output_type": "stream", 1618 "text": [ 1619 "04:47:33 DEBUG : Set attribute [/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.cpus] to: 0,3-5\"\n", 1620 "04:47:33 DEBUG : sudo -- sh -c 'echo 0,3-5 > '\\''/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.cpus'\\'''\n", 1621 "04:47:33 DEBUG : sudo -- sh -c 'cat '\\''/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.cpus'\\'''\n", 1622 "04:47:34 DEBUG : Set attribute [/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.mems] to: 0\"\n", 1623 "04:47:34 DEBUG : sudo -- sh -c 'echo 0 > '\\''/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.mems'\\'''\n", 1624 "04:47:34 DEBUG : sudo -- sh -c 'cat '\\''/sys/fs/cgroup/devlib_cpuset/LITTLE/cpuset.mems'\\'''\n" 1625 ] 1626 } 1627 ], 1628 "source": [ 1629 "# Setup CPUs and MEMORY nodes for the LITTLE partition\n", 1630 "cpuset_littles.set(cpus=te.target.bl.littles, mems=0)" 1631 ] 1632 }, 1633 { 1634 "cell_type": "code", 1635 "execution_count": 52, 1636 "metadata": { 1637 "collapsed": false 1638 }, 1639 "outputs": [ 1640 { 1641 "name": "stderr", 1642 "output_type": "stream", 1643 "text": [ 1644 "04:52:55 DEBUG : Reading cpuset attributes from:\n", 1645 "04:52:55 DEBUG : /sys/fs/cgroup/devlib_cpuset\n", 1646 "04:52:55 DEBUG : /root/devlib-target/bin/shutils cgroups_get_attributes /sys/fs/cgroup/devlib_cpuset cpuset\n", 1647 "04:52:55 DEBUG : Reading cpuset attributes from:\n", 1648 "04:52:55 DEBUG : /sys/fs/cgroup/devlib_cpuset/LITTLE\n", 1649 "04:52:55 DEBUG : /root/devlib-target/bin/shutils cgroups_get_attributes /sys/fs/cgroup/devlib_cpuset/LITTLE cpuset\n" 1650 ] 1651 }, 1652 { 1653 "name": "stdout", 1654 "output_type": "stream", 1655 "text": [ 1656 "cpuset:/ cpus: 0-5\n", 1657 "cpuset:/LITTLE cpus: 0,3-5\n" 1658 ] 1659 } 1660 ], 1661 "source": [ 1662 "# Dump the configuraiton of each controller\n", 1663 "for cgname in cgroups:\n", 1664 " cgroup = cpuset.cgroup(cgname)\n", 1665 " attrs = cgroup.get()\n", 1666 " cpus = attrs['cpus']\n", 1667 " print '{}:{:<15} cpus: {}'.format(cpuset.kind, cgroup.name, cpus)" 1668 ] 1669 }, 1670 { 1671 "cell_type": "code", 1672 "execution_count": 53, 1673 "metadata": { 1674 "collapsed": true 1675 }, 1676 "outputs": [], 1677 "source": [ 1678 "# Methods exists to move tasks in/out and in between groups\n", 1679 "# cpuset_littles.add_task()" 1680 ] 1681 }, 1682 { 1683 "cell_type": "markdown", 1684 "metadata": {}, 1685 "source": [ 1686 "# Sample energy from the target" 1687 ] 1688 }, 1689 { 1690 "cell_type": "code", 1691 "execution_count": 6, 1692 "metadata": { 1693 "collapsed": false, 1694 "scrolled": false 1695 }, 1696 "outputs": [ 1697 { 1698 "name": "stderr", 1699 "output_type": "stream", 1700 "text": [ 1701 "03:02:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n", 1702 "03:02:39 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n", 1703 "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", 1704 "03:02:39 DEBUG : RESET: {'a53': {'total': 0, 'last': 1335.646094, 'delta': 0}, 'a57': {'total': 0, 'last': 2052.693486, 'delta': 0}}\n", 1705 "03:02:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n", 1706 "03:02:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n", 1707 "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", 1708 "03:02:40 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n", 1709 "03:02:41 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n", 1710 "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", 1711 "03:02:43 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n", 1712 "03:02:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n", 1713 "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", 1714 "03:02:44 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon13/energy1_input'\\'''\n", 1715 "03:02:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/class/hwmon/hwmon14/energy1_input'\\'''\n", 1716 "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" 1717 ] 1718 }, 1719 { 1720 "name": "stdout", 1721 "output_type": "stream", 1722 "text": [ 1723 "First read: {\n", 1724 " \"a53\": {\n", 1725 " \"total\": 0.7240460000000439, \n", 1726 " \"last\": 1336.37014, \n", 1727 " \"delta\": 0.35342100000002574\n", 1728 " }, \n", 1729 " \"a57\": {\n", 1730 " \"total\": 0.9984340000000884, \n", 1731 " \"last\": 2053.69192, \n", 1732 " \"delta\": 0.4987300000002506\n", 1733 " }\n", 1734 "}\n", 1735 "Second read: {\n", 1736 " \"a53\": {\n", 1737 " \"total\": 1.4408379999999852, \n", 1738 " \"last\": 1337.086932, \n", 1739 " \"delta\": 0.19358299999998962\n", 1740 " }, \n", 1741 " \"a57\": {\n", 1742 " \"total\": 2.4585919999999533, \n", 1743 " \"last\": 2055.152078, \n", 1744 " \"delta\": 0.4880590000002485\n", 1745 " }\n", 1746 "}\n" 1747 ] 1748 } 1749 ], 1750 "source": [ 1751 "# Reset and sample energy counters\n", 1752 "te.emeter.reset()\n", 1753 "\n", 1754 "# Sleep some time\n", 1755 "time.sleep(2)\n", 1756 "\n", 1757 "# Sample energy consumption since last reset\n", 1758 "nrg = te.emeter.sample()\n", 1759 "nrg = json.dumps(te.emeter.sample(), indent=4)\n", 1760 "print \"First read: \", nrg\n", 1761 "\n", 1762 "# Sleep some more time\n", 1763 "time.sleep(2)\n", 1764 "\n", 1765 "# Sample again\n", 1766 "nrg = te.emeter.sample()\n", 1767 "nrg = json.dumps(te.emeter.sample(), indent=4)\n", 1768 "print \"Second read: \", nrg" 1769 ] 1770 }, 1771 { 1772 "cell_type": "markdown", 1773 "metadata": {}, 1774 "source": [ 1775 "# Configure FTrace for a sepcific experiment" 1776 ] 1777 }, 1778 { 1779 "cell_type": "code", 1780 "execution_count": 7, 1781 "metadata": { 1782 "collapsed": false 1783 }, 1784 "outputs": [ 1785 { 1786 "name": "stderr", 1787 "output_type": "stream", 1788 "text": [ 1789 "02:59:43 DEBUG : /usr/bin/scp -r /home/derkling/Code/lisa/libs/devlib/devlib/bin/arm64/trace-cmd root (a] 192.168.0.1:/root/devlib-target/bin/trace-cmd\n", 1790 "02:59:44 DEBUG : chmod a+x /root/devlib-target/bin/trace-cmd\n", 1791 "02:59:44 DEBUG : cat /sys/kernel/debug/tracing/available_events\n", 1792 "02:59:44 INFO : FTrace - Enabled tracepoints:\n", 1793 "02:59:44 INFO : FTrace - cpu_idle\n", 1794 "02:59:44 INFO : FTrace - cpu_capacity\n", 1795 "02:59:44 INFO : FTrace - cpu_frequency\n", 1796 "02:59:44 INFO : FTrace - sched_switch\n" 1797 ] 1798 } 1799 ], 1800 "source": [ 1801 "# Configure a specific set of events to trace\n", 1802 "te.ftrace_conf(\n", 1803 " { \n", 1804 " \"events\" : [ \n", 1805 " \"cpu_idle\", \n", 1806 " \"cpu_capacity\",\n", 1807 " \"cpu_frequency\",\n", 1808 " \"sched_switch\",\n", 1809 " ], \n", 1810 " \"buffsize\" : 10240 \n", 1811 " }\n", 1812 ")" 1813 ] 1814 }, 1815 { 1816 "cell_type": "code", 1817 "execution_count": 8, 1818 "metadata": { 1819 "collapsed": false 1820 }, 1821 "outputs": [ 1822 { 1823 "name": "stderr", 1824 "output_type": "stream", 1825 "text": [ 1826 "02:59:45 DEBUG : sudo -- sh -c 'echo 10240 > '\\''/sys/kernel/debug/tracing/buffer_size_kb'\\'''\n", 1827 "02:59:45 DEBUG : sudo -- sh -c 'cat '\\''/sys/kernel/debug/tracing/buffer_size_kb'\\'''\n", 1828 "02:59:45 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd reset'\n", 1829 "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", 1830 "02:59:48 DEBUG : sudo -- sh -c 'echo TRACE_MARKER_START > '\\''/sys/kernel/debug/tracing/trace_marker'\\'''\n", 1831 "02:59:48 DEBUG : Trace CPUFreq frequencies\n", 1832 "02:59:48 DEBUG : sudo -- sh -c '/root/devlib-target/bin/shutils cpufreq_trace_all_frequencies'\n", 1833 "02:59:48 DEBUG : uname -a\n", 1834 "02:59:49 DEBUG : Trace CPUFreq frequencies\n", 1835 "02:59:49 DEBUG : sudo -- sh -c '/root/devlib-target/bin/shutils cpufreq_trace_all_frequencies'\n", 1836 "02:59:49 DEBUG : sudo -- sh -c 'echo TRACE_MARKER_STOP > '\\''/sys/kernel/debug/tracing/trace_marker'\\'''\n", 1837 "02:59:49 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd stop'\n" 1838 ] 1839 } 1840 ], 1841 "source": [ 1842 "# Start/Stop a FTrace session\n", 1843 "te.ftrace.start()\n", 1844 "te.target.execute(\"uname -a\")\n", 1845 "te.ftrace.stop()" 1846 ] 1847 }, 1848 { 1849 "cell_type": "code", 1850 "execution_count": 9, 1851 "metadata": { 1852 "collapsed": false 1853 }, 1854 "outputs": [ 1855 { 1856 "name": "stderr", 1857 "output_type": "stream", 1858 "text": [ 1859 "02:59:50 DEBUG : sudo -- sh -c '/root/devlib-target/bin/trace-cmd extract -o /root/devlib-target/trace.dat'\n", 1860 "02:59:51 DEBUG : /usr/bin/scp -r root (a] 192.168.0.1:/root/devlib-target/trace.dat /home/derkling/Code/lisa/results/TestEnvExample/trace.dat\n" 1861 ] 1862 } 1863 ], 1864 "source": [ 1865 "# Collect and visualize the trace\n", 1866 "trace_file = os.path.join(te.res_dir, 'trace.dat')\n", 1867 "te.ftrace.get_trace(trace_file)\n", 1868 "output = os.popen(\"DISPLAY=:0.0 kernelshark {}\".format(trace_file))" 1869 ] 1870 } 1871 ], 1872 "metadata": { 1873 "kernelspec": { 1874 "display_name": "Python 2", 1875 "language": "python", 1876 "name": "python2" 1877 }, 1878 "language_info": { 1879 "codemirror_mode": { 1880 "name": "ipython", 1881 "version": 2 1882 }, 1883 "file_extension": ".py", 1884 "mimetype": "text/x-python", 1885 "name": "python", 1886 "nbconvert_exporter": "python", 1887 "pygments_lexer": "ipython2", 1888 "version": "2.7.9" 1889 } 1890 }, 1891 "nbformat": 4, 1892 "nbformat_minor": 0 1893 } 1894