Commit 9e1e9d66 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull RTLA updates from Steven Rostedt:

 - Simplify option parsing

   Auto-generate getopt_long() optstring for short options from long
   options array, avoiding the need to specify it manually and reducing
   the surface for mistakes.

 - Add unit tests

   Implement unit tests (make unit-tests) using libcheck, next to
   existing runtime tests (make check). Currently, three functions from
   utils.c are tested.

 - Add --stack-format option

   In addition to stopping stack pointer decoding (with -s/--stack
   option) on first unresolvable pointer, allow also skipping
   unresolvable pointers and displaying everything, configurable with a
   new option.

 - Unify number of CPUs into one global variable

   Use one global variable, nr_cpus, to store the number of CPUs instead
   of retrieving it and passing it at multiple places.

 - Fix behavior in various corner cases

   Make RTLA behave correctly in several corner cases: memory allocation
   failure, invalid value read from kernel side, thread creation
   failure, malformed time value input, and read/write failure or
   interruption by signal.

 - Improve string handling

   Simplify several places in the code that handle strings, including
   parsing of action arguments. A few new helper functions and variables
   are added for that purpose.

 - Get rid of magic numbers

   Few places handling paths use a magic number of 1024. Replace it with
   MAX_PATH and ARRAY_SIZE() macro.

 - Unify threshold handling

   Code that handles response to latency threshold is duplicated between
   tools, which has led to bugs in the past. Unify it into a new helper
   as much as possible.

 - Fix segfault on SIGINT during cleanup

   The SIGINT handler touches dynamically allocated memory. Detach it
   before freeing it during cleanup to prevent segmentation fault and
   discarding of output buffers. Also, properly document SIGINT handling
   while at it.

* tag 'trace-rtla-v7.1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (28 commits)
  Documentation/rtla: Document SIGINT behavior
  rtla: Fix segfault on multiple SIGINTs
  rtla/utils: Fix loop condition in PID validation
  rtla/utils: Fix resource leak in set_comm_sched_attr()
  rtla/trace: Fix I/O handling in save_trace_to_file()
  rtla/trace: Fix write loop in trace_event_save_hist()
  rtla/timerlat: Simplify RTLA_NO_BPF environment variable check
  rtla: Use str_has_prefix() for option prefix check
  rtla: Enforce exact match for time unit suffixes
  rtla: Use str_has_prefix() for prefix checks
  rtla: Add str_has_prefix() helper function
  rtla: Handle pthread_create() failure properly
  rtla/timerlat: Add bounds check for softirq vector
  rtla: Simplify code by caching string lengths
  rtla: Replace magic number with MAX_PATH
  rtla: Introduce common_threshold_handler() helper
  rtla/actions: Simplify argument parsing
  rtla: Use strdup() to simplify code
  rtla: Exit on memory allocation failures during initialization
  tools/rtla: Remove unneeded nr_cpus from for_each_monitored_cpu
  ...
parents fdbfee9f 82374995
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
.. 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
===========

+12 −0
Original line number Diff line number Diff line
@@ -83,3 +83,15 @@

        **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.

**--stack-format** *format*

        Adjust the format of the stack trace printed during auto-analysis.

        The supported values for *format* are:

        * **truncate**    Print the stack trace up to the first unknown address (default).
        * **skip**        Skip unknown addresses.
        * **full**        Print the entire stack trace, including unknown addresses.

        For unknown addresses, the raw pointer is printed.
+3 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ FEATURE_TESTS_EXTRA := \
         hello                          \
         libbabeltrace                  \
         libcapstone                    \
         libcheck                       \
         libbfd-liberty                 \
         libbfd-liberty-z               \
         libopencsd                     \
@@ -176,6 +177,8 @@ ifneq ($(PKG_CONFIG),)
  $(foreach package,$(FEATURE_PKG_CONFIG),$(call feature_pkg_config,$(package)))
endif

FEATURE_CHECK_LDFLAGS-libcheck = -lcheck

# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
# If in the future we need per-feature checks/flags for features not
# mentioned in this list we need to refactor this ;-).
+4 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ FILES= \
         test-timerfd.bin                       \
         test-libbabeltrace.bin                 \
         test-libcapstone.bin			\
         test-libcheck.bin			\
         test-compile-32.bin                    \
         test-compile-x32.bin                   \
         test-zlib.bin                          \
@@ -307,6 +308,9 @@ $(OUTPUT)test-libbabeltrace.bin:
$(OUTPUT)test-libcapstone.bin:
	$(BUILD) # -lcapstone provided by $(FEATURE_CHECK_LDFLAGS-libcapstone)

$(OUTPUT)test-libcheck.bin:
	$(BUILD) # -lcheck is provided by $(FEATURE_CHECK_LDFLAGS-libcheck)

$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -Wall -Werror -o $@ test-compile.c

+8 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
#include <check.h>

int main(void)
{
	Suite *s = suite_create("test");
	return s == 0;
}
Loading