diff options
Diffstat (limited to 'tools/perf/Documentation')
30 files changed, 1971 insertions, 343 deletions
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile index bd498d49695..3ba1c0b0990 100644 --- a/tools/perf/Documentation/Makefile +++ b/tools/perf/Documentation/Makefile @@ -1,3 +1,6 @@ +include ../../scripts/Makefile.include +include ../config/utilities.mak +  MAN1_TXT= \  	$(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \  		$(wildcard perf-*.txt)) \ @@ -6,10 +9,11 @@ MAN5_TXT=  MAN7_TXT=  MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT) -MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT)) -MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) +_MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT)) +_MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) -DOC_HTML=$(MAN_HTML) +MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML)) +MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML))  ARTICLES =  # with their own formatting rules. @@ -18,11 +22,17 @@ API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technica  SP_ARTICLES += $(API_DOCS)  SP_ARTICLES += technical/api-index -DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES)) +_DOC_HTML = $(_MAN_HTML) +_DOC_HTML+=$(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES)) +DOC_HTML=$(addprefix $(OUTPUT),$(_DOC_HTML)) + +_DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) +_DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT)) +_DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) -DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) -DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT)) -DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) +DOC_MAN1=$(addprefix $(OUTPUT),$(_DOC_MAN1)) +DOC_MAN5=$(addprefix $(OUTPUT),$(_DOC_MAN5)) +DOC_MAN7=$(addprefix $(OUTPUT),$(_DOC_MAN7))  # Make the path relative to DESTDIR, not prefix  ifndef DESTDIR @@ -50,6 +60,7 @@ MAKEINFO=makeinfo  INSTALL_INFO=install-info  DOCBOOK2X_TEXI=docbook2x-texi  DBLATEX=dblatex +XMLTO=xmlto  ifndef PERL_PATH  	PERL_PATH = /usr/bin/perl  endif @@ -57,6 +68,16 @@ endif  -include ../config.mak.autogen  -include ../config.mak +_tmp_tool_path := $(call get-executable,$(ASCIIDOC)) +ifeq ($(_tmp_tool_path),) +	missing_tools = $(ASCIIDOC) +endif + +_tmp_tool_path := $(call get-executable,$(XMLTO)) +ifeq ($(_tmp_tool_path),) +	missing_tools += $(XMLTO) +endif +  #  # For asciidoc ...  #	-7.1.2,	no extra settings are needed. @@ -123,17 +144,18 @@ NO_SUBDIR = :  endif  ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V -	QUIET_ASCIIDOC	= @echo '   ' ASCIIDOC $@; -	QUIET_XMLTO	= @echo '   ' XMLTO $@; -	QUIET_DB2TEXI	= @echo '   ' DB2TEXI $@; -	QUIET_MAKEINFO	= @echo '   ' MAKEINFO $@; -	QUIET_DBLATEX	= @echo '   ' DBLATEX $@; -	QUIET_XSLTPROC	= @echo '   ' XSLTPROC $@; -	QUIET_GEN	= @echo '   ' GEN $@; +ifneq ($(V),1) +	QUIET_ASCIIDOC	= @echo '  ASCIIDOC '$@; +	QUIET_XMLTO	= @echo '  XMLTO    '$@; +	QUIET_DB2TEXI	= @echo '  DB2TEXI  '$@; +	QUIET_MAKEINFO	= @echo '  MAKEINFO '$@; +	QUIET_DBLATEX	= @echo '  DBLATEX  '$@; +	QUIET_XSLTPROC	= @echo '  XSLTPROC '$@; +	QUIET_GEN	= @echo '  GEN      '$@;  	QUIET_STDERR	= 2> /dev/null  	QUIET_SUBDIR0	= +@subdir= -	QUIET_SUBDIR1	= ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \ +	QUIET_SUBDIR1	= ;$(NO_SUBDIR) \ +			   echo '  SUBDIR   ' $$subdir; \  			  $(MAKE) $(PRINT_DIR) -C $$subdir  	export V  endif @@ -150,53 +172,67 @@ man1: $(DOC_MAN1)  man5: $(DOC_MAN5)  man7: $(DOC_MAN7) -info: perf.info perfman.info +info: $(OUTPUT)perf.info $(OUTPUT)perfman.info -pdf: user-manual.pdf +pdf: $(OUTPUT)user-manual.pdf  install: install-man -install-man: man -	$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir) -#	$(INSTALL) -d -m 755 $(DESTDIR)$(man5dir) -#	$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir) -	$(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir) -#	$(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir) -#	$(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir) +check-man-tools: +ifdef missing_tools +	$(error "You need to install $(missing_tools) for man pages") +endif + +do-install-man: man +	$(call QUIET_INSTALL, Documentation-man) \ +		$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir); \ +#		$(INSTALL) -d -m 755 $(DESTDIR)$(man5dir); \ +#		$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir); \ +		$(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir); \ +#		$(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir); \ +#		$(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir) + +install-man: check-man-tools man + +ifdef missing_tools +  DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed) +else +  DO_INSTALL_MAN = do-install-man +endif + +try-install-man: $(DO_INSTALL_MAN)  install-info: info -	$(INSTALL) -d -m 755 $(DESTDIR)$(infodir) -	$(INSTALL) -m 644 perf.info perfman.info $(DESTDIR)$(infodir) +	$(call QUIET_INSTALL, Documentation-info) \ +		$(INSTALL) -d -m 755 $(DESTDIR)$(infodir); \ +		$(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir); \  	if test -r $(DESTDIR)$(infodir)/dir; then \ -	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\ -	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\ +		$(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\ +		$(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\  	else \  	  echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \  	fi  install-pdf: pdf -	$(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir) -	$(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir) - -install-html: html -	'$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir) +	$(call QUIET_INSTALL, Documentation-pdf) \ +		$(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir); \ +		$(INSTALL) -m 644 $(OUTPUT)user-manual.pdf $(DESTDIR)$(pdfdir) -../PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE -	$(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) PERF-VERSION-FILE +#install-html: html +#	'$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir) --include ../PERF-VERSION-FILE  #  # Determine "include::" file references in asciidoc files.  # -doc.dep : $(wildcard *.txt) build-docdep.perl +$(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl  	$(QUIET_GEN)$(RM) $@+ $@ && \  	$(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \  	mv $@+ $@ --include doc.dep +-include $(OUPTUT)doc.dep -cmds_txt = cmds-ancillaryinterrogators.txt \ +_cmds_txt = cmds-ancillaryinterrogators.txt \  	cmds-ancillarymanipulators.txt \  	cmds-mainporcelain.txt \  	cmds-plumbinginterrogators.txt \ @@ -205,32 +241,38 @@ cmds_txt = cmds-ancillaryinterrogators.txt \  	cmds-synchelpers.txt \  	cmds-purehelpers.txt \  	cmds-foreignscminterface.txt +cmds_txt=$(addprefix $(OUTPUT),$(_cmds_txt)) -$(cmds_txt): cmd-list.made +$(cmds_txt): $(OUTPUT)cmd-list.made -cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT) +$(OUTPUT)cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)  	$(QUIET_GEN)$(RM) $@ && \  	$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \  	date >$@ +CLEAN_FILES =									\ +	$(MAN_XML) $(addsuffix +,$(MAN_XML))					\ +	$(MAN_HTML) $(addsuffix +,$(MAN_HTML))					\ +	$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7)				\ +	$(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++			\ +	$(OUTPUT)perf.info $(OUTPUT)perfman.info				\ +	$(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep		\ +	$(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt		\ +	$(cmds_txt) $(OUTPUT)*.made  clean: -	$(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7 -	$(RM) *.texi *.texi+ *.texi++ perf.info perfman.info -	$(RM) howto-index.txt howto/*.html doc.dep -	$(RM) technical/api-*.html technical/api-index.txt -	$(RM) $(cmds_txt) *.made +	$(call QUIET_CLEAN, Documentation) $(RM) $(CLEAN_FILES) -$(MAN_HTML): %.html : %.txt +$(MAN_HTML): $(OUTPUT)%.html : %.txt  	$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \  	$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \  		$(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \  	mv $@+ $@ -%.1 %.5 %.7 : %.xml +$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml  	$(QUIET_XMLTO)$(RM) $@ && \ -	xmlto -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< +	$(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< -%.xml : %.txt +$(OUTPUT)%.xml : %.txt  	$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \  	$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \  		$(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \ @@ -239,25 +281,25 @@ $(MAN_HTML): %.html : %.txt  XSLT = docbook.xsl  XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css -user-manual.html: user-manual.xml +$(OUTPUT)user-manual.html: $(OUTPUT)user-manual.xml  	$(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $< -perf.info: user-manual.texi -	$(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi +$(OUTPUT)perf.info: $(OUTPUT)user-manual.texi +	$(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ $(OUTPUT)user-manual.texi -user-manual.texi: user-manual.xml +$(OUTPUT)user-manual.texi: $(OUTPUT)user-manual.xml  	$(QUIET_DB2TEXI)$(RM) $@+ $@ && \ -	$(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \ +	$(DOCBOOK2X_TEXI) $(OUTPUT)user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \  	$(PERL_PATH) fix-texi.perl <$@++ >$@+ && \  	rm $@++ && \  	mv $@+ $@ -user-manual.pdf: user-manual.xml +$(OUTPUT)user-manual.pdf: $(OUTPUT)user-manual.xml  	$(QUIET_DBLATEX)$(RM) $@+ $@ && \  	$(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \  	mv $@+ $@ -perfman.texi: $(MAN_XML) cat-texi.perl +$(OUTPUT)perfman.texi: $(MAN_XML) cat-texi.perl  	$(QUIET_DB2TEXI)$(RM) $@+ $@ && \  	($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \  		--to-stdout $(xml) &&) true) > $@++ && \ @@ -265,7 +307,7 @@ perfman.texi: $(MAN_XML) cat-texi.perl  	rm $@++ && \  	mv $@+ $@ -perfman.info: perfman.texi +$(OUTPUT)perfman.info: $(OUTPUT)perfman.texi  	$(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi  $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml @@ -288,15 +330,14 @@ $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt  	sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+ && \  	mv $@+ $@ -install-webdoc : html -	'$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST) - -quick-install: quick-install-man +# UNIMPLEMENTED +#install-webdoc : html +#	'$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST) -quick-install-man: -	'$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir) +# quick-install: quick-install-man -quick-install-html: -	'$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir) +# quick-install-man: +#	'$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir) -.PHONY: .FORCE-PERF-VERSION-FILE +#quick-install-html: +#	'$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir) diff --git a/tools/perf/Documentation/android.txt b/tools/perf/Documentation/android.txt new file mode 100644 index 00000000000..8484c3a04a6 --- /dev/null +++ b/tools/perf/Documentation/android.txt @@ -0,0 +1,78 @@ +How to compile perf for Android +========================================= + +I. Set the Android NDK environment +------------------------------------------------ + +(a). Use the Android NDK +------------------------------------------------ +1. You need to download and install the Android Native Development Kit (NDK). +Set the NDK variable to point to the path where you installed the NDK: +  export NDK=/path/to/android-ndk + +2. Set cross-compiling environment variables for NDK toolchain and sysroot. +For arm: +  export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi- +  export NDK_SYSROOT=${NDK}/platforms/android-9/arch-arm +For x86: +  export NDK_TOOLCHAIN=${NDK}/toolchains/x86-4.6/prebuilt/linux-x86/bin/i686-linux-android- +  export NDK_SYSROOT=${NDK}/platforms/android-9/arch-x86 + +This method is not working for Android NDK versions up to Revision 8b. +perf uses some bionic enhancements that are not included in these NDK versions. +You can use method (b) described below instead. + +(b). Use the Android source tree +----------------------------------------------- +1. Download the master branch of the Android source tree. +Set the environment for the target you want using: +  source build/envsetup.sh +  lunch + +2. Build your own NDK sysroot to contain latest bionic changes and set the +NDK sysroot environment variable. +  cd ${ANDROID_BUILD_TOP}/ndk +For arm: +  ./build/tools/build-ndk-sysroot.sh --abi=arm +  export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-arm +For x86: +  ./build/tools/build-ndk-sysroot.sh --abi=x86 +  export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-x86 + +3. Set the NDK toolchain environment variable. +For arm: +  export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/arm-linux-androideabi- +For x86: +  export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/i686-linux-android- + +II. Compile perf for Android +------------------------------------------------ +You need to run make with the NDK toolchain and sysroot defined above: +For arm: +  make ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}" +For x86: +  make ARCH=x86 CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}" + +III. Install perf +----------------------------------------------- +You need to connect to your Android device/emulator using adb. +Install perf using: +  adb push perf /data/perf + +If you also want to use perf-archive you need busybox tools for Android. +For installing perf-archive, you first need to replace #!/bin/bash with #!/system/bin/sh: +  sed 's/#!\/bin\/bash/#!\/system\/bin\/sh/g' perf-archive >> /tmp/perf-archive +  chmod +x /tmp/perf-archive +  adb push /tmp/perf-archive /data/perf-archive + +IV. Environment settings for running perf +------------------------------------------------ +Some perf features need environment variables to run properly. +You need to set these before running perf on the target: +  adb shell +  # PERF_PAGER=cat + +IV. Run perf +------------------------------------------------ +Run perf on your device/emulator to which you previously connected using adb: +  # ./data/perf diff --git a/tools/perf/Documentation/examples.txt b/tools/perf/Documentation/examples.txt index 8eb6c489fb1..a4e39215648 100644 --- a/tools/perf/Documentation/examples.txt +++ b/tools/perf/Documentation/examples.txt @@ -17,8 +17,8 @@ titan:~> perf list    kmem:kmem_cache_alloc_node               [Tracepoint event]    kmem:kfree                               [Tracepoint event]    kmem:kmem_cache_free                     [Tracepoint event] -  kmem:mm_page_free_direct                 [Tracepoint event] -  kmem:mm_pagevec_free                     [Tracepoint event] +  kmem:mm_page_free                        [Tracepoint event] +  kmem:mm_page_free_batched                [Tracepoint event]    kmem:mm_page_alloc                       [Tracepoint event]    kmem:mm_page_alloc_zone_locked           [Tracepoint event]    kmem:mm_page_pcpu_drain                  [Tracepoint event] @@ -29,15 +29,15 @@ measured. For example the page alloc/free properties of a 'hackbench  run' are:   titan:~> perf stat -e kmem:mm_page_pcpu_drain -e kmem:mm_page_alloc - -e kmem:mm_pagevec_free -e kmem:mm_page_free_direct ./hackbench 10 + -e kmem:mm_page_free_batched -e kmem:mm_page_free ./hackbench 10   Time: 0.575   Performance counter stats for './hackbench 10':            13857  kmem:mm_page_pcpu_drain            27576  kmem:mm_page_alloc -           6025  kmem:mm_pagevec_free -          20934  kmem:mm_page_free_direct +           6025  kmem:mm_page_free_batched +          20934  kmem:mm_page_free      0.613972165  seconds time elapsed @@ -45,8 +45,8 @@ You can observe the statistical properties as well, by using the  'repeat the workload N times' feature of perf stat:   titan:~> perf stat --repeat 5 -e kmem:mm_page_pcpu_drain -e -   kmem:mm_page_alloc -e kmem:mm_pagevec_free -e -   kmem:mm_page_free_direct ./hackbench 10 +   kmem:mm_page_alloc -e kmem:mm_page_free_batched -e +   kmem:mm_page_free ./hackbench 10   Time: 0.627   Time: 0.644   Time: 0.564 @@ -57,8 +57,8 @@ You can observe the statistical properties as well, by using the            12920  kmem:mm_page_pcpu_drain    ( +-   3.359% )            25035  kmem:mm_page_alloc         ( +-   3.783% ) -           6104  kmem:mm_pagevec_free       ( +-   0.934% ) -          18376  kmem:mm_page_free_direct   ( +-   4.941% ) +           6104  kmem:mm_page_free_batched  ( +-   0.934% ) +          18376  kmem:mm_page_free	    ( +-   4.941% )      0.643954516  seconds time elapsed   ( +-   2.363% ) @@ -66,7 +66,7 @@ Furthermore, these tracepoints can be used to sample the workload as  well. For example the page allocations done by a 'git gc' can be  captured the following way: - titan:~/git> perf record -f -e kmem:mm_page_alloc -c 1 ./git gc + titan:~/git> perf record -e kmem:mm_page_alloc -c 1 ./git gc   Counting objects: 1148, done.   Delta compression using up to 2 threads.   Compressing objects: 100% (450/450), done. @@ -120,7 +120,7 @@ Furthermore, call-graph sampling can be done too, of page  allocations - to see precisely what kind of page allocations there  are: - titan:~/git> perf record -f -g -e kmem:mm_page_alloc -c 1 ./git gc + titan:~/git> perf record -g -e kmem:mm_page_alloc -c 1 ./git gc   Counting objects: 1148, done.   Delta compression using up to 2 threads.   Compressing objects: 100% (450/450), done. @@ -158,15 +158,15 @@ Or you can observe the whole system's page allocations for 10  seconds:  titan:~/git> perf stat -a -e kmem:mm_page_pcpu_drain -e -kmem:mm_page_alloc -e kmem:mm_pagevec_free -e -kmem:mm_page_free_direct sleep 10 +kmem:mm_page_alloc -e kmem:mm_page_free_batched -e +kmem:mm_page_free sleep 10   Performance counter stats for 'sleep 10':           171585  kmem:mm_page_pcpu_drain           322114  kmem:mm_page_alloc -          73623  kmem:mm_pagevec_free -         254115  kmem:mm_page_free_direct +          73623  kmem:mm_page_free_batched +         254115  kmem:mm_page_free     10.000591410  seconds time elapsed @@ -174,15 +174,15 @@ Or observe how fluctuating the page allocations are, via statistical  analysis done over ten 1-second intervals:   titan:~/git> perf stat --repeat 10 -a -e kmem:mm_page_pcpu_drain -e -   kmem:mm_page_alloc -e kmem:mm_pagevec_free -e -   kmem:mm_page_free_direct sleep 1 +   kmem:mm_page_alloc -e kmem:mm_page_free_batched -e +   kmem:mm_page_free sleep 1   Performance counter stats for 'sleep 1' (10 runs):            17254  kmem:mm_page_pcpu_drain    ( +-   3.709% )            34394  kmem:mm_page_alloc         ( +-   4.617% ) -           7509  kmem:mm_pagevec_free       ( +-   4.820% ) -          25653  kmem:mm_page_free_direct   ( +-   3.672% ) +           7509  kmem:mm_page_free_batched  ( +-   4.820% ) +          25653  kmem:mm_page_free	    ( +-   3.672% )      1.058135029  seconds time elapsed   ( +-   3.089% ) diff --git a/tools/perf/Documentation/jit-interface.txt b/tools/perf/Documentation/jit-interface.txt new file mode 100644 index 00000000000..a8656f56491 --- /dev/null +++ b/tools/perf/Documentation/jit-interface.txt @@ -0,0 +1,15 @@ +perf supports a simple JIT interface to resolve symbols for dynamic code generated +by a JIT. + +The JIT has to write a /tmp/perf-%d.map  (%d = pid of process) file + +This is a text file. + +Each line has the following format, fields separated with spaces: + +START SIZE symbolname + +START and SIZE are hex numbers without 0x. +symbolname is the rest of the line, so it could contain special characters. + +The ownership of the file has to match the process. diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt index b2c63309a65..e9cd39a92dc 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt @@ -22,14 +22,79 @@ OPTIONS  -------  -i::  --input=:: -        Input file name. (default: perf.data) +        Input file name. (default: perf.data unless stdin is a fifo) + +-d:: +--dsos=<dso[,dso...]>:: +        Only consider symbols in these dsos. +-s:: +--symbol=<symbol>:: +        Symbol to annotate. + +-f:: +--force:: +        Don't complain, do it. + +-v:: +--verbose:: +        Be more verbose. (Show symbol address, etc) + +-D:: +--dump-raw-trace:: +        Dump raw trace in ASCII. + +-k:: +--vmlinux=<file>:: +        vmlinux pathname. + +-m:: +--modules:: +        Load module symbols. WARNING: use only with -k and LIVE kernel. + +-l:: +--print-line:: +        Print matching source lines (may be slow). + +-P:: +--full-paths:: +        Don't shorten the displayed pathnames.  --stdio:: Use the stdio interface. ---tui:: Use the TUI interface Use of --tui requires a tty, if one is not +--tui:: Use the TUI interface. Use of --tui requires a tty, if one is not  	present, as when piping to other commands, the stdio interface is  	used. This interfaces starts by centering on the line with more -	samples, TAB/UNTAB cycles thru the lines with more samples. +	samples, TAB/UNTAB cycles through the lines with more samples. + +--gtk:: Use the GTK interface. + +-C:: +--cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can +	be provided as a comma-separated list with no space: 0,1. Ranges of +	CPUs are specified with -: 0-2. Default is to report samples on all +	CPUs. + +--asm-raw:: +	Show raw instruction encoding of assembly instructions. + +--source:: +	Interleave source code with assembly code. Enabled by default, +	disable with --no-source. + +--symfs=<directory>:: +        Look for files with symbols relative to this directory. + +-M:: +--disassembler-style=:: Set disassembler style for objdump. + +--objdump=<path>:: +        Path to objdump binary. + +--skip-missing:: +	Skip symbols that cannot be annotated. + +--group:: +	Show event group information together  SEE ALSO  -------- diff --git a/tools/perf/Documentation/perf-archive.txt b/tools/perf/Documentation/perf-archive.txt index fae174dc7d0..ac6ecbb3e66 100644 --- a/tools/perf/Documentation/perf-archive.txt +++ b/tools/perf/Documentation/perf-archive.txt @@ -12,9 +12,9 @@ SYNOPSIS  DESCRIPTION  ----------- -This command runs runs perf-buildid-list --with-hits, and collects the files -with the buildids found so that analisys of perf.data contents can be possible -on another machine. +This command runs perf-buildid-list --with-hits, and collects the files with the +buildids found so that analysis of perf.data contents can be possible on another +machine.  SEE ALSO diff --git a/tools/perf/Documentation/perf-bench.txt b/tools/perf/Documentation/perf-bench.txt index a3dbadb26ef..4464ad770d5 100644 --- a/tools/perf/Documentation/perf-bench.txt +++ b/tools/perf/Documentation/perf-bench.txt @@ -12,7 +12,7 @@ SYNOPSIS  DESCRIPTION  ----------- -This 'perf bench' command is general framework for benchmark suites. +This 'perf bench' command is a general framework for benchmark suites.  COMMON OPTIONS  -------------- @@ -45,14 +45,26 @@ SUBSYSTEM  'sched'::  	Scheduler and IPC mechanisms. +'mem':: +	Memory access performance. + +'numa':: +	NUMA scheduling and MM benchmarks. + +'futex':: +	Futex stressing benchmarks. + +'all':: +	All benchmark subsystems. +  SUITES FOR 'sched'  ~~~~~~~~~~~~~~~~~~  *messaging*::  Suite for evaluating performance of scheduler and IPC mechanisms.  Based on hackbench by Rusty Russell. -Options of *pipe* -^^^^^^^^^^^^^^^^^ +Options of *messaging* +^^^^^^^^^^^^^^^^^^^^^^  -p::  --pipe::  Use pipe() instead of socketpair() @@ -115,6 +127,88 @@ Example of *pipe*                  59004 ops/sec  --------------------- +SUITES FOR 'mem' +~~~~~~~~~~~~~~~~ +*memcpy*:: +Suite for evaluating performance of simple memory copy in various ways. + +Options of *memcpy* +^^^^^^^^^^^^^^^^^^^ +-l:: +--length:: +Specify length of memory to copy (default: 1MB). +Available units are B, KB, MB, GB and TB (case insensitive). + +-r:: +--routine:: +Specify routine to copy (default: default). +Available routines are depend on the architecture. +On x86-64, x86-64-unrolled, x86-64-movsq and x86-64-movsb are supported. + +-i:: +--iterations:: +Repeat memcpy invocation this number of times. + +-c:: +--cycle:: +Use perf's cpu-cycles event instead of gettimeofday syscall. + +-o:: +--only-prefault:: +Show only the result with page faults before memcpy. + +-n:: +--no-prefault:: +Show only the result without page faults before memcpy. + +*memset*:: +Suite for evaluating performance of simple memory set in various ways. + +Options of *memset* +^^^^^^^^^^^^^^^^^^^ +-l:: +--length:: +Specify length of memory to set (default: 1MB). +Available units are B, KB, MB, GB and TB (case insensitive). + +-r:: +--routine:: +Specify routine to set (default: default). +Available routines are depend on the architecture. +On x86-64, x86-64-unrolled, x86-64-stosq and x86-64-stosb are supported. + +-i:: +--iterations:: +Repeat memset invocation this number of times. + +-c:: +--cycle:: +Use perf's cpu-cycles event instead of gettimeofday syscall. + +-o:: +--only-prefault:: +Show only the result with page faults before memset. + +-n:: +--no-prefault:: +Show only the result without page faults before memset. + +SUITES FOR 'numa' +~~~~~~~~~~~~~~~~~ +*mem*:: +Suite for evaluating NUMA workloads. + +SUITES FOR 'futex' +~~~~~~~~~~~~~~~~~~ +*hash*:: +Suite for evaluating hash tables. + +*wake*:: +Suite for evaluating wake calls. + +*requeue*:: +Suite for evaluating requeue calls. +  SEE ALSO  --------  linkperf:perf[1] diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt index c1057701a7d..fd77d81ea74 100644 --- a/tools/perf/Documentation/perf-buildid-cache.txt +++ b/tools/perf/Documentation/perf-buildid-cache.txt @@ -21,9 +21,29 @@ OPTIONS  -a::  --add=::          Add specified file to the cache. +-k:: +--kcore:: +        Add specified kcore file to the cache. For the current host that is +        /proc/kcore which requires root permissions to read. Be aware that +        running 'perf buildid-cache' as root may update root's build-id cache +        not the user's. Use the -v option to see where the file is created. +        Note that the copied file contains only code sections not the whole core +        image. Note also that files "kallsyms" and "modules" must also be in the +        same directory and are also copied.  All 3 files are created with read +        permissions for root only. kcore will not be added if there is already a +        kcore in the cache (with the same build-id) that has the same modules at +        the same addresses. Use the -v option to see if a copy of kcore is +        actually made.  -r::  --remove=::          Remove specified file from the cache. +-M:: +--missing=::  +	List missing build ids in the cache for the specified file. +-u:: +--update:: +	Update specified file of the cache. It can be used to update kallsyms +	kernel dso to vmlinux in order to support annotation.  -v::  --verbose::  	Be more verbose. diff --git a/tools/perf/Documentation/perf-buildid-list.txt b/tools/perf/Documentation/perf-buildid-list.txt index 01b642c0bf8..25c52efcc7f 100644 --- a/tools/perf/Documentation/perf-buildid-list.txt +++ b/tools/perf/Documentation/perf-buildid-list.txt @@ -16,14 +16,23 @@ This command displays the buildids found in a perf.data file, so that other  tools can be used to fetch packages with matching symbol tables for use by  perf report. +It can also be used to show the build id of the running kernel or in an ELF +file using -i/--input. +  OPTIONS  ------- +-H:: +--with-hits:: +        Show only DSOs with hits.  -i::  --input=:: -        Input file name. (default: perf.data) +        Input file name. (default: perf.data unless stdin is a fifo)  -f::  --force::  	Don't do ownership validation. +-k:: +--kernel:: +	Show running kernel build id.  -v::  --verbose::  	Be more verbose. diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index 20d97d84ea1..b3b8abae62b 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt @@ -3,46 +3,61 @@ perf-diff(1)  NAME  ---- -perf-diff - Read two perf.data files and display the differential profile +perf-diff - Read perf.data files and display the differential profile  SYNOPSIS  --------  [verse] -'perf diff' [oldfile] [newfile] +'perf diff' [baseline file] [data file1] [[data file2] ... ]  DESCRIPTION  ----------- -This command displays the performance difference amongst two perf.data files -captured via perf record. +This command displays the performance difference amongst two or more perf.data +files captured via perf record.  If no parameters are passed it will assume perf.data.old and perf.data. +The differential profile is displayed only for events matching both +specified perf.data files. +  OPTIONS  ------- +-D:: +--dump-raw-trace:: +        Dump raw trace in ASCII. + +-m:: +--modules:: +        Load module symbols. WARNING: use only with -k and LIVE kernel +  -d::  --dsos=::  	Only consider symbols in these dsos. CSV that understands -	file://filename entries. +	file://filename entries.  This option will affect the percentage +	of the Baseline/Delta column.  See --percentage for more info.  -C::  --comms=::  	Only consider symbols in these comms. CSV that understands -	file://filename entries. +	file://filename entries.  This option will affect the percentage +	of the Baseline/Delta column.  See --percentage for more info.  -S::  --symbols=::  	Only consider these symbols. CSV that understands -	file://filename entries. +	file://filename entries.  This option will affect the percentage +	of the Baseline/Delta column.  See --percentage for more info.  -s::  --sort=:: -	Sort by key(s): pid, comm, dso, symbol. +	Sort by key(s): pid, comm, dso, symbol, cpu, parent, srcline. +	Please see description of --sort in the perf-report man page.  -t::  --field-separator=::  	Use a special separator character and don't pad with spaces, replacing -	all occurances of this separator in symbol names (and other output) +	all occurrences of this separator in symbol names (and other output)  	with a '.' character, that thus it's the only non valid separator.  -v:: @@ -50,6 +65,142 @@ OPTIONS  	Be verbose, for instance, show the raw counts in addition to the  	diff. +-f:: +--force:: +       Don't complain, do it. + +--symfs=<directory>:: +        Look for files with symbols relative to this directory. + +-b:: +--baseline-only:: +        Show only items with match in baseline. + +-c:: +--compute:: +        Differential computation selection - delta,ratio,wdiff (default is delta). +        See COMPARISON METHODS section for more info. + +-p:: +--period:: +        Show period values for both compared hist entries. + +-F:: +--formula:: +        Show formula for given computation. + +-o:: +--order:: +       Specify compute sorting column number. + +--percentage:: +	Determine how to display the overhead percentage of filtered entries. +	Filters can be applied by --comms, --dsos and/or --symbols options. + +	"relative" means it's relative to filtered entries only so that the +	sum of shown entries will be always 100%.  "absolute" means it retains +	the original value before and after the filter is applied. + +COMPARISON +---------- +The comparison is governed by the baseline file. The baseline perf.data +file is iterated for samples. All other perf.data files specified on +the command line are searched for the baseline sample pair. If the pair +is found, specified computation is made and result is displayed. + +All samples from non-baseline perf.data files, that do not match any +baseline entry, are displayed with empty space within baseline column +and possible computation results (delta) in their related column. + +Example files samples: +- file A with samples f1, f2, f3, f4,    f6 +- file B with samples     f2,     f4, f5 +- file C with samples f1, f2,         f5 + +Example output: +  x - computation takes place for pair +  b - baseline sample percentage + +- perf diff A B C + +  baseline/A compute/B compute/C  samples +  --------------------------------------- +  b                    x          f1 +  b          x         x          f2 +  b                               f3 +  b          x                    f4 +  b                               f6 +             x         x          f5 + +- perf diff B A C + +  baseline/B compute/A compute/C  samples +  --------------------------------------- +  b          x         x          f2 +  b          x                    f4 +  b                    x          f5 +             x         x          f1 +             x                    f3 +             x                    f6 + +- perf diff C B A + +  baseline/C compute/B compute/A  samples +  --------------------------------------- +  b                    x          f1 +  b          x         x          f2 +  b          x                    f5 +                       x          f3 +             x         x          f4 +                       x          f6 + +COMPARISON METHODS +------------------ +delta +~~~~~ +If specified the 'Delta' column is displayed with value 'd' computed as: + +  d = A->period_percent - B->period_percent + +with: +  - A/B being matching hist entry from data/baseline file specified +    (or perf.data/perf.data.old) respectively. + +  - period_percent being the % of the hist entry period value within +    single data file + +  - with filtering by -C, -d and/or -S, period_percent might be changed +    relative to how entries are filtered.  Use --percentage=absolute to +    prevent such fluctuation. + +ratio +~~~~~ +If specified the 'Ratio' column is displayed with value 'r' computed as: + +  r = A->period / B->period + +with: +  - A/B being matching hist entry from data/baseline file specified +    (or perf.data/perf.data.old) respectively. + +  - period being the hist entry period value + +wdiff:WEIGHT-B,WEIGHT-A +~~~~~~~~~~~~~~~~~~~~~~~ +If specified the 'Weighted diff' column is displayed with value 'd' computed as: + +   d = B->period * WEIGHT-A - A->period * WEIGHT-B + +  - A/B being matching hist entry from data/baseline file specified +    (or perf.data/perf.data.old) respectively. + +  - period being the hist entry period value + +  - WEIGHT-A/WEIGHT-B being user suplied weights in the the '-c' option +    behind ':' separator like '-c wdiff:1,2'. +    - WIEGHT-A being the weight of the data file +    - WIEGHT-B being the weight of the baseline data file +  SEE ALSO  -------- -linkperf:perf-record[1] +linkperf:perf-record[1], linkperf:perf-report[1] diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt new file mode 100644 index 00000000000..1ceb3700ffb --- /dev/null +++ b/tools/perf/Documentation/perf-evlist.txt @@ -0,0 +1,38 @@ +perf-evlist(1) +============== + +NAME +---- +perf-evlist - List the event names in a perf.data file + +SYNOPSIS +-------- +[verse] +'perf evlist <options>' + +DESCRIPTION +----------- +This command displays the names of events sampled in a perf.data file. + +OPTIONS +------- +-i:: +--input=:: +        Input file name. (default: perf.data unless stdin is a fifo) + +-F:: +--freq=:: +	Show just the sample frequency used for each event. + +-v:: +--verbose=:: +	Show all fields. + +-g:: +--group:: +	Show event group information. + +SEE ALSO +-------- +linkperf:perf-record[1], linkperf:perf-list[1], +linkperf:perf-report[1] diff --git a/tools/perf/Documentation/perf-inject.txt b/tools/perf/Documentation/perf-inject.txt index 025630d43cd..a00a34276c5 100644 --- a/tools/perf/Documentation/perf-inject.txt +++ b/tools/perf/Documentation/perf-inject.txt @@ -29,6 +29,17 @@ OPTIONS  -v::  --verbose::  	Be more verbose. +-i:: +--input=:: +	Input file name. (default: stdin) +-o:: +--output=:: +	Output file name. (default: stdout) +-s:: +--sched-stat:: +	Merge sched_stat and sched_switch for getting events where and how long +	tasks slept. sched_switch contains a callchain where a task slept and +	sched_stat contains a timeslice how long a task slept.  SEE ALSO  -------- diff --git a/tools/perf/Documentation/perf-kmem.txt b/tools/perf/Documentation/perf-kmem.txt index a52fcde894c..7c8fbbf3f61 100644 --- a/tools/perf/Documentation/perf-kmem.txt +++ b/tools/perf/Documentation/perf-kmem.txt @@ -23,7 +23,7 @@ OPTIONS  -------  -i <file>::  --input=<file>:: -	Select the input file (default: perf.data) +	Select the input file (default: perf.data unless stdin is a fifo)  --caller::  	Show per-callsite statistics diff --git a/tools/perf/Documentation/perf-kvm.txt b/tools/perf/Documentation/perf-kvm.txt index d004e19fe6d..52276a6d2b7 100644 --- a/tools/perf/Documentation/perf-kvm.txt +++ b/tools/perf/Documentation/perf-kvm.txt @@ -10,9 +10,10 @@ SYNOPSIS  [verse]  'perf kvm' [--host] [--guest] [--guestmount=<path>  	[--guestkallsyms=<path> --guestmodules=<path> | --guestvmlinux=<path>]] -	{top|record|report|diff|buildid-list} +	{top|record|report|diff|buildid-list} [<options>]  'perf kvm' [--host] [--guest] [--guestkallsyms=<path> --guestmodules=<path> -	| --guestvmlinux=<path>] {top|record|report|diff|buildid-list} +	| --guestvmlinux=<path>] {top|record|report|diff|buildid-list|stat} [<options>] +'perf kvm stat [record|report|live] [<options>]  DESCRIPTION  ----------- @@ -22,11 +23,18 @@ There are a couple of variants of perf kvm:    a performance counter profile of guest os in realtime    of an arbitrary workload. -  'perf kvm record <command>' to record the performance couinter profile -  of an arbitrary workload and save it into a perf data file. If both -  --host and --guest are input, the perf data file name is perf.data.kvm. -  If there is  no --host but --guest, the file name is perf.data.guest. -  If there is no --guest but --host, the file name is perf.data.host. +  'perf kvm record <command>' to record the performance counter profile +  of an arbitrary workload and save it into a perf data file. We set the +  default behavior of perf kvm as --guest, so if neither --host nor --guest +  is input, the perf data file name is perf.data.guest. If --host is input, +  the perf data file name is perf.data.kvm. If you want to record data into +  perf.data.host, please input --host --no-guest. The behaviors are shown as +  following: +    Default('')         ->  perf.data.guest +    --host              ->  perf.data.kvm +    --guest             ->  perf.data.guest +    --host --guest      ->  perf.data.kvm +    --host --no-guest   ->  perf.data.host    'perf kvm report' to display the performance counter profile information    recorded via perf kvm record. @@ -36,13 +44,37 @@ There are a couple of variants of perf kvm:    'perf kvm buildid-list' to  display the buildids found in a perf data file,    so that other tools can be used to fetch packages with matching symbol tables -  for use by perf report. +  for use by perf report. As buildid is read from /sys/kernel/notes in os, then +  if you want to list the buildid for guest, please make sure your perf data file +  was captured with --guestmount in perf kvm record. + +  'perf kvm stat <command>' to run a command and gather performance counter +  statistics. +  Especially, perf 'kvm stat record/report' generates a statistical analysis +  of KVM events. Currently, vmexit, mmio and ioport events are supported. +  'perf kvm stat record <command>' records kvm events and the events between +  start and end <command>. +  And this command produces a file which contains tracing results of kvm +  events. + +  'perf kvm stat report' reports statistical data which includes events +  handled time, samples, and so on. + +  'perf kvm stat live' reports statistical data in a live mode (similar to +  record + report but with statistical data updated live at a given display +  rate).  OPTIONS  ------- ---host=:: +-i:: +--input=<path>:: +        Input file name. +-o:: +--output=<path>:: +        Output file name. +--host::          Collect host side performance profile. ---guest=:: +--guest::          Collect guest side performance profile.  --guestmount=<path>::  	Guest os root file system mount directory. Users mounts guest os @@ -61,8 +93,64 @@ OPTIONS  	kernel module information. Users copy it out from guest os.  --guestvmlinux=<path>::  	Guest os kernel vmlinux. +-v:: +--verbose:: +	Be more verbose (show counter open errors, etc). + +STAT REPORT OPTIONS +------------------- +--vcpu=<value>:: +       analyze events which occures on this vcpu. (default: all vcpus) + +--event=<value>:: +       event to be analyzed. Possible values: vmexit, mmio, ioport. +       (default: vmexit) +-k:: +--key=<value>:: +       Sorting key. Possible values: sample (default, sort by samples +       number), time (sort by average time). +-p:: +--pid=:: +    Analyze events only for given process ID(s) (comma separated list). + +STAT LIVE OPTIONS +----------------- +-d:: +--display:: +        Time in seconds between display updates + +-m:: +--mmap-pages=:: +    Number of mmap data pages (must be a power of two) or size +    specification with appended unit character - B/K/M/G. The +    size is rounded up to have nearest pages power of two value. + +-a:: +--all-cpus:: +        System-wide collection from all CPUs. + +-p:: +--pid=:: +    Analyze events only for given process ID(s) (comma separated list). + +--vcpu=<value>:: +       analyze events which occures on this vcpu. (default: all vcpus) + + +--event=<value>:: +       event to be analyzed. Possible values: vmexit, mmio, ioport. +       (default: vmexit) + +-k:: +--key=<value>:: +       Sorting key. Possible values: sample (default, sort by samples +       number), time (sort by average time). + +--duration=<value>:: +       Show events other than HLT that take longer than duration usecs.  SEE ALSO  --------  linkperf:perf-top[1], linkperf:perf-record[1], linkperf:perf-report[1], -linkperf:perf-diff[1], linkperf:perf-buildid-list[1] +linkperf:perf-diff[1], linkperf:perf-buildid-list[1], +linkperf:perf-stat[1] diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt index 399751befee..6fce6a62220 100644 --- a/tools/perf/Documentation/perf-list.txt +++ b/tools/perf/Documentation/perf-list.txt @@ -8,29 +8,52 @@ perf-list - List all symbolic event types  SYNOPSIS  --------  [verse] -'perf list' +'perf list' [hw|sw|cache|tracepoint|pmu|event_glob]  DESCRIPTION  -----------  This command displays the symbolic event types which can be selected in the  various perf commands with the -e option. +[[EVENT_MODIFIERS]]  EVENT MODIFIERS  ---------------  Events can optionally have a modifer by appending a colon and one or -more modifiers.  Modifiers allow the user to restrict when events are -counted with 'u' for user-space, 'k' for kernel, 'h' for hypervisor. +more modifiers. Modifiers allow the user to restrict the events to be +counted. The following modifiers exist: + + u - user-space counting + k - kernel counting + h - hypervisor counting + G - guest counting (in KVM guests) + H - host counting (not in KVM guests) + p - precise level + S - read sample value (PERF_SAMPLE_READ) + D - pin the event to the PMU  The 'p' modifier can be used for specifying how precise the instruction -address should be. The 'p' modifier is currently only implemented for -Intel PEBS and can be specified multiple times: -  0 - SAMPLE_IP can have arbitrary skid -  1 - SAMPLE_IP must have constant skid -  2 - SAMPLE_IP requested to have 0 skid -  3 - SAMPLE_IP must have 0 skid +address should be. The 'p' modifier can be specified multiple times: -The PEBS implementation now supports up to 2. + 0 - SAMPLE_IP can have arbitrary skid + 1 - SAMPLE_IP must have constant skid + 2 - SAMPLE_IP requested to have 0 skid + 3 - SAMPLE_IP must have 0 skid + +For Intel systems precise event sampling is implemented with PEBS +which supports up to precise-level 2. + +On AMD systems it is implemented using IBS (up to precise-level 2). +The precise modifier works with event types 0x76 (cpu-cycles, CPU +clocks not halted) and 0xC1 (micro-ops retired). Both events map to +IBS execution sampling (IBS op) with the IBS Op Counter Control bit +(IbsOpCntCtl) set respectively (see AMD64 Architecture Programmer’s +Manual Volume 2: System Programming, 13.3 Instruction-Based +Sampling). Examples to use IBS: + + perf record -a -e cpu-cycles:p ...    # use ibs op counting cycles + perf record -a -e r076:p ...          # same as -e cpu-cycles:p + perf record -a -e r0C1:p ...          # use ibs op counting micro-ops  RAW HARDWARE EVENT DESCRIPTOR  ----------------------------- @@ -42,6 +65,11 @@ layout of IA32_PERFEVTSELx MSRs (see [Intel® 64 and IA-32 Architectures Softwar  of IA32_PERFEVTSELx MSRs) or AMD's PerfEvtSeln (see [AMD64 Architecture Programmer’s Manual Volume 2: System Programming], Page 344,  Figure 13-7 Performance Event-Select Register (PerfEvtSeln)). +Note: Only the following bit fields can be set in x86 counter +registers: event, umask, edge, inv, cmask. Esp. guest/host only and +OS/user mode flags must be setup using <<EVENT_MODIFIERS, EVENT +MODIFIERS>>. +  Example:  If the Intel docs for a QM720 Core i7 describe an event as: @@ -63,11 +91,32 @@ details. Some of them are referenced in the SEE ALSO section below.  OPTIONS  ------- -None + +Without options all known events will be listed. + +To limit the list use: + +. 'hw' or 'hardware' to list hardware events such as cache-misses, etc. + +. 'sw' or 'software' to list software events such as context switches, etc. + +. 'cache' or 'hwcache' to list hardware cache events such as L1-dcache-loads, etc. + +. 'tracepoint' to list all tracepoint events, alternatively use +  'subsys_glob:event_glob' to filter by tracepoint subsystems such as sched, +  block, etc. + +. 'pmu' to print the kernel supplied PMU events. + +. If none of the above is matched, it will apply the supplied glob to all +  events, printing the ones that match. + +One or more types can be used at the same time, listing the events for the +types specified.  SEE ALSO  --------  linkperf:perf-stat[1], linkperf:perf-top[1],  linkperf:perf-record[1],  http://www.intel.com/Assets/PDF/manual/253669.pdf[Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 3B: System Programming Guide], -http://support.amd.com/us/Processor_TechDocs/24593.pdf[AMD64 Architecture Programmer’s Manual Volume 2: System Programming] +http://support.amd.com/us/Processor_TechDocs/24593_APM_v2.pdf[AMD64 Architecture Programmer’s Manual Volume 2: System Programming] diff --git a/tools/perf/Documentation/perf-lock.txt b/tools/perf/Documentation/perf-lock.txt index b317102138c..ab25be28c9d 100644 --- a/tools/perf/Documentation/perf-lock.txt +++ b/tools/perf/Documentation/perf-lock.txt @@ -8,7 +8,7 @@ perf-lock - Analyze lock events  SYNOPSIS  --------  [verse] -'perf lock' {record|report|trace} +'perf lock' {record|report|script|info}  DESCRIPTION  ----------- @@ -20,10 +20,47 @@ and statistics with this 'perf lock' command.    produces the file "perf.data" which contains tracing    results of lock events. -  'perf lock trace' shows raw lock events. -    'perf lock report' reports statistical data. +  'perf lock script' shows raw lock events. + +  'perf lock info' shows metadata like threads or addresses +  of lock instances. + +COMMON OPTIONS +-------------- + +-i:: +--input=<file>:: +        Input file name. (default: perf.data unless stdin is a fifo) + +-v:: +--verbose:: +        Be more verbose (show symbol address, etc). + +-D:: +--dump-raw-trace:: +        Dump raw trace in ASCII. + +REPORT OPTIONS +-------------- + +-k:: +--key=<value>:: +        Sorting key. Possible values: acquired (default), contended, +	avg_wait, wait_total, wait_max, wait_min. + +INFO OPTIONS +------------ + +-t:: +--threads:: +	dump thread list in perf.data + +-m:: +--map:: +	dump map of lock instances (address:name table) +  SEE ALSO  --------  linkperf:perf[1] diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt new file mode 100644 index 00000000000..1d78a4064da --- /dev/null +++ b/tools/perf/Documentation/perf-mem.txt @@ -0,0 +1,52 @@ +perf-mem(1) +=========== + +NAME +---- +perf-mem - Profile memory accesses + +SYNOPSIS +-------- +[verse] +'perf mem' [<options>] (record [<command>] | report) + +DESCRIPTION +----------- +"perf mem -t <TYPE> record" runs a command and gathers memory operation data +from it, into perf.data. Perf record options are accepted and are passed through. + +"perf mem -t <TYPE> report" displays the result. It invokes perf report with the +right set of options to display a memory access profile. + +Note that on Intel systems the memory latency reported is the use-latency, +not the pure load (or store latency). Use latency includes any pipeline +queueing delays in addition to the memory subsystem latency. + +OPTIONS +------- +<command>...:: +	Any command you can specify in a shell. + +-t:: +--type=:: +	Select the memory operation type: load or store (default: load) + +-D:: +--dump-raw-samples=:: +	Dump the raw decoded samples on the screen in a format that is easy to parse with +	one sample per line. + +-x:: +--field-separator:: +	Specify the field separator used when dump raw samples (-D option). By default, +	The separator is the space character. + +-C:: +--cpu-list:: +	Restrict dump of raw samples to those provided via this option. Note that the same +	option can be passed in record mode. It will be interpreted the same way as perf +	record. + +SEE ALSO +-------- +linkperf:perf-record[1], linkperf:perf-report[1] diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt index 62de1b7f4e7..1513935c399 100644 --- a/tools/perf/Documentation/perf-probe.txt +++ b/tools/perf/Documentation/perf-probe.txt @@ -16,7 +16,7 @@ or  or  'perf probe' --list  or -'perf probe' [options] --line='FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]' +'perf probe' [options] --line='LINE'  or  'perf probe' [options] --vars='PROBEPOINT' @@ -34,9 +34,11 @@ OPTIONS  	Specify vmlinux path which has debuginfo (Dwarf binary).  -m:: ---module=MODNAME:: +--module=MODNAME|PATH::  	Specify module name in which perf-probe searches probe points -	or lines. +	or lines. If a path of module file is passed, perf-probe +	treat it as an offline module (this means you can add a probe on +        a module which has not been loaded yet).  -s::  --source=PATH:: @@ -73,6 +75,18 @@ OPTIONS  	(Only for --vars) Show external defined variables in addition to local  	variables. +-F:: +--funcs:: +	Show available functions in given module or kernel. With -x/--exec, +	can also list functions in a user space executable / shared library. + +--filter=FILTER:: +	(Only for --vars and --funcs) Set filter. FILTER is a combination of glob +	pattern, see FILTER PATTERN for detail. +	Default FILTER is "!__k???tab_* & !__crc_*" for --vars, and "!_*" +	for --funcs. +	If several filters are specified, only the last filter is used. +  -f::  --force::  	Forcibly add events with existing name. @@ -85,6 +99,15 @@ OPTIONS  --max-probes::  	Set the maximum number of probe points for an event. Default is 128. +-x:: +--exec=PATH:: +	Specify path to the executable or shared library file for user +	space tracing. Can also be used with --funcs option. + +In absence of -m/-x options, perf probe checks if the first argument after +the options is an absolute path name. If its an absolute path, perf probe +uses it as a target module/target user space binary to probe. +  PROBE SYNTAX  ------------  Probe points are defined by following syntax. @@ -113,17 +136,20 @@ Each probe argument follows below syntax.  'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), local array with fixed index (e.g. array[1], var->array[0], var->pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.)  'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type. +On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. +  LINE SYNTAX  ----------- -Line range is descripted by following syntax. +Line range is described by following syntax. - "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]" + "FUNC[@SRC][:RLN[+NUM|-RLN2]]|SRC[:ALN[+NUM|-ALN2]]"  FUNC specifies the function name of showing lines. 'RLN' is the start line  number from function entry line, and 'RLN2' is the end line number. As same as  probe syntax, 'SRC' means the source file path, 'ALN' is start line number,  and 'ALN2' is end line number in the file. It is also possible to specify how -many lines to show by using 'NUM'. +many lines to show by using 'NUM'. Moreover, 'FUNC@SRC' combination is good +for searching a specific function when several functions share same name.  So, "source.c:100-120" shows lines between 100th to l20th in source.c file. And "func:10+20" shows 20 lines from 10th line of func function.  LAZY MATCHING @@ -135,6 +161,14 @@ e.g.  This provides some sort of flexibility and robustness to probe point definitions against minor code changes. For example, actual 10th line of schedule() can be moved easily by modifying schedule(), but the same line matching 'rq=cpu_rq*' may still exist in the function.) +FILTER PATTERN +-------------- + The filter pattern is a glob matching pattern(s) to filter variables. + In addition, you can use "!" for specifying filter-out rule. You also can give several rules combined with "&" or "|", and fold those rules as one rule by using "(" ")". + +e.g. + With --filter "foo* | bar*", perf probe -V shows variables which start with "foo" or "bar". + With --filter "!foo* & *bar", perf probe -V shows variables which don't start with "foo" and end with "bar", like "fizzbar". But "foobar" is filtered out.  EXAMPLES  -------- @@ -160,6 +194,13 @@ Delete all probes on schedule().   ./perf probe --del='schedule*' +Add probes at zfree() function on /bin/zsh + + ./perf probe -x /bin/zsh zfree or ./perf probe /bin/zsh zfree + +Add probes at malloc() function on libc + + ./perf probe -x /lib/libc.so.6 malloc or ./perf probe /lib/libc.so.6 malloc  SEE ALSO  -------- diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index a91f9f9e6e5..d460049cae8 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -39,26 +39,37 @@ OPTIONS            be passed as follows: '\mem:addr[:[r][w][x]]'.            If you want to profile read-write accesses in 0x1000, just set            'mem:0x1000:rw'. + +--filter=<filter>:: +        Event filter. +  -a:: -        System-wide collection. +--all-cpus:: +        System-wide collection from all CPUs.  -l::          Scale counter values.  -p::  --pid=:: -	Record events on existing pid. +	Record events on existing process ID (comma separated list). + +-t:: +--tid=:: +        Record events on existing thread ID (comma separated list). +        This option also disables inheritance by default.  Enable it by adding +        --inherit. + +-u:: +--uid=:: +        Record events in threads owned by uid. Name or number.  -r::  --realtime=::  	Collect data with this RT SCHED_FIFO priority. --A:: ---append:: -	Append to the output file to do incremental profiling. --f:: ---force:: -	Overwrite existing data file. (deprecated) +--no-buffering:: +	Collect data without buffering.  -c::  --count=:: @@ -77,11 +88,25 @@ OPTIONS  -m::  --mmap-pages=:: -	Number of mmap data pages. +	Number of mmap data pages (must be a power of two) or size +	specification with appended unit character - B/K/M/G. The +	size is rounded up to have nearest pages power of two value.  -g:: +	Enables call-graph (stack chain/backtrace) recording. +  --call-graph:: -	Do call-graph (stack chain/backtrace) recording. +	Setup and enable call-graph (stack chain/backtrace) recording, +	implies -g. + +	Allows specifying "fp" (frame pointer) or "dwarf" +	(DWARF's CFI - Call Frame Information) as the method to collect +	the information used to show the call graphs. + +	In some systems, where binaries are build with gcc +	--fomit-frame-pointer, using the "fp" method will produce bogus +	call graphs, using "dwarf", if available (perf tools linked to +	the libunwind library) should be used instead.  -q::  --quiet:: @@ -99,6 +124,11 @@ OPTIONS  --data::  	Sample addresses. +-T:: +--timestamp:: +	Sample timestamps. Use it with 'perf report -D' to see the timestamps, +	for instance. +  -n::  --no-samples::  	Don't sample. @@ -109,8 +139,8 @@ Collect raw sample records from all opened counters (default for tracepoint coun  -C::  --cpu:: -Collect samples only on the list of cpus provided. Multiple CPUs can be provided as a -comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. +Collect samples only on the list of CPUs provided. Multiple CPUs can be provided as a +comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.  In per-thread mode with inheritance mode on (default), samples are captured only when  the thread executes on the designated CPUs. Default is to monitor all CPUs. @@ -120,6 +150,70 @@ Do not update the builid cache. This saves some overhead in situations  where the information in the perf.data file (which includes buildids)  is sufficient. +-G name,...:: +--cgroup name,...:: +monitor only in the container (cgroup) called "name". This option is available only +in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to +container "name" are monitored when they run on the monitored CPUs. Multiple cgroups +can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup +to first event, second cgroup to second event and so on. It is possible to provide +an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have +corresponding events, i.e., they always refer to events defined earlier on the command +line. + +-b:: +--branch-any:: +Enable taken branch stack sampling. Any type of taken branch may be sampled. +This is a shortcut for --branch-filter any. See --branch-filter for more infos. + +-j:: +--branch-filter:: +Enable taken branch stack sampling. Each sample captures a series of consecutive +taken branches. The number of branches captured with each sample depends on the +underlying hardware, the type of branches of interest, and the executed code. +It is possible to select the types of branches captured by enabling filters. The +following filters are defined: + +        - any:  any type of branches +        - any_call: any function call or system call +        - any_ret: any function return or system call return +        - ind_call: any indirect branch +        - u:  only when the branch target is at the user level +        - k: only when the branch target is in the kernel +        - hv: only when the target is at the hypervisor level +	- in_tx: only when the target is in a hardware transaction +	- no_tx: only when the target is not in a hardware transaction +	- abort_tx: only when the target is a hardware transaction abort +	- cond: conditional branches + ++ +The option requires at least one branch type among any, any_call, any_ret, ind_call, cond. +The privilege levels may be omitted, in which case, the privilege levels of the associated +event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege +levels are subject to permissions.  When sampling on multiple events, branch stack sampling +is enabled for all the sampling events. The sampled branch type is the same for all events. +The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k +Note that this feature may not be available on all processors. + +--weight:: +Enable weightened sampling. An additional weight is recorded per sample and can be +displayed with the weight and local_weight sort keys.  This currently works for TSX +abort events and some memory events in precise mode on modern Intel CPUs. + +--transaction:: +Record transaction flags for transaction related events. + +--per-thread:: +Use per-thread mmaps.  By default per-cpu mmaps are created.  This option +overrides that and uses per-thread mmaps.  A side-effect of that is that +inheritance is automatically disabled.  --per-thread is ignored with a warning +if combined with -a or -C options. + +-D:: +--delay=:: +After starting the program, wait msecs before measuring. This is useful to +filter out the startup phase of the program, which is often very different. +  SEE ALSO  --------  linkperf:perf-stat[1], linkperf:perf-list[1] diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 12052c9ed0b..d2b59af62bc 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -19,51 +19,190 @@ OPTIONS  -------  -i::  --input=:: -        Input file name. (default: perf.data) --d:: ---dsos=:: -	Only consider symbols in these dsos. CSV that understands -	file://filename entries. +        Input file name. (default: perf.data unless stdin is a fifo) + +-v:: +--verbose:: +        Be more verbose. (show symbol address, etc) +  -n::  --show-nr-samples::  	Show the number of samples for each symbol + +--showcpuutilization:: +        Show sample percentage for different cpu modes. +  -T::  --threads::  	Show per-thread event counters --C:: +-c::  --comms=::  	Only consider symbols in these comms. CSV that understands -	file://filename entries. +	file://filename entries.  This option will affect the percentage of +	the overhead column.  See --percentage for more info. +-d:: +--dsos=:: +	Only consider symbols in these dsos. CSV that understands +	file://filename entries.  This option will affect the percentage of +	the overhead column.  See --percentage for more info.  -S::  --symbols=::  	Only consider these symbols. CSV that understands -	file://filename entries. +	file://filename entries.  This option will affect the percentage of +	the overhead column.  See --percentage for more info. + +--symbol-filter=:: +	Only show symbols that match (partially) with this filter. + +-U:: +--hide-unresolved:: +        Only display entries resolved to a symbol.  -s::  --sort=:: -	Sort by key(s): pid, comm, dso, symbol, parent. +	Sort histogram entries by given key(s) - multiple keys can be specified +	in CSV format.  Following sort keys are available: +	pid, comm, dso, symbol, parent, cpu, srcline, weight, local_weight. + +	Each key has following meaning: + +	- comm: command (name) of the task which can be read via /proc/<pid>/comm +	- pid: command and tid of the task +	- dso: name of library or module executed at the time of sample +	- symbol: name of function executed at the time of sample +	- parent: name of function matched to the parent regex filter. Unmatched +	entries are displayed as "[other]". +	- cpu: cpu number the task ran at the time of sample +	- srcline: filename and line number executed at the time of sample.  The +	DWARF debugging info must be provided. +	- weight: Event specific weight, e.g. memory latency or transaction +	abort cost. This is the global weight. +	- local_weight: Local weight version of the weight above. +	- transaction: Transaction abort flags. +	- overhead: Overhead percentage of sample +	- overhead_sys: Overhead percentage of sample running in system mode +	- overhead_us: Overhead percentage of sample running in user mode +	- overhead_guest_sys: Overhead percentage of sample running in system mode +	on guest machine +	- overhead_guest_us: Overhead percentage of sample running in user mode on +	guest machine +	- sample: Number of sample +	- period: Raw number of event count of sample + +	By default, comm, dso and symbol keys are used. +	(i.e. --sort comm,dso,symbol) + +	If --branch-stack option is used, following sort keys are also +	available: +	dso_from, dso_to, symbol_from, symbol_to, mispredict. + +	- dso_from: name of library or module branched from +	- dso_to: name of library or module branched to +	- symbol_from: name of function branched from +	- symbol_to: name of function branched to +	- mispredict: "N" for predicted branch, "Y" for mispredicted branch +	- in_tx: branch in TSX transaction +	- abort: TSX transaction abort. + +	And default sort keys are changed to comm, dso_from, symbol_from, dso_to +	and symbol_to, see '--branch-stack'. + +-F:: +--fields=:: +	Specify output field - multiple keys can be specified in CSV format. +	Following fields are available: +	overhead, overhead_sys, overhead_us, overhead_children, sample and period. +	Also it can contain any sort key(s). + +	By default, every sort keys not specified in -F will be appended +	automatically. + +	If --mem-mode option is used, following sort keys are also available +	(incompatible with --branch-stack): +	symbol_daddr, dso_daddr, locked, tlb, mem, snoop, dcacheline. + +	- symbol_daddr: name of data symbol being executed on at the time of sample +	- dso_daddr: name of library or module containing the data being executed +	on at the time of sample +	- locked: whether the bus was locked at the time of sample +	- tlb: type of tlb access for the data at the time of sample +	- mem: type of memory access for the data at the time of sample +	- snoop: type of snoop (if any) for the data at the time of sample +	- dcacheline: the cacheline the data address is on at the time of sample + +	And default sort keys are changed to local_weight, mem, sym, dso, +	symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'. + +-p:: +--parent=<regex>:: +        A regex filter to identify parent. The parent is a caller of this +	function and searched through the callchain, thus it requires callchain +	information recorded. The pattern is in the exteneded regex format and +	defaults to "\^sys_|^do_page_fault", see '--sort parent'. + +-x:: +--exclude-other:: +        Only display entries with parent-match.  -w:: ---field-width=:: +--column-widths=<width[,width...]>::  	Force each column width to the provided list, for large terminal  	readability.  -t::  --field-separator=:: -  	Use a special separator character and don't pad with spaces, replacing -	all occurances of this separator in symbol names (and other output) +	all occurrences of this separator in symbol names (and other output)  	with a '.' character, that thus it's the only non valid separator. --g [type,min]:: +-D:: +--dump-raw-trace:: +        Dump raw trace in ASCII. + +-g [type,min[,limit],order[,key]]::  --call-graph:: -        Display callchains using type and min percent threshold. +        Display call chains using type, min percent threshold, optional print +	limit and order.  	type can be either: -	- flat: single column, linear exposure of callchains. +	- flat: single column, linear exposure of call chains.  	- graph: use a graph tree, displaying absolute overhead rates.  	- fractal: like graph, but displays relative rates. Each branch of  		 the tree is considered as a new profiled object. + -	Default: fractal,0.5. + +	order can be either: +	- callee: callee based call graph. +	- caller: inverted caller based call graph. + +	key can be: +	- function: compare on functions +	- address: compare on individual code addresses + +	Default: fractal,0.5,callee,function. + +--children:: +	Accumulate callchain of children to parent entry so that then can +	show up in the output.  The output will have a new "Children" column +	and will be sorted on the data.  It requires callchains are recorded. + +--max-stack:: +	Set the stack depth limit when parsing the callchain, anything +	beyond the specified depth will be ignored. This is a trade-off +	between information loss and faster processing especially for +	workloads that can have a very long callchain stack. + +	Default: 127 + +-G:: +--inverted:: +        alias for inverted caller based call graph. + +--ignore-callees=<regex>:: +        Ignore callees of the function(s) matching the given regex. +        This has the effect of collecting the callers of each such +        function into one place in the call-graph tree. + +--pretty=<key>:: +        Pretty printing style.  key: normal, raw  --stdio:: Use the stdio interface. @@ -72,6 +211,100 @@ OPTIONS  	requires a tty, if one is not present, as when piping to other  	commands, the stdio interface is used. +--gtk:: Use the GTK2 interface. + +-k:: +--vmlinux=<file>:: +        vmlinux pathname + +--kallsyms=<file>:: +        kallsyms pathname + +-m:: +--modules:: +        Load module symbols. WARNING: This should only be used with -k and +        a LIVE kernel. + +-f:: +--force:: +        Don't complain, do it. + +--symfs=<directory>:: +        Look for files with symbols relative to this directory. + +-C:: +--cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can +	be provided as a comma-separated list with no space: 0,1. Ranges of +	CPUs are specified with -: 0-2. Default is to report samples on all +	CPUs. + +-M:: +--disassembler-style=:: Set disassembler style for objdump. + +--source:: +	Interleave source code with assembly code. Enabled by default, +	disable with --no-source. + +--asm-raw:: +	Show raw instruction encoding of assembly instructions. + +--show-total-period:: Show a column with the sum of periods. + +-I:: +--show-info:: +	Display extended information about the perf.data file. This adds +	information which may be very large and thus may clutter the display. +	It currently includes: cpu and numa topology of the host system. + +-b:: +--branch-stack:: +	Use the addresses of sampled taken branches instead of the instruction +	address to build the histograms. To generate meaningful output, the +	perf.data file must have been obtained using perf record -b or +	perf record --branch-filter xxx where xxx is a branch filter option. +	perf report is able to auto-detect whether a perf.data file contains +	branch stacks and it will automatically switch to the branch view mode, +	unless --no-branch-stack is used. + +--objdump=<path>:: +        Path to objdump binary. + +--group:: +	Show event group information together. + +--demangle:: +	Demangle symbol names to human readable form. It's enabled by default, +	disable with --no-demangle. + +--mem-mode:: +	Use the data addresses of samples in addition to instruction addresses +	to build the histograms.  To generate meaningful output, the perf.data +	file must have been obtained using perf record -d -W and using a +	special event -e cpu/mem-loads/ or -e cpu/mem-stores/. See +	'perf mem' for simpler access. + +--percent-limit:: +	Do not show entries which have an overhead under that percent. +	(Default: 0). + +--percentage:: +	Determine how to display the overhead percentage of filtered entries. +	Filters can be applied by --comms, --dsos and/or --symbols options and +	Zoom operations on the TUI (thread, dso, etc). + +	"relative" means it's relative to filtered entries only so that the +	sum of shown entries will be always 100%.  "absolute" means it retains +	the original value before and after the filter is applied. + +--header:: +	Show header information in the perf.data file.  This includes +	various information like hostname, OS and perf version, cpu/mem +	info, perf command line, event list and so on.  Currently only +	--stdio output supports this feature. + +--header-only:: +	Show only perf.data header (forces --stdio). +  SEE ALSO  -------- -linkperf:perf-stat[1] +linkperf:perf-stat[1], linkperf:perf-annotate[1] diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt index 8417644a616..8ff4df95695 100644 --- a/tools/perf/Documentation/perf-sched.txt +++ b/tools/perf/Documentation/perf-sched.txt @@ -8,11 +8,11 @@ perf-sched - Tool to trace/measure scheduler properties (latencies)  SYNOPSIS  --------  [verse] -'perf sched' {record|latency|replay|trace} +'perf sched' {record|latency|map|replay|script}  DESCRIPTION  ----------- -There are four variants of perf sched: +There are five variants of perf sched:    'perf sched record <command>' to record the scheduling events    of an arbitrary workload. @@ -20,8 +20,8 @@ There are four variants of perf sched:    'perf sched latency' to report the per task scheduling latencies    and other scheduling properties of the workload. -  'perf sched trace' to see a detailed trace of the workload that -  was recorded. +  'perf sched script' to see a detailed trace of the workload that +   was recorded (aliased to 'perf script' for now).    'perf sched replay' to simulate the workload that was recorded    via perf sched record. (this is done by starting up mockup threads @@ -30,8 +30,22 @@ There are four variants of perf sched:    of the workload as it occurred when it was recorded - and can repeat    it a number of times, measuring its performance.) +  'perf sched map' to print a textual context-switching outline of +  workload captured via perf sched record.  Columns stand for +  individual CPUs, and the two-letter shortcuts stand for tasks that +  are running on a CPU. A '*' denotes the CPU that had the event, and +  a dot signals an idle CPU. +  OPTIONS  ------- +-i:: +--input=<file>:: +        Input file name. (default: perf.data unless stdin is a fifo) + +-v:: +--verbose:: +        Be more verbose. (show symbol address, etc) +  -D::  --dump-raw-trace=::          Display verbose dump of the sched data. diff --git a/tools/perf/Documentation/perf-trace-perl.txt b/tools/perf/Documentation/perf-script-perl.txt index ee6525ee6d6..d00bef23134 100644 --- a/tools/perf/Documentation/perf-trace-perl.txt +++ b/tools/perf/Documentation/perf-script-perl.txt @@ -1,19 +1,19 @@ -perf-trace-perl(1) +perf-script-perl(1)  ==================  NAME  ---- -perf-trace-perl - Process trace data with a Perl script +perf-script-perl - Process trace data with a Perl script  SYNOPSIS  --------  [verse] -'perf trace' [-s [Perl]:script[.pl] ] +'perf script' [-s [Perl]:script[.pl] ]  DESCRIPTION  ----------- -This perf trace option is used to process perf trace data using perf's +This perf script option is used to process perf script data using perf's  built-in Perl interpreter.  It reads and processes the input file and  displays the results of the trace analysis implemented in the given  Perl script, if any. @@ -21,7 +21,7 @@ Perl script, if any.  STARTER SCRIPTS  --------------- -You can avoid reading the rest of this document by running 'perf trace +You can avoid reading the rest of this document by running 'perf script  -g perl' in the same directory as an existing perf.data trace file.  That will generate a starter script containing a handler for each of  the event types in the trace file; it simply prints every available @@ -30,13 +30,13 @@ field for each event in the trace file.  You can also look at the existing scripts in  ~/libexec/perf-core/scripts/perl for typical examples showing how to  do basic things like aggregate event data, print results, etc.  Also, -the check-perf-trace.pl script, while not interesting for its results, +the check-perf-script.pl script, while not interesting for its results,  attempts to exercise all of the main scripting features.  EVENT HANDLERS  -------------- -When perf trace is invoked using a trace script, a user-defined +When perf script is invoked using a trace script, a user-defined  'handler function' is called for each event in the trace.  If there's  no handler function defined for a given event type, the event is  ignored (or passed to a 'trace_handled' function, see below) and the @@ -63,7 +63,6 @@ The format file for the sched_wakep event defines the following fields          field:unsigned char common_flags;          field:unsigned char common_preempt_count;          field:int common_pid; -        field:int common_lock_depth;          field:char comm[TASK_COMM_LEN];          field:pid_t pid; @@ -112,7 +111,7 @@ write a useful trace script.  The sections below cover the rest.  SCRIPT LAYOUT  ------------- -Every perf trace Perl script should start by setting up a Perl module +Every perf script Perl script should start by setting up a Perl module  search path and 'use'ing a few support modules (see module  descriptions below): @@ -162,7 +161,7 @@ sub trace_unhandled  ----  The remaining sections provide descriptions of each of the available -built-in perf trace Perl modules and their associated functions. +built-in perf script Perl modules and their associated functions.  AVAILABLE MODULES AND FUNCTIONS  ------------------------------- @@ -170,7 +169,7 @@ AVAILABLE MODULES AND FUNCTIONS  The following sections describe the functions and variables available  via the various Perf::Trace::* Perl modules.  To use the functions and  variables from the given module, add the corresponding 'use -Perf::Trace::XXX' line to your perf trace script. +Perf::Trace::XXX' line to your perf script script.  Perf::Trace::Core Module  ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -204,7 +203,7 @@ argument.  Perf::Trace::Util Module  ~~~~~~~~~~~~~~~~~~~~~~~~ -Various utility functions for use with perf trace: +Various utility functions for use with perf script:    nsecs($secs, $nsecs) - returns total nsecs given secs/nsecs pair    nsecs_secs($nsecs) - returns whole secs portion given nsecs @@ -214,4 +213,4 @@ Various utility functions for use with perf trace:  SEE ALSO  -------- -linkperf:perf-trace[1] +linkperf:perf-script[1] diff --git a/tools/perf/Documentation/perf-trace-python.txt b/tools/perf/Documentation/perf-script-python.txt index 693be804dd3..9f1f054b843 100644 --- a/tools/perf/Documentation/perf-trace-python.txt +++ b/tools/perf/Documentation/perf-script-python.txt @@ -1,19 +1,19 @@ -perf-trace-python(1) +perf-script-python(1)  ====================  NAME  ---- -perf-trace-python - Process trace data with a Python script +perf-script-python - Process trace data with a Python script  SYNOPSIS  --------  [verse] -'perf trace' [-s [Python]:script[.py] ] +'perf script' [-s [Python]:script[.py] ]  DESCRIPTION  ----------- -This perf trace option is used to process perf trace data using perf's +This perf script option is used to process perf script data using perf's  built-in Python interpreter.  It reads and processes the input file and  displays the results of the trace analysis implemented in the given  Python script, if any. @@ -23,15 +23,15 @@ A QUICK EXAMPLE  This section shows the process, start to finish, of creating a working  Python script that aggregates and extracts useful information from a -raw perf trace stream.  You can avoid reading the rest of this +raw perf script stream.  You can avoid reading the rest of this  document if an example is enough for you; the rest of the document  provides more details on each step and lists the library functions  available to script writers.  This example actually details the steps that were used to create the -'syscall-counts' script you see when you list the available perf trace -scripts via 'perf trace -l'.  As such, this script also shows how to -integrate your script into the list of general-purpose 'perf trace' +'syscall-counts' script you see when you list the available perf script +scripts via 'perf script -l'.  As such, this script also shows how to +integrate your script into the list of general-purpose 'perf script'  scripts listed by that command.  The syscall-counts script is a simple script, but demonstrates all the @@ -105,25 +105,25 @@ That single stream will be recorded in a file in the current directory  called perf.data.  Once we have a perf.data file containing our data, we can use the -g -'perf trace' option to generate a Python script that will contain a +'perf script' option to generate a Python script that will contain a  callback handler for each event type found in the perf.data trace  stream (for more details, see the STARTER SCRIPTS section).  ---- -# perf trace -g python -generated Python script: perf-trace.py +# perf script -g python +generated Python script: perf-script.py  The output file created also in the current directory is named -perf-trace.py.  Here's the file in its entirety: +perf-script.py.  Here's the file in its entirety: -# perf trace event handlers, generated by perf trace -g python +# perf script event handlers, generated by perf script -g python  # Licensed under the terms of the GNU GPL License version 2  # The common_* event handler fields are the most useful fields common to  # all events.  They don't necessarily correspond to the 'common_*' fields  # in the format files.  Those fields not available as handler params can  # be retrieved using Python functions of the form common_*(context). -# See the perf-trace-python Documentation for the list of available functions. +# See the perf-script-python Documentation for the list of available functions.  import os  import sys @@ -160,7 +160,7 @@ def print_header(event_name, cpu, secs, nsecs, pid, comm):  ----  At the top is a comment block followed by some import statements and a -path append which every perf trace script should include. +path append which every perf script script should include.  Following that are a couple generated functions, trace_begin() and  trace_end(), which are called at the beginning and the end of the @@ -189,8 +189,8 @@ simply a utility function used for that purpose.  Let's rename the  script and run it to see the default output:  ---- -# mv perf-trace.py syscall-counts.py -# perf trace -s syscall-counts.py +# mv perf-script.py syscall-counts.py +# perf script -s syscall-counts.py  raw_syscalls__sys_enter     1 00840.847582083     7506 perf                  id=1, args=  raw_syscalls__sys_enter     1 00840.847595764     7506 perf                  id=1, args= @@ -315,7 +315,7 @@ def print_syscall_totals():  The script can be run just as before: -  # perf trace -s syscall-counts.py +  # perf script -s syscall-counts.py  So those are the essential steps in writing and running a script.  The  process can be generalized to any tracepoint or set of tracepoints @@ -324,19 +324,18 @@ interested in by looking at the list of available events shown by  'perf list' and/or look in /sys/kernel/debug/tracing events for  detailed event and field info, record the corresponding trace data  using 'perf record', passing it the list of interesting events, -generate a skeleton script using 'perf trace -g python' and modify the +generate a skeleton script using 'perf script -g python' and modify the  code to aggregate and display it for your particular needs.  After you've done that you may end up with a general-purpose script  that you want to keep around and have available for future use.  By  writing a couple of very simple shell scripts and putting them in the  right place, you can have your script listed alongside the other -scripts listed by the 'perf trace -l' command e.g.: +scripts listed by the 'perf script -l' command e.g.:  ---- -root@tropicana:~# perf trace -l +root@tropicana:~# perf script -l  List of available trace scripts: -  workqueue-stats                      workqueue stats (ins/exe/create/destroy)    wakeup-latency                       system-wide min/max/avg wakeup latency    rw-by-file <comm>                    r/w activity for a program, by file    rw-by-pid                            system-wide r/w activity @@ -365,14 +364,14 @@ perf record -a -e raw_syscalls:sys_enter  The 'report' script is also a shell script with the same base name as  your script, but with -report appended.  It should also be located in  the perf/scripts/python/bin directory.  In that script, you write the -'perf trace -s' command-line needed for running your script: +'perf script -s' command-line needed for running your script:  ----  # cat kernel-source/tools/perf/scripts/python/bin/syscall-counts-report  #!/bin/bash  # description: system-wide syscall counts -perf trace -s ~/libexec/perf-core/scripts/python/syscall-counts.py +perf script -s ~/libexec/perf-core/scripts/python/syscall-counts.py  ----  Note that the location of the Python script given in the shell script @@ -390,38 +389,37 @@ total 32  drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 .  drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 ..  drwxr-xr-x 2 trz trz 4096 2010-01-26 22:29 bin --rw-r--r-- 1 trz trz 2548 2010-01-26 22:29 check-perf-trace.py +-rw-r--r-- 1 trz trz 2548 2010-01-26 22:29 check-perf-script.py  drwxr-xr-x 3 trz trz 4096 2010-01-26 22:49 Perf-Trace-Util  -rw-r--r-- 1 trz trz 1462 2010-01-26 22:30 syscall-counts.py  ----  Once you've done that (don't forget to do a new 'make install', -otherwise your script won't show up at run-time), 'perf trace -l' +otherwise your script won't show up at run-time), 'perf script -l'  should show a new entry for your script:  ---- -root@tropicana:~# perf trace -l +root@tropicana:~# perf script -l  List of available trace scripts: -  workqueue-stats                      workqueue stats (ins/exe/create/destroy)    wakeup-latency                       system-wide min/max/avg wakeup latency    rw-by-file <comm>                    r/w activity for a program, by file    rw-by-pid                            system-wide r/w activity    syscall-counts                       system-wide syscall counts  ---- -You can now perform the record step via 'perf trace record': +You can now perform the record step via 'perf script record': -  # perf trace record syscall-counts +  # perf script record syscall-counts -and display the output using 'perf trace report': +and display the output using 'perf script report': -  # perf trace report syscall-counts +  # perf script report syscall-counts  STARTER SCRIPTS  ---------------  You can quickly get started writing a script for a particular set of -trace data by generating a skeleton script using 'perf trace -g +trace data by generating a skeleton script using 'perf script -g  python' in the same directory as an existing perf.data trace file.  That will generate a starter script containing a handler for each of  the event types in the trace file; it simply prints every available @@ -430,13 +428,13 @@ field for each event in the trace file.  You can also look at the existing scripts in  ~/libexec/perf-core/scripts/python for typical examples showing how to  do basic things like aggregate event data, print results, etc.  Also, -the check-perf-trace.py script, while not interesting for its results, +the check-perf-script.py script, while not interesting for its results,  attempts to exercise all of the main scripting features.  EVENT HANDLERS  -------------- -When perf trace is invoked using a trace script, a user-defined +When perf script is invoked using a trace script, a user-defined  'handler function' is called for each event in the trace.  If there's  no handler function defined for a given event type, the event is  ignored (or passed to a 'trace_handled' function, see below) and the @@ -463,7 +461,6 @@ The format file for the sched_wakep event defines the following fields          field:unsigned char common_flags;          field:unsigned char common_preempt_count;          field:int common_pid; -        field:int common_lock_depth;          field:char comm[TASK_COMM_LEN];          field:pid_t pid; @@ -510,7 +507,7 @@ write a useful trace script.  The sections below cover the rest.  SCRIPT LAYOUT  ------------- -Every perf trace Python script should start by setting up a Python +Every perf script Python script should start by setting up a Python  module search path and 'import'ing a few support modules (see module  descriptions below): @@ -559,15 +556,15 @@ def trace_unhandled(event_name, context, common_cpu, common_secs,  ----  The remaining sections provide descriptions of each of the available -built-in perf trace Python modules and their associated functions. +built-in perf script Python modules and their associated functions.  AVAILABLE MODULES AND FUNCTIONS  -------------------------------  The following sections describe the functions and variables available -via the various perf trace Python modules.  To use the functions and +via the various perf script Python modules.  To use the functions and  variables from the given module, add the corresponding 'from XXXX -import' line to your perf trace script. +import' line to your perf script script.  Core.py Module  ~~~~~~~~~~~~~~ @@ -610,7 +607,7 @@ argument.  Util.py Module  ~~~~~~~~~~~~~~ -Various utility functions for use with perf trace: +Various utility functions for use with perf script:    nsecs(secs, nsecs) - returns total nsecs given secs/nsecs pair    nsecs_secs(nsecs) - returns whole secs portion given nsecs @@ -620,4 +617,4 @@ Various utility functions for use with perf trace:  SEE ALSO  -------- -linkperf:perf-trace[1] +linkperf:perf-script[1] diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt new file mode 100644 index 00000000000..05f9a0a6784 --- /dev/null +++ b/tools/perf/Documentation/perf-script.txt @@ -0,0 +1,221 @@ +perf-script(1) +============= + +NAME +---- +perf-script - Read perf.data (created by perf record) and display trace output + +SYNOPSIS +-------- +[verse] +'perf script' [<options>] +'perf script' [<options>] record <script> [<record-options>] <command> +'perf script' [<options>] report <script> [script-args] +'perf script' [<options>] <script> <required-script-args> [<record-options>] <command> +'perf script' [<options>] <top-script> [script-args] + +DESCRIPTION +----------- +This command reads the input file and displays the trace recorded. + +There are several variants of perf script: + +  'perf script' to see a detailed trace of the workload that was +  recorded. + +  You can also run a set of pre-canned scripts that aggregate and +  summarize the raw trace data in various ways (the list of scripts is +  available via 'perf script -l').  The following variants allow you to +  record and run those scripts: + +  'perf script record <script> <command>' to record the events required +  for 'perf script report'.  <script> is the name displayed in the +  output of 'perf script --list' i.e. the actual script name minus any +  language extension.  If <command> is not specified, the events are +  recorded using the -a (system-wide) 'perf record' option. + +  'perf script report <script> [args]' to run and display the results +  of <script>.  <script> is the name displayed in the output of 'perf +  trace --list' i.e. the actual script name minus any language +  extension.  The perf.data output from a previous run of 'perf script +  record <script>' is used and should be present for this command to +  succeed.  [args] refers to the (mainly optional) args expected by +  the script. + +  'perf script <script> <required-script-args> <command>' to both +  record the events required for <script> and to run the <script> +  using 'live-mode' i.e. without writing anything to disk.  <script> +  is the name displayed in the output of 'perf script --list' i.e. the +  actual script name minus any language extension.  If <command> is +  not specified, the events are recorded using the -a (system-wide) +  'perf record' option.  If <script> has any required args, they +  should be specified before <command>.  This mode doesn't allow for +  optional script args to be specified; if optional script args are +  desired, they can be specified using separate 'perf script record' +  and 'perf script report' commands, with the stdout of the record step +  piped to the stdin of the report script, using the '-o -' and '-i -' +  options of the corresponding commands. + +  'perf script <top-script>' to both record the events required for +  <top-script> and to run the <top-script> using 'live-mode' +  i.e. without writing anything to disk.  <top-script> is the name +  displayed in the output of 'perf script --list' i.e. the actual +  script name minus any language extension; a <top-script> is defined +  as any script name ending with the string 'top'. + +  [<record-options>] can be passed to the record steps of 'perf script +  record' and 'live-mode' variants; this isn't possible however for +  <top-script> 'live-mode' or 'perf script report' variants. + +  See the 'SEE ALSO' section for links to language-specific +  information on how to write and run your own trace scripts. + +OPTIONS +------- +<command>...:: +	Any command you can specify in a shell. + +-D:: +--dump-raw-script=:: +        Display verbose dump of the trace data. + +-L:: +--Latency=:: +        Show latency attributes (irqs/preemption disabled, etc). + +-l:: +--list=:: +        Display a list of available trace scripts. + +-s ['lang']:: +--script=:: +        Process trace data with the given script ([lang]:script[.ext]). +	If the string 'lang' is specified in place of a script name, a +        list of supported languages will be displayed instead. + +-g:: +--gen-script=:: +        Generate perf-script.[ext] starter script for given language, +        using current perf.data. + +-a:: +        Force system-wide collection.  Scripts run without a <command> +        normally use -a by default, while scripts run with a <command> +        normally don't - this option allows the latter to be run in +        system-wide mode. + +-i:: +--input=:: +        Input file name. (default: perf.data unless stdin is a fifo) + +-d:: +--debug-mode:: +        Do various checks like samples ordering and lost events. + +-f:: +--fields:: +        Comma separated list of fields to print. Options are: +        comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline. +        Field list can be prepended with the type, trace, sw or hw, +        to indicate to which event type the field list applies. +        e.g., -f sw:comm,tid,time,ip,sym  and -f trace:time,cpu,trace + +		perf script -f <fields> + +	is equivalent to: + +		perf script -f trace:<fields> -f sw:<fields> -f hw:<fields> +     +	i.e., the specified fields apply to all event types if the type string +	is not given. +     +	The arguments are processed in the order received. A later usage can +	reset a prior request. e.g.: +     +		-f trace: -f comm,tid,time,ip,sym +     +	The first -f suppresses trace events (field list is ""), but then the +	second invocation sets the fields to comm,tid,time,ip,sym. In this case a +	warning is given to the user: +     +		"Overriding previous field request for all events." +     +	Alternativey, consider the order: +     +		-f comm,tid,time,ip,sym -f trace: +     +	The first -f sets the fields for all events and the second -f +	suppresses trace events. The user is given a warning message about +	the override, and the result of the above is that only S/W and H/W +	events are displayed with the given fields. +     +	For the 'wildcard' option if a user selected field is invalid for an +	event type, a message is displayed to the user that the option is +	ignored for that type. For example: +     +		$ perf script -f comm,tid,trace +		'trace' not valid for hardware events. Ignoring. +		'trace' not valid for software events. Ignoring. +     +	Alternatively, if the type is given an invalid field is specified it +	is an error. For example: +     +        perf script -v -f sw:comm,tid,trace +        'trace' not valid for software events. +     +	At this point usage is displayed, and perf-script exits. +     +	Finally, a user may not set fields to none for all event types. +	i.e., -f "" is not allowed. + +-k:: +--vmlinux=<file>:: +        vmlinux pathname + +--kallsyms=<file>:: +        kallsyms pathname + +--symfs=<directory>:: +        Look for files with symbols relative to this directory. + +-G:: +--hide-call-graph:: +        When printing symbols do not display call chain. + +-C:: +--cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can +	be provided as a comma-separated list with no space: 0,1. Ranges of +	CPUs are specified with -: 0-2. Default is to report samples on all +	CPUs. + +-c:: +--comms=:: +	Only display events for these comms. CSV that understands +	file://filename entries. + +-I:: +--show-info:: +	Display extended information about the perf.data file. This adds +	information which may be very large and thus may clutter the display. +	It currently includes: cpu and numa topology of the host system. +	It can only be used with the perf script report mode. + +--show-kernel-path:: +	Try to resolve the path of [kernel.kallsyms] + +--show-task-events +	Display task related events (e.g. FORK, COMM, EXIT). + +--show-mmap-events +	Display mmap related events (e.g. MMAP, MMAP2). + +--header +	Show perf.data header. + +--header-only +	Show only perf.data header. + +SEE ALSO +-------- +linkperf:perf-record[1], linkperf:perf-script-perl[1], +linkperf:perf-script-python[1] diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 4b3a2d46b43..29ee857c09c 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -8,8 +8,8 @@ perf-stat - Run a command and gather performance counter statistics  SYNOPSIS  --------  [verse] -'perf stat' [-e <EVENT> | --event=EVENT] [-S] [-a] <command> -'perf stat' [-e <EVENT> | --event=EVENT] [-S] [-a] -- <command> [<options>] +'perf stat' [-e <EVENT> | --event=EVENT] [-a] <command> +'perf stat' [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>]  DESCRIPTION  ----------- @@ -35,24 +35,113 @@ OPTIONS          child tasks do not inherit counters  -p::  --pid=<pid>:: -        stat events on existing pid +        stat events on existing process id (comma separated list) + +-t:: +--tid=<tid>:: +        stat events on existing thread id (comma separated list) +  -a:: -        system-wide collection +--all-cpus:: +        system-wide collection from all CPUs  -c:: -        scale counter values +--scale:: +	scale/normalize counter values + +-r:: +--repeat=<n>:: +	repeat command and print average + stddev (max: 100). 0 means forever.  -B:: +--big-num::          print large numbers with thousands' separators according to locale  -C::  --cpu=:: -Count only on the list of cpus provided. Multiple CPUs can be provided as a -comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. +Count only on the list of CPUs provided. Multiple CPUs can be provided as a +comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.  In per-thread mode, this option is ignored. The -a option is still necessary  to activate system-wide monitoring. Default is to count on all CPUs. +-A:: +--no-aggr:: +Do not aggregate counts across all monitored CPUs in system-wide mode (-a). +This option is only valid in system-wide mode. + +-n:: +--null:: +        null run - don't start any counters + +-v:: +--verbose:: +        be more verbose (show counter open errors, etc) + +-x SEP:: +--field-separator SEP:: +print counts using a CSV-style output to make it easy to import directly into +spreadsheets. Columns are separated by the string specified in SEP. + +-G name:: +--cgroup name:: +monitor only in the container (cgroup) called "name". This option is available only +in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to +container "name" are monitored when they run on the monitored CPUs. Multiple cgroups +can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup +to first event, second cgroup to second event and so on. It is possible to provide +an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have +corresponding events, i.e., they always refer to events defined earlier on the command +line. + +-o file:: +--output file:: +Print the output into the designated file. + +--append:: +Append to the output file designated with the -o option. Ignored if -o is not specified. + +--log-fd:: + +Log output to fd, instead of stderr.  Complementary to --output, and mutually exclusive +with it.  --append may be used here.  Examples: +     3>results  perf stat --log-fd 3          -- $cmd +     3>>results perf stat --log-fd 3 --append -- $cmd + +--pre:: +--post:: +	Pre and post measurement hooks, e.g.: + +perf stat --repeat 10 --null --sync --pre 'make -s O=defconfig-build/clean' -- make -s -j64 O=defconfig-build/ bzImage + +-I msecs:: +--interval-print msecs:: +	Print count deltas every N milliseconds (minimum: 100ms) +	example: perf stat -I 1000 -e cycles -a sleep 5 + +--per-socket:: +Aggregate counts per processor socket for system-wide mode measurements.  This +is a useful mode to detect imbalance between sockets.  To enable this mode, +use --per-socket in addition to -a. (system-wide).  The output includes the +socket number and the number of online processors on that socket. This is +useful to gauge the amount of aggregation. + +--per-core:: +Aggregate counts per physical processor for system-wide mode measurements.  This +is a useful mode to detect imbalance between physical cores.  To enable this mode, +use --per-core in addition to -a. (system-wide).  The output includes the +core number and the number of online logical processors on that physical processor. + +-D msecs:: +--delay msecs:: +After starting the program, wait msecs before measuring. This is useful to +filter out the startup phase of the program, which is often very different. + +-T:: +--transaction:: + +Print statistics of transactional execution if supported. +  EXAMPLES  -------- diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentation/perf-test.txt index 1c4b5f5b7f7..d1d3e5121f8 100644 --- a/tools/perf/Documentation/perf-test.txt +++ b/tools/perf/Documentation/perf-test.txt @@ -8,15 +8,25 @@ perf-test - Runs sanity tests.  SYNOPSIS  --------  [verse] -'perf test <options>' +'perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]'  DESCRIPTION  ----------- -This command does assorted sanity tests, initially thru linked routines but +This command does assorted sanity tests, initially through linked routines but  also will look for a directory with more tests in the form of scripts. +To get a list of available tests use 'perf test list', specifying a test name +fragment will show all tests that have it. + +To run just specific tests, inform test name fragments or the numbers obtained +from 'perf test list'. +  OPTIONS  ------- +-s:: +--skip:: +	Tests to skip (comma separater numeric list). +  -v::  --verbose::  	Be more verbose. diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt index 4b1788355ec..5e0f986dff3 100644 --- a/tools/perf/Documentation/perf-timechart.txt +++ b/tools/perf/Documentation/perf-timechart.txt @@ -8,7 +8,7 @@ perf-timechart - Tool to visualize total system behavior during a workload  SYNOPSIS  --------  [verse] -'perf timechart' {record} +'perf timechart' [<timechart options>] {record} [<record options>]  DESCRIPTION  ----------- @@ -20,24 +20,72 @@ There are two variants of perf timechart:    'perf timechart' to turn a trace into a Scalable Vector Graphics file,    that can be viewed with popular SVG viewers such as 'Inkscape'. -OPTIONS -------- +TIMECHART OPTIONS +-----------------  -o::  --output=::          Select the output file (default: output.svg)  -i::  --input=:: -        Select the input file (default: perf.data) +        Select the input file (default: perf.data unless stdin is a fifo)  -w::  --width=::          Select the width of the SVG file (default: 1000)  -P::  --power-only::          Only output the CPU power section of the diagram +-T:: +--tasks-only:: +        Don't output processor state transitions  -p::  --process::          Select the processes to display, by name or PID +--symfs=<directory>:: +        Look for files with symbols relative to this directory. +-n:: +--proc-num:: +        Print task info for at least given number of tasks. +-t:: +--topology:: +        Sort CPUs according to topology. +--highlight=<duration_nsecs|task_name>:: +	Highlight tasks (using different color) that run more than given +	duration or tasks with given name. If number is given it's interpreted +	as number of nanoseconds. If non-numeric string is given it's +	interpreted as task name. + +RECORD OPTIONS +-------------- +-P:: +--power-only:: +        Record only power-related events +-T:: +--tasks-only:: +        Record only tasks-related events +-g:: +--callchain:: +        Do call-graph (stack chain/backtrace) recording + +EXAMPLES +-------- + +$ perf timechart record git pull + +  [ perf record: Woken up 13 times to write data ] +  [ perf record: Captured and wrote 4.253 MB perf.data (~185801 samples) ] + +$ perf timechart + +  Written 10.2 seconds of trace to output.svg. + +Record system-wide timechart: + +  $ perf timechart record + +  then generate timechart and highlight 'gcc' tasks: + +  $ perf timechart --highlight gcc  SEE ALSO  -------- diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index 1f9687663f2..180ae02137a 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt @@ -12,7 +12,7 @@ SYNOPSIS  DESCRIPTION  ----------- -This command generates and displays a performance counter profile in realtime. +This command generates and displays a performance counter profile in real time.  OPTIONS @@ -27,8 +27,8 @@ OPTIONS  -C <cpu-list>::  --cpu=<cpu>:: -Monitor only on the list of cpus provided. Multiple CPUs can be provided as a -comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. +Monitor only on the list of CPUs provided. Multiple CPUs can be provided as a +comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.  Default is to monitor all CPUS.  -d <seconds>:: @@ -50,13 +50,16 @@ Default is to monitor all CPUS.  --count-filter=<count>::  	Only display functions with more events than this. +--group:: +        Put the counters into a counter group. +  -F <freq>::  --freq=<freq>::  	Profile at this frequency.  -i::  --inherit:: -	Child tasks inherit counters, only makes sens with -p option. +	Child tasks do not inherit counters.  -k <path>::  --vmlinux=<path>:: @@ -64,20 +67,41 @@ Default is to monitor all CPUS.  -m <pages>::  --mmap-pages=<pages>:: -	Number of mmapped data pages. +	Number of mmap data pages (must be a power of two) or size +	specification with appended unit character - B/K/M/G. The +	size is rounded up to have nearest pages power of two value.  -p <pid>::  --pid=<pid>:: -	Profile events on existing pid. +	Profile events on existing Process ID (comma separated list). + +-t <tid>:: +--tid=<tid>:: +        Profile events on existing thread ID (comma separated list). + +-u:: +--uid=:: +        Record events in threads owned by uid. Name or number.  -r <priority>::  --realtime=<priority>::  	Collect data with this RT SCHED_FIFO priority. --s <symbol>::  --sym-annotate=<symbol>::          Annotate this symbol. +-K:: +--hide_kernel_symbols:: +        Hide kernel symbols. + +-U:: +--hide_user_symbols:: +        Hide user symbols. + +-D:: +--dump-symtab:: +        Dump the symbol table used for profiling. +  -v::  --verbose::  	Be more verbose (show counter open errors, etc). @@ -86,6 +110,89 @@ Default is to monitor all CPUS.  --zero::  	Zero history across display updates. +-s:: +--sort:: +	Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight, +	local_weight, abort, in_tx, transaction, overhead, sample, period. +	Please see description of --sort in the perf-report man page. + +--fields=:: +	Specify output field - multiple keys can be specified in CSV format. +	Following fields are available: +	overhead, overhead_sys, overhead_us, overhead_children, sample and period. +	Also it can contain any sort key(s). + +	By default, every sort keys not specified in --field will be appended +	automatically. + +-n:: +--show-nr-samples:: +	Show a column with the number of samples. + +--show-total-period:: +	Show a column with the sum of periods. + +--dsos:: +	Only consider symbols in these dsos.  This option will affect the +	percentage of the overhead column.  See --percentage for more info. + +--comms:: +	Only consider symbols in these comms.  This option will affect the +	percentage of the overhead column.  See --percentage for more info. + +--symbols:: +	Only consider these symbols.  This option will affect the +	percentage of the overhead column.  See --percentage for more info. + +-M:: +--disassembler-style=:: Set disassembler style for objdump. + +--source:: +	Interleave source code with assembly code. Enabled by default, +	disable with --no-source. + +--asm-raw:: +	Show raw instruction encoding of assembly instructions. + +-g:: +	Enables call-graph (stack chain/backtrace) recording. + +--call-graph:: +	Setup and enable call-graph (stack chain/backtrace) recording, +	implies -g. + +--children:: +	Accumulate callchain of children to parent entry so that then can +	show up in the output.  The output will have a new "Children" column +	and will be sorted on the data.  It requires -g/--call-graph option +	enabled. + +--max-stack:: +	Set the stack depth limit when parsing the callchain, anything +	beyond the specified depth will be ignored. This is a trade-off +	between information loss and faster processing especially for +	workloads that can have a very long callchain stack. + +	Default: 127 + +--ignore-callees=<regex>:: +        Ignore callees of the function(s) matching the given regex. +        This has the effect of collecting the callers of each such +        function into one place in the call-graph tree. + +--percent-limit:: +	Do not show entries which have an overhead under that percent. +	(Default: 0). + +--percentage:: +	Determine how to display the overhead percentage of filtered entries. +	Filters can be applied by --comms, --dsos and/or --symbols options and +	Zoom operations on the TUI (thread, dso, etc). + +	"relative" means it's relative to filtered entries only so that the +	sum of shown entries will be always 100%. "absolute" means it retains +	the original value before and after the filter is applied. +  INTERACTIVE PROMPTING KEYS  -------------------------- @@ -110,9 +217,6 @@ INTERACTIVE PROMPTING KEYS  [S]::  	Stop annotation, return to full profile display. -[w]:: -	Toggle between weighted sum and individual count[E]r profile. -  [z]::  	Toggle event count zeroing across display updates. @@ -124,4 +228,4 @@ Pressing any unmapped key displays a menu, and prompts for input.  SEE ALSO  -------- -linkperf:perf-stat[1], linkperf:perf-list[1] +linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-report[1] diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt index 26aff6bf9e5..fae38d9a44a 100644 --- a/tools/perf/Documentation/perf-trace.txt +++ b/tools/perf/Documentation/perf-trace.txt @@ -3,109 +3,110 @@ perf-trace(1)  NAME  ---- -perf-trace - Read perf.data (created by perf record) and display trace output +perf-trace - strace inspired tool  SYNOPSIS  --------  [verse] -'perf trace' [<options>] -'perf trace' [<options>] record <script> [<record-options>] <command> -'perf trace' [<options>] report <script> [script-args] -'perf trace' [<options>] <script> <required-script-args> [<record-options>] <command> -'perf trace' [<options>] <top-script> [script-args] +'perf trace' +'perf trace record'  DESCRIPTION  ----------- -This command reads the input file and displays the trace recorded. - -There are several variants of perf trace: - -  'perf trace' to see a detailed trace of the workload that was -  recorded. - -  You can also run a set of pre-canned scripts that aggregate and -  summarize the raw trace data in various ways (the list of scripts is -  available via 'perf trace -l').  The following variants allow you to -  record and run those scripts: - -  'perf trace record <script> <command>' to record the events required -  for 'perf trace report'.  <script> is the name displayed in the -  output of 'perf trace --list' i.e. the actual script name minus any -  language extension.  If <command> is not specified, the events are -  recorded using the -a (system-wide) 'perf record' option. - -  'perf trace report <script> [args]' to run and display the results -  of <script>.  <script> is the name displayed in the output of 'perf -  trace --list' i.e. the actual script name minus any language -  extension.  The perf.data output from a previous run of 'perf trace -  record <script>' is used and should be present for this command to -  succeed.  [args] refers to the (mainly optional) args expected by -  the script. - -  'perf trace <script> <required-script-args> <command>' to both -  record the events required for <script> and to run the <script> -  using 'live-mode' i.e. without writing anything to disk.  <script> -  is the name displayed in the output of 'perf trace --list' i.e. the -  actual script name minus any language extension.  If <command> is -  not specified, the events are recorded using the -a (system-wide) -  'perf record' option.  If <script> has any required args, they -  should be specified before <command>.  This mode doesn't allow for -  optional script args to be specified; if optional script args are -  desired, they can be specified using separate 'perf trace record' -  and 'perf trace report' commands, with the stdout of the record step -  piped to the stdin of the report script, using the '-o -' and '-i -' -  options of the corresponding commands. - -  'perf trace <top-script>' to both record the events required for -  <top-script> and to run the <top-script> using 'live-mode' -  i.e. without writing anything to disk.  <top-script> is the name -  displayed in the output of 'perf trace --list' i.e. the actual -  script name minus any language extension; a <top-script> is defined -  as any script name ending with the string 'top'. - -  [<record-options>] can be passed to the record steps of 'perf trace -  record' and 'live-mode' variants; this isn't possible however for -  <top-script> 'live-mode' or 'perf trace report' variants. - -  See the 'SEE ALSO' section for links to language-specific -  information on how to write and run your own trace scripts. +This command will show the events associated with the target, initially +syscalls, but other system events like pagefaults, task lifetime events, +scheduling events, etc. -OPTIONS -------- -<command>...:: -	Any command you can specify in a shell. - --D:: ---dump-raw-trace=:: -        Display verbose dump of the trace data. - --L:: ---Latency=:: -        Show latency attributes (irqs/preemption disabled, etc). +This is a live mode tool in addition to working with perf.data files like +the other perf tools. Files can be generated using the 'perf record' command +but the session needs to include the raw_syscalls events (-e 'raw_syscalls:*'). +Alernatively, the 'perf trace record' can be used as a shortcut to +automatically include the raw_syscalls events when writing events to a file. --l:: ---list=:: -        Display a list of available trace scripts. +The following options apply to perf trace; options to perf trace record are +found in the perf record man page. --s ['lang']:: ---script=:: -        Process trace data with the given script ([lang]:script[.ext]). -	If the string 'lang' is specified in place of a script name, a -        list of supported languages will be displayed instead. - --g:: ---gen-script=:: -        Generate perf-trace.[ext] starter script for given language, -        using current perf.data. +OPTIONS +-------  -a:: -        Force system-wide collection.  Scripts run without a <command> -        normally use -a by default, while scripts run with a <command> -        normally don't - this option allows the latter to be run in -        system-wide mode. - +--all-cpus:: +        System-wide collection from all CPUs. + +-e:: +--expr:: +	List of events to show, currently only syscall names. +	Prefixing with ! shows all syscalls but the ones specified.  You may +	need to escape it. + +-o:: +--output=:: +	Output file name. + +-p:: +--pid=:: +	Record events on existing process ID (comma separated list). + +-t:: +--tid=:: +        Record events on existing thread ID (comma separated list). + +-u:: +--uid=:: +        Record events in threads owned by uid. Name or number. + +-v:: +--verbose=:: +        Verbosity level. + +-i:: +--no-inherit:: +	Child tasks do not inherit counters. + +-m:: +--mmap-pages=:: +	Number of mmap data pages (must be a power of two) or size +	specification with appended unit character - B/K/M/G. The +	size is rounded up to have nearest pages power of two value. + +-C:: +--cpu:: +Collect samples only on the list of CPUs provided. Multiple CPUs can be provided as a +comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. +In per-thread mode with inheritance mode on (default), Events are captured only when +the thread executes on the designated CPUs. Default is to monitor all CPUs. + +--duration: +	Show only events that had a duration greater than N.M ms. + +--sched: +	Accrue thread runtime and provide a summary at the end of the session. + +-i +--input +	Process events from a given perf data file. + +-T +--time +	Print full timestamp rather time relative to first sample. + +--comm:: +        Show process COMM right beside its ID, on by default, disable with --no-comm. + +-s:: +--summary:: +	Show only a summary of syscalls by thread with min, max, and average times +    (in msec) and relative stddev. + +-S:: +--with-summary:: +	Show all syscalls followed by a summary by thread with min, max, and +    average times (in msec) and relative stddev. + +--tool_stats:: +	Show tool stats such as number of times fd->pathname was discovered thru +	hooking the open syscall return + vfs_getname or via reading /proc/pid/fd, etc.  SEE ALSO  -------- -linkperf:perf-record[1], linkperf:perf-trace-perl[1], -linkperf:perf-trace-python[1] +linkperf:perf-record[1], linkperf:perf-script[1] diff --git a/tools/perf/Documentation/perfconfig.example b/tools/perf/Documentation/perfconfig.example new file mode 100644 index 00000000000..767ea2436e1 --- /dev/null +++ b/tools/perf/Documentation/perfconfig.example @@ -0,0 +1,29 @@ +[colors] + +	# These were the old defaults +	top = red, lightgray +	medium = green, lightgray +	normal = black, lightgray +	selected = lightgray, magenta +	code = blue, lightgray +	addr = magenta, lightgray + +[tui] + +	# Defaults if linked with libslang +	report = on +	annotate = on +	top = on + +[buildid] + +	# Default, disable using /dev/null +	dir = /root/.debug + +[annotate] + +	# Defaults +	hide_src_code = false +	use_offset = true +	jump_arrows = true +	show_nr_jumps = false  | 
