All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@linutronix.de>
Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Tzvetomir Stoyanov <tstoyanov@vmware.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jiri Olsa <jolsa@redhat.com>,
	linux-trace-devel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 32/73] tools lib traceevent: Man pages for registering print function
Date: Fri, 17 May 2019 16:35:30 -0300	[thread overview]
Message-ID: <20190517193611.4974-33-acme@kernel.org> (raw)
In-Reply-To: <20190517193611.4974-1-acme@kernel.org>

From: Tzvetomir Stoyanov <tstoyanov@vmware.com>

Create man pages for libtraceevent APIs:

  tep_register_print_function()
  tep_unregister_print_function()

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linux-trace-devel@vger.kernel.org
Link: http://lkml.kernel.org/r/20190510200107.857252818@goodmis.org
Link: http://lore.kernel.org/linux-trace-devel/20190503091119.23399-13-tstoyanov@vmware.com
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 .../libtraceevent-reg_print_func.txt          | 155 ++++++++++++++++++
 1 file changed, 155 insertions(+)
 create mode 100644 tools/lib/traceevent/Documentation/libtraceevent-reg_print_func.txt

diff --git a/tools/lib/traceevent/Documentation/libtraceevent-reg_print_func.txt b/tools/lib/traceevent/Documentation/libtraceevent-reg_print_func.txt
new file mode 100644
index 000000000000..708dce91ebd8
--- /dev/null
+++ b/tools/lib/traceevent/Documentation/libtraceevent-reg_print_func.txt
@@ -0,0 +1,155 @@
+libtraceevent(3)
+================
+
+NAME
+----
+tep_register_print_function,tep_unregister_print_function -
+Registers / Unregisters a helper function.
+
+SYNOPSIS
+--------
+[verse]
+--
+*#include <event-parse.h>*
+
+enum *tep_func_arg_type* {
+	TEP_FUNC_ARG_VOID,
+	TEP_FUNC_ARG_INT,
+	TEP_FUNC_ARG_LONG,
+	TEP_FUNC_ARG_STRING,
+	TEP_FUNC_ARG_PTR,
+	TEP_FUNC_ARG_MAX_TYPES
+};
+
+typedef unsigned long long (*pass:[*]tep_func_handler*)(struct trace_seq pass:[*]s, unsigned long long pass:[*]args);
+
+int *tep_register_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, enum tep_func_arg_type _ret_type_, char pass:[*]_name_, _..._);
+int *tep_unregister_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, char pass:[*]_name_);
+--
+
+DESCRIPTION
+-----------
+Some events may have helper functions in the print format arguments.
+This allows a plugin to dynamically create a way to process one of
+these functions.
+
+The _tep_register_print_function()_ registers such helper function. The _tep_
+argument is the trace event parser context. The _func_ argument  is a pointer
+to the helper function. The _ret_type_ argument is  the return type of the
+helper function, value from the _tep_func_arg_type_ enum. The _name_ is the name
+of the helper function, as seen in the print format arguments. The _..._ is a
+variable list of _tep_func_arg_type_ enums, the _func_ function arguments.
+This list must end with _TEP_FUNC_ARG_VOID_. See 'EXAMPLE' section.
+
+The _tep_unregister_print_function()_ unregisters a helper function, previously
+registered with _tep_register_print_function()_. The _tep_ argument is the
+trace event parser context. The _func_ and _name_ arguments are the same, used
+when the helper function was registered.
+
+The _tep_func_handler_ is the type of the helper function. The _s_ argument is
+the trace sequence, it can be used to create a custom string.
+The _args_  is a list of arguments, defined when the helper function was
+registered.
+
+RETURN VALUE
+------------
+The _tep_register_print_function()_ function returns 0 in case of success.
+In case of an error, TEP_ERRNO_... code is returned.
+
+The _tep_unregister_print_function()_ returns 0 in case of success, or -1 in
+case of an error.
+
+EXAMPLE
+-------
+Some events have internal functions calls, that appear in the print format
+output. For example "tracefs/events/i915/g4x_wm/format" has:
+[source,c]
+--
+print fmt: "pipe %c, frame=%u, scanline=%u, wm %d/%d/%d, sr %s/%d/%d/%d, hpll %s/%d/%d/%d, fbc %s",
+	    ((REC->pipe) + 'A'), REC->frame, REC->scanline, REC->primary,
+	    REC->sprite, REC->cursor, yesno(REC->cxsr), REC->sr_plane,
+	    REC->sr_cursor, REC->sr_fbc, yesno(REC->hpll), REC->hpll_plane,
+	    REC->hpll_cursor, REC->hpll_fbc, yesno(REC->fbc)
+--
+Notice the call to function _yesno()_ in the print arguments. In the kernel
+context, this function has the following implementation:
+[source,c]
+--
+static const char *yesno(int x)
+{
+	static const char *yes = "yes";
+	static const char *no = "no";
+
+	return x ? yes : no;
+}
+--
+The user space event parser has no idea how to handle this _yesno()_ function.
+The _tep_register_print_function()_ API can be used to register a user space
+helper function, mapped to the kernel's _yesno()_:
+[source,c]
+--
+#include <event-parse.h>
+#include <trace-seq.h>
+...
+struct tep_handle *tep = tep_alloc();
+...
+static const char *yes_no_helper(int x)
+{
+	return x ? "yes" : "no";
+}
+...
+	if ( tep_register_print_function(tep,
+				    yes_no_helper,
+				    TEP_FUNC_ARG_STRING,
+				    "yesno",
+				    TEP_FUNC_ARG_INT,
+				    TEP_FUNC_ARG_VOID) != 0) {
+		/* Failed to register yes_no_helper function */
+	}
+
+/*
+   Now, when the event parser encounters this yesno() function, it will know
+   how to handle it.
+*/
+...
+	if (tep_unregister_print_function(tep, yes_no_helper, "yesno") != 0) {
+		/* Failed to unregister yes_no_helper function */
+	}
+--
+
+FILES
+-----
+[verse]
+--
+*event-parse.h*
+	Header file to include in order to have access to the library APIs.
+*trace-seq.h*
+	Header file to include in order to have access to trace sequences
+	related APIs. Trace sequences are used to allow a function to call
+	several other functions to create a string of data to use.
+*-ltraceevent*
+	Linker switch to add when building a program that uses the library.
+--
+
+SEE ALSO
+--------
+_libtraceevent(3)_, _trace-cmd(1)_
+
+AUTHOR
+------
+[verse]
+--
+*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
+*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
+--
+REPORTING BUGS
+--------------
+Report bugs to  <linux-trace-devel@vger.kernel.org>
+
+LICENSE
+-------
+libtraceevent is Free Software licensed under the GNU LGPL 2.1
+
+RESOURCES
+---------
+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
-- 
2.20.1


  parent reply	other threads:[~2019-05-17 19:38 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 19:34 [GIT PULL] perf/core improvements and fixes Arnaldo Carvalho de Melo
2019-05-17 19:34 ` Arnaldo Carvalho de Melo
2019-05-17 19:34 ` [PATCH 01/73] perf annotate: Remove hist__account_cycles() from callback Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 02/73] perf test: Fix spelling mistake "leadking" -> "leaking" Arnaldo Carvalho de Melo
2019-05-17 19:35   ` Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 03/73] csky: Add support for libdw Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 04/73] tools lib traceevent: Remove hard coded install paths from pkg-config file Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 05/73] perf tools: Speed up report for perf compiled with linwunwind Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 06/73] tools arch: Update arch/x86/lib/memcpy_64.S copy used in 'perf bench mem memcpy' Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 07/73] tools arch uapi: Sync the x86 kvm.h copy Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 08/73] tools x86 uapi asm: Sync the pt_regs.h copy with the kernel sources Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 09/73] tools pci: Do not delete pcitest.sh in 'make clean' Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 10/73] perf record: Fix suggestion to get list of registers usable with --user-regs and --intr-regs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 11/73] perf parse-regs: Improve error output when faced with unknown register name Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 12/73] perf tools x86: Add support for recording and printing XMM registers Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 13/73] perf scripts python: exported-sql-viewer.py: Move view creation Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 14/73] perf scripts python: exported-sql-viewer.py: Fix error when shrinking / enlarging font Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 15/73] perf scripts python: exported-sql-viewer.py: Add tree level Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 16/73] perf scripts python: exported-sql-viewer.py: Add copy to clipboard Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 17/73] perf scripts python: exported-sql-viewer.py: Add context menu Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 18/73] perf scripts python: exported-sql-viewer.py: Add 'About' dialog box Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 19/73] perf vendor events intel: Add uncore_upi JSON support Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 20/73] perf machine: Null-terminate version char array upon fgets(/proc/version) error Arnaldo Carvalho de Melo
2019-05-18  0:05   ` Donald Yandt
2019-05-20 14:46     ` Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 21/73] tools lib traceevent: Introduce man pages Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 22/73] tools lib traceevent: Add support for man pages with multiple names Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 23/73] tools lib traceevent: Man pages for tep_handler related APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 24/73] tools lib traceevent: Man page for header_page APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 25/73] tools lib traceevent: Man page for get/set cpus APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 26/73] tools lib traceevent: Man page for file endian APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 27/73] tools lib traceevent: Man page for host " Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 28/73] tools lib traceevent: Man page for page size APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 29/73] tools lib traceevent: Man page for tep_strerror() Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 30/73] tools lib traceevent: Man pages for event handler APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 31/73] tools lib traceevent: Man pages for function related libtraceevent APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` Arnaldo Carvalho de Melo [this message]
2019-05-17 19:35 ` [PATCH 33/73] tools lib traceevent: Man page for tep_read_number() Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 34/73] tools lib traceevent: Man pages for event find APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 35/73] tools lib traceevent: Man page for list events APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 36/73] tools lib traceevent: Man pages for libtraceevent event get APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 37/73] tools lib traceevent: Man pages for find field APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 38/73] tools lib traceevent: Man pages for get field value APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 39/73] tools lib traceevent: Man pages for print field APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 40/73] tools lib traceevent: Man page for tep_read_number_field() Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 41/73] tools lib traceevent: Man pages for event fields APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 42/73] tools lib traceevent: Man pages for event filter APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 43/73] tools lib traceevent: Man pages for parse event APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 44/73] tools lib traceevent: Man page for tep_parse_header_page() Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 45/73] tools lib traceevent: Man pages for APIs used to extract common fields from a record Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 46/73] tools lib traceevent: Man pages for trace sequences APIs Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 47/73] perf build tests: Add NO_LIBZSTD=1 to make_minimal Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 48/73] perf session: Define 'bytes_transferred' and 'bytes_compressed' metrics Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 49/73] perf record: Implement COMPRESSED event record and its attributes Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 50/73] perf mmap: Implement dedicated memory buffer for data compression Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 51/73] perf tools: Introduce Zstd streaming based compression API Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 52/73] perf record: Implement compression for serial trace streaming Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 53/73] perf record: Implement compression for AIO " Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 54/73] perf report: Add stub processing of compressed events for -D Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 55/73] perf record: Implement -z,--compression_level[=<n>] option Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 56/73] perf report: Implement perf.data record decompression Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 57/73] perf inject: Enable COMPRESSED " Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 58/73] perf tests: Implement Zstd comp/decomp integration test Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 59/73] perf test zstd: Fixup verbose mode output Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 60/73] perf jevents: Remove unused variable Arnaldo Carvalho de Melo
2019-05-17 19:35 ` [PATCH 61/73] perf vendor events arm64: Remove [[:xdigit:]] wildcard Arnaldo Carvalho de Melo
2019-05-17 19:35   ` Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 62/73] perf vendor events arm64: Map Brahma-B53 CPUID to cortex-a53 events Arnaldo Carvalho de Melo
2019-05-17 19:36   ` Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 63/73] perf vendor events arm64: Add Cortex-A57 and Cortex-A72 events Arnaldo Carvalho de Melo
2019-05-17 19:36   ` Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 64/73] perf parse-regs: Split parse_regs Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 65/73] perf parse-regs: Add generic support for arch__intr/user_reg_mask() Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 66/73] perf regs x86: Add X86 specific arch__intr_reg_mask() Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 67/73] perf intel-pt: Fix instructions sampling rate Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 68/73] perf intel-pt: Fix improved sample timestamp Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 69/73] perf intel-pt: Fix sample timestamp wrt non-taken branches Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 70/73] perf docs: Add description for stderr Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 71/73] perf tools: Add a 'percore' event qualifier Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 72/73] perf stat: Factor out aggregate counts printing Arnaldo Carvalho de Melo
2019-05-17 19:36 ` [PATCH 73/73] perf stat: Support 'percore' event qualifier Arnaldo Carvalho de Melo
2019-05-18  8:27 ` [GIT PULL] perf/core improvements and fixes Ingo Molnar
2019-05-18  8:27   ` Ingo Molnar
2019-05-18  8:42 ` [PATCH] tools/headers: Synchronize kernel ABI headers Ingo Molnar
2019-05-18  8:42   ` Ingo Molnar
2019-05-18 13:39   ` Arnaldo Carvalho de Melo
2019-05-18 13:39     ` Arnaldo Carvalho de Melo
2019-05-18 17:12     ` Ingo Molnar
2019-05-18 17:12       ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190517193611.4974-33-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tstoyanov@vmware.com \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.