Skip to content

Instantly share code, notes, and snippets.

@jlelli
Created June 19, 2018 09:42
Show Gist options
  • Save jlelli/57ff1e9dc72c8fde693bb8ba49ba9673 to your computer and use it in GitHub Desktop.
Save jlelli/57ff1e9dc72c8fde693bb8ba49ba9673 to your computer and use it in GitHub Desktop.
Test Cpuset in default hierarchy (v10)
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2018-06-19 08:57:53,023 INFO : root : Using LISA logging configuration:\n",
"2018-06-19 08:57:53,025 INFO : root : /home/juri/work/lisa/logging.conf\n"
]
}
],
"source": [
"import logging\n",
"from conf import LisaLogging\n",
"LisaLogging.setup()\n",
"\n",
"# Uncomment the follwing line to enabled devlib debugging statements\n",
"# logging.getLogger('ssh').setLevel(logging.DEBUG)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
]
}
],
"source": [
"# Generate plots inline\n",
"%pylab inline\n",
"\n",
"import copy\n",
"import json\n",
"import os\n",
"\n",
"# Support to access the remote target\n",
"import devlib\n",
"from env import TestEnv\n",
"\n",
"# Support to configure and run RTApp based workloads\n",
"from wlgen import RTA, Periodic, PerfMessaging\n",
"\n",
"# Support for performance analysis of RTApp workloads\n",
"from perf_analysis import PerfAnalysis\n",
"\n",
"# Support for trace events analysis\n",
"from trace import Trace\n",
"\n",
"# Suport for FTrace events parsing and visualization\n",
"import trappy\n",
"\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test environment setup"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Setup a target configuration\n",
"my_conf = {\n",
" \n",
" # Define the kind of target platform to use for the experiments\n",
" \"platform\" : 'linux', # Linux system, 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\" : 'xeon_E5-2609_v3',\n",
" \n",
" # Define devlib module to load\n",
" \"modules\" : [\n",
" #'bl', # enable big.LITTLE support\n",
" #'cpufreq' # enable CPUFreq support\n",
" 'hotplug'\n",
" ],\n",
" \n",
" \"exclude_modules\" : [\n",
" 'cpufreq'\n",
" ],\n",
"\n",
" # Account to access the remote target\n",
" \"host\" : '127.0.0.1',\n",
" \"port\" : '10022',\n",
" \"username\" : 'root',\n",
" \"password\" : '',\n",
"\n",
" # Comment the following line to force rt-app calibration on your target\n",
" \"rtapp-calib\" : {\n",
" \"0\": 23, \"1\": 23, \"2\": 23, \"3\": 23\n",
" },\n",
" \n",
" # Binary tools required to run this experiment\n",
" # These tools must be present in the tools/ folder for the architecture\n",
" \"tools\" : ['rt-app', 'taskset', 'trace-cmd', 'perf'],\n",
" \n",
" # FTrace events end buffer configuration\n",
" \"ftrace\" : {\n",
" \"events\" : [\n",
" \"sched_switch\"\n",
" ],\n",
" \"buffsize\" : 20240\n",
" },\n",
" \n",
" \"results_dir\" : \"cpuset-cgroup2-waiman-v10\"\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2018-06-19 08:57:54,638 INFO : TestEnv : Using base path: /home/juri/work/lisa\n",
"2018-06-19 08:57:54,642 INFO : TestEnv : Loading custom (inline) target configuration\n",
"2018-06-19 08:57:54,645 INFO : TestEnv : Devlib modules to load: ['cpuidle', 'hotplug']\n",
"2018-06-19 08:57:54,647 INFO : TestEnv : Connecting linux target:\n",
"2018-06-19 08:57:54,651 INFO : TestEnv : username : root\n",
"2018-06-19 08:57:54,655 INFO : TestEnv : host : 127.0.0.1\n",
"2018-06-19 08:57:54,658 INFO : TestEnv : password : \n",
"2018-06-19 08:57:54,659 INFO : TestEnv : port : 10022\n",
"2018-06-19 08:57:54,661 INFO : TestEnv : Connection settings:\n",
"2018-06-19 08:57:54,663 INFO : TestEnv : {'username': 'root', 'host': '127.0.0.1', 'password': '', 'port': '10022'}\n",
"2018-06-19 08:57:58,214 INFO : TestEnv : Initializing target workdir:\n",
"2018-06-19 08:57:58,219 INFO : TestEnv : /root/devlib-target\n",
"2018-06-19 08:58:00,862 INFO : TestEnv : Attempting to read energy model from target\n",
"2018-06-19 08:58:00,866 ERROR : TestEnv : Couldn't read target energy model: Requires cpufreq devlib module. Please ensure \"cpufreq\" is listed in your target/test modules\n",
"2018-06-19 08:58:00,871 INFO : TestEnv : Topology:\n",
"2018-06-19 08:58:00,873 INFO : TestEnv : [[0, 1, 2, 3]]\n",
"2018-06-19 08:58:00,876 WARNING : TestEnv : Unable to identify cluster frequencies\n",
"2018-06-19 08:58:06,666 INFO : TestEnv : Enabled tracepoints:\n",
"2018-06-19 08:58:06,669 INFO : TestEnv : sched_switch\n",
"2018-06-19 08:58:06,670 INFO : TestEnv : Using configuration provided RTApp calibration\n",
"2018-06-19 08:58:06,672 INFO : TestEnv : Using RT-App calibration values:\n",
"2018-06-19 08:58:06,674 INFO : TestEnv : {\"0\": 23, \"1\": 23, \"2\": 23, \"3\": 23}\n",
"2018-06-19 08:58:06,675 INFO : TestEnv : Set results folder to:\n",
"2018-06-19 08:58:06,676 INFO : TestEnv : /home/juri/work/lisa/results/cpuset-cgroup2-waiman-v10\n",
"2018-06-19 08:58:06,678 INFO : TestEnv : Experiment results available also in:\n",
"2018-06-19 08:58:06,679 INFO : TestEnv : /home/juri/work/lisa/results_latest\n"
]
}
],
"source": [
"te = TestEnv(my_conf, force_new=True, wipe=False)\n",
"target = te.target"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2018-06-19 08:58:06,688 INFO : root : Target ABI: x86_64, CPus: ['QEMU Virtual version 2.5+', 'QEMU Virtual version 2.5+', 'QEMU Virtual version 2.5+', 'QEMU Virtual version 2.5+']\n"
]
}
],
"source": [
"logging.info(\"Target ABI: %s, CPus: %s\",\n",
" target.abi,\n",
" target.cpuinfo.cpu_names)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Mount"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"target.execute('mount -t cgroup none /sys/fs/cgroup');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Create and modify a single domain root"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: ', 'doms_cur[0]: 0-3 rd->span: 0-3 (n)', '']"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"target.execute('mkdir /sys/fs/cgroup/group1');"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 0-1 > /sys/fs/cgroup/group1/cpuset.cpus');"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 0 > /sys/fs/cgroup/group1/cpuset.mems');"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 0 > /sys/fs/cgroup/cpuset.sched_load_balance');"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: 2-3', 'doms_cur[0]: 0-1 rd->span: 0-1 (n)', '']"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### There are now 2 root domains (2-3 is the (default) root and 0-1 is group1)\n",
"### Note that CPUs 2-3 are now part of def_root_domain, as load balance is disabled for root"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 0 > /sys/fs/cgroup/group1/cpuset.cpus');"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: 1-3', 'doms_cur[0]: 0 rd->span: 0 (n)', '']"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo '' > /sys/fs/cgroup/group1/cpuset.cpus');"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['', '']"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /sys/fs/cgroup/group1/cpuset.cpus').split('\\r\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Weird, I could successfully remove the last CPU from group1 cpus (domains stay the same though)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 0-3 > /sys/fs/cgroup/group1/cpuset.cpus');"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: ', 'doms_cur[0]: 0-3 rd->span: 0-3 (n)', '']"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### With cgroup v1 root domain can become empty"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"target.execute('rmdir /sys/fs/cgroup/group1');"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: 0-3', '']"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 1 > /sys/fs/cgroup/cpuset.sched_load_balance');"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: ', 'doms_cur[0]: 0-3 rd->span: 0-3 (n)', '']"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Create and modify two domain roots"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [],
"source": [
"target.execute('mkdir /sys/fs/cgroup/group1');\n",
"target.execute('mkdir /sys/fs/cgroup/group2');"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 0-1 > /sys/fs/cgroup/group1/cpuset.cpus');\n",
"target.execute('echo 2-3 > /sys/fs/cgroup/group2/cpuset.cpus');"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 0 > /sys/fs/cgroup/cpuset.sched_load_balance');"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: ',\n",
" 'doms_cur[0]: 0-1 rd->span: 0-1 (n)',\n",
" 'doms_cur[1]: 2-3 rd->span: 2-3 (n)',\n",
" '']"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [],
"source": [
"target.execute('echo 0 > /sys/fs/cgroup/group1/cpuset.cpus');\n",
"target.execute('echo 1-2 > /sys/fs/cgroup/group2/cpuset.cpus');"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: 3',\n",
" 'doms_cur[0]: 0 rd->span: 0 (n)',\n",
" 'doms_cur[1]: 1-2 rd->span: 1-2 (n)',\n",
" '']"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Hotplug"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [],
"source": [
"target.hotplug.offline(2)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: 3',\n",
" 'doms_cur[0]: 0 rd->span: 0 (n)',\n",
" 'doms_cur[1]: 1 rd->span: 1 (n)',\n",
" '']"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
"target.hotplug.online(2)"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: 2-3',\n",
" 'doms_cur[0]: 0 rd->span: 0 (n)',\n",
" 'doms_cur[1]: 1 rd->span: 1 (n)',\n",
" '']"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### CPU2 membership is lost after an hotplug event"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
"target.hotplug.offline(2)"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
"target.execute('rmdir /sys/fs/cgroup/group2');"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [],
"source": [
"target.hotplug.online(2)"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['def_root_domain: 1-3', 'doms_cur[0]: 0 rd->span: 0 (n)', '']"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"target.execute('cat /proc/doms_debug').split('\\r\\n')"
]
}
],
"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.14"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment