Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Peios Kernel

Tools

Single-page view · as markdown

Kernel tools

Peios Kernel / Administration / Tools

This book covers user-space tools that are shipped with the kernel source; more additions are needed here:

  • The realtime Linux analysis tool
  • Runtime verification (rv) tool
  • Python libraries

Feature tables in Peios documentation

Peios Kernel / Administration / Tools

Peios uses feat.parse_features.ParseFeature to read the architecture support tables in Documentation/features/. The kernel-feat Trail plugin turns the parsed records into Markdown. These tables describe support in the source tree; they do not report which features are enabled in a particular Peios build.

The parser lives in tools/lib/python/feat/parse_features.py. The plugin entry point and its renderer are tools/docs/trail-kernel-doc/trail-kernel-feat and feat_markdown.py in the same directory. The entry point adds tools/lib/python/ to Python's module search path.

Writing a feature table #

To show the complete matrix, write this in a Trail article:

```{kernel-feat} Documentation/features
```

To show one architecture, add :arch: x86 inside the fence. The directory is relative to the kernel source root configured for the plugin. The plugin rejects unknown architecture names and directories with no feature records.

Parser interface #

ParseFeature(prefix, debug=0, enable_fname=False)

prefix names the directory to scan. debug controls parser diagnostics; enable_fname is used by the inherited text-output helpers. Peios constructs the parser with debugging and filename output disabled, then calls parse().

MethodBehaviour
parse()Recursively scans the directory, parses feature files and returns self.data. The root arch-support.txt template is excluded.
parse_feat_file(fname)Reads one arch-support.txt file and adds its feature record to self.data. Directories and other filenames are skipped.
parse_error(fname, ln, msg, data=None)Reports malformed input with its source location. Missing required fields prevent that record from being added.

The returned dictionary is keyed by feature name. Each record contains:

KeyMeaning
whereSource filename, also used for dependency tracking.
subsysSubsystem name derived from the feature's directory path.
kconfigKconfig expression recorded by the source.
descriptionShort feature description.
commentsAdditional source comments collected by the parser.
tableArchitecture name to status string. The source marker .. becomes ---.

Peios's renderer sorts and presents these records itself. The parser's output_arch_table(), output_feature(), output_matrix() and related ReST formatting helpers are not part of the Trail rendering path.

Maintaining the integration #

The plugin parses a given directory once per request and reuses its records across matrix and architecture views. Its dependency response includes the directory, the files represented by the records, and the parser and renderer code. Tracking the directory lets Trail notice new feature files too.

When updating the parser, check the record keys above and both rendered views. Changes to the architecture tables are documentation input changes; they do not by themselves change Peios's kernel configuration.

Jobserver coordination for optional Peios builds

Peios Kernel / Administration / Tools

The kernel retains tools/lib/python/jobserver.py and its command wrapper, scripts/jobserver-exec, for commands that need to share Make's parallel-build budget. The Clang-LTO initcall-ordering rule in scripts/Makefile.vmlinux_o uses this wrapper. Peios's current peios/config/config.x86_64.base sets CONFIG_LTO_NONE=y, so that rule is inactive in the base configuration. Trail's documentation build does not use this helper.

Reserving parallel work #

JobserverExec() claims the jobserver tokens currently available and adds one for the calling task's existing reservation. It passes that total to a child through the PARALLELISM environment variable. The child must honour that variable for the reservation to constrain its parallel work.

The helper reads jobserver information from MAKEFLAGS. It accepts inherited numeric pipe descriptors and the fifo:PATH form. It opens a nonblocking read handle so that it can collect the available tokens without waiting for every other Make task to finish. The resulting budget is the capacity available at that moment, not necessarily the original make -j value.

Python interface #

InterfaceBehaviour
JobserverExec()Initialises token storage and connection state; it does not reserve tokens until opened.
open()Attempts to connect and collect available tokens. Repeated calls while open do nothing.
run(cmd, *args, **pwargs)Ensures the helper is open, sets PARALLELISM when a budget was obtained, and returns the result of subprocess.call(). Additional arguments are forwarded to that call.
close()Returns the collected token bytes to the jobserver and clears the open-state flag.
Context-manager entry and exitCalls open() on entry and close() on exit, including exceptional exits.
warn(text, *args)Writes a warning to standard error.

Use the context manager to return reservations after the child finishes:

from jobserver import JobserverExec

with JobserverExec() as jobserver:
    status = jobserver.run(["command-that-honours-PARALLELISM"])

The import requires the kernel's tools/lib/python/ on Python's module search path; scripts/jobserver-exec arranges this for command-line use.

The state fields are claim (the child budget, including the caller's slot), jobs (the reserved token bytes), reader, writer and is_open. Use one instance for one reservation lifecycle. close() returns tokens; it does not reset all fields or provide a fresh connection for reuse.

Command wrapper and fallback behaviour #

From the kernel source root, the wrapper's invocation is:

python3 scripts/jobserver-exec COMMAND [ARGUMENT ...]

The wrapper runs the command inside a JobserverExec context. The present wrapper does not propagate the child return code through sys.exit(); callers needing that status should account for this when choosing how to invoke it. The Python run() method itself returns the child status.

When no usable jobserver is found, the helper still runs the command and does not set a new PARALLELISM value. It does not clear a value already inherited from the environment. When it does set the variable, it changes the current Python process's environment and does not restore the previous value afterward.

These details matter when embedding the helper in a longer-running process. They do not change Peios's default build configuration or enable LTO.

Kernel ABI documentation tool modules

Peios Kernel / Administration / Tools

  • kabi_parser
  • kabi_regex
  • kabi_symbols
  • kabi_helpers

ABI parser helpers in Peios

Peios Kernel / Administration / Tools

tools/lib/python/abi/helpers.py supplies constants used by the ABI parser. Peios retains this module because the kernel-abi Trail plugin uses that parser to read Documentation/ABI/.

Source directory #

ABI_DIR is the string Documentation/ABI/. The parser uses it when interpreting source paths. It is not the Trail site's output directory. The plugin constructs an absolute input path from its configured kernel source root and passes that path to AbiParser.

Diagnostic controls #

AbiDebug is a class containing integer constants. The parser accepts their values through its debug constructor argument; the Trail plugin uses the default value, zero.

ConstantValueParser use
WHAT_PARSING1Detailed parsing diagnostics for a What: entry.
WHAT_OPEN2File-opening diagnostics.
DUMP_ABI_STRUCTS4Dumps the collected ABI data after parsing.

The implementation checks WHAT_PARSING using equality. The other two checks use bit masks. For the detailed What: trace, set debug=AbiDebug.WHAT_PARSING alone; combining it with another value does not enable that trace. The logger must also be configured to emit debug messages to display it.

The module also defines flags for the optional undefined-ABI checker and its regular-expression grouping diagnostics, plus the CLI help string DEBUG_HELP. Those controls are used by separate tooling and are not exposed as Trail fence options. Peios's documentation build does not run that checker.

Keeping plugin output valid #

The plugin writes its JSON response to standard output and configures the ABI logger to use standard error. Keep diagnostics separate from the response when changing the integration. These helpers describe documentation tooling; an ABI entry appearing in the generated reference is not evidence that its interface is enabled in a running Peios kernel.

ABI documentation parsing in Peios

Peios Kernel / Administration / Tools

Peios's kernel-abi Trail plugin reads the retained Documentation/ABI/ tree with abi.abi_parser.AbiParser. It renders the resulting data through tools/docs/trail-kernel-doc/abi_markdown.py. The parser lives in tools/lib/python/abi/abi_parser.py and uses the ABI helper constants.

These pages document the interfaces described in the source tree. The parser does not inspect the running system or determine which interfaces a Peios configuration enables.

Writing an ABI view #

For a symbol reference for the stable ABI records:

```{kernel-abi} stable
:no-files:
```

The argument can be stable, testing, obsolete, removed or README. Without flags, a level shows both its symbols and its source files. :no-files: selects the symbols; :no-symbols: selects the files. These flags take no value and cannot be combined. README renders the introduction.

Parser interface #

AbiParser(directory, logger=None, enable_lineno=False, show_warnings=True, debug=0)

directory names the ABI source tree. logger receives diagnostics; the plugin supplies its kernel-abi logger, configured for standard error. The remaining arguments control source-line output, warnings and debugging. The Trail plugin keeps their defaults.

The plugin constructs one parser for the request, calls parse_abi(), then calls check_issues(). It passes the same populated parser to AbiMarkdown for every requested view. check_issues() reports inconsistencies through the logger; it does not produce the rendered documentation.

InterfacePurpose
parse_abi()Reads the ABI tree and populates the parser's dictionaries.
parse_file(fname, path, basename)Parses an individual ABI source file with its ABI level and basename; used by the tree scan.
parse_readme(nametag, fname)Populates an introduction record from a README source.
check_issues()Reports symbols documented in more than one source file.
dataParsed symbol records and source-file records.
what_refsMaps a documented What: name to its record key for reference resolution.
what_symbolsTracks the files and locations associated with each What: name.
file_refsMaps source filenames to the parser's inherited reference labels.

Data consumed by Trail #

Symbol records carry the what names, ABI level in path, source locations in file, and fields such as description, date, kernelversion, contact and users when present. A source-file record has type equal to File. The renderer separates these records into symbol and file views and retains their metadata.

AbiMarkdown registers the targets for all views before resolving links. It creates its own deterministic abi-… and abi-file-… anchors; it does not use the parser's ReST output as Trail page content. Mentions of documented ABI paths and ABI source files in descriptions can then link to the corresponding view.

The parser's doc(), desc_rst() and search-oriented output methods belong to other front ends. Peios's Trail integration consumes the dictionaries directly.

Maintaining the integration #

The plugin reports the ABI directory, parsed source files, parser modules and renderer modules as dependencies. A newly added ABI file therefore participates in rebuild detection as well as changes to existing records.

After an upstream parser update, check symbol and file views together: a page can contain the right prose while its cross-references or source metadata are wrong. Keep diagnostics on standard error so that the plugin response remains valid JSON.

ABI pattern matching for optional Peios checks

Peios Kernel / Administration / Tools

tools/lib/python/abi/abi_regex.py provides AbiRegex, a subclass of AbiParser. The optional tools/docs/get_abi.py undefined command uses it to compare sysfs paths with documented ABI names. Peios's Trail ABI renderer uses the base parser directly; building the documentation does not run this comparison.

Construction and parsing #

AbiRegex(*args, **kwargs) accepts the base parser's arguments, including the ABI directory, logger and debug controls. It also accepts search_string. When supplied and nonempty, this is compiled as a regular expression and stored in re_string; an invalid expression raises ValueError.

parse_abi(*args, **kwargs) first runs the inherited ABI parser. It then converts What: names beginning with /sys into patterns, stores the pattern strings in each record's regex list, and groups the compiled expressions in regex_group. File records and non-sysfs names do not generate search patterns. Call it before requesting candidate expressions. The system-symbol checker performs this initialisation when its check starts.

The conversion applies the ordered substitutions in re_whats. They handle the numeric ranges, placeholders, alternative names and wildcard conventions found in the inherited ABI documentation. escape_symbols controls escaping within those transformations. These are documentation-matching heuristics, not a definition of valid kernel ABI syntax.

Searching the groups #

Method or fieldPurpose
regex_append(what, new)Compiles the transformed pattern and adds it to a search group. Invalid patterns produce a warning and are not added.
get_regexes(what)Returns candidate compiled expressions for a sysfs path, using its path components and the fallback group. It does not itself decide whether the path matches.
regex_groupDictionary from group name to compiled expression list.
leave_othersName of the fallback group: others.
skip_namesCommon components excluded during group selection, currently devices and hwmon.
re_symbol_nameRecognises components usable for grouping.
re_has_numRetained compiled expression for numeric-pattern detection; the current grouping methods do not use it.

Grouping reduces the number of patterns examined for each path. The checker calls get_regexes() for the path and tests those candidates against its names and aliases. A match suggests that an ABI description covers the name; it does not validate the interface's values or behaviour.

Filtering and diagnostics #

search_string has two uses in the retained implementation. SystemSymbols uses the compiled re_string to select paths for checking. During pattern creation, regex_append() also prints a What: name when it contains the original search string literally. That diagnostic is a substring test, so it need not select the same names as the regular expression.

The inherited debug value accepts the AbiDebug constants. REGEX reports transformed patterns, SUBGROUP_MAP reports grouping decisions, SUBGROUP_DICT dumps the groups, and SUBGROUP_SIZE prints the largest groups. Debug log messages also require an appropriate logger level. The command-line front end configures this when its global --debug option is nonzero.

Maintaining the optional checker #

If an ABI naming convention changes, review the transformation order and group selection together. A missed match may come from an unsupported naming pattern, an omitted candidate group, or genuinely missing documentation. Preserve the original What: name when investigating; the transformed expression alone can hide the cause. The checker is available for Peios audits, but it is not a configured documentation-build or release gate.

Checking Peios sysfs documentation coverage

Peios Kernel / Administration / Tools

tools/lib/python/abi/system_symbols.py provides SystemSymbols, the optional checker behind tools/docs/get_abi.py undefined. It compares names found in a sysfs tree with patterns derived from Documentation/ABI/. Peios retains the tool for manual audits; Trail does not run it when rendering ABI documentation.

For an audit of a running Peios system, use that system's sysfs tree and the matching Peios source revision. Running against a build workstation's /sys describes the workstation, not a Peios image being built there. The results also depend on the devices and modules present at the time of the scan.

Command-line use #

From the matching kernel source root on the system being examined:

python3 tools/docs/get_abi.py -D Documentation/ABI undefined --jobs 1

To restrict the check to paths matching a pattern, add --search-string after undefined. To inspect the selected names without performing the matching work, add --dry-run there instead.

Option after undefinedPurpose
--sysfs-dir PATH / -S PATHSelects the sysfs root; the default is /sys.
--search-string REGEX / -s REGEXSelects paths through a regular-expression search.
--show-hints / -HShows the candidate expressions tried for an unmatched path.
--jobs N / -j N / --max-workers NSelects the worker count; the CLI defaults to one.
--max-chunk-size N / -c NSets the maximum work-batch size; the CLI defaults to 50.
--found / -fEnables additional diagnostics for matched entries.
--dry-run / -dLists selected path references instead of scheduling match checks. Sysfs scanning and ABI parsing still occur.

The global -D/--dir selects the ABI documentation directory and precedes the subcommand. Global -d means --debug; after undefined, -d means --dry-run. Prefer the long names when writing audit instructions.

Python interface #

SystemSymbols(abi, sysfs="/sys", hints=False) receives an AbiRegex instance. Construction immediately scans sysfs and builds the path graph; it is not a lazy operation.

MethodBehaviour
graph_add_file(path, link=None)Adds a path and an optional alias to the graph, avoiding an already-recorded path.
print_graph(root_prefix="", root=None, level=0)Prints a diagnostic tree, with a recursion-depth limit.
check_file(refs, found)Tests batches of related names against candidate ABI patterns and returns result dictionaries containing found, fname and msg.
get_fileref(all_refs, chunk_size)Yields batches of path-reference lists for scheduling.
check_undefined_symbols(max_workers=None, chunk_size=50, found=None, dry_run=None)Parses the ABI documentation, selects path references, runs the comparisons and prints unmatched paths.

The collected state includes root (the nested path graph), files (recorded paths), aliases, abi, log, sysfs, hints and re_ignore. Graph nodes store their associated names in __name. The walker handles symlinks before directories to avoid recursively traversing directory links. An alternate sysfs root is normalised toward /sys names for matching documentation.

The scan deliberately excludes categories such as module information, parameters, firmware, cgroups and debugging/tracing trees. It inventories names and filesystem relationships; it does not validate the contents returned by sysfs attributes. Treat the inventory and exclusion rules as part of the tool's scope, especially when supplying an alternate root.

Work scheduling and results #

The Python method defaults to the detected CPU count when no worker count is supplied; the CLI explicitly supplies its default of one. Multiple workers use a process pool and shuffled batches. A single worker uses a thread executor. The batch size is bounded by the selected chunk size and available work.

An unmatched path is printed as PATH not found.. This is a prompt to inspect the source documentation and the pattern conversion, not proof of a broken kernel interface. Conversely, a matching name does not establish that an interface behaves as documented. The command reports findings as text; it does not turn the number of unmatched paths into a failing process exit status. Any future automated Peios audit needs to define how it interprets those results.

For debugging, start with a narrow search and --show-hints. The GRAPH and UNDEFINED flags from AbiDebug expose the path graph and individual pattern comparisons. The associated pattern reference explains grouping and the limitations of the inherited name transformations.

Kernel-doc modules

Peios Kernel / Administration / Tools

  • kdoc_parser
  • kdoc_output
  • kdoc_ancillary

Kernel-doc helpers used by Peios

Peios Kernel / Administration / Tools

Peios's documentation plugins use two ancillary parts of tools/lib/python/kdoc/: the regular-expression helpers used by kernel-doc, and the C-header parser used to build UAPI symbol references.

Regular-expression helpers #

kdoc.kdoc_re.KernRe(string, cache=True, flags=0) wraps a compiled Python regular expression and remembers the most recent match() or search() result. The kernel-doc parser and shared output module use these objects throughout their declaration handling.

MethodBehaviour
match(string)Matches at the start and stores the result in last_match.
search(string)Searches the string and stores the result in last_match.
group(num)Reads a group from the stored match; call only after a successful match or search.
findall(string)Returns all matches using the compiled expression.
split(string)Splits using the compiled expression.
sub(sub, string, count=0)Replaces matches, with zero meaning no replacement-count limit.

Adding two KernRe objects concatenates their patterns and combines their flags. Because matching updates object state, consume captured groups before reusing the same object for another match.

NestedMatch() supports expressions followed by paired delimiters, such as nested parentheses in C declarations. search(regex, line) yields matching substrings whose delimiters balance. sub(regex, sub, line, count=0) replaces such matches; a \1 in the replacement refers to the paired contents without the outer delimiters. These helpers support the parser's text processing; they do not constitute a general C parser.

UAPI header symbols #

kdoc.parse_data_structs.ParseDataStructs(debug=False) identifies symbols in a header and computes their documentation references. Peios's kernel-include plugin uses it when a block requests :generate-cross-refs: with :toc:.

parse_file(file_in, exceptions=None) reads the header and optional exception file. The resulting symbols dictionary groups entries by kind. Each entry maps a symbol name to (reference, line), where the stored line index starts at zero. DEF_SYMBOL_TYPES describes the groups and their default reference roles:

KindSymbols
ioctlIOCTL command definitions.
defineOther macros and definitions.
symbolValues declared within enumerations.
typedefTypedef names.
enumNamed enumerations.
structStructures.

The exception file can remove a symbol from the reference table, redirect its documentation target, or set the C namespace:

ignore <type> <symbol>
replace <type> <old_symbol> <new_reference>
namespace <namespace>

new_reference can be a plain target or an explicit inherited role such as :c:type:. These role strings are parser data, not Trail syntax that article authors need to introduce. Keep existing header exception files alongside their source documentation and pass them through the plugin.

Rendering and diagnostics #

tools/docs/trail-kernel-doc/uapi_markdown.py consumes the symbol dictionary. It resolves the parser's reference roles against Trail's anchor index and displays source line numbers starting at one. Label references look for rst-… anchors; C references look for c-… anchors, including tagged types. Unresolved symbols remain visible; :warn-broken: reports them for review.

The include plugin records the header, exception file and parser/renderer code as dependencies. Parser diagnostics are kept away from the JSON response on standard output. The parser's gen_output(), gen_toc() and write_output() ReST helpers are not used for Trail rendering.

Other modules in the source tree #

The retained standalone tools/docs/parse-headers.py command uses enrich_formatter.EnrichFormatter for argument help. That formatter is outside the Trail integration described here. latex_fonts and python_version support the inherited Sphinx/PDF and setup tooling; Peios's Trail build does not use them. Their source remains available, but this reference concentrates on the modules used by the live documentation plugins.

Kernel-doc rendering in Peios

Peios Kernel / Administration / Tools

Peios renders parsed kernel-doc records with tools/docs/trail-kernel-doc/kdoc_markdown.py. Its MarkdownFormat class inherits OutputFormat from tools/lib/python/kdoc/kdoc_output.py, reusing selection and dispatch while providing Markdown-specific output handlers. The upstream module remains an active dependency even though its man-page and ReST renderers are not used to build the Trail site.

Shared output interface #

The parser coordinator calls the following OutputFormat methods:

MethodRole
set_config(config)Supplies the shared parser configuration and warning callback.
set_filter(export, internal, symbol, nosymbol, function_table, enable_lineno, no_doc_sections)Sets declaration selection for the current source.
set_symbols(symbols)Makes a file's parsed item list available to an output implementation.
msg(fname, name, args)Clears the item output buffer, applies selection, dispatches by declaration kind and returns rendered text.
check_doc(name, args)Selects a DOC: section and emits its applicable warnings.
check_declaration(dtype, name, args)Selects a declaration and emits its applicable warnings.

The modes are OUTPUT_ALL (0), OUTPUT_INCLUDE (1), OUTPUT_EXPORTED (2) and OUTPUT_INTERNAL (3). Exclusions in nosymbol apply alongside the selection. The coordinator prepares function_table from explicit identifiers or export scans. The Trail entry point resolves fence options before calling this interface.

The base class's output hooks are empty. A renderer implements out_doc(), out_function(), out_enum(), out_var(), out_typedef() and out_struct(); the last handles both structures and unions. Each receives (fname, name, args) and appends text to self.data.

Markdown rendering #

MarkdownFormat(parent=None) supplies these hooks. begin(reference) sets the current Trail page and prepares its anchor set. The renderer emits declarations, parameter or member descriptions, and named sections from the parsed KdocItem.

heading_markdown(kind, name, title) registers a target and emits its explicit anchor only once per page. Functions, macros, variables and typedefs use c-NAME; tagged types use c-struct-NAME, c-union-NAME or c-enum-NAME. The symbol registry allows a mention in one block to link to a declaration documented by another block. References are resolved after the blocks have registered their targets.

The inherited function_pointer expression is also used when rendering function-pointer parameters. This is a separate dependency on kdoc_output.py, in addition to OutputFormat itself.

text(), sections() and items() convert comment prose and assemble the Markdown body. purpose() emits the short description. The parser's KernelDoc.undescribed marker is interpreted when deciding how to display missing parameter or member descriptions.

Embedded content #

A child MarkdownFormat(parent=parent) shares symbol and page-anchor registries with its parent but owns a separate output buffer. This is needed when a comment expands another kernel-doc block while the parent is still being rendered. The plugin supplies the nested-expansion callbacks and the reviewed Mermaid figure integration.

Other Peios documentation renderers reuse the comment-to-Markdown converter for inherited ReST prose. For example, the ABI renderer disables kernel-doc-specific highlighting when interpreting ordinary ABI descriptions.

Maintaining the renderer #

When updating OutputFormat, check method signatures, filter behaviour and the KdocItem fields consumed by all Markdown hooks. Changes to RestFormat or ManFormat need review only if they also affect shared code; neither class supplies Peios's Trail output. Keep generated anchors stable when changing presentation so that existing documentation links continue to work.

Kernel-doc parsing in Peios

Peios Kernel / Administration / Tools

Peios keeps C API documentation beside its declarations and expands it into Trail pages with the kernel-doc plugin. The plugin uses the kernel's Python parser in tools/lib/python/kdoc/ and supplies a Markdown output format.

A page requests source comments with a fence such as:

```{kernel-doc} drivers/base/core.c
:export:
```

Paths are relative to the configured kernel source root. The plugin resolves the path, selects the requested declarations, and reports the files it read as build dependencies. Its entry point is tools/docs/trail-kernel-doc/trail-kernel-doc.

File handling #

kdoc.kdoc_files.KernelFiles coordinates parsing, caching, diagnostics and output. Peios constructs it as KernelFiles(out_style=style, logger=logger), where style is a MarkdownFormat instance and the logger writes to standard error.

MethodBehaviour
parse(file_list, export_file=None)Parses the requested sources and any additional files needed to identify exported symbols.
parse_file(fname)Parses comments and exports together; caches the results by filename.
process_export_file(fname)Scans only export declarations in an additional source file.
msg(...)Applies the selection and yields (filename, rendered_text) pairs.
warning(msg) / error(msg)Logs a diagnostic and increments the error count.

msg() accepts enable_lineno, export, internal, symbol, nosymbol, no_doc_sections, filenames and export_file. Peios passes an explicit filenames list so that cached results from another block do not appear in the current block. An empty :identifiers: option selects declarations without DOC: sections; :functions: is an alias for :identifiers:.

The results dictionary holds the parsed items by filename. files and export_files record inputs already processed; export_table holds the exported names for each file. The plugin includes these inputs in its dependency response. Use a new coordinator when the underlying source needs to be parsed afresh.

GlobSourceFiles(srctree=None, valid_extensions=None) supports this coordinator. Its parse_files(file_list, file_not_found_cb) iterator accepts files and directories, recursively selecting source extensions within directories. The Trail entry point expands option globs before handing them to KernelFiles.

Parsed records #

kdoc.kdoc_item.KdocItem(name, fname, type, start_line, **other_stuff) carries a parsed declaration or documentation section into the output stage.

AttributeContent
name, fname, typeIdentifier, source filename and declaration kind.
declaration_start_lineSource position of the declaration.
sectionsNamed documentation sections and their text.
parameterlistOrdered parameter or member names.
parameterdescsDescriptions indexed by parameter or member name.
parametertypesParsed types indexed by parameter or member name.
parameterdesc_start_linesSource positions associated with parameter descriptions.
other_stuffAdditional declaration-specific values, such as purpose and prototype information.

set_sections(sections, start_lines) and set_params(names, descs, types, starts) populate these collections. get(key, default=None) and item[key] read only other_stuff; they do not look up the named attributes above. The renderer reads structured fields as attributes and uses get() for optional declaration-specific fields.

Parser internals #

kdoc.kdoc_parser.KernelDoc(config, fname) handles one C source file. parse_kdoc() returns the exported-symbol set and the list of parsed items. parse_export() performs an export-only scan. The coordinator supplies the configuration and diagnostic callback used by both paths.

The parser uses state and its state_actions table to move through comment headers, bodies and declarations. KernelEntry(config, fname, ln) accumulates the current comment, sections and warnings before a KdocItem is emitted. The apply_transforms(), trim_whitespace() and trim_private_members() helpers support declaration processing. These are internal parser machinery; a Trail plugin should enter through KernelFiles rather than drive the state handlers.

Nested documentation and updates #

Some C comments contain another kernel-doc directive. Peios handles that through a child MarkdownFormat and a separate KernelFiles coordinator, sharing the parent's symbol registry while keeping its output buffer separate. Nested source and export files also become dependencies.

An upstream parser change can affect every live kernel-doc page, even when its RST wrapper has not changed. Review the parser, the record fields consumed by the renderer, selection behaviour and generated links together. Existing source-comment warnings are reported separately from conversion failures.

Python libraries

Peios Kernel / Administration / Tools

  • jobserver
  • feat
  • Kernel-doc modules
  • Kernel ABI documentation tool modules

The realtime Linux analysis tool

Peios Kernel / Administration / Tools / rtla

RTLA provides a set of tools for the analysis of the kernel's realtime behavior on specific hardware.

  • rtla
  • rtla-osnoise
  • rtla-osnoise-hist
  • rtla-osnoise-top
  • rtla-timerlat
  • rtla-timerlat-hist
  • rtla-timerlat-top
  • rtla-hwnoise

rtla-hwnoise

Peios Kernel / Administration / Tools / rtla

Detect and quantify hardware-related noise #

Manual section: 1

SYNOPSIS #

rtla hwnoise [OPTIONS]

DESCRIPTION #

rtla hwnoise collects the periodic summary from the osnoise tracer running with interrupts disabled. By disabling interrupts, and the scheduling of threads as a consequence, only non-maskable interrupts and hardware-related noise is allowed.

The tool also allows the configurations of the osnoise tracer and the collection of the tracer output.

OPTIONS #

-a, --auto us

Set the automatic trace mode. This mode sets some commonly used options while debugging the system. It is equivalent to use -s us -T 1 -t.

-p, --period us

Set the osnoise tracer period in microseconds.

-r, --runtime us

Set the osnoise tracer runtime in microseconds.

-s, --stop us

Stop the trace if a single sample is higher than the argument in microseconds. If -T is set, it will also save the trace to the output.

-S, --stop-total us

Stop the trace if the total sample is higher than the argument in microseconds. If -T is set, it will also save the trace to the output.

-T, --threshold us

Specify the minimum delta between two time reads to be considered noise. The default threshold is 5 us.

-t, --trace [file]

Save the stopped trace to [file|osnoise_trace.txt].

-q, --quiet

Print only a summary at the end of the session.

-c, --cpus cpu-list

Set the hwnoise tracer to run the sample threads in the cpu-list.

By default, the hwnoise tracer runs the sample threads on all CPUs.

-H, --house-keeping cpu-list

Run rtla control threads only on the given cpu-list.

If omitted, rtla will attempt to auto-migrate its main thread to any CPU that is not running any workload threads.

-d, --duration time[s|m|h|d]

Set the duration of the session.

-D, --debug

Print debug info.

-e, --event sys:event

Enable an event in the trace (-t) session. The argument can be a specific event, e.g., -e sched:sched_switch, or all events of a system group, e.g., -e sched. Multiple -e are allowed. It is only active when -t or -a are set.

--filter <filter>

Filter the previous -e sys:event event with <filter>. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.

  • --trigger <trigger>

    Enable a trace event trigger to the previous -e sys:event. If the hist: trigger is activated, the output histogram will be automatically saved to a file named system_event_hist.txt. For example, the command:

    rtla <command> <mode> -t -e osnoise:irq_noise --trigger="hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount"

    Will automatically save the content of the histogram associated to osnoise:irq_noise event in osnoise_irq_noise_hist.txt.

    For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.

-P, --priority o:prio|r:prio|f:prio|d:runtime:period

Set scheduling parameters to the hwnoise tracer threads, the format to set the priority are:

  • o:prio - use SCHED_OTHER with prio;

  • r:prio - use SCHED_RR with prio;

  • f:prio - use SCHED_FIFO with prio;

  • d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period in nanoseconds.

If not set, tracer threads keep their default priority. For rtla user threads, it is set to SCHED_FIFO with priority 95. For kernel threads, see osnoise and timerlat tracer documentation for the running kernel version.

-C, --cgroup [cgroup]

Set a cgroup to the tracer's threads. If the -C option is passed without arguments, the tracer's thread will inherit rtla's cgroup. Otherwise, the threads will be placed on the cgroup passed to the option.

If not set, the behavior differs between workload types. User workloads created by rtla will inherit rtla's cgroup. Kernel workloads are assigned the root cgroup.

--warm-up s

After starting the workload, let it run for s seconds before starting collecting the data, allowing the system to warm-up. Statistical data generated during warm-up is discarded.

  • --trace-buffer-size kB

    Set the per-cpu trace buffer size in kB for the tracing output.

    If not set, the default tracefs buffer size is used.

--on-threshold action

Defines an action to be executed when tracing is stopped on a latency threshold specified by -a/--auto, -s/--stop, or -S/--stop-total.

Multiple --on-threshold actions may be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

Supported actions are:

  • trace[,file=<filename>]

    Saves trace output, optionally taking a filename. Alternative to -t/--trace. Note that unlike -t/--trace, specifying this multiple times will result in the trace being saved multiple times.

  • signal,num=<sig>,pid=<pid>

    Sends signal to process. "parent" might be specified in place of pid to target the parent process of rtla.

  • shell,command=<command>

    Execute shell command.

  • continue

    Continue tracing after actions are executed instead of stopping.

Example:

$ rtla hwnoise -s 20 --on-threshold trace --on-threshold shell,command="grep ipi_send osnoise_trace.txt" --on-threshold signal,num=2,pid=parent

This will save a trace with the default filename "osnoise_trace.txt", print its lines that contain the text "ipi_send" on standard output, and send signal 2 (SIGINT) to the parent process.

Performance Considerations:

Due to implementational limitations, actions might be delayed up to one second after tracing is stopped.

--on-end action

Defines an action to be executed at the end of tracing.

Multiple --on-end actions can be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

See the documentation for --on-threshold for the list of supported actions, with the exception that continue has no effect.

Example:

$ rtla hwnoise -d 5s --on-end trace

This runs rtla with the default options, and saves trace output at the end.

-h, --help

Print help menu.

EXAMPLE #

In the example below, the rtla hwnoise tool is set to run on CPUs 1-7 on a system with 8 cores/16 threads with hyper-threading enabled.

The tool is set to detect any noise higher than one microsecond, to run for ten minutes, displaying a summary of the report at the end of the session:

# rtla hwnoise -c 1-7 -T 1 -d 10m -q
                                        Hardware-related Noise
duration:   0 00:10:00 | time is in us
CPU Period       Runtime        Noise  % CPU Aval   Max Noise   Max Single          HW          NMI
  1 #599       599000000          138    99.99997           3            3           4           74
  2 #599       599000000           85    99.99998           3            3           4           75
  3 #599       599000000           86    99.99998           4            3           6           75
  4 #599       599000000           81    99.99998           4            4           2           75
  5 #599       599000000           85    99.99998           2            2           2           75
  6 #599       599000000           76    99.99998           2            2           0           75
  7 #599       599000000           77    99.99998           3            3           0           75

The first column shows the CPU, and the second column shows how many Periods the tool ran during the session. The Runtime is the time the tool effectively runs on the CPU. The Noise column is the sum of all noise that the tool observed, and the % CPU Aval is the relation between the Runtime and Noise.

The Max Noise column is the maximum hardware noise the tool detected in a single period, and the Max Single is the maximum single noise seen.

The HW and NMI columns show the total number of hardware and NMI noise occurrence observed by the tool.

For example, CPU 3 ran 599 periods of 1 second Runtime. The CPU received 86 us of noise during the entire execution, leaving 99.99997 % of CPU time for the application. In the worst single period, the CPU caused 4 us of noise to the application, but it was certainly caused by more than one single noise, as the Max Single noise was of 3 us. The CPU has HW noise, at a rate of six occurrences/ten minutes. The CPU also has NMIs, at a higher frequency: around seven per second.

The tool should report 0 hardware-related noise in the ideal situation. For example, by disabling hyper-threading to remove the hardware noise, and disabling the TSC watchdog to remove the NMI (it is possible to identify this using tracing options of rtla hwnoise), it was possible to reach the ideal situation in the same hardware:

# rtla hwnoise -c 1-7 -T 1 -d 10m -q
                                        Hardware-related Noise
duration:   0 00:10:00 | time is in us
CPU Period       Runtime        Noise  % CPU Aval   Max Noise   Max Single          HW          NMI
  1 #599       599000000            0   100.00000           0            0           0            0
  2 #599       599000000            0   100.00000           0            0           0            0
  3 #599       599000000            0   100.00000           0            0           0            0
  4 #599       599000000            0   100.00000           0            0           0            0
  5 #599       599000000            0   100.00000           0            0           0            0
  6 #599       599000000            0   100.00000           0            0           0            0
  7 #599       599000000            0   100.00000           0            0           0            0

SEE ALSO #

rtla-osnoise(1)

Osnoise tracer documentation: <https://www.kernel.org/doc/html/latest/trace/osnoise-tracer.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

EXIT STATUS #

0  Passed: the test did not hit the stop tracing condition
1  Error: invalid argument
2  Failed: the test hit the stop tracing condition

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rtla is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rtla-osnoise-hist

Peios Kernel / Administration / Tools / rtla

Display a histogram of the osnoise tracer samples #

Manual section: 1

SYNOPSIS #

rtla osnoise hist [OPTIONS]

DESCRIPTION #

The rtla osnoise tool is an interface for the osnoise tracer. The osnoise tracer dispatches a kernel thread per-cpu. These threads read the time in a loop while with preemption, softirq and IRQs enabled, thus allowing all the sources of operating system noise during its execution. The osnoise's tracer threads take note of the delta between each time read, along with an interference counter of all sources of interference. At the end of each period, the osnoise tracer displays a summary of the results.

The rtla osnoise hist tool collects all osnoise:sample_threshold occurrence in a histogram, displaying the results in a user-friendly way. The tool also allows many configurations of the osnoise tracer and the collection of the tracer output.

OPTIONS #

-a, --auto us

Set the automatic trace mode. This mode sets some commonly used options while debugging the system. It is equivalent to use -s us -T 1 -t.

-p, --period us

Set the osnoise tracer period in microseconds.

-r, --runtime us

Set the osnoise tracer runtime in microseconds.

-s, --stop us

Stop the trace if a single sample is higher than the argument in microseconds. If -T is set, it will also save the trace to the output.

-S, --stop-total us

Stop the trace if the total sample is higher than the argument in microseconds. If -T is set, it will also save the trace to the output.

-T, --threshold us

Specify the minimum delta between two time reads to be considered noise. The default threshold is 5 us.

-t, --trace [file]

Save the stopped trace to [file|osnoise_trace.txt].

-b, --bucket-size N

Set the histogram bucket size (default 1).

-E, --entries N

Set the number of entries of the histogram (default 256).

--no-header

Do not print header.

--no-summary

Do not print summary.

--no-index

Do not print index.

--with-zeros

Print zero only entries.

-c, --cpus cpu-list

Set the osnoise hist tracer to run the sample threads in the cpu-list.

By default, the osnoise hist tracer runs the sample threads on all CPUs.

-H, --house-keeping cpu-list

Run rtla control threads only on the given cpu-list.

If omitted, rtla will attempt to auto-migrate its main thread to any CPU that is not running any workload threads.

-d, --duration time[s|m|h|d]

Set the duration of the session.

-D, --debug

Print debug info.

-e, --event sys:event

Enable an event in the trace (-t) session. The argument can be a specific event, e.g., -e sched:sched_switch, or all events of a system group, e.g., -e sched. Multiple -e are allowed. It is only active when -t or -a are set.

--filter <filter>

Filter the previous -e sys:event event with <filter>. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.

  • --trigger <trigger>

    Enable a trace event trigger to the previous -e sys:event. If the hist: trigger is activated, the output histogram will be automatically saved to a file named system_event_hist.txt. For example, the command:

    rtla <command> <mode> -t -e osnoise:irq_noise --trigger="hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount"

    Will automatically save the content of the histogram associated to osnoise:irq_noise event in osnoise_irq_noise_hist.txt.

    For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.

-P, --priority o:prio|r:prio|f:prio|d:runtime:period

Set scheduling parameters to the osnoise hist tracer threads, the format to set the priority are:

  • o:prio - use SCHED_OTHER with prio;

  • r:prio - use SCHED_RR with prio;

  • f:prio - use SCHED_FIFO with prio;

  • d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period in nanoseconds.

If not set, tracer threads keep their default priority. For rtla user threads, it is set to SCHED_FIFO with priority 95. For kernel threads, see osnoise and timerlat tracer documentation for the running kernel version.

-C, --cgroup [cgroup]

Set a cgroup to the tracer's threads. If the -C option is passed without arguments, the tracer's thread will inherit rtla's cgroup. Otherwise, the threads will be placed on the cgroup passed to the option.

If not set, the behavior differs between workload types. User workloads created by rtla will inherit rtla's cgroup. Kernel workloads are assigned the root cgroup.

--warm-up s

After starting the workload, let it run for s seconds before starting collecting the data, allowing the system to warm-up. Statistical data generated during warm-up is discarded.

  • --trace-buffer-size kB

    Set the per-cpu trace buffer size in kB for the tracing output.

    If not set, the default tracefs buffer size is used.

--on-threshold action

Defines an action to be executed when tracing is stopped on a latency threshold specified by -a/--auto, -s/--stop, or -S/--stop-total.

Multiple --on-threshold actions may be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

Supported actions are:

  • trace[,file=<filename>]

    Saves trace output, optionally taking a filename. Alternative to -t/--trace. Note that unlike -t/--trace, specifying this multiple times will result in the trace being saved multiple times.

  • signal,num=<sig>,pid=<pid>

    Sends signal to process. "parent" might be specified in place of pid to target the parent process of rtla.

  • shell,command=<command>

    Execute shell command.

  • continue

    Continue tracing after actions are executed instead of stopping.

Example:

$ rtla osnoise hist -s 20 --on-threshold trace --on-threshold shell,command="grep ipi_send osnoise_trace.txt" --on-threshold signal,num=2,pid=parent

This will save a trace with the default filename "osnoise_trace.txt", print its lines that contain the text "ipi_send" on standard output, and send signal 2 (SIGINT) to the parent process.

Performance Considerations:

Due to implementational limitations, actions might be delayed up to one second after tracing is stopped.

--on-end action

Defines an action to be executed at the end of tracing.

Multiple --on-end actions can be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

See the documentation for --on-threshold for the list of supported actions, with the exception that continue has no effect.

Example:

$ rtla osnoise hist -d 5s --on-end trace

This runs rtla with the default options, and saves trace output at the end.

-h, --help

Print help menu.

EXAMPLE #

In the example below, osnoise tracer threads are set to run with real-time priority FIFO:1, on CPUs 0-11, for 900ms at each period (1s by default). The reason for reducing the runtime is to avoid starving the rtla tool. The tool is also set to run for one minute. The output histogram is set to group outputs in buckets of 10us and 25 entries:

[root@f34 ~/]# rtla osnoise hist -P F:1 -c 0-11 -r 900000 -d 1M -b 10 -E 25
# RTLA osnoise histogram
# Time unit is microseconds (us)
# Duration:   0 00:01:00
Index   CPU-000   CPU-001   CPU-002   CPU-003   CPU-004   CPU-005   CPU-006   CPU-007   CPU-008   CPU-009   CPU-010   CPU-011
0         42982     46287     51779     53740     52024     44817     49898     36500     50408     50128     49523     52377
10        12224      8356      2912       878      2667     10155      4573     18894      4214      4836      5708      2413
20            8         5        12         2        13        24        20        41        29        53        39        39
30            1         1         0         0        10         3         6        19        15        31        30        38
40            0         0         0         0         0         4         2         7         2         3         8        11
50            0         0         0         0         0         0         0         0         0         1         1         2
over:         0         0         0         0         0         0         0         0         0         0         0         0
count:    55215     54649     54703     54620     54714     55003     54499     55461     54668     55052     55309     54880
min:          0         0         0         0         0         0         0         0         0         0         0         0
avg:          0         0         0         0         0         0         0         0         0         0         0         0
max:         30        30        20        20        30        40        40        40        40        50        50        50

SEE ALSO #

rtla-osnoise(1), rtla-osnoise-top(1)

osnoise tracer documentation: <https://www.kernel.org/doc/html/latest/trace/osnoise-tracer.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

EXIT STATUS #

0  Passed: the test did not hit the stop tracing condition
1  Error: invalid argument
2  Failed: the test hit the stop tracing condition

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rtla is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rtla-osnoise-top

Peios Kernel / Administration / Tools / rtla

Display a summary of the operating system noise #

Manual section: 1

SYNOPSIS #

rtla osnoise top [OPTIONS]

DESCRIPTION #

The rtla osnoise tool is an interface for the osnoise tracer. The osnoise tracer dispatches a kernel thread per-cpu. These threads read the time in a loop while with preemption, softirq and IRQs enabled, thus allowing all the sources of operating system noise during its execution. The osnoise's tracer threads take note of the delta between each time read, along with an interference counter of all sources of interference. At the end of each period, the osnoise tracer displays a summary of the results.

rtla osnoise top collects the periodic summary from the osnoise tracer, including the counters of the occurrence of the interference source, displaying the results in a user-friendly format.

The tool also allows many configurations of the osnoise tracer and the collection of the tracer output.

OPTIONS #

-a, --auto us

Set the automatic trace mode. This mode sets some commonly used options while debugging the system. It is equivalent to use -s us -T 1 -t.

-p, --period us

Set the osnoise tracer period in microseconds.

-r, --runtime us

Set the osnoise tracer runtime in microseconds.

-s, --stop us

Stop the trace if a single sample is higher than the argument in microseconds. If -T is set, it will also save the trace to the output.

-S, --stop-total us

Stop the trace if the total sample is higher than the argument in microseconds. If -T is set, it will also save the trace to the output.

-T, --threshold us

Specify the minimum delta between two time reads to be considered noise. The default threshold is 5 us.

-t, --trace [file]

Save the stopped trace to [file|osnoise_trace.txt].

-q, --quiet

Print only a summary at the end of the session.

-c, --cpus cpu-list

Set the osnoise top tracer to run the sample threads in the cpu-list.

By default, the osnoise top tracer runs the sample threads on all CPUs.

-H, --house-keeping cpu-list

Run rtla control threads only on the given cpu-list.

If omitted, rtla will attempt to auto-migrate its main thread to any CPU that is not running any workload threads.

-d, --duration time[s|m|h|d]

Set the duration of the session.

-D, --debug

Print debug info.

-e, --event sys:event

Enable an event in the trace (-t) session. The argument can be a specific event, e.g., -e sched:sched_switch, or all events of a system group, e.g., -e sched. Multiple -e are allowed. It is only active when -t or -a are set.

--filter <filter>

Filter the previous -e sys:event event with <filter>. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.

  • --trigger <trigger>

    Enable a trace event trigger to the previous -e sys:event. If the hist: trigger is activated, the output histogram will be automatically saved to a file named system_event_hist.txt. For example, the command:

    rtla <command> <mode> -t -e osnoise:irq_noise --trigger="hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount"

    Will automatically save the content of the histogram associated to osnoise:irq_noise event in osnoise_irq_noise_hist.txt.

    For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.

-P, --priority o:prio|r:prio|f:prio|d:runtime:period

Set scheduling parameters to the osnoise top tracer threads, the format to set the priority are:

  • o:prio - use SCHED_OTHER with prio;

  • r:prio - use SCHED_RR with prio;

  • f:prio - use SCHED_FIFO with prio;

  • d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period in nanoseconds.

If not set, tracer threads keep their default priority. For rtla user threads, it is set to SCHED_FIFO with priority 95. For kernel threads, see osnoise and timerlat tracer documentation for the running kernel version.

-C, --cgroup [cgroup]

Set a cgroup to the tracer's threads. If the -C option is passed without arguments, the tracer's thread will inherit rtla's cgroup. Otherwise, the threads will be placed on the cgroup passed to the option.

If not set, the behavior differs between workload types. User workloads created by rtla will inherit rtla's cgroup. Kernel workloads are assigned the root cgroup.

--warm-up s

After starting the workload, let it run for s seconds before starting collecting the data, allowing the system to warm-up. Statistical data generated during warm-up is discarded.

  • --trace-buffer-size kB

    Set the per-cpu trace buffer size in kB for the tracing output.

    If not set, the default tracefs buffer size is used.

--on-threshold action

Defines an action to be executed when tracing is stopped on a latency threshold specified by -a/--auto, -s/--stop, or -S/--stop-total.

Multiple --on-threshold actions may be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

Supported actions are:

  • trace[,file=<filename>]

    Saves trace output, optionally taking a filename. Alternative to -t/--trace. Note that unlike -t/--trace, specifying this multiple times will result in the trace being saved multiple times.

  • signal,num=<sig>,pid=<pid>

    Sends signal to process. "parent" might be specified in place of pid to target the parent process of rtla.

  • shell,command=<command>

    Execute shell command.

  • continue

    Continue tracing after actions are executed instead of stopping.

Example:

$ rtla osnoise top -s 20 --on-threshold trace --on-threshold shell,command="grep ipi_send osnoise_trace.txt" --on-threshold signal,num=2,pid=parent

This will save a trace with the default filename "osnoise_trace.txt", print its lines that contain the text "ipi_send" on standard output, and send signal 2 (SIGINT) to the parent process.

Performance Considerations:

Due to implementational limitations, actions might be delayed up to one second after tracing is stopped.

--on-end action

Defines an action to be executed at the end of tracing.

Multiple --on-end actions can be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

See the documentation for --on-threshold for the list of supported actions, with the exception that continue has no effect.

Example:

$ rtla osnoise top -d 5s --on-end trace

This runs rtla with the default options, and saves trace output at the end.

-h, --help

Print help menu.

EXAMPLE #

In the example below, the rtla osnoise top tool is set to run with a real-time priority FIFO:1, on CPUs 0-3, for 900ms at each period (1s by default). The reason for reducing the runtime is to avoid starving the rtla tool. The tool is also set to run for one minute and to display a summary of the report at the end of the session:

[root@f34 ~]# rtla osnoise top -P F:1 -c 0-3 -r 900000 -d 1M -q
                                        Operating System Noise
duration:   0 00:01:00 | time is in us
CPU Period       Runtime        Noise  % CPU Aval   Max Noise   Max Single          HW          NMI          IRQ      Softirq       Thread
  0 #59         53100000       304896    99.42580        6978           56         549            0        53111         1590           13
  1 #59         53100000       338339    99.36282        8092           24         399            0        53130         1448           31
  2 #59         53100000       290842    99.45227        6582           39         855            0        53110         1406           12
  3 #59         53100000       204935    99.61405        6251           33         290            0        53156         1460           12

SEE ALSO #

rtla-osnoise(1), rtla-osnoise-hist(1)

Osnoise tracer documentation: <https://www.kernel.org/doc/html/latest/trace/osnoise-tracer.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

EXIT STATUS #

0  Passed: the test did not hit the stop tracing condition
1  Error: invalid argument
2  Failed: the test hit the stop tracing condition

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rtla is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rtla-osnoise

Peios Kernel / Administration / Tools / rtla

Measure the operating system noise #

Manual section: 1

SYNOPSIS #

rtla osnoise [MODE] ...

DESCRIPTION #

The rtla osnoise tool is an interface for the osnoise tracer. The osnoise tracer dispatches a kernel thread per-cpu. These threads read the time in a loop while with preemption, softirq and IRQs enabled, thus allowing all the sources of operating system noise during its execution. The osnoise's tracer threads take note of the delta between each time read, along with an interference counter of all sources of interference. At the end of each period, the osnoise tracer displays a summary of the results.

The osnoise tracer outputs information in two ways. It periodically prints a summary of the noise of the operating system, including the counters of the occurrence of the source of interference. It also provides information for each noise via the osnoise: tracepoints. The rtla osnoise top mode displays information about the periodic summary from the osnoise tracer. The rtla osnoise hist mode displays information about the noise using the osnoise: tracepoints. For further details, please refer to the respective man page.

MODES #

top

Prints the summary from osnoise tracer.

hist

Prints a histogram of osnoise samples.

If no MODE is given, the top mode is called, passing the arguments.

OPTIONS #

-h, --help

Display the help text.

For other options, see the man page for the corresponding mode.

SEE ALSO #

rtla-osnoise-top(1), rtla-osnoise-hist(1)

Osnoise tracer documentation: <https://www.kernel.org/doc/html/latest/trace/osnoise-tracer.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

EXIT STATUS #

0  Passed: the test did not hit the stop tracing condition
1  Error: invalid argument
2  Failed: the test hit the stop tracing condition

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rtla is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rtla-timerlat-hist

Peios Kernel / Administration / Tools / rtla

Histograms of the operating system timer latency #

Manual section: 1

SYNOPSIS #

rtla timerlat hist [OPTIONS] ...

DESCRIPTION #

The rtla timerlat tool is an interface for the timerlat tracer. The timerlat tracer dispatches a kernel thread per-cpu. These threads set a periodic timer to wake themselves up and go back to sleep. After the wakeup, they collect and generate useful information for the debugging of operating system timer latency.

The timerlat tracer outputs information in two ways. It periodically prints the timer latency at the timer IRQ handler and the Thread handler. It also enables the trace of the most relevant information via osnoise: tracepoints.

The rtla timerlat tool sets the options of the timerlat tracer and collects and displays a summary of the results. By default, the collection is done synchronously in kernel space using a dedicated BPF program attached to the timerlat tracer. If either BPF or the osnoise:timerlat_sample tracepoint it attaches to is unavailable, the rtla timerlat tool falls back to using tracefs to process the data asynchronously in user space.

The rtla timerlat hist displays a histogram of each tracer event occurrence. This tool uses the periodic information, and the osnoise: tracepoints are enabled when using the -T option.

OPTIONS #

-a, --auto us

Set the automatic trace mode. This mode sets some commonly used options while debugging the system. It is equivalent to use -T us -s us -t. By default, timerlat tracer uses FIFO:95 for timerlat threads, thus equivalent to -P f:95.

-p, --period us

Set the timerlat tracer period in microseconds.

-i, --irq us

Stop trace if the IRQ latency is higher than the argument in us.

-T, --thread us

Stop trace if the Thread latency is higher than the argument in us.

-s, --stack us

Save the stack trace at the IRQ if a Thread latency is higher than the argument in us.

-t, --trace [file]

Save the stopped trace to [file|timerlat_trace.txt].

  • --dma-latency us

    Set the /dev/cpu_dma_latency to us, aiming to bound exit from idle latencies. cyclictest sets this value to 0 by default, use --dma-latency 0 to have similar results.

  • --deepest-idle-state n

    Disable idle states higher than n for cpus that are running timerlat threads to reduce exit from idle latencies. If n is -1, all idle states are disabled. On exit from timerlat, the idle state setting is restored to its original state before running timerlat.

    Requires rtla to be built with libcpupower.

-k, --kernel-threads

Use timerlat kernel-space threads, in contrast of -u.

-u, --user-threads

Set timerlat to run without a workload, and then dispatches user-space workloads to wait on the timerlat_fd. Once the workload is awakened, it goes to sleep again adding so the measurement for the kernel-to-user and user-to-kernel to the tracer output. --user-threads will be used unless the user specify -k.

-U, --user-load

Set timerlat to run without workload, waiting for the user to dispatch a per-cpu task that waits for a new period on the tracing/osnoise/per_cpu/cpu$ID/timerlat_fd. See linux/tools/rtla/example/timerlat_load.py for an example of user-load code.

--bpf-action bpf-program

Loads a BPF program from an ELF file and executes it when a latency threshold is exceeded.

The BPF program must be a valid ELF file loadable with libbpf. The program must contain a function named action_handler, stored in an ELF section with the tp_ prefix. The prefix is used by libbpf to set BPF program type to BPF_PROG_TYPE_TRACEPOINT.

The program receives a struct trace_event_raw_timerlat_sample parameter containing timerlat sample data.

An example is provided in tools/tracing/rtla/example/timerlat_bpf_action.c. This example demonstrates how to create a BPF program that prints latency information using bpf_trace_printk() when a threshold is exceeded.

Note: BPF actions require BPF support to be available. If BPF is not available or disabled, the tool falls back to tracefs mode and BPF actions are not supported.

-b, --bucket-size N

Set the histogram bucket size (default 1).

-E, --entries N

Set the number of entries of the histogram (default 256).

--no-header

Do not print header.

--no-summary

Do not print summary.

--no-index

Do not print index.

--with-zeros

Print zero only entries.

-c, --cpus cpu-list

Set the timerlat hist tracer to run the sample threads in the cpu-list.

By default, the timerlat hist tracer runs the sample threads on all CPUs.

-H, --house-keeping cpu-list

Run rtla control threads only on the given cpu-list.

If omitted, rtla will attempt to auto-migrate its main thread to any CPU that is not running any workload threads.

-d, --duration time[s|m|h|d]

Set the duration of the session.

-D, --debug

Print debug info.

-e, --event sys:event

Enable an event in the trace (-t) session. The argument can be a specific event, e.g., -e sched:sched_switch, or all events of a system group, e.g., -e sched. Multiple -e are allowed. It is only active when -t or -a are set.

--filter <filter>

Filter the previous -e sys:event event with <filter>. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.

  • --trigger <trigger>

    Enable a trace event trigger to the previous -e sys:event. If the hist: trigger is activated, the output histogram will be automatically saved to a file named system_event_hist.txt. For example, the command:

    rtla <command> <mode> -t -e osnoise:irq_noise --trigger="hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount"

    Will automatically save the content of the histogram associated to osnoise:irq_noise event in osnoise_irq_noise_hist.txt.

    For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.

-P, --priority o:prio|r:prio|f:prio|d:runtime:period

Set scheduling parameters to the timerlat hist tracer threads, the format to set the priority are:

  • o:prio - use SCHED_OTHER with prio;

  • r:prio - use SCHED_RR with prio;

  • f:prio - use SCHED_FIFO with prio;

  • d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period in nanoseconds.

If not set, tracer threads keep their default priority. For rtla user threads, it is set to SCHED_FIFO with priority 95. For kernel threads, see osnoise and timerlat tracer documentation for the running kernel version.

-C, --cgroup [cgroup]

Set a cgroup to the tracer's threads. If the -C option is passed without arguments, the tracer's thread will inherit rtla's cgroup. Otherwise, the threads will be placed on the cgroup passed to the option.

If not set, the behavior differs between workload types. User workloads created by rtla will inherit rtla's cgroup. Kernel workloads are assigned the root cgroup.

--warm-up s

After starting the workload, let it run for s seconds before starting collecting the data, allowing the system to warm-up. Statistical data generated during warm-up is discarded.

  • --trace-buffer-size kB

    Set the per-cpu trace buffer size in kB for the tracing output.

    If not set, the default tracefs buffer size is used.

--on-threshold action

Defines an action to be executed when tracing is stopped on a latency threshold specified by -a/--auto, -i/--irq, or -T/--thread.

Multiple --on-threshold actions may be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

Supported actions are:

  • trace[,file=<filename>]

    Saves trace output, optionally taking a filename. Alternative to -t/--trace. Note that unlike -t/--trace, specifying this multiple times will result in the trace being saved multiple times.

  • signal,num=<sig>,pid=<pid>

    Sends signal to process. "parent" might be specified in place of pid to target the parent process of rtla.

  • shell,command=<command>

    Execute shell command.

  • continue

    Continue tracing after actions are executed instead of stopping.

Example:

$ rtla timerlat hist -T 20 --on-threshold trace --on-threshold shell,command="grep ipi_send timerlat_trace.txt" --on-threshold signal,num=2,pid=parent

This will save a trace with the default filename "timerlat_trace.txt", print its lines that contain the text "ipi_send" on standard output, and send signal 2 (SIGINT) to the parent process.

Performance Considerations:

For time-sensitive actions, it is recommended to run rtla timerlat with BPF support and RT priority. Note that due to implementational limitations, actions might be delayed up to one second after tracing is stopped if BPF mode is not available or disabled.

--on-end action

Defines an action to be executed at the end of tracing.

Multiple --on-end actions can be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

See the documentation for --on-threshold for the list of supported actions, with the exception that continue has no effect.

Example:

$ rtla timerlat hist -d 5s --on-end trace

This runs rtla with the default options, and saves trace output at the end.

-h, --help

Print help menu.

--dump-tasks

prints the task running on all CPUs if stop conditions are met (depends on !--no-aa)

--no-aa

disable auto-analysis, reducing rtla timerlat cpu usage

EXAMPLE #

In the example below, rtla timerlat hist is set to run for 10 minutes, in the cpus 0-4, skipping zero only lines. Moreover, rtla timerlat hist will change the priority of the timerlat threads to run under SCHED_DEADLINE priority, with a 100us runtime every 1ms period. The 1ms period is also passed to the timerlat tracer. Auto-analysis is disabled to reduce overhead

[root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1000 --no-aa
# RTLA timerlat histogram
# Time unit is microseconds (us)
# Duration:   0 00:10:00
Index   IRQ-000   Thr-000   IRQ-001   Thr-001   IRQ-002   Thr-002   IRQ-003   Thr-003   IRQ-004   Thr-004
0        276489         0    206089         0    466018         0    481102         0    205546         0
1        318327     35487    388149     30024     94531     48382     83082     71078    388026     55730
2          3282    122584      4019    126527     28231    109012     23311     89309      4568     98739
3           940     11815       837      9863      6209     16227      6895     17196       910      9780
4           444     17287       424     11574      2097     38443      2169     36736       462     13476
5           206     43291       255     25581      1223    101908      1304    101137       236     28913
6           132    101501        96     64584       635    213774       757    215471        99     73453
7            74    169347        65    124758       350     57466       441     53639        69    148573
8            53     85183        31    156751       229      9052       306      9026        39    139907
9            22     10387        12     42762       161      2554       225      2689        19     26192
10           13      1898         8      5770       114      1247       128      1405        13      3772
11            9       560         9       924        71       686        76       765         8       713
12            4       256         2       360        50       411        64       474         3       278
13            2       167         2       172        43       256        53       350         4       180
14            1        88         1       116        15       198        42       223         0       115
15            2        63         3        94        11       139        20       150         0        58
16            2        37         0        56         5        78        10       102         0        39
17            0        18         0        28         4        57         8        80         0        15
18            0         8         0        17         2        50         6        56         0        12
19            0         9         0         5         0        19         0        48         0        18
20            0         4         0         8         0        11         2        27         0         4
21            0         2         0         3         1         9         1        18         0         6
22            0         1         0         3         1         7         0         3         0         5
23            0         2         0         4         0         2         0         7         0         2
24            0         2         0         2         1         3         0         3         0         5
25            0         0         0         1         0         1         0         1         0         3
26            0         1         0         0         0         2         0         2         0         0
27            0         0         0         3         0         1         0         0         0         1
28            0         0         0         3         0         0         0         1         0         0
29            0         0         0         2         0         2         0         1         0         3
30            0         1         0         0         0         0         0         0         0         0
31            0         1         0         0         0         0         0         2         0         2
32            0         0         0         1         0         2         0         0         0         0
33            0         0         0         2         0         0         0         0         0         1
34            0         0         0         0         0         0         0         0         0         2
35            0         1         0         1         0         0         0         0         0         1
36            0         1         0         0         0         1         0         1         0         0
37            0         0         0         1         0         0         0         0         0         0
40            0         0         0         0         0         1         0         1         0         0
41            0         0         0         0         0         0         0         0         0         1
42            0         0         0         0         0         0         0         0         0         1
44            0         0         0         0         0         1         0         0         0         0
46            0         0         0         0         0         0         0         1         0         0
47            0         0         0         0         0         0         0         0         0         1
50            0         0         0         0         0         0         0         0         0         1
54            0         0         0         1         0         0         0         0         0         0
58            0         0         0         1         0         0         0         0         0         0
over:         0         0         0         0         0         0         0         0         0         0
count:   600002    600002    600002    600002    600002    600002    600002    600002    600002    600002
min:          0         1         0         1         0         1         0         1         0         1
avg:          0         5         0         5         0         4         0         4         0         5
max:         16        36        15        58        24        44        21        46        13        50

SEE ALSO #

rtla-timerlat(1), rtla-timerlat-top(1)

timerlat tracer documentation: <https://www.kernel.org/doc/html/latest/trace/timerlat-tracer.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

EXIT STATUS #

0  Passed: the test did not hit the stop tracing condition
1  Error: invalid argument
2  Failed: the test hit the stop tracing condition

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rtla is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rtla-timerlat-top

Peios Kernel / Administration / Tools / rtla

Measures the operating system timer latency #

Manual section: 1

SYNOPSIS #

rtla timerlat top [OPTIONS] ...

DESCRIPTION #

The rtla timerlat tool is an interface for the timerlat tracer. The timerlat tracer dispatches a kernel thread per-cpu. These threads set a periodic timer to wake themselves up and go back to sleep. After the wakeup, they collect and generate useful information for the debugging of operating system timer latency.

The timerlat tracer outputs information in two ways. It periodically prints the timer latency at the timer IRQ handler and the Thread handler. It also enables the trace of the most relevant information via osnoise: tracepoints.

The rtla timerlat tool sets the options of the timerlat tracer and collects and displays a summary of the results. By default, the collection is done synchronously in kernel space using a dedicated BPF program attached to the timerlat tracer. If either BPF or the osnoise:timerlat_sample tracepoint it attaches to is unavailable, the rtla timerlat tool falls back to using tracefs to process the data asynchronously in user space.

The rtla timerlat top displays a summary of the periodic output from the timerlat tracer. It also provides information for each operating system noise via the osnoise: tracepoints that can be seen with the option -T.

OPTIONS #

-a, --auto us

Set the automatic trace mode. This mode sets some commonly used options while debugging the system. It is equivalent to use -T us -s us -t. By default, timerlat tracer uses FIFO:95 for timerlat threads, thus equivalent to -P f:95.

-p, --period us

Set the timerlat tracer period in microseconds.

-i, --irq us

Stop trace if the IRQ latency is higher than the argument in us.

-T, --thread us

Stop trace if the Thread latency is higher than the argument in us.

-s, --stack us

Save the stack trace at the IRQ if a Thread latency is higher than the argument in us.

-t, --trace [file]

Save the stopped trace to [file|timerlat_trace.txt].

  • --dma-latency us

    Set the /dev/cpu_dma_latency to us, aiming to bound exit from idle latencies. cyclictest sets this value to 0 by default, use --dma-latency 0 to have similar results.

  • --deepest-idle-state n

    Disable idle states higher than n for cpus that are running timerlat threads to reduce exit from idle latencies. If n is -1, all idle states are disabled. On exit from timerlat, the idle state setting is restored to its original state before running timerlat.

    Requires rtla to be built with libcpupower.

-k, --kernel-threads

Use timerlat kernel-space threads, in contrast of -u.

-u, --user-threads

Set timerlat to run without a workload, and then dispatches user-space workloads to wait on the timerlat_fd. Once the workload is awakened, it goes to sleep again adding so the measurement for the kernel-to-user and user-to-kernel to the tracer output. --user-threads will be used unless the user specify -k.

-U, --user-load

Set timerlat to run without workload, waiting for the user to dispatch a per-cpu task that waits for a new period on the tracing/osnoise/per_cpu/cpu$ID/timerlat_fd. See linux/tools/rtla/example/timerlat_load.py for an example of user-load code.

--bpf-action bpf-program

Loads a BPF program from an ELF file and executes it when a latency threshold is exceeded.

The BPF program must be a valid ELF file loadable with libbpf. The program must contain a function named action_handler, stored in an ELF section with the tp_ prefix. The prefix is used by libbpf to set BPF program type to BPF_PROG_TYPE_TRACEPOINT.

The program receives a struct trace_event_raw_timerlat_sample parameter containing timerlat sample data.

An example is provided in tools/tracing/rtla/example/timerlat_bpf_action.c. This example demonstrates how to create a BPF program that prints latency information using bpf_trace_printk() when a threshold is exceeded.

Note: BPF actions require BPF support to be available. If BPF is not available or disabled, the tool falls back to tracefs mode and BPF actions are not supported.

-q, --quiet

Print only a summary at the end of the session.

-c, --cpus cpu-list

Set the timerlat top tracer to run the sample threads in the cpu-list.

By default, the timerlat top tracer runs the sample threads on all CPUs.

-H, --house-keeping cpu-list

Run rtla control threads only on the given cpu-list.

If omitted, rtla will attempt to auto-migrate its main thread to any CPU that is not running any workload threads.

-d, --duration time[s|m|h|d]

Set the duration of the session.

-D, --debug

Print debug info.

-e, --event sys:event

Enable an event in the trace (-t) session. The argument can be a specific event, e.g., -e sched:sched_switch, or all events of a system group, e.g., -e sched. Multiple -e are allowed. It is only active when -t or -a are set.

--filter <filter>

Filter the previous -e sys:event event with <filter>. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.

  • --trigger <trigger>

    Enable a trace event trigger to the previous -e sys:event. If the hist: trigger is activated, the output histogram will be automatically saved to a file named system_event_hist.txt. For example, the command:

    rtla <command> <mode> -t -e osnoise:irq_noise --trigger="hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount"

    Will automatically save the content of the histogram associated to osnoise:irq_noise event in osnoise_irq_noise_hist.txt.

    For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.

-P, --priority o:prio|r:prio|f:prio|d:runtime:period

Set scheduling parameters to the timerlat top tracer threads, the format to set the priority are:

  • o:prio - use SCHED_OTHER with prio;

  • r:prio - use SCHED_RR with prio;

  • f:prio - use SCHED_FIFO with prio;

  • d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period in nanoseconds.

If not set, tracer threads keep their default priority. For rtla user threads, it is set to SCHED_FIFO with priority 95. For kernel threads, see osnoise and timerlat tracer documentation for the running kernel version.

-C, --cgroup [cgroup]

Set a cgroup to the tracer's threads. If the -C option is passed without arguments, the tracer's thread will inherit rtla's cgroup. Otherwise, the threads will be placed on the cgroup passed to the option.

If not set, the behavior differs between workload types. User workloads created by rtla will inherit rtla's cgroup. Kernel workloads are assigned the root cgroup.

--warm-up s

After starting the workload, let it run for s seconds before starting collecting the data, allowing the system to warm-up. Statistical data generated during warm-up is discarded.

  • --trace-buffer-size kB

    Set the per-cpu trace buffer size in kB for the tracing output.

    If not set, the default tracefs buffer size is used.

--on-threshold action

Defines an action to be executed when tracing is stopped on a latency threshold specified by -a/--auto, -i/--irq, or -T/--thread.

Multiple --on-threshold actions may be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

Supported actions are:

  • trace[,file=<filename>]

    Saves trace output, optionally taking a filename. Alternative to -t/--trace. Note that unlike -t/--trace, specifying this multiple times will result in the trace being saved multiple times.

  • signal,num=<sig>,pid=<pid>

    Sends signal to process. "parent" might be specified in place of pid to target the parent process of rtla.

  • shell,command=<command>

    Execute shell command.

  • continue

    Continue tracing after actions are executed instead of stopping.

Example:

$ rtla timerlat top -T 20 --on-threshold trace --on-threshold shell,command="grep ipi_send timerlat_trace.txt" --on-threshold signal,num=2,pid=parent

This will save a trace with the default filename "timerlat_trace.txt", print its lines that contain the text "ipi_send" on standard output, and send signal 2 (SIGINT) to the parent process.

Performance Considerations:

For time-sensitive actions, it is recommended to run rtla timerlat with BPF support and RT priority. Note that due to implementational limitations, actions might be delayed up to one second after tracing is stopped if BPF mode is not available or disabled.

--on-end action

Defines an action to be executed at the end of tracing.

Multiple --on-end actions can be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.

See the documentation for --on-threshold for the list of supported actions, with the exception that continue has no effect.

Example:

$ rtla timerlat top -d 5s --on-end trace

This runs rtla with the default options, and saves trace output at the end.

-h, --help

Print help menu.

--dump-tasks

prints the task running on all CPUs if stop conditions are met (depends on !--no-aa)

--no-aa

disable auto-analysis, reducing rtla timerlat cpu usage

--aa-only us

Set stop tracing conditions and run without collecting and displaying statistics. Print the auto-analysis if the system hits the stop tracing condition. This option is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of collecting the statistics.

EXAMPLE #

In the example below, the timerlat tracer is dispatched in cpus 1-23 in the automatic trace mode, instructing the tracer to stop if a 40 us latency or higher is found:

# timerlat -a 40 -c 1-23 -q
                                   Timer Latency
  0 00:00:12   |          IRQ Timer Latency (us)        |         Thread Timer Latency (us)
CPU COUNT      |      cur       min       avg       max |      cur       min       avg       max
  1 #12322     |        0         0         1        15 |       10         3         9        31
  2 #12322     |        3         0         1        12 |       10         3         9        23
  3 #12322     |        1         0         1        21 |        8         2         8        34
  4 #12322     |        1         0         1        17 |       10         2        11        33
  5 #12322     |        0         0         1        12 |        8         3         8        25
  6 #12322     |        1         0         1        14 |       16         3        11        35
  7 #12322     |        0         0         1        14 |        9         2         8        29
  8 #12322     |        1         0         1        22 |        9         3         9        34
  9 #12322     |        0         0         1        14 |        8         2         8        24
 10 #12322     |        1         0         0        12 |        9         3         8        24
 11 #12322     |        0         0         0        15 |        6         2         7        29
 12 #12321     |        1         0         0        13 |        5         3         8        23
 13 #12319     |        0         0         1        14 |        9         3         9        26
 14 #12321     |        1         0         0        13 |        6         2         8        24
 15 #12321     |        1         0         1        15 |       12         3        11        27
 16 #12318     |        0         0         1        13 |        7         3        10        24
 17 #12319     |        0         0         1        13 |       11         3         9        25
 18 #12318     |        0         0         0        12 |        8         2         8        20
 19 #12319     |        0         0         1        18 |       10         2         9        28
 20 #12317     |        0         0         0        20 |        9         3         8        34
 21 #12318     |        0         0         0        13 |        8         3         8        28
 22 #12319     |        0         0         1        11 |        8         3        10        22
 23 #12320     |       28         0         1        28 |       41         3        11        41
rtla timerlat hit stop tracing
## CPU 23 hit stop tracing, analyzing it ##
IRQ handler delay:                                        27.49 us (65.52 %)
IRQ latency:                                              28.13 us
Timerlat IRQ duration:                                     9.59 us (22.85 %)
Blocking thread:                                           3.79 us (9.03 %)
                       objtool:49256                       3.79 us
  Blocking thread stacktrace
              -> timerlat_irq
              -> __hrtimer_run_queues
              -> hrtimer_interrupt
              -> __sysvec_apic_timer_interrupt
              -> sysvec_apic_timer_interrupt
              -> asm_sysvec_apic_timer_interrupt
              -> _raw_spin_unlock_irqrestore
              -> cgroup_rstat_flush_locked
              -> cgroup_rstat_flush_irqsafe
              -> mem_cgroup_flush_stats
              -> mem_cgroup_wb_stats
              -> balance_dirty_pages
              -> balance_dirty_pages_ratelimited_flags
              -> btrfs_buffered_write
              -> btrfs_do_write_iter
              -> vfs_write
              -> __x64_sys_pwrite64
              -> do_syscall_64
              -> entry_SYSCALL_64_after_hwframe
------------------------------------------------------------------------
  Thread latency:                                          41.96 us (100%)

The system has exit from idle latency!
  Max timerlat IRQ latency from idle: 17.48 us in cpu 4
Saving trace to timerlat_trace.txt

In this case, the major factor was the delay suffered by the IRQ handler that handles timerlat wakeup: 65.52%. This can be caused by the current thread masking interrupts, which can be seen in the blocking thread stacktrace: the current thread (objtool:49256) disabled interrupts via raw spin lock operations inside mem cgroup, while doing write syscall in a btrfs file system.

The raw trace is saved in the timerlat_trace.txt file for further analysis.

Note that rtla timerlat was dispatched without changing timerlat tracer threads' priority. That is generally not needed because these threads have priority FIFO:95 by default, which is a common priority used by real-time kernel developers to analyze scheduling delays.

SEE ALSO #

rtla-timerlat(1), rtla-timerlat-hist(1)

timerlat tracer documentation: <https://www.kernel.org/doc/html/latest/trace/timerlat-tracer.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

EXIT STATUS #

0  Passed: the test did not hit the stop tracing condition
1  Error: invalid argument
2  Failed: the test hit the stop tracing condition

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rtla is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rtla-timerlat

Peios Kernel / Administration / Tools / rtla

Measures the operating system timer latency #

Manual section: 1

SYNOPSIS #

rtla timerlat [MODE] ...

DESCRIPTION #

The rtla timerlat tool is an interface for the timerlat tracer. The timerlat tracer dispatches a kernel thread per-cpu. These threads set a periodic timer to wake themselves up and go back to sleep. After the wakeup, they collect and generate useful information for the debugging of operating system timer latency.

The timerlat tracer outputs information in two ways. It periodically prints the timer latency at the timer IRQ handler and the Thread handler. It also enables the trace of the most relevant information via osnoise: tracepoints.

The rtla timerlat tool sets the options of the timerlat tracer and collects and displays a summary of the results. By default, the collection is done synchronously in kernel space using a dedicated BPF program attached to the timerlat tracer. If either BPF or the osnoise:timerlat_sample tracepoint it attaches to is unavailable, the rtla timerlat tool falls back to using tracefs to process the data asynchronously in user space.

The rtla timerlat top mode displays a summary of the periodic output from the timerlat tracer. The rtla timerlat hist mode displays a histogram of each tracer event occurrence. For further details, please refer to the respective man page.

MODES #

top

Prints the summary from timerlat tracer.

hist

Prints a histogram of timerlat samples.

If no MODE is given, the top mode is called, passing the arguments.

OPTIONS #

-h, --help

Display the help text.

For other options, see the man page for the corresponding mode.

SEE ALSO #

rtla-timerlat-top(1), rtla-timerlat-hist(1)

timerlat tracer documentation: <https://www.kernel.org/doc/html/latest/trace/timerlat-tracer.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

EXIT STATUS #

0  Passed: the test did not hit the stop tracing condition
1  Error: invalid argument
2  Failed: the test hit the stop tracing condition

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rtla is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rtla

Peios Kernel / Administration / Tools / rtla

Real-time Linux Analysis tool #

Manual section: 1

SYNOPSIS #

rtla COMMAND [OPTIONS]

DESCRIPTION #

The rtla is a meta-tool that includes a set of commands that aims to analyze the real-time properties of Linux. But instead of testing Linux as a black box, rtla leverages kernel tracing capabilities to provide precise information about the properties and root causes of unexpected results.

COMMANDS #

osnoise

Gives information about the operating system noise (osnoise).

timerlat

Measures the IRQ and thread timer latency.

OPTIONS #

-h, --help

Display the help text.

For other options, see the man page for the corresponding command.

SEE ALSO #

rtla-osnoise(1), rtla-timerlat(1)

AUTHOR #

Daniel Bristot de Oliveira <bristot@kernel.org>

EXIT STATUS #

0  Passed: the test did not hit the stop tracing condition
1  Error: invalid argument
2  Failed: the test hit the stop tracing condition

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rtla is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

Runtime verification (rv) tool

Peios Kernel / Administration / Tools / rv

rv tool provides the interface for a collection of runtime verification (rv) monitors.

  • rv
  • rv-list
  • rv-mon
  • rv-mon-wip
  • rv-mon-wwnr
  • rv-mon-sched

REPORTING BUGS

Peios Kernel / Administration / Tools / rv

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rv is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2022 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rv-list

Peios Kernel / Administration / Tools / rv

List available monitors #

Manual section: 1

SYNOPSIS #

rv list [OPTIONS]

DESCRIPTION #

The rv list command prints all available monitors. These monitors can be enabled using the rv mon command.

OPTIONS #

-h, --help

Print help menu.

SEE ALSO #

rv(1), rv-mon(1)

Linux kernel RV documentation: <https://www.kernel.org/doc/html/latest/trace/rv/index.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rv is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2022 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rv-mon-sched

Peios Kernel / Administration / Tools / rv

Scheduler monitors collection #

Manual section: 1

SYNOPSIS #

rv mon sched [OPTIONS]

rv mon <NESTED_MONITOR> [OPTIONS]

rv mon sched:<NESTED_MONITOR> [OPTIONS]

DESCRIPTION #

The scheduler monitor collection is a container for several monitors to model the behaviour of the scheduler. Each monitor describes a specification that the scheduler should follow.

As a monitor container, it will enable all nested monitors and set them according to OPTIONS. Nevertheless nested monitors can also be activated independently both by name and by specifying sched: , e.g. to enable only monitor tss you can do any of:

# rv mon sched:tss

# rv mon tss

See kernel documentation for further information about this monitor: <https://docs.kernel.org/trace/rv/monitor_sched.html>

OPTIONS #

-h, --help

Print the monitor's options and the available reactors list.

-r, --reactor reactor

Enables the reactor. See -h for a list of available reactors.

-s, --self

When tracing (-t), also print the events that happened during the rv command itself. If the rv command itself generates too many events, the tool might get busy processing its own events only.

-t, --trace

Trace monitor's events and error.

-v, --verbose

Print debug messages.

NESTED MONITOR #

  • The available nested monitors are:

    • scpd: schedule called with preemption disabled

    • snep: schedule does not enable preempt

    • sncid: schedule not called with interrupt disabled

    • snroc: set non runnable on its own context

    • sco: scheduling context operations

    • tss: task switch while scheduling

SEE ALSO #

rv(1), rv-mon(1)

Linux kernel RV documentation: <https://www.kernel.org/doc/html/latest/trace/rv/index.html>

AUTHOR #

Written by Gabriele Monaco <gmonaco@redhat.com>

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rv is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2022 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rv-mon-wip

Peios Kernel / Administration / Tools / rv

Wakeup In Preemptive monitor #

Manual section: 1

SYNOPSIS #

rv mon wip [OPTIONS]

DESCRIPTION #

The wakeup in preemptive (wip) monitor is a sample per-cpu monitor that checks if the wakeup events always take place with preemption disabled.

See kernel documentation for further information about this monitor: <https://docs.kernel.org/trace/rv/monitor_wip.html>

OPTIONS #

-h, --help

Print the monitor's options and the available reactors list.

-r, --reactor reactor

Enables the reactor. See -h for a list of available reactors.

-s, --self

When tracing (-t), also print the events that happened during the rv command itself. If the rv command itself generates too many events, the tool might get busy processing its own events only.

-t, --trace

Trace monitor's events and error.

-v, --verbose

Print debug messages.

SEE ALSO #

rv(1), rv-mon(1)

Linux kernel RV documentation: <https://www.kernel.org/doc/html/latest/trace/rv/index.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rv is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2022 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rv-mon-wwnr

Peios Kernel / Administration / Tools / rv

Wakeup While Not Running monitor #

Manual section: 1

SYNOPSIS #

rv mon wip [OPTIONS]

DESCRIPTION #

The wakeup while not running (wwnr) is a per-task sample monitor.

See kernel documentation for further information about this monitor: <https://docs.kernel.org/trace/rv/monitor_wwnr.html>

OPTIONS #

-h, --help

Print the monitor's options and the available reactors list.

-r, --reactor reactor

Enables the reactor. See -h for a list of available reactors.

-s, --self

When tracing (-t), also print the events that happened during the rv command itself. If the rv command itself generates too many events, the tool might get busy processing its own events only.

-t, --trace

Trace monitor's events and error.

-v, --verbose

Print debug messages.

SEE ALSO #

rv(1), rv-mon(1)

Linux kernel RV documentation: <https://www.kernel.org/doc/html/latest/trace/rv/index.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rv is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2022 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rv-mon

Peios Kernel / Administration / Tools / rv

List available monitors #

Manual section: 1

SYNOPSIS #

rv mon [-h] monitor_name [-h] [MONITOR OPTIONS]

DESCRIPTION #

The rv mon command runs the monitor named monitor_name. Each monitor has its own set of options. The rv list command shows all available monitors.

OPTIONS #

-h, --help

Print help menu.

AVAILABLE MONITORS #

The rv tool provides the interface for a set of monitors. Use the rv list command to list all available monitors.

Each monitor has its own set of options. See man rv-mon-monitor_name for details about each specific monitor. Also, running rv mon monitor_name -h display the help menu with the available options.

SEE ALSO #

rv(1), rv-mon(1)

Linux kernel RV documentation: <https://www.kernel.org/doc/html/latest/trace/rv/index.html>

AUTHOR #

Written by Daniel Bristot de Oliveira <bristot@kernel.org>

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rv is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2022 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

rv

Peios Kernel / Administration / Tools / rv

Runtime Verification #

Manual section: 1

SYNOPSIS #

rv COMMAND [OPTIONS]

DESCRIPTION #

Runtime Verification (RV) is a lightweight (yet rigorous) method for formal verification with a practical approach for complex systems. Instead of relying on a fine-grained model of a system (e.g., a re-implementation a instruction level), RV works by analyzing the trace of the system's actual execution, comparing it against a formal specification of the system behavior.

The rv tool provides the interface for a collection of runtime verification (rv) monitors.

COMMANDS #

list

List all available monitors.

mon

Run monitor.

OPTIONS #

-h, --help

Display the help text.

For other options, see the man page for the corresponding command.

SEE ALSO #

rv-list(1), rv-mon(1)

Linux kernel RV documentation: <https://www.kernel.org/doc/html/latest/trace/rv/index.html>

AUTHOR #

Daniel Bristot de Oliveira <bristot@kernel.org>

REPORTING BUGS #

Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>

LICENSE #

rv is Free Software licensed under the GNU GPLv2

COPYING #

Copyright (C) 2022 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).

Peios Learn — documentation for Peios software.

Built with Trail.