numa_num_task_cpus() returns here > 100 CPUs while the system has only
32 populated. The BIOS assumes that I can probably use larger CPUs (with
more cores) on the socket so the number of "configured CPUs" is rather
high.
It makes sense to use the current affinity instead of looking
at the number of possible CPUs which could be brought online.
It still depends on the affinity of the created threads
if the additional CPUs can be used. In a container setup
this may not be the case.
Use sched_getaffinity() to figure out the number of possible CPUs.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- Edited the commit message to remove reference to -S
Signed-off-by: John Kacur <jkacur@redhat.com>
New option -W/--bucket-width allows the user to specify how large of a
range of latencies is covered by a single bucket, including allowing the
creation of sub-microsecond buckets.
When the flag is not used, output should be unchanged. However, if a
bucket width is specified that is not a multiple of one microsecond,
latencies will be output as fractional microseconds, at nanosecond
precision. This includes JSON output.
When using this option, it is up to the user to determine what level
of precision is meaningful relative to measurement error, as is noted
in the documentation.
Signed-off-by: Crystal Wood <swood@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
At some point
self.testduration = 10
was changed to
self.testduration = 30
but retained the comment, "ten seconds"
Just change the comment to say, "in seconds" so it's clear what unit
we are talking about.
Signed-off-by: John Kacur <jkacur@redhat.com>
In Python 3, "/" is a float division operator, as opposed to Python 2,
which defaults to integer division. This results in an error when
calculating width, which assumes an integer.
Update width division to integer division with the "//" operator.
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
print_usage_exit(0) never returns, but the compiler doesn't understand
this. In any case it is not harmful to add a break after this statement.
Do so to keep the unhelpful compiler warning from triggering.
Signed-off-by: John Kacur <jkacur@redhat.com>
Using cyclictest without specifying affinity via -a, I was
noticing a strange issue where the rt threads where not
migrating when being blocked.
After lots of debugging in the kernel, I found its actually an
issue with cyclictest.
When using -t there is no behavioral difference between specifying
-a or not specifying -a.
This can be confirmed by adding printf messages around the
pthread_setaffinity_np() call in the threadtest function.
Currently:
root@localhost:~/rt-tests# ./cyclictest -t -a -q -D1
Affining thread 0 to cpu: 0
Affining thread 1 to cpu: 1
Affining thread 2 to cpu: 2
Affining thread 3 to cpu: 3
Affining thread 4 to cpu: 4
Affining thread 5 to cpu: 5
Affining thread 7 to cpu: 7
Affining thread 6 to cpu: 6
T: 0 (15034) P: 0 I:1000 C: 1000 Min: 82 Act: 184 Avg: 180 Max: 705
...
root@localhost:~/rt-tests# ./cyclictest -t -q -D1
Affining thread 0 to cpu: 0
Affining thread 1 to cpu: 1
Affining thread 2 to cpu: 2
Affining thread 3 to cpu: 3
Affining thread 4 to cpu: 4
Affining thread 5 to cpu: 5
Affining thread 6 to cpu: 6
Affining thread 7 to cpu: 7
T: 0 (15044) P: 0 I:1000 C: 1000 Min: 74 Act: 144 Avg: 162 Max: 860
..
This issue seems to come from the logic in process_options():
/* if smp wasn't requested, test for numa automatically */
if (!smp) {
numa = numa_initialize();
if (setaffinity == AFFINITY_UNSPECIFIED)
setaffinity = AFFINITY_USEALL;
}
Here, by setting setaffinity = AFFINITY_USEALL, we effectively
pin each thread to its respective cpu, same as the "-a" option.
This was most recently introduced in commit bdb8350f1b
("Revert "cyclictest: Use affinity_mask for steering
thread placement"").
This seems erronious to me, so I wanted to share this patch
which removes the overriding AFFINITY_UNSPECIFIED with
AFFINITY_USEALL by default. Also, some additional tweaks to
preserve the existing numa allocation affinity.
With this patch, we no longer call pthread_setaffinity_np() in the
"./cyclictest -t -q -D1" case.
Cc: John Kacur <jkacur@redhat.com>
Cc: Connor O'Brien <connoro@google.com>
Cc: Qais Yousef <qais.yousef@arm.com>
Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
cyclictest has tracelimit to stop running when max latency
is higher than threshold but cyclicdeadline doesn't.
Therefore, tracelimit is introduced to cyclicdeadline in
this commit, once max latency is over, test stops and log
prints at the bottom of the ftrace file.
Signed-off-by: Song Chen <chensong_2000@189.cn>
Reviewed-by: Daniel Wagner <wagi@monom.org>
- Fixed style problems reported by checkpatch from kernel, namely
- Don't initialize static to 0
- no space after open parenthesis
- removed multiple spaces after Reviewed-by
Signed-off-by: John Kacur <jkacur@redhat.com>
Using verbose with affinity and no affinity mask causes a
segmentation mask. Fix this by checking if the affinity mask is NULL
before printing the verbose message.
Reported-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
Assuming the current affinity mask of the task is 0x31 (CPUs 0, 4, 5).
Starting cyclictest with '-S' option will fork the following threads:
- monitor, mask 0x31
- measure thread 1, mask 0x01
- measure thread 2, mask 0x10
- measure thread 3, mask 0x20
works as expected. Using the options '-S --mainaffinity=0' leads to:
- monitor, mask 0x01
- measure thread 1, mask 0x01
- measure thread 2, mask 0x01
- measure thread 3, mask 0x01
because the mask of the main thread has been reset early to 0x01 and
does not allow a CPU mask outside of this mask while setting the
affinity for the new threads.
Delay setting the affinity of the main/ monitor thread after the
measuring threads have been deployed. This leads to the following
state:
- monitor, mask 0x01
- measure thread 1, mask 0x01
- measure thread 2, mask 0x10
- measure thread 3, mask 0x20
Signed-off-by: Sebastian Andrzej Savior <bigeasy@linutronix.de>
Signed-off-by: John Kacur <jkacur@redhat.com>
We observerved strange performance regression with hackbench, but only with
its default mode instead of pipe mode. It turned out it was unix domain
socket to blame rather than the scheduler. Because on older kernels, there
was a big lock. And modifications to the scheduler made the contension
worse.
However pipe mode is much different from the default af_unix mode. So it's
hard to prove it's really the case. So we think it might be a good idea to
have af_inet mode for hackbench.
After implementing it, we compare these three modes. And the result shows
as what we expect, that only af_unix mode has regression, the others don't.
This proves adding af_inet mode is valuable.
Signed-off-by: Yihao Wu <wuyihao@linux.alibaba.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
This very early program in the rt-tests suite has been completed
rewritten and is now called pi_stress. There is no reason to keep these
old files around.
Signed-off-by: John Kacur <jkacur@redhat.com>
Updating has_smi_counter to match most recent turbostat code, in
order to support recent cpu models (e.g. Ice Lake).
Restructured the code to match the turbostat functions so it will
be easier to keep the code in sync in the future.
Signed-off-by: Bart Wensley <bwensley@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
The hwlat tracer can be configured to run on a set of cpus via
tracing_cpumask [1].
Add a new option cpu-list to support the configuration of
tracing_cpumask in the format of cpu list.
For example, if we want the thread to run on CPU 1,2,3 and 5,
we can specify the cpu list to 1-3,5
The value to pass to hwlatdetect is:
$ hwlatdetect --cpu-list=1-3,5
[1]: https://docs.kernel.org/trace/hwlat_detector.html
Signed-off-by: Oscar Shiang <oscar0225@livemail.tw>
Signed-off-by: John Kacur <jkacur@redhat.com>
Knowing which CPU went above the trace threshold is useful information,
even when not tracing. So let's print it.
Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
When parse /proc/cpuinfo, the size of "flags" may exceed 1024,
this will cause "realloc(): invalid next size" error, increase
the buf size to 2048 to fix this case.
Signed-off-by: Liwei Song <liwei.song@windriver.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
When using isolcpus kernel command line option, the CPUs
specified at isolcpus= are not part of the run time environment
cpumask.
This causes "cyclictest -a isolatedcpus" to fail with:
WARN: Couldn't setaffinity in main thread: Invalid argument
FATAL: No allowable cpus to run on
# /dev/cpu_dma_latency set to 0us
To fix this, ignore the runtime cpumask if neither "+", "!"
are specified in the cpu list string.
Suggested by Sebastian Andrzej Siewior.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
v2: fix changelog typo
v3: simplified version (John Kacur)
Signed-off-by: John Kacur <jkacur@redhat.com>
Make sure that -a all and -a '+' are passed to parse_cpumask().
Currently this doesn't work correctly if there is a space after -a and the
string.
While we are at it, fix the message in oslat which calls
numa_parse_cpustring_all directly to say that.
Signed-off-by: John Kacur <jkacur@redhat.com>
The option --bias does not require an argument and the bias should
be estimated later.
There is no need to provide USEC to --bias option.
Signed-off-by: Oscar Shiang <oscar0225@livemail.tw>
Signed-off-by: John Kacur <jkacur@redhat.com>
numa_initialize() returns 0 only when numa_available() returns -1,
which means that libnuma is unavailable.
The return values in the comment should be corrected to 1 if all
functions are available and 0 when the functions are unavailable.
Signed-off-by: Oscar Shiang <oscar0225@livemail.tw>
Signed-off-by: John Kacur <jkacur@redhat.com>
clock_nanosleep is default now.
There is no need to use -s with -n.
Signed-off-by: Oscar Shiang <oscar0225@livemail.tw>
Signed-off-by: John Kacur <jkacur@redhat.com>
If /sys/fs/cgroup exists and it is type cgroup2, cyclicdeadline mounts it a
second time as cgroup.
systemd is creating cgroup2 for logins and this can hang the machine and
not allow logins.
Fix this by:
If /sys/fs/cgroup exists, then use it for cyclicdeadline_test.
If it exists but the type is not recognized, exit with an error.
Do not simply mount it as type cgroup.
TODO: If the file doesn't exit but cgroups are supported in the kernel,
the file could be created and mounted.
Signed-off-by: John Kacur <jkacur@redhat.com>
If /sys/fs/cgroup exists and it is type cgroup2, deadline mounts it a
second time as cgroup.
systemd is creating cgroup2 for logins and this can hang the machine and
not allow logins.
Fix this by:
If /sys/fs/cgroup exists, then use it for deadline_test.
If it exists but the type is not recognized, exit with an error.
Do not simply mount it as type cgroup.
TODO: If the file doesn't exit but cgroups are supported in the kernel,
the file could be created and mounted.
Signed-off-by: John Kacur <jkacur@redhat.com>
Two copies of "bufsize", initialised with the same value are declared
in enclosed blocks. Remove the redundant declaration.
Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
Signed-off-by: John Kacur <jkacur@redhat.com>
The timespec structure "stop" is initialised whether it is used or not
as the compiler is not smart enough to figure out that it's use is
always guarded by the "duration" variable. As a result, "stop" needs
to be initialised whether it's used or not to avoid a compiler
warning.
Replace the duplicate memset statements by initializing "stop" using
structure initialiser.
Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
Signed-off-by: John Kacur <jkacur@redhat.com>
KVARS, KVARNAMELEN and KVALUELEN defines are not used in
cyclictest. Drop them.
Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
Signed-off-by: John Kacur <jkacur@redhat.com>
- Remove class Kmod
Kmod was used for loading and unloading of a kernel module, but
hwlatdetect uses ftrace now so this class is unneeded.
- Improve the spacing in the code
Signed-off-by: John Kacur <jkacur@redhat.com>
- Use abstractmethod decorator instead of raising error if a method is
not overridden.
- Remove unnecessary trailing comma
- fix import order
Signed-off-by: John Kacur <jkacur@redhat.com>
hwlatdetect converted to using ftrace a long time ago.
Since we no longer need to load a kernel module, the class Hwlat can be
removed.
Signed-off-by: John Kacur <jkacur@redhat.com>
histogram and histofall take a required argument.
If the user fails to supply one, display the help and exit with an error
Signed-off-by: John Kacur <jkacur@redhat.com>
Fix a floating point exception that can occur if sd->nr_adjust is 0
by checking it before performing a division by zero.
Signed-off-by: John Kacur <jkacur@redhat.com>
This patch adds the long option --default-system
--default-system runs cyclictest without attempting any tuning.
Power management is not suppressed so cyclictest measures the system as
it is configured.
This is effectively the same as --laptop, but makes it clear to the user
what is done and why.
Tested-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
- Update the help and man page for --latency
- Fix some sorting of --latency and --loops
Tested-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>