mirror of
https://github.com/torvalds/linux
synced 2026-07-22 02:00:44 +09:00
Instead of using getopt_long() directly to parse the command line
arguments given to an RTLA tool, use libsubcmd's parse_options().
Utilizing libsubcmd for parsing command line arguments has several
benefits:
- A help message is automatically generated by libsubcmd from the
specification, removing the need of writing it by hand.
- Options are sorted into groups based on which part of tracing (CPU,
thread, auto-analysis, tuning, histogram) they relate to.
- Common parsing patterns for numerical and boolean values now share
code, with the target variable being stored in the option array.
To avoid duplication of the option parsing logic, RTLA-specific
macros defining struct option values are created:
- RTLA_OPT_* for options common to all tools
- OSNOISE_OPT_* and TIMERLAT_OPT_* for options specific to
osnoise/timerlat tools
- HIST_OPT_* macros for options specific to histogram-based tools.
Individual *_parse_args() functions then construct an array out of
these macros that is then passed to libsubcmd's parse_options().
All code specific to command line options parsing is moved out of the
individual tool files into a new file, cli.c, which also contains the
contents of the rtla.c file. A private header, cli_p.h, is added
alongside the public header cli.h, so that unit tests are able to test
statically declared option callbacks.
Minor changes:
- The return value of tool-level help option changes to 129, as this is
the value set by libsubcmd; this is reflected in affected test cases.
The implementation of help for command-level and tracer-level help
is set to 129 as well for consistency, and the change is reflected in
exit value documentation.
- Related to the above, {rtla,osnoise,timerlat}_usage() are marked
__noreturn and exit() is removed from after they are called for
cleaner code.
- The error messages for invalid argument for options --dma-latency and
-E/--entries were corrected, fixing off-by-one in the limits.
Note that unsetting options (using --no-<opt> syntax) is currently not
implemented for options that use custom callbacks. For --irq and
--thread, it will never be implemented, as they conflict with already
existing --no-irq and --no-thread with a different meaning.
Assisted-by: Composer:composer-1.5
Link: https://lore.kernel.org/r/20260528103254.2990068-5-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
47 lines
1.5 KiB
Plaintext
47 lines
1.5 KiB
Plaintext
.. SPDX-License-Identifier: GPL-2.0
|
|
|
|
SIGINT BEHAVIOR
|
|
===============
|
|
|
|
On the first SIGINT, RTLA exits after collecting all outstanding samples up to
|
|
the point of receiving the signal.
|
|
|
|
When receiving more than one SIGINT, RTLA discards any outstanding samples, and
|
|
exits while displaying only samples that have already been processed.
|
|
|
|
If SIGINT is received during RTLA cleanup, RTLA exits immediately via
|
|
the default signal handler.
|
|
|
|
Note: For the purpose of SIGINT behavior, the expiry of duration specified via
|
|
the -d/--duration option is treated as equivalent to receiving a SIGINT. For
|
|
example, a SIGINT received after duration expired but samples have not been
|
|
processed yet will drop any outstanding samples.
|
|
|
|
Also note that when using the timerlat tool in BPF mode, samples are processed
|
|
in-kernel; RTLA only copies them out to display them to the user. A second
|
|
SIGINT does not affect in-kernel sample aggregation.
|
|
|
|
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
|
|
129 Help: either user requested help or incorrect option was specified
|
|
|
|
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).
|