From: Kevin Hilman <khilman@linaro.org>
To: Mats Liljegren <liljegren.mats2@gmail.com>
Cc: Linux Test Project General Discussions
<ltp-list@lists.sourceforge.net>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [LTP] Testing absence of ticks with nohz_full
Date: Thu, 13 Mar 2014 15:10:04 -0700 [thread overview]
Message-ID: <7hsiqlkawz.fsf@paris.lan> (raw)
In-Reply-To: <531DC318.7060504@gmail.com> (Mats Liljegren's message of "Mon, 10 Mar 2014 14:50:16 +0100")
Mats Liljegren <liljegren.mats2@gmail.com> writes:
> My company (Enea) wants to create test case(s) that verifies that you
> can run an application without having ticks going on the CPU that the
> application runs on. This would utilize the new nohz_full feature
> available from kernel version 3.10.
>
> I cannot find any existing test case in LTP in this area, so I assume
> I have to create the test case myself.
It's not in LTP, but I have a shell script[1] does some setup and load
generation that I use to validate nohz_full. The setup and
prerequisites can be a bit tricky, but some of the things it does:
- disables the residual 1Hz (if my patch is applied)
- pinning the unbound "writeback" workqueue to CPU0
- force timer migration using hotplug
- sets up CPUsets and tries to migrate all tasks to CPU0
(I think this part came from a script from you awhile ago)
It then uses 'stress' to generate load on specific CPUs and uses
trace-cmd to record the traces.
I currently look at the traces manually to see if it worked, but adding
other step to automatially look at the traces would be a good next step.
Kevin
[1]
#!/bin/bash
# Check that we have cpusets enabled in the kernel
if ! grep -q -s cpuset /proc/filesystems ; then
echo "Error: Kernel is lacking support for cpuset!"
exit 1
fi
# Try to disable sched_tick_max_deferment
if [ -e /sys/kernel/debug/sched_tick_max_deferment ]; then
echo -1 > /sys/kernel/debug/sched_tick_max_deferment
else
echo "WARNING: unable to set sched_tick_max_deferment"
fi
# if CONFIG_LOCKUP_DETECTOR is enabled, a periodic timer fires
# on *every* CPU, including idle ones. Disable it.
if [ -e /proc/sys/kernel/watchdog ]; then
echo 0 > /proc/sys/kernel/watchdog
fi
declare -a all_cpus=(`for file in /sys/devices/system/cpu/cpu*/online; do basename $(dirname $file); done`)
declare -a cpus=( ${all_cpus[@]/cpu0/} ) # without CPU0
max_cpu=$((${#all_cpus[@]} - 1))
#
# Force migration off of NO_HZ CPUs using hotplug
# TODO: document what happens without this
#
for cpu in ${cpus[@]}; do
echo 0 > /sys/devices/system/cpu/$cpu/online
done
for cpu in ${cpus[@]}; do
echo 1 > /sys/devices/system/cpu/$cpu/online
done
# TODO: document what happens without this
# pin the writeback workqueue to CPU0
echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
# make sure that the /dev/cpuset dir exits
# and mount the cpuset filesystem if needed
[ -d /dev/cpuset ] || mkdir /dev/cpuset
[ -e /dev/cpuset/tasks ] || mount -t cpuset none /dev/cpuset
# Create 2 cpusets. One GP and one NOHZ domain.
[ -d /dev/cpuset/gp ] || mkdir /dev/cpuset/gp
[ -d /dev/cpuset/rt ] || mkdir /dev/cpuset/rt
# Assume a single memory node
echo 0 > /dev/cpuset/gp/mems
echo 0 > /dev/cpuset/rt/mems
# Setup the GP domain: CPU0
echo 0 > /dev/cpuset/gp/cpus
# Setup the NOHZ domain: CPU1+
echo 1-$max_cpu > /dev/cpuset/rt/cpus
# Try to move all processes in top set to the GP set.
for pid in `cat /dev/cpuset/tasks`; do
if [ -d /proc/$pid ]; then
echo $pid > /dev/cpuset/gp/tasks 2>/dev/null
if [ $? != 0 ]; then
echo -n "Cannot move PID $pid: "
echo "$(cat /proc/$pid/status | grep ^Name | cut -f2)"
fi
fi
done
# Disable load balancing on top level (otherwise the child-sets' setting
# won't take effect.)
echo 0 > /dev/cpuset/sched_load_balance
# Enable load balancing withing the GP domain
echo 1 > /dev/cpuset/gp/sched_load_balance
#echo 1 > /dev/cpuset/rt/sched_load_balance
# But disallow load balancing within the NOHZ domain
echo 0 > /dev/cpuset/rt/sched_load_balance
DURATION=30
BACKOFF=$((DURATION / 8 * 1000000))
# Move self into GP domain
echo $$ > /dev/cpuset/gp/tasks
trace-cmd start -b 10000 -e sched -e irq -e timer -e signal
#trace-cmd start -b 100000 -e all
# GP domain
stress -q --cpu 2 --vm 2 --timeout $DURATION &
GP_PID=$!
# NOHZ domain
echo $$ > /dev/cpuset/rt/tasks || exit 1
# 2 temporarly overlapping tasks
stress -q --cpu 1 --timeout $[DURATION / 3] &
stress -q --cpu 1 --backoff $BACKOFF --timeout $[DURATION - 1] &
NOHZ_PID=$!
# start another busy task on the last CPU for >2 CPU machines
if [ $max_cpu > 1 ]; then
taskset -c $max_cpu stress -q --cpu 1 --timeout $DURATION &
fi
# Switch back to GP
echo $$ > /dev/cpuset/gp/tasks
# Wait for GP task(s) to finish
wait $GP_PID
trace-cmd stop
trace-cmd extract
sync
exit 0
#
# Cleanup
#
# Try to move all from GP back to root
for pid in `cat /dev/cpuset/gp/tasks`; do
if [ -d /proc/$pid ]; then
echo $pid > /dev/cpuset/tasks 2>/dev/null
if [ $? != 0 ]; then
echo -n "Cannot move PID $pid: "
echo "$(cat /proc/$pid/status | grep ^Name | cut -f2)"
fi
fi
done
# Remove the CPUsets
rmdir /dev/cpuset/gp
rmdir /dev/cpuset/rt
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-03-13 22:10 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-10 13:50 [LTP] Testing absence of ticks with nohz_full Mats Liljegren
2014-03-10 14:04 ` chrubis
2014-03-10 15:17 ` Frederic Weisbecker
2014-03-10 15:27 ` Steven Rostedt
2014-03-10 15:33 ` Frederic Weisbecker
2014-03-11 10:34 ` Mats Liljegren
2014-03-11 23:31 ` Steven Rostedt
2014-03-13 22:10 ` Kevin Hilman [this message]
2014-03-17 16:35 ` Mats Liljegren
2014-04-16 15:48 ` [LTP] [RFC][PATCH] partrt_nohz_full: Introducing a new test case Mats Liljegren
2014-04-16 15:48 ` Mats Liljegren
2014-04-22 15:47 ` chrubis
[not found] ` <20140423124410.29874232@mats-desktop>
2014-04-23 11:34 ` chrubis
[not found] ` <20140424105218.5cd2b5bf@mats-desktop>
2014-04-24 9:06 ` chrubis
[not found] ` <20140424140358.63dac752@mats-desktop>
2014-04-24 12:35 ` chrubis
2014-04-22 14:07 ` chrubis
[not found] ` <20140423084101.536f03f0@mats-desktop>
2014-04-23 10:24 ` chrubis
2014-04-28 15:06 ` [LTP] [PATCH v2] " Mats Liljegren
2014-04-28 15:06 ` [LTP] [PATCH] " Mats Liljegren
2014-05-06 16:20 ` chrubis
[not found] ` <20140507132016.40361a0a@mats-desktop>
2014-05-07 12:17 ` chrubis
2014-05-13 14:11 ` [LTP] [PATCH v3] " Mats Liljegren
2014-05-13 14:11 ` Mats Liljegren
2014-06-02 17:17 ` chrubis
[not found] ` <20140603104018.3b0cba6f@mats-desktop>
2014-06-03 11:31 ` chrubis
[not found] ` <20141030171737.3eb800f1@mats-desktop>
2014-11-26 13:40 ` Cyril Hrubis
2014-05-28 16:45 ` Mats Liljegren
2014-05-29 12:21 ` chrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7hsiqlkawz.fsf@paris.lan \
--to=khilman@linaro.org \
--cc=fweisbec@gmail.com \
--cc=liljegren.mats2@gmail.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox