summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <ukleinek@debian.org>2016-04-14 09:02:44 +0200
committerUwe Kleine-König <ukleinek@debian.org>2016-04-14 09:02:44 +0200
commit3b1c099625ce4347c529156bf583d95d4076dbde (patch)
treeeefe8eee300dfe4524fe5590d6870e06e3308a44
parent55d4500f383c5153d80126ed57a129a0a28743dd (diff)
parent0e8a13a6465a1b9b48374afce628693ddc298b92 (diff)
downloadrt-tests-3b1c099625ce4347c529156bf583d95d4076dbde.tar.gz
rt-tests-3b1c099625ce4347c529156bf583d95d4076dbde.tar.xz
[debian] Merge tag 'v0.97' of git://git.kernel.org/pub/scm/utils/rt-tests/rt-tests
v0.97 Signed-off-by: John Kacur <jkacur@gmail.com>
-rw-r--r--.gitattributes2
-rw-r--r--Makefile62
-rw-r--r--rt-tests.spec-in524
-rw-r--r--src/cyclictest/cyclictest.84
-rw-r--r--src/cyclictest/cyclictest.c287
-rwxr-xr-xsrc/hwlatdetect/hwlatdetect.py42
-rw-r--r--src/pi_tests/pi_stress.c2
-rw-r--r--src/pi_tests/pip_stress.c6
-rw-r--r--src/signaltest/signaltest.c2
9 files changed, 316 insertions, 615 deletions
diff --git a/.gitattributes b/.gitattributes
index 0867b81..0116a6c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,4 @@
.gitattributes export-ignore
.gitignore export-ignore
-rt-tests.spec-in export-ignore
+doc export-ignore
scripts export-ignore
diff --git a/Makefile b/Makefile
index 1e4b7d1..280fd3b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
-VERSION = 0.96
-CC=$(CROSS_COMPILE)gcc
-AR=$(CROSS_COMPILE)ar
+VERSION = 0.97
+CC?=$(CROSS_COMPILE)gcc
+AR?=$(CROSS_COMPILE)ar
OBJDIR = bld
@@ -140,7 +140,7 @@ LIBOBJS =$(addprefix $(OBJDIR)/,error.o rt-get_cpu.o rt-sched.o rt-utils.o)
$(OBJDIR)/librttest.a: $(LIBOBJS)
$(AR) rcs $@ $^
-CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec *.d *.a
+CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej *.d *.a
CLEANUP += $(if $(wildcard .git), ChangeLog)
.PHONY: clean
@@ -153,17 +153,13 @@ clean:
RPMDIRS = BUILD BUILDROOT RPMS SRPMS SPECS
.PHONY: distclean
distclean: clean
- rm -rf $(RPMDIRS) releases *.tar.gz *.tar.asc rt-tests.spec tmp
+ rm -rf $(RPMDIRS) releases *.tar.gz *.tar.asc tmp
.PHONY: rebuild
rebuild:
$(MAKE) clean
$(MAKE) all
-.PHONY: changelog
-changelog:
- git log >ChangeLog
-
.PHONY: install
install: all install_hwlatdetect
mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(mandir)/man4"
@@ -191,56 +187,11 @@ install_hwlatdetect: hwlatdetect
ln -s $(PYLIB)/hwlatdetect.py "$(DESTDIR)$(bindir)/hwlatdetect" ; \
gzip -c src/hwlatdetect/hwlatdetect.8 >"$(DESTDIR)$(mandir)/man8/hwlatdetect.8.gz" ; \
fi
-.PHONY: release
-release: distclean changelog
- mkdir -p releases
- mkdir -p tmp/rt-tests
- cp -r Makefile COPYING ChangeLog MAINTAINERS doc README.markdown src tmp/rt-tests
- rm -f rt-tests-$(VERSION).tar rt-tests-$(VERSION).tar.asc
- tar -C tmp -cf rt-tests-$(VERSION).tar rt-tests
- gpg2 --default-key clrkwllms@kernel.org --detach-sign --armor rt-tests-$(VERSION).tar
- gzip rt-tests-$(VERSION).tar
- rm -f ChangeLog
- cp rt-tests-$(VERSION).tar.gz rt-tests-$(VERSION).tar.asc releases
.PHONY: tarball
tarball:
git archive --worktree-attributes --prefix=rt-tests-${VERSION}/ -o rt-tests-${VERSION}.tar v${VERSION}
-.PHONY: push
-push: release
- scripts/do-git-push $(VERSION)
-
-.PHONY: pushtest
-pushtest: release
- scripts/do-git-push --test $(VERSION)
-
-rt-tests.spec: Makefile rt-tests.spec-in
- sed s/__VERSION__/$(VERSION)/ <$@-in >$@
-ifeq ($(NUMA),1)
- sed -i -e 's/__MAKE_NUMA__/NUMA=1/' $@
- sed -i -e 's/__BUILDREQUIRES_NUMA__/numactl-devel/' $@
-else
- sed -i -e 's/__MAKE_NUMA__//' $@
- sed -i -e 's/__BUILDREQUIRES_NUMA__//' $@
-endif
-
-
-HERE := $(shell pwd)
-RPMARGS := --define "_topdir $(HERE)" \
- --define "_sourcedir $(HERE)/releases" \
- --define "_builddir $(HERE)/BUILD" \
-
-.PHONY: rpm
-rpm: rpmdirs release rt-tests.spec
- rpmbuild -ba $(RPMARGS) rt-tests.spec
-
-.PHONY: rpmdirs
-rpmdirs:
- @[ -d BUILD ] || mkdir BUILD
- @[ -d RPMS ] || mkdir RPMS
- @[ -d SRPMS ] || mkdir SRPMS
-
.PHONY: help
help:
@echo ""
@@ -248,10 +199,9 @@ help:
@echo ""
@echo " all : build all tests (default"
@echo " install : install tests to local filesystem"
- @echo " release : build source tarfile"
- @echo " rpm : build RPM package"
@echo " clean : remove object files"
@echo " distclean : remove all generated files"
+ @echo " tarball : make a rt-tests tarball suitable for release"
@echo " help : print this message"
.PHONY: tags
diff --git a/rt-tests.spec-in b/rt-tests.spec-in
deleted file mode 100644
index 937d2dc..0000000
--- a/rt-tests.spec-in
+++ /dev/null
@@ -1,524 +0,0 @@
-%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
-
-Summary: Programs that test various rt-features
-Name: rt-tests
-# These will be setup by the "make rpm" logic
-# Version: __VERSION__
-# BuildRequires: __BUILDREQUIRES_NUMA__
-# Numa argument to make: __MAKE_NUMA__
-#
-Version: __VERSION__
-Release: 1%{?dist}
-License: GPLv2
-Group: Development/Tools
-URL: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/rt-tests.git
-Source0: %{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-Obsoletes: cyclictest signaltest pi_tests
-ExclusiveArch: x86_64
-BuildRequires: __BUILDREQUIRES_NUMA__ python
-
-%description
-rt-tests is a set of programs that test and measure various components of
-real-time kernel behavior. This package measures timer, signal, and hardware
-latency. It also tests the functioning of priority-inheritance mutexes.
-
-%prep
-%setup -qn rt-tests
-
-%build
-make __MAKE_NUMA__
-
-%install
-rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/%{python_sitelib}
-make DESTDIR=$RPM_BUILD_ROOT prefix=/usr install
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root,-)
-%{python_sitelib}/hwlatdetect.py*
-/usr/bin/cyclictest
-/usr/bin/pi_stress
-/usr/bin/signaltest
-/usr/bin/hwlatdetect
-/usr/bin/rt-migrate-test
-/usr/bin/pip_stress
-/usr/bin/ptsematest
-/usr/bin/sendme
-/usr/bin/sigwaittest
-/usr/bin/svsematest
-/usr/bin/pmqtest
-/usr/bin/hackbench
-/usr/src/backfire/backfire.c
-/usr/src/backfire/Makefile
-%doc
-/usr/share/man/man8/cyclictest.8.gz
-/usr/share/man/man8/pi_stress.8.gz
-/usr/share/man/man8/hwlatdetect.8.gz
-/usr/share/man/man4/backfire.4.gz
-/usr/share/man/man8/ptsematest.8.gz
-/usr/share/man/man8/sendme.8.gz
-/usr/share/man/man8/sigwaittest.8.gz
-/usr/share/man/man8/svsematest.8.gz
-/usr/share/man/man8/pmqtest.8.gz
-/usr/share/man/man8/hackbench.8.gz
-/usr/share/man/man8/signaltest.8.gz
-
-%changelog
-* Thu Oct 22 2015 John Kacur <jkacur@redhat.com> - 0.96-1
-- Clark Williams
- - Makefile: add target to create OBJDIR before use
- - specfile: add signaltest manpage to files section and remove trailing
- whitespace in changelog
- - Makefile: have distclean remove .asc file for tarball
-
-- Henrik Austad
- - Android: clean up the bypass ifdeffery
- - Android: rename arch from bionic to android
- - Android: Expand match for android in ostype
- - rt-sched.h: do not unconditionally define syscall-numbers
-
-- John Kacur
- - cyclictest: Clean-ups in timerthread before working on it
- - Makefile: OBJDIR should be an order-only-prerequisite
- - Makefile: Move TARGETS back to a more logical place in the Makefile
- - cyclictest: Add a feature to record spikes
- - cyclictest: fix #ifdef broken by NO_PTHREAD_SETAFFINITY
-- Uwe Kleine-König
- - Fix some trivial typos found by codespell
-
-* Wed Oct 07 2015 John Kacur <jkacur@redhat.com> - 0.95-1
-- Henrik Austad
- - cyclictest: move redefine of CPUSET back to uclib
-- John Kacur
- - Explicitly separate VPATH paths with a colon
- - build: Generate .o, .a, and .d files in bld dir
- - signaltest: call process_options before calling check_privs
- - signaltest: Check the status of pthread_create
- - rt-utils: Add John Kacur to the copyright
- - rt-utils: Fix some checkpatch errors in rt-utils.c
- - signaltest: Add a man page to signaltest
- - Makefile: Document certain compiling options
- - Makefile: Only call cc -dumpmachine once in the makefile
- - Bionic: Move android functionality into it's own arch Makefile
-- Uwe Kleine-König
- - backfire: remove unused header file
- - remove several unused Makefiles
- - rt-migrate-test: remove space before \n
- - drop compiling without NPTL support
-
-* Mon Sep 21 2015 John Kacur <jkacur@redhat.com> - 0.94-1
-- Clark Williams
- - hwlatdetect: initial cut at tracking the amount of SMIs that occurred
- during a run
- - rt-migrate-test: updated to latest code from rostedt
-- Darren Hart
- - rt-tests: Allow for user-specified PYLIB
- - rt-tests: Break out install_hwlatdetect
-- Henrik Austad
- - Add CROSS_COMPILE-switch to CC and AR
- - Add syscall-number for sched_(gs)etattr() for tile
- - Add a rebuild-switch to Makefile
- - Makefile: add librttest to rt-migrate-test
- - android: adjust target for android
-- John Kacur
- - Fix VERSION in rt-migrate-test
- - numa_on_and_available: Remove from main in cyclictest
-- Josh Cartwright
- - rt-tests: workaround poor gzip implementations
- - hackbench: cleanup error handling in create_worker
- - cyclictest: consistently make all functions 'static'
- - cyclictest: use correct type when allocating cpu bitmask size
- - cyclictest: drop impossible use_fifo conditional
- - cyclictest: fail if use_fifo && thread creation failed
- - error: mark fatal, err_exit, err_quit as being noreturn
- - cyclictest: add option for dumping the histogram in a file
-
-* Thu Aug 13 2015 John Kacur <jkacur@redhat.com> - 0.93-1
-- Alexander Stein
- - cyclictest: Fix long priority help text option
- - cyclictest: Fix long priority help text option
-- Clark Williams
- - makefile: fixed release target
- - hwlatdetect: added --watch option to watch output in realtime
- - doc: fix VERSION in release-checklist.txt
-- John Kacur
- - Fix warning: unused variable ‘c’
- - Fix possible exit on error without releasing mutex
- - Create a .gitattribute file to specify what files git-archive should
- ignore
- - Add .tar files to .gitignore
- - Change VERSION_STRING to VERSION
- - Create an rt-tests.tar file using git-archive
-
-* Tue Jun 09 2015 John Kacur <jkacur@redhat.com> - 0.92-1
-- Anna-Maria Gleixner (2):
- - cyclictest: Convert the offset of the alignment option to microseconds
- - cyclictest: Align measurement threads to the next full second
- - cyclictest: Ensure that next wakeup time is never in the past
-- Daniel Wagner (1):
- - pi_stress: Clear affinity for DEADLINE tasks
-- John Kacur (3):
- - Fix minor grammar mistake in the help output
- - Allow building with -DHAVE_PARSE_CPUSTRING_ALL
- - Add a MAINTAINERS file
-- Michael Olbrich (2):
- - Makefile: pi_stress need librttest.a so it should depend on it
- - Makefile: cleanup linking to librttest.a
-- Sebastian Andrzej Siewior (1):
- - cyclictest: consider the 4 as the major version
-
-* Tue Feb 17 2015 Clark Williams <williams@redhat.com> - 0.91-1
-- From Boris Egorov <egorov@linux.com>
- - rt-migrate-test: exit early if nr_runs is non-positive
- - rt-migrate-test: use variables instead of macros
-- From Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
- - pi_stress: remove timestamp of compilation from version output
-- rt-migrate-test: make sure input parameters are converted to correct units
-- rt-migrate-test: sanity check --prio value
-
-* Tue Jan 27 2015 Clark Williams <williams@redhat.com> - 0.90-1
-- pip_stress: parameterize usleep value to work-around platform issues
-- From Daniel Wagner <daniel.wagner@bmw-carit.de>:
- - pi_stress: Store schedule attributes per thread
- - rt-utils: Add gettid()
- - rt-utils: Add helper to parse/print scheduling policies
- - rt-sched: Add sched_setattr/sched_getattr API
- - pi_stress: Use error.h for logging and debugging
- - error: Add debug() function
- - pi_stress: Remove unused TIMER_SIGNAL definition
- - rt-tests.h: Remove unused header file
- - hackbench: Don't re-assign context for each fd
-- From Joakim Hernberg <jbh@alchemy.lu>:
- - cyclictest: make affinity option only use number of online cpus
-- From John Kacur <jkacur@redhat.com>:
- - cyclictest: Add long option --laptop to preserve battery power
- - cyclictest: Fix help for long options only
- - cyclictest: Change the output from function sighand() to stderr
- - cyclictest: Always print an err message if write of 0 to cpu-dma_latency fails
- - rt_numa.h: Suppress discards 'const' qualifier warning
- - lib: Rework err_msg_n to output strerror after message
-- From Alexey Brodkin <Alexey.Brodkin@synopsys.com>:
- - Makefile: allow building selected tests with non-NPTL toolchain
-
-* Sun Mar 30 2014 Clark Williams <williams@redhat.com> - 0.89-1
-- clean up debugging comments and printfs from last release
-- ran hwlatdetect.py through 2to3, works for both python2 and 3
-
-* Fri Mar 28 2014 Clark Williams <williams@redhat.com> - 0.88-1
-- From Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
- - cyclictest: Fix tracemark output when the latency threshold is hit on ARM
-- From Gary S. Robertson <gary.robertson@linaro.org>:
- - cyclictest: Restore CPU affinity function for non-NUMA builds
- - cyclictest: Don't offer --numa option when unavailable
-
-* Wed Dec 11 2013 Clark Williams <williams@redhat.com> - 0.87-1
-- From Aaron Fabbri <ajfabbri@gmail.com>:
- - cyclictest: CPU affinity now takes arbitrary set of cpus
-
-* Fri Nov 15 2013 Clark Williams <williams@redhat.com> - 0.86-1
-- cyclictest: allow break threshold without doing any tracing
-- cyclictest: add named fifo for statistics
-- from John Kacur <jkacur@redhat.com>:
- - cyclictest: Align option fixes
- - Makefile: Don't tag files in dir BUILD from rpm builds
- - Makefile: Add BUILDROOT and SPECS to the dirs to remove for distclean
- - Makefile: Add tmp dir to distclean and "make release" call distclean
- - Makefile: Don't tag tmp files created when making a release
-- from Nicholas Mc Guire <der.herr@hofr.at>:
- - cyclictest: add align thread wakeup times option
-- cyclictest: modify option handling to use enumerated types
-- from Sebastian Andrzej Siewior <bigeasy@linutronix.de>:
- - hackbench: init child's struct before using it
-- from Jim Somerville <Jim.Somerville@windriver.com>:
- - cyclictest: finish removal of 1 second first loops
-- from Frank Rowand <frank.rowand@am.sony.com>:
- - rt-tests: NUMA optional for make rpm
- - cyclictest: white space cleanup
-
-* Tue Nov 13 2012 Clark Williams <williams@redhat.com> - 0.85-1
-- [cyclictest] add tracemark function back to breaktrace logic
-- from Frank Rowand <frank.rowand@am.sony.com>:
- - [cyclictest] report large measured clock latency
- - [cyclictest] cleanup getopt_long() parameters
-- from John Kacur <jkacur@redhat.com>:
- - [Makefile] add CPPFLAGS to pattern rule for dependencies
- - [gitignore] exclude patches and .a archives
-- from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
- - Makefile: separate CFLAGS and CPPFLAGS
- - have printf use %s format for strings
-- from Bhavesh Davda <bhavesh@vmware.com>:
- - cyclictest: histogram overflow instance tracking
- - cyclictest: whitespace cleanup
-
-* Wed May 9 2012 Clark Williams <williams@redhat.com> - 0.84-1
-- [cyclictest] added -Q/--priospread option to
-- from Markus Kohlhase <mail@markus-kohlhase.de>
- - [docs] added description from osadl.org
-- from Darren Hart <dvhart@linux.intel.com>
- - Makefile: Support user supplied CFLAGS and LDFLAGS
-- from Steven Rostedt <rostedt@goodmis.org>
- - rt-tests: Update rt-migrate-test to use ftrace infrastructure
-- from John Kacur <jkacur@redhat.com>
- - .gitignore: differentiate between program names and directories
- - pi_stress: Check the status of sched_getaffinity
- - Makefile: Introduce a static library
- - Move info, warn, and fatal functions to error.[ch]
- - install: Fix failed to create symbolic link hwlatdetect file exists
- - cyclictest: Make cyclictest fail if it cannot run with requested priority
-- from Frank Rowand <frank.rowand@am.sony.com>
- - cyclictest: segfault with '-a'
- - cyclictest: avoid unneeded warning
- - cyclictest: warn of interaction between '-a', '--smp', and '--numa'
- - Makefile: get machinetype from compiler instead of uname
- - cyclictest: incorrect first latency value for --verbose option
- - cyclictest: printf format compile warning
-
-* Mon Sep 26 2011 Clark Williams <williams@redhat.com> - 0.83-1
-- modified Makefile to be smarter about building with NUMA
-
-* Wed Sep 21 2011 Clark Williams <williams@redhat.com> - 0.82-1
-- fix print that causes error in histogram processing
-
-* Tue Sep 20 2011 Clark Williams <williams@redhat.com> - 0.81-1
-- cleaned up previous hack for /dev/cpu_dma_latency interface
-
-* Tue Sep 20 2011 Clark Williams <williams@redhat.com> - 0.80-1
-- use /dev/cpu_dma_latency interface to prevent cstate transitions
- in cyclictest
-
-* Thu Sep 15 2011 Clark Williams <williams@redhat.com> - 0.79-1
-- added signal_workers routine to hackbench
-- added -F/--fifo option to hackbench
-
-* Wed Sep 14 2011 Clark Williams <williams@redhat.com> - 0.78-1
-- modified hackebench signal logic
-
-* Fri Sep 9 2011 Clark Williams <williams@redhat.com> - 0.77-1
-- removed tracemark functions (too much contention on multiprocessors)
-
-* Wed Sep 7 2011 Clark Williams <williams@redhat.com> - 0.76-1
-- only turn on /proc/sys/kernel/ftrace_enabled for a tracer that
- needs it
-- make sure to set current_tracer to function for -f switch
-
-* Fri Sep 2 2011 Clark Williams <williams@redhat.com> - 0.75-1
-- added utility routines for mounting debugfs and event/tracing manipulation
-- from Steven Rostedt <srostedt@redhat.com>:
- - allow events for all tracers
- - Have -I and -P together also be -B
- - do not touch tracing_thresh
- - only check file descriptor in tracemark() function
- - use interval on first loop instead of 1 second
- - allow tracemark() to take variable args
-
-* Thu Aug 18 2011 Clark Williams <williams@redhat.com> - 0.74-1
-- changes to deal with 3.0 kernel
-- fixed buildrequires in specfile for Python
-- fixed spelling error in printf in cyclictest
-- from John Kacur <jkacur@redhat.com>
- - Make the function header style consistent with the rest of cyclictest.
- - Spelling clean-ups
-- from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
- - fix possible buffer overflow in string handling
-
-* Mon May 9 2011 Clark Williams <williams@redhat.com> - 0.73-1
-- fixed signal handling in hackbench (avoid thousands of zombies)
-- from Geunsik Lim <geunsik.lim@samsung.com>
- - fix incorrect wakeup interface in cyclictest
-- from Wolfram Sang <w.sang@pengutronix.de>
- - Simplify Makefile using -D option to install
-- from Carsten Emde <C.Emde@osadl.org>
- - add histogram summary column option (-H) to cyclictest
-- from Daniel Sangorrin <daniel.sangorrin@gmail.com>
- - fix sched_setaffinity type error when building with UCLIB
-- from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
- - install backfire's Makefile
- - modernize backfire's Makefile
-
-* Fri Jun 25 2010 Clark Williams <williams@redhat.com> - 0.72-1
-- changed 'diff' variable in timerthread() routine to be unsigned
- 64-bit to avoid overflow issues in debugging
-- included <stdint.h> and changed all 'long long' declarations to
- use uint64_t and int64_t
-
-* Tue May 18 2010 Clark Williams <williams@redhat.com> - 0.71-1
-- from Michal Schmit <mschmidt@redhat.com>:
- - fix accumulating overruns in periodic timer mode
-
-* Fri Apr 9 2010 Clark Williams <williams@redhat.com> - 0.70-1
-- from Olaf Hering <olaf@aepfle.de>
- - skip python dependency during install if python not available
-
-* Fri Apr 9 2010 Clark Williams <williams@redhat.com> - 0.69-1
-- fix bus error in cyclictest on NUMA systems with more than 16 cores
-- reset default cyclictest policy to SCHED_OTHER
-- from Carsten Emde <C.Emde@osadl.org>
- - add pmqest program for testing posix message queue performance
- - misc doc fixes
-
-* Fri Mar 19 2010 Clark Williams <williams@redhat.com> - 0.68-1
-- fix tracing difference between 2.6.24 and 2.6.33
-
-* Tue Mar 16 2010 Clark Williams <williams@redhat.com> - 0.67-1
-- modified specfile to add hackbench
-- modified internal ftrace logic for correct tracing
-- Changed rpm %description field to be more descriptive (BZ# 572323)
-- from Carsten Emde <c.emde@osadl.org>
- - added smp option to svsematest
- - fixed policy display in cyclictest
-- from John Kacur <jkacur@redhat.com>
- - changed default scheduling policy to SCHED_FIFO
- - fixed spelling mistake on cyclictest man page
- - use symbolic names for scheduling policy
- - reverted commit 582be2a52c43801a10d318de7491f1cc7243d5cf to
- deal with bug in priority distribution
-- from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
- - renamed pip to pip_stress
- - eliminated use of temp files in dependency generation
- - install backfire.c module source in /usr/src/backfire
-- from David Sommerseth <davids@redhat.com>
- - added new-and-improved hackbench to rt-tests
-
-* Mon Feb 15 2010 Clark Williams <williams@redhat.com> - 0.66-1
-- fix incorrect usage of sched_setscheduler in check_privs()
-
-* Mon Feb 8 2010 Clark Williams <williams@redhat.com> - 0.65-1
-- add workaround to hwlatdetect for incorrect initializer in
- smi_detector.ko
-
-* Fri Jan 29 2010 Clark Williams <williams@redhat.com> - 0.64-1
-- from John Kacur <jkacur@redhat.com>
- - automatic dependency generation
- - style cleanups
- - libnuma code cleanups
- - add copyright to rt_numa.h
-
-* Wed Jan 27 2010 Clark Williams <williams@redhat.com> - 0.63-1
-- added support for libnuma V1 API
-
-* Tue Jan 26 2010 Clark Williams <williams@redhat.com> - 0.62-1
-- added NUMA option
-- patch from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
- to clarify source copyrights
-- moved hwlatdetect to python site-library
-
-* Wed Jan 13 2010 Clark Williams <williams@redhat.com> - 0.61-1
-- added --smp/-S option to setup for basic SMP testing
-- added warn() and fatal() utility functions
-
-* Tue Dec 29 2009 Clark Williams <williams@redhat.com> - 0.60-1
-- John Kacur <jkacur@redhat.com>:
- - added pip test (process based priority inheritance)
- - refactored some error routines into the common library
- - added 'make tags' option to Makefile
-- Michael Olbrich <m.olbrich@pengutronix.de> added an unbuffered
- output option to cyclictest (-u/--unbuffered)
-
-* Mon Dec 21 2009 Clark Williams <williams@redhat.com> - 0.59-1
-- deleted classic_pi
-- David Sommerseth <davids@redhat.com>:
- - added help text for -M (refresh-on-max) option for cyclictest
- - fixed parsing of --mlockall in signaltest
-- Carsten Emde <C.Emde@osadl.org> provided a better explaination
- for using the kernel module with the backfire program
-- John Kacur <jkacur@redhat.com> cleaned up the trailing comments
- on the guard macros in src/lib/rt-utils.h
-
-* Mon Dec 21 2009 Clark Williams <williams@redhat.com> - 0.58-1
-- merged jkacur's portable getcpu() code
-- fixed inadvertent conversion of some source to DOS text files
-
-* Mon Dec 14 2009 Clark Williams <williams@redhat.com> - 0.57-1
-- John Kacur <jkacur@redhat.com> folded in Carsten Emde's tests
- - ptsematest
- - sigwaittest
- - svsematest
- - sendme
-- Carsten Emde <carsten.emde@osadl.org> created a utility library
- moving functions from cyclictest into src/lib/rt-utils.c
-- Makefile cleanups from jkacur
-
-* Thu Dec 10 2009 Clark Williams <williams@redhat.com> - 0.56-1
-- cyclictest: added code to print break thread id with -b
-
-* Thu Nov 19 2009 Clark Williams <williams@redhat.com> - 0.55-1
-- pi_stress: cosmetic newline added
-- fixes from John Kacur <jkacur@redhat.com>
- - pi_stress: Remove racy state variables that cause watchdog to trigger
- - pi_stress: Check whether quiet is set, before taking shutdown_mtx
- - pi_stress: Use a pthread_mutex_t for the global variable shutdown
-
-* Tue Nov 17 2009 Clark Williams <williams@redhat.com> - 0.54-1
-- patches from John Kacur <jkacur@redhat.com>
- - fix source style issues in pi_stress
- - add a DEBUG option to the Makefile
- - use CFLAGS for C compiler options
- - label targets as PHONY if not generating actual file
-- patch to remove rt-tests.spec from .PHONY in Makefile
-
-* Mon Nov 16 2009 Clark Williams <williams@redhat.com> - 0.53-2
-- added back missing dist tag for release
-
-* Tue Oct 6 2009 Clark Williams <williams@redhat.com> - 0.53-1
-- fixed incorrect format string in hwlatdetect.py
-- added docs/release-checklist.txt
-
-* Mon Sep 21 2009 Clark Williams <williams@redhat.com> - 0.52-1
-- fixes and cleanups to pi_stress from jkacur
-- added rostedt's rt-migrate-test
-
-* Thu Sep 3 2009 Clark Williams <williams@redhat.com> - 0.51-1
-- two manpage fixes from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-- added -M option from Arnaldo Carvahlo de Melo <acme@redhat.com>
- (for use on low-bandwidth connections, defer's update until new max hit)
-
-* Fri Jul 24 2009 Clark Williams <williams@redhat.com> - 0.50-2
-- minor patch to fix reporting option of hwlatdetect
-
-* Thu Jul 16 2009 Clark Williams <williams@redhat.com> - 0.50-1
-- patch to cyclictest from Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- to process options before checking for root user
-- patch to cyclictest from Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- to exit with proper error code on exit
-- added scripts/do-git-push script
-- added push target to Makefile
-- rewrite of hwlatdetect script to handle old smi_detector module
-
-* Sun Jul 5 2009 Clark Williams <williams@redhat.com> - 0.47-1
-- patch from GeunSik Lim <leemgs1@gmail.com> to reorder options for readability
-- patch from GeunSik Lim <leemgs1@gmail.com> to add --policy option
-- patch from GeunSik Lim <leemgs1@gmail.com> to clarify -h option usage
-- modified --policy to take scheduler policy name instead of integers
-
-* Thu Jul 2 2009 Clark Williams <williams@redhat.com> - 0.46-1
-- added fix from Daniel Gollub <dgollub@suse.de> (doomsday latency)
-
-* Thu Jul 2 2009 Clark Williams <williams@redhat.com> - 0.45-1
-- bugfix from Daniel Gollub <dgollub@suse.de> (fix cyclictest segfault)
-- cyclictest format change from Sven-Thorsten Dietrich <sdietrich@suse.de>
-- added help target to Makefile
-
-* Tue Jun 30 2009 Clark Williams <williams@redhat.com> - 0.44-1
-- fix to specfile (renamed smidetect to hwlatdetect)
-- added code to hwlatdetect allow setting window and width properly
-
-* Thu Jun 25 2009 Clark Williams <williams@redhat.com> - 0.43-1
-- manpage fixes from Uwe Kleine-Konig <u.kleine-koenig@pengutronix.de>
-
-* Fri Jun 12 2009 Clark Williams <williams@redhat.com> - 0.42-1
-- renamed smidetect -> hwlatdetect
-
-* Thu May 28 2009 Clark Williams <williams@redhat.com> - 0.41-1
-- added Stefan Agner's patch to fix calculating time difference
- when delta is bigger than 2147 seconds
-
-* Wed May 13 2009 Clark Williams <williams@redhat.com> - 0.40-1
-- added smidetect
-
-* Thu Jan 03 2008 Clark Williams <williams@redhat.com> - 0.18-1
-- Initial build.
diff --git a/src/cyclictest/cyclictest.8 b/src/cyclictest/cyclictest.8
index 4e169aa..437e7a6 100644
--- a/src/cyclictest/cyclictest.8
+++ b/src/cyclictest/cyclictest.8
@@ -188,6 +188,10 @@ memory allocations using the numa(3) policy library. Thread stacks and
data structures are allocated from the NUMA node local to the core to
which the thread is bound. Requires the underlying kernel to have NUMA
support compiled in.
+.TP
+.B \\-\-smi
+Enable SMI count/detection on processors with SMI count support.
+
.SH SEE ALSO
.BR numactl (8),
.\" .br
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index f5a67dc..158bced 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -111,6 +111,13 @@ extern int clock_nanosleep(clockid_t __clock_id, int __flags,
#define KVARNAMELEN 32
#define KVALUELEN 32
+#if (defined(__i386__) || defined(__x86_64__))
+#define ARCH_HAS_SMI_COUNTER
+#endif
+
+#define MSR_SMI_COUNT 0x00000034
+#define MSR_SMI_COUNT_MASK 0xFFFFFFFF
+
int enable_events;
static char *policyname(int policy);
@@ -143,6 +150,7 @@ struct thread_param {
int cpu;
int node;
int tnum;
+ int msr_fd;
};
/* Struct for statistics */
@@ -154,6 +162,7 @@ struct thread_stat {
long act;
double avg;
long *values;
+ long *smis;
long *hist_array;
long *outliers;
pthread_t thread;
@@ -164,6 +173,7 @@ struct thread_stat {
long cycleofmax;
long hist_overflow;
long num_outliers;
+ unsigned long smi_count;
};
static pthread_mutex_t trigger_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -192,6 +202,7 @@ static void trigger_update(struct thread_param *par, int diff, int64_t ts);
static int shutdown;
static int tracelimit = 0;
static int notrace = 0;
+static int trace_marker = 0;
static int ftrace = 0;
static int kernelversion;
static int verbose = 0;
@@ -212,6 +223,12 @@ static pthread_t fifo_threadid;
static int laptop = 0;
static int use_histfile = 0;
+#ifdef ARCH_HAS_SMI_COUNTER
+static int smi = 0;
+#else
+#define smi 0
+#endif
+
static pthread_cond_t refresh_on_max_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t refresh_on_max_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -479,6 +496,9 @@ static void tracemark(char *fmt, ...)
static void tracing(int on)
{
+ if (notrace)
+ return;
+
if (on) {
switch (kernelversion) {
case KV_26_LT18: gettimeofday(0,(struct timezone *)1); break;
@@ -511,11 +531,21 @@ static int settracer(char *tracer)
return -1;
}
-static void setup_tracer(void)
+static void open_tracemark_fd(void)
{
- if (!tracelimit || notrace)
+ char path[MAX_PATH];
+
+ if (tracemark_fd >= 0)
return;
+ sprintf(path, "%s/%s", fileprefix, "trace_marker");
+ tracemark_fd = open(path, O_WRONLY);
+ if (tracemark_fd < 0)
+ warn("unable to open trace_marker file: %s\n", path);
+}
+
+static void debugfs_prepare(void)
+{
if (mount_debugfs(NULL))
fatal("could not mount debugfs");
@@ -530,6 +560,26 @@ static void setup_tracer(void)
"TRACERs not configured?\n", testname);
} else
fileprefix = procfileprefix;
+}
+
+static void enable_trace_mark(void)
+{
+ if (!trace_marker)
+ return;
+
+ if (!tracelimit)
+ fatal("--tracemark requires -b\n");
+
+ debugfs_prepare();
+ open_tracemark_fd();
+}
+
+static void setup_tracer(void)
+{
+ if (!tracelimit || notrace)
+ return;
+
+ debugfs_prepare();
if (kernelversion >= KV_26_33) {
int ret;
@@ -639,14 +689,7 @@ static void setup_tracer(void)
fatal("unable to open %s for tracing", path);
}
- /* open the tracemark file descriptor */
- if (tracemark_fd == -1) {
- char path[MAX_PATH];
- strcat(strcpy(path, fileprefix), "trace_marker");
- if ((tracemark_fd = open(path, O_WRONLY)) == -1)
- warn("unable to open trace_marker file: %s\n", path);
- }
-
+ open_tracemark_fd();
} else {
setkernvar("trace_all_cpus", "1");
setkernvar("trace_freerunning", "1");
@@ -772,6 +815,125 @@ try_again:
return err;
}
+#ifdef ARCH_HAS_SMI_COUNTER
+static int open_msr_file(int cpu)
+{
+ int fd;
+ char pathname[32];
+
+ /* SMI needs thread affinity */
+ sprintf(pathname, "/dev/cpu/%d/msr", cpu);
+ fd = open(pathname, O_RDONLY);
+ if (fd < 0)
+ warn("%s open failed, try chown or chmod +r "
+ "/dev/cpu/*/msr, or run as root\n", pathname);
+
+ return fd;
+}
+
+static int get_msr(int fd, off_t offset, unsigned long long *msr)
+{
+ ssize_t retval;
+
+ retval = pread(fd, msr, sizeof *msr, offset);
+
+ if (retval != sizeof *msr)
+ return 1;
+
+ return 0;
+}
+
+static int get_smi_counter(int fd, unsigned long *counter)
+{
+ int retval;
+ unsigned long long msr;
+
+ retval = get_msr(fd, MSR_SMI_COUNT, &msr);
+ if (retval)
+ return retval;
+
+ *counter = (unsigned long) (msr & MSR_SMI_COUNT_MASK);
+
+ return 0;
+}
+
+#include <cpuid.h>
+
+/* Based on turbostat's check */
+static int has_smi_counter(void)
+{
+ unsigned int ebx, ecx, edx, max_level;
+ unsigned int fms, family, model;
+
+ fms = family = model = ebx = ecx = edx = 0;
+
+ __get_cpuid(0, &max_level, &ebx, &ecx, &edx);
+
+ /* check genuine intel */
+ if (!(ebx == 0x756e6547 && edx == 0x49656e69 && ecx == 0x6c65746e))
+ return 0;
+
+ __get_cpuid(1, &fms, &ebx, &ecx, &edx);
+ family = (fms >> 8) & 0xf;
+
+ if (family != 6)
+ return 0;
+
+ /* no MSR */
+ if (!(edx & (1 << 5)))
+ return 0;
+
+ model = (((fms >> 16) & 0xf) << 4) + ((fms >> 4) & 0xf);
+
+ switch (model) {
+ case 0x1A: /* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */
+ case 0x1E: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */
+ case 0x1F: /* Core i7 and i5 Processor - Nehalem */
+ case 0x25: /* Westmere Client - Clarkdale, Arrandale */
+ case 0x2C: /* Westmere EP - Gulftown */
+ case 0x2E: /* Nehalem-EX Xeon - Beckton */
+ case 0x2F: /* Westmere-EX Xeon - Eagleton */
+ case 0x2A: /* SNB */
+ case 0x2D: /* SNB Xeon */
+ case 0x3A: /* IVB */
+ case 0x3E: /* IVB Xeon */
+ case 0x3C: /* HSW */
+ case 0x3F: /* HSX */
+ case 0x45: /* HSW */
+ case 0x46: /* HSW */
+ case 0x3D: /* BDW */
+ case 0x47: /* BDW */
+ case 0x4F: /* BDX */
+ case 0x56: /* BDX-DE */
+ case 0x4E: /* SKL */
+ case 0x5E: /* SKL */
+ case 0x37: /* BYT */
+ case 0x4D: /* AVN */
+ case 0x4C: /* AMT */
+ case 0x57: /* PHI */
+ break;
+ default:
+ return 0;
+ }
+
+ return 1;
+}
+#else
+static int open_msr_file(int cpu)
+{
+ return -1;
+}
+
+static int get_smi_counter(int fd, unsigned long *counter)
+{
+ return 1;
+}
+static int has_smi_counter(void)
+{
+ return 0;
+}
+#endif
+
/*
* timer thread
*
@@ -798,6 +960,7 @@ static void *timerthread(void *param)
int stopped = 0;
cpu_set_t mask;
pthread_t thread;
+ unsigned long smi_now, smi_old;
/* if we're running in numa mode, set our memory node */
if (par->node != -1)
@@ -835,6 +998,17 @@ static void *timerthread(void *param)
fatal("timerthread%d: failed to set priority to %d\n",
par->cpu, par->prio);
+ if(smi) {
+ par->msr_fd = open_msr_file(par->cpu);
+ if (par->msr_fd < 0)
+ fatal("Could not open MSR interface, errno: %d\n",
+ errno);
+ /* get current smi count to use as base value */
+ if (get_smi_counter(par->msr_fd, &smi_old))
+ fatal("Could not read SMI counter, errno: %d\n",
+ par->cpu, errno);
+ }
+
/* Get current time */
if (aligned || secaligned) {
pthread_barrier_wait(&globalt_barr);
@@ -892,6 +1066,7 @@ static void *timerthread(void *param)
while (!shutdown) {
uint64_t diff;
+ unsigned long diff_smi = 0;
int sigs, ret;
/* Wait for next period */
@@ -957,6 +1132,17 @@ static void *timerthread(void *param)
goto out;
}
+ if (smi) {
+ if (get_smi_counter(par->msr_fd, &smi_now)) {
+ warn("Could not read SMI counter, errno: %d\n",
+ par->cpu, errno);
+ goto out;
+ }
+ diff_smi = smi_now - smi_old;
+ stat->smi_count += diff_smi;
+ smi_old = smi_now;
+ }
+
if (use_nsecs)
diff = calcdiff_ns(now, next);
else
@@ -974,6 +1160,7 @@ static void *timerthread(void *param)
trigger_update(par, diff, calctime(now));
}
+
if (duration && (calcdiff(now, stop) >= 0))
shutdown++;
@@ -991,8 +1178,11 @@ static void *timerthread(void *param)
}
stat->act = diff;
- if (par->bufmsk)
+ if (par->bufmsk) {
stat->values[stat->cycles & par->bufmsk] = diff;
+ if (smi)
+ stat->smis[stat->cycles & par->bufmsk] = diff_smi;
+ }
/* Update the histogram */
if (histogram) {
@@ -1038,10 +1228,12 @@ out:
setitimer(ITIMER_REAL, &itimer, NULL);
}
+ /* close msr file */
+ if (smi)
+ close(par->msr_fd);
/* switch to normal */
schedp.sched_priority = 0;
sched_setscheduler(0, SCHED_OTHER, &schedp);
-
stat->threadstarted = -1;
return NULL;
@@ -1126,10 +1318,14 @@ static void display_help(int error)
" --spike=trigger record all spikes > trigger\n"
" --spike-nodes these are the number of spikes we can record\n"
" the default is 1024 if not specified\n"
+#ifdef ARCH_HAS_SMI_COUNTER
+ " --smi Enable SMI counting\n"
+#endif
"-t --threads one thread per available processor\n"
"-t [NUM] --threads=NUM number of threads:\n"
" without NUM, threads = max_cpus\n"
" without -t default = 1\n"
+ " --tracemark write a trace mark when -b latency is exceeded\n"
"-T TRACE --tracer=TRACER set tracing function\n"
" configured tracers: %s\n"
"-u --unbuffered force unbuffered output for live processing\n"
@@ -1220,7 +1416,6 @@ static void parse_cpumask(const char *option, const int max_cpus)
}
}
-
static void handlepolicy(char *polname)
{
if (strncasecmp(polname, "other", 5) == 0)
@@ -1272,7 +1467,7 @@ enum option_values {
OPT_SYSTEM, OPT_SMP, OPT_THREADS, OPT_TRACER, OPT_TRIGGER,
OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE, OPT_WAKEUP,
OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
- OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP,
+ OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI, OPT_TRACEMARK,
};
/* Process commandline options */
@@ -1322,10 +1517,12 @@ static void process_options (int argc, char *argv[], int max_cpus)
{"resolution", no_argument, NULL, OPT_RESOLUTION },
{"secaligned", optional_argument, NULL, OPT_SECALIGNED },
{"system", no_argument, NULL, OPT_SYSTEM },
+ {"smi", no_argument, NULL, OPT_SMI },
{"smp", no_argument, NULL, OPT_SMP },
{"spike", required_argument, NULL, OPT_TRIGGER },
{"spike-nodes", required_argument, NULL, OPT_TRIGGER_NODES },
{"threads", optional_argument, NULL, OPT_THREADS },
+ {"tracemark", no_argument, NULL, OPT_TRACEMARK },
{"tracer", required_argument, NULL, OPT_TRACER },
{"unbuffered", no_argument, NULL, OPT_UNBUFFERED },
{"numa", no_argument, NULL, OPT_NUMA },
@@ -1560,6 +1757,16 @@ static void process_options (int argc, char *argv[], int max_cpus)
ct_debug = 1; break;
case OPT_LAPTOP:
laptop = 1; break;
+ case OPT_SMI:
+#ifdef ARCH_HAS_SMI_COUNTER
+ smi = 1;
+#else
+ fatal("--smi is not available on your arch\n");
+#endif
+ break;
+ case OPT_TRACEMARK:
+ notrace = 1; /* using --tracemark implies --notrace */
+ trace_marker = 1; break;
}
}
@@ -1571,6 +1778,15 @@ static void process_options (int argc, char *argv[], int max_cpus)
}
}
+ if (smi) {
+ if (setaffinity == AFFINITY_UNSPECIFIED)
+ fatal("SMI counter relies on thread affinity\n");
+
+ if (!has_smi_counter())
+ fatal("SMI counter is not supported "
+ "on this processor\n");
+ }
+
if (tracelimit)
fileprefix = procfileprefix;
@@ -1698,7 +1914,7 @@ static void sighand(int sig)
shutdown = 1;
if (refresh_on_max)
pthread_cond_signal(&refresh_on_max_cond);
- if (tracelimit && !notrace)
+ if (tracelimit)
tracing(0);
}
@@ -1810,27 +2026,44 @@ static void print_stat(FILE *fp, struct thread_param *par, int index, int verbos
char *fmt;
if (use_nsecs)
fmt = "T:%2d (%5d) P:%2d I:%ld C:%7lu "
- "Min:%7ld Act:%8ld Avg:%8ld Max:%8ld\n";
+ "Min:%7ld Act:%8ld Avg:%8ld Max:%8ld";
else
fmt = "T:%2d (%5d) P:%2d I:%ld C:%7lu "
- "Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n";
+ "Min:%7ld Act:%5ld Avg:%5ld Max:%8ld";
+
fprintf(fp, fmt, index, stat->tid, par->prio,
- par->interval, stat->cycles, stat->min, stat->act,
- stat->cycles ?
+ par->interval, stat->cycles, stat->min,
+ stat->act, stat->cycles ?
(long)(stat->avg/stat->cycles) : 0, stat->max);
+
+ if (smi)
+ fprintf(fp," SMI:%8ld", stat->smi_count);
+
+ fprintf(fp, "\n");
}
} else {
while (stat->cycles != stat->cyclesread) {
+ unsigned long diff_smi;
long diff = stat->values
[stat->cyclesread & par->bufmsk];
+ if (smi)
+ diff_smi = stat->smis
+ [stat->cyclesread & par->bufmsk];
+
if (diff > stat->redmax) {
stat->redmax = diff;
stat->cycleofmax = stat->cyclesread;
}
if (++stat->reduce == oscope_reduction) {
- fprintf(fp, "%8d:%8lu:%8ld\n", index,
- stat->cycleofmax, stat->redmax);
+ if (!smi)
+ fprintf(fp, "%8d:%8lu:%8ld\n", index,
+ stat->cycleofmax, stat->redmax);
+ else
+ fprintf(fp, "%8d:%8lu:%8ld%8ld\n",
+ index, stat->cycleofmax,
+ stat->redmax, diff_smi);
+
stat->reduce = 0;
stat->redmax = 0;
}
@@ -1969,6 +2202,8 @@ int main(int argc, char **argv)
setup_tracer();
+ enable_trace_mark();
+
if (check_timer())
warn("High resolution timers not available\n");
@@ -2154,6 +2389,13 @@ int main(int argc, char **argv)
goto outall;
memset(stat->values, 0, bufsize);
par->bufmsk = VALBUF_SIZE - 1;
+ if (smi) {
+ int bufsize = VALBUF_SIZE * sizeof(long);
+ stat->smis = threadalloc(bufsize, node);
+ if (!stat->smis)
+ goto outall;
+ memset(stat->smis, 0, bufsize);
+ }
}
par->prio = priority;
@@ -2192,6 +2434,7 @@ int main(int argc, char **argv)
stat->max = 0;
stat->avg = 0.0;
stat->threadstarted = 1;
+ stat->smi_count = 0;
status = pthread_create(&stat->thread, &attr, timerthread, par);
if (status)
fatal("failed to create thread %d: %s\n", i, strerror(status));
@@ -2303,7 +2546,7 @@ int main(int argc, char **argv)
}
out:
/* ensure that the tracer is stopped */
- if (tracelimit && !notrace)
+ if (tracelimit)
tracing(0);
diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index dbf3f67..d9ef027 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -7,6 +7,8 @@
# modify it under the terms of the GNU General Public License Version 2
# as published by the Free Software Foundation.
+from __future__ import print_function
+
import sys
import os
import time
@@ -77,15 +79,21 @@ class DebugFS(object):
val = f.readline()
f.close()
else:
- fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK)
+ f = os.fdopen(os.open(path, os.O_RDONLY|os.O_NONBLOCK), "r")
try:
- val = os.read(fd, 256)
+ val = f.readline()
except OSError as e:
+ print ("errno: %s" % e)
+ if e.errno == errno.EAGAIN:
+ val = None
+ else:
+ raise
+ except IOError as e:
if e.errno == errno.EAGAIN:
val = None
else:
raise
- os.close(fd)
+ f.close()
return val
def putval(self, item, value):
@@ -108,6 +116,14 @@ class Kmod(object):
''' class to manage loading and unloading hwlat.ko'''
names = ("hwlat_detector", "smi_detector")
+ def __check_builtin(self):
+ for l in open(os.path.join('/lib/modules', os.uname()[2], 'modules.builtin'), "r"):
+ for m in Kmod.names:
+ if m in l:
+ debug("found %s as builtin" % m)
+ return m
+ return None
+
def __find_modname(self):
debug("looking for modules")
path = os.path.join("/lib/modules",
@@ -123,6 +139,15 @@ class Kmod(object):
def __init__(self):
self.preloaded = False
+ self.builtin = False
+
+ # check for builtin
+ self.modname = self.__check_builtin()
+ if self.modname:
+ self.builtin = True
+ return
+
+ # now look for module
f = open ('/proc/modules')
for l in f:
field = l.split()
@@ -136,6 +161,9 @@ class Kmod(object):
self.modname = self.__find_modname()
def load(self):
+ if self.builtin:
+ debug("not loading %s (builtin)" % self.modname)
+ return True
if self.preloaded:
debug("not loading %s (already loaded)" % self.modname)
return True
@@ -143,7 +171,7 @@ class Kmod(object):
return (subprocess.call(cmd) == 0)
def unload(self):
- if self.preloaded:
+ if self.preloaded or self.builtin:
debug("Not unloading %s" % self.modname)
return True
cmd = ['/sbin/modprobe', '-r', self.modname]
@@ -275,7 +303,7 @@ class Hwlat(object):
while val:
val = val.strip()
self.samples.append(val)
- if watch: print val
+ if watch: print(val)
debug("got a latency sample: %s" % val)
val = self.get_sample()
time.sleep(0.1)
@@ -371,7 +399,7 @@ class Smi(object):
val = val.strip()
if int(val) >= threshold:
self.samples.append(val)
- if watch: print val
+ if watch: print(val)
debug("got a latency sample: %s (threshold: %d)" % (val, self.get("threshold")))
time.sleep(0.1)
except KeyboardInterrupt as e:
@@ -552,7 +580,7 @@ if __name__ == '__main__':
if count > detect.initsmi[i]:
smis = count - detect.initsmi[i]
total_smis += smis
- print "%d SMIs occured on cpu %d" % (smis, i)
+ print("%d SMIs occured on cpu %d" % (smis, i))
info("SMIs during run: %d" % total_smis)
if reportfile:
diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
index a02f706..36b64ca 100644
--- a/src/pi_tests/pi_stress.c
+++ b/src/pi_tests/pi_stress.c
@@ -634,7 +634,7 @@ int verify_cpu(int cpu)
if (status == -1) {
err = errno;
fprintf(stderr, "sched_getaffinity %s\n", strerror(err));
- exit(-1);
+ exit(1);
}
if (CPU_ISSET(cpu, &mask))
diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c
index a0477cc..e6cf0ce 100644
--- a/src/pi_tests/pip_stress.c
+++ b/src/pi_tests/pip_stress.c
@@ -95,7 +95,7 @@ int main(void)
*minimum_priority = sched_get_priority_min(policy);
if (check_privs())
- exit(-1);
+ exit(1);
mptr = mmap_page(); /* Get a page of shared memory */
resource = (pthread_mutex_t*)mptr; /* point our lock to it */
@@ -138,7 +138,7 @@ int main(void)
pid2 = fork(); /* parent code */
if (pid2 == -1) {
perror("fork: ");
- exit(-1);
+ exit(1);
} else if (pid2 != 0) { /* parent code */
high(pid2);
} else { /* child code */
@@ -231,7 +231,7 @@ void *mmap_page(void)
mptr = mmap(NULL, pgsize, PROTRW, MMAP_FLAGS, 0, 0);
if (mptr == MAP_FAILED) {
perror("In function mmap_page - mmap");
- exit(-1);
+ exit(1);
}
return mptr;
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index b80969b..59f979e 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -323,7 +323,7 @@ int main(int argc, char **argv)
process_options(argc, argv);
if (check_privs())
- exit(-1);
+ exit(1);
/* lock all memory (prevent paging) */
if (lockall)