Skip to content
Permalink
Beau-Belgrave/…
Switch branches/tags

Commits on Nov 4, 2021

  1. user_events: Add documentation file

    Add a documentation file about user_events with example code, etc.
    explaining how it may be used.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  2. user_events: Optimize writing events by only copying data once

    Pass iterator through to probes to allow copying data directly to the
    probe buffers instead of taking multiple copies. Enables eBPF user and
    raw iterator types out to programs for no-copy scenarios.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  3. user_events: Add self-test for perf_event integration

    Tests perf can be attached to and written out correctly. Ensures attach
    updates status bits in user programs.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  4. user_events: Add self-test for dynamic_events integration

    Tests matching deletes, creation of basic and complex types. Ensures
    common patterns work correctly when interacting with dynamic_events
    file.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  5. user_events: Add self-test for ftrace integration

    Tests basic functionality of registering/deregistering, status and
    writing data out via ftrace mechanisms within user_events.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  6. user_events: Add basic perf and eBPF support

    Adds support to write out user_event data to perf_probe/perf files as
    well as to any attached eBPF program.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  7. user_events: Handle matching arguments from dyn_events

    Ensures that when dynamic events requests a match with arguments that
    they match what is in the user_event.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  8. user_events: Add print_fmt generation support for basic types

    Addes print_fmt format generation for basic types that are supported for
    user processes. Only supports sizes that are the same on 32 and 64 bit.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  9. user_events: Add minimal support for trace_event into ftrace

    Minimal support for interacting with dynamic events, trace_event and
    ftrace. Core outline of flow between user process, ioctl and trace_event
    APIs.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021
  10. user_events: Add UABI header for user access to user_events

    Define the basic structs and ioctl commands that allow user processes to
    interact with user_events.
    
    Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
    Beau Belgrave authored and intel-lab-lkp committed Nov 4, 2021

Commits on Nov 2, 2021

  1. ftrace/samples: Add missing prototype for my_direct_func

    There's compilation fail reported kernel test robot for W=1 build:
    
      >> samples/ftrace/ftrace-direct-multi.c:8:6: warning: no previous
      prototype for function 'my_direct_func' [-Wmissing-prototypes]
         void my_direct_func(unsigned long ip)
    
    The inlined assembly is used outside function, so we can't make
    my_direct_func static and pass it as asm input argument.
    
    However my_tramp is already extern so I think there's no problem
    keeping my_direct_func extern as well and just add its prototype.
    
    Link: https://lkml.kernel.org/r/20211101153907.377668-1-jolsa@kernel.org
    
    Reported-by: kernel test robot <lkp@intel.com>
    Fixes: 5fae941 ("ftrace/samples: Add multi direct interface test module")
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Jiri Olsa authored and rostedt committed Nov 2, 2021
  2. tracing/selftests: Add tests for hist trigger expression parsing

    Add tests for the parsing of hist trigger expressions; and to
    validate expression evaluation.
    
    Link: https://lkml.kernel.org/r/20211029183339.3216491-5-kaleshsingh@google.com
    
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Nov 2, 2021
  3. tracing/histogram: Document hist trigger variables

    Update the tracefs README to describe how hist trigger variables
    can be created.
    
    Link: https://lkml.kernel.org/r/20211029183339.3216491-4-kaleshsingh@google.com
    
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Nov 2, 2021
  4. tracing/histogram: Update division by 0 documentation

    If the divisor is a constant and zero, the undeifned case can be
    detected and an error returned instead of -1.
    
    Link: https://lkml.kernel.org/r/20211029183339.3216491-3-kaleshsingh@google.com
    
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Nov 2, 2021
  5. tracing/histogram: Optimize division by constants

    If the divisor is a constant use specific division functions to
    avoid extra branches when the trigger is hit.
    
    If the divisor constant but not a power of 2, the division can be
    replaced with a multiplication and shift in the following case:
    
    Let X = dividend and Y = divisor.
    
    Choose Z = some power of 2. If Y <= Z, then:
        X / Y = (X * (Z / Y)) / Z
    
    (Z / Y) is a constant (mult) which is calculated at parse time, so:
        X / Y = (X * mult) / Z
    
    The division by Z can be replaced by a shift since Z is a power of 2:
        X / Y = (X * mult) >> shift
    
    As long, as X < Z the results will not be off by more than 1.
    
    Link: https://lkml.kernel.org/r/20211029232410.3494196-1-kaleshsingh@google.com
    
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Nov 2, 2021

Commits on Nov 1, 2021

  1. tracing/osnoise: Remove PREEMPT_RT ifdefs from inside functions

    Remove CONFIG_PREEMPT_RT from inside functions, avoiding
    compilation problems in the future.
    
    Link: https://lkml.kernel.org/r/37ee0881b033cdc513efc84ebea26cf77880c8c2.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021
  2. tracing/osnoise: Remove STACKTRACE ifdefs from inside functions

    Remove CONFIG_STACKTRACE from inside functions, avoiding
    compilation problems in the future.
    
    Link: https://lkml.kernel.org/r/3465cca2f28e1ba602a1fc8bdb28d12950b5226e.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021
  3. tracing/osnoise: Allow multiple instances of the same tracer

    Currently, the user can start only one instance of timerlat/osnoise
    tracers and the tracers cannot run in parallel.
    
    As starting point to add more flexibility, let's allow the same tracer to
    run on different trace instances. The workload will start when the first
    trace_array (instance) is registered and stop when the last instance
    is unregistered.
    
    So, while this patch allows the same tracer to run in multiple
    instances (e.g., two instances running osnoise), it still does not allow
    instances of timerlat and osnoise in parallel (e.g., one timerlat and
    osnoise). That is because the osnoise: events have different behavior
    depending on which tracer is enabled (osnoise or timerlat). Enabling
    the parallel usage of these two tracers is in my TODO list.
    
    Link: https://lkml.kernel.org/r/38c8f14b613492a4f3f938d9d3bf0b063b72f0f0.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021
  4. tracing/osnoise: Remove TIMERLAT ifdefs from inside functions

    Remove CONFIG_TIMERLAT_TRACER from inside functions, avoiding
    compilation problems in the future.
    
    Link: https://lkml.kernel.org/r/8245abb5a112d249f5da6c1df499244ad9e647bc.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021
  5. tracing/osnoise: Support a list of trace_array *tr

    osnoise/timerlat were built to run a single instance, and for this,
    a single variable is enough to store the current struct trace_array
    *tr with information about the tracing instance. This is done via
    the *osnoise_trace variable. A trace_array represents a trace instance.
    
    In preparation to support multiple instances, replace the
    *osnoise_trace variable with an RCU protected list of instances.
    
    The operations that refer to an instance now propagate to all
    elements of the list (all instances).
    
    Also, replace the osnoise_busy variable with a check if the list
    has elements (busy).
    
    No functional change is expected with this patch, i.e., only one
    instance is allowed yet.
    
    Link: https://lkml.kernel.org/r/91d006e889b9a5d1ff258fe6077f021ae3f26372.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021
  6. tracing/osnoise: Use start/stop_per_cpu_kthreads() on osnoise_cpus_wr…

    …ite()
    
    When writing a new CPU mask via osnoise/cpus, if the tracer is running,
    the workload is restarted to follow the new cpumask. The restart is
    currently done using osnoise_workload_start/stop(), which disables the
    workload *and* the instrumentation. However, disabling the
    instrumentation is not necessary.
    
    Calling start/stop_per_cpu_kthreads() is enough to apply the new
    osnoise/cpus config.
    
    Link: https://lkml.kernel.org/r/ee633e82867c5b88851aa6040522a799c0034486.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021
  7. tracing/osnoise: Split workload start from the tracer start

    In preparation from supporting multiple trace instances, create
    workload start/stop specific functions.
    
    No functional change.
    
    Link: https://lkml.kernel.org/r/74b090971e9acdd13625be1c28ef3270d2275e77.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021
  8. tracing/osnoise: Improve comments about barrier need for NMI callbacks

    trace_osnoise_callback_enabled is used by ftrace_nmi_enter/exit()
    to know when to call the NMI callback. The barrier is used to
    avoid having callbacks enabled before the resetting date during
    the start or to touch the values after stopping the tracer.
    
    Link: https://lkml.kernel.org/r/a413b8f14aa9312fbd1ba99f96225a8aed831053.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021
  9. tracing/osnoise: Do not follow tracing_cpumask

    In preparation to support multiple instances, decouple the
    osnoise/timelat workload from instance-specific tracing_cpumask.
    
    Different instances can have conflicting cpumasks, making osnoise
    workload management needlessly complex. Osnoise already has its
    global cpumask.
    
    I also thought about using the first instance mask, but the
    "first" instance could be removed before the others.
    
    This also fixes the problem that changing the tracing_mask was not
    re-starting the trace.
    
    Link: https://lkml.kernel.org/r/169a71bcc919ce3ab53ae6f9ca5cde57fffaf9c6.1635702894.git.bristot@kernel.org
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Daniel Bristot de Oliveira authored and rostedt committed Nov 1, 2021

Commits on Oct 30, 2021

  1. tracing/histogram: Fix semicolon.cocci warnings

    kernel/trace/trace_events_hist.c:6039:2-3: Unneeded semicolon
    
     Remove unneeded semicolon.
    
    Generated by: scripts/coccinelle/misc/semicolon.cocci
    
    Link: https://lkml.kernel.org/r/20211030005615.GA41257@3074f0d39c61
    
    Fixes: c5eac6e ("tracing/histogram: Simplify handling of .sym-offset in expressions")
    CC: Kalesh Singh <kaleshsingh@google.com>
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    intel-lab-lkp authored and rostedt committed Oct 30, 2021

Commits on Oct 29, 2021

  1. tracing/histogram: Fix documentation inline emphasis warning

    This fixes the warning:
    
    Documentation/trace/histogram.rst:1766: WARNING: Inline emphasis
    start-string without end-string
    
    The issue was caused by an unescaped '*' character.
    
    Link: https://lore.kernel.org/all/20211028170548.2597449-1-kaleshsingh@google.com/T/#m77da47432f5cc6521d4294ffdb9621949cc35d04
    Link: https://lkml.kernel.org/r/20211028170548.2597449-1-kaleshsingh@google.com
    
    Fixes: 2d2f6d4 ("tracing/histogram: Document expression arithmetic and constants")
    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Oct 29, 2021

Commits on Oct 27, 2021

  1. tracing: Increase PERF_MAX_TRACE_SIZE to handle Sentinel1 and docker …

    …together
    
    Running endpoint security solutions like Sentinel1 that use perf-based
    tracing heavily lead to this repeated dump complaining about dockerd.
    The default value of 2048 is nowhere near not large enough.
    
    Using the prior patch "tracing: show size of requested buffer", we get
    "perf buffer not large enough, wanted 6644, have 6144", after repeated
    up-sizing (I did 2/4/6/8K). With 8K, the problem doesn't occur at all,
    so below is the trace for 6K.
    
    I'm wondering if this value should be selectable at boot time, but this
    is a good starting point.
    
    ```
    ------------[ cut here ]------------
    perf buffer not large enough, wanted 6644, have 6144
    WARNING: CPU: 1 PID: 4997 at kernel/trace/trace_event_perf.c:402 perf_trace_buf_alloc+0x8c/0xa0
    Modules linked in: [..]
    CPU: 1 PID: 4997 Comm: sh Tainted: G                T 5.13.13-x86_64-00039-gb3959163488e torvalds#63
    Hardware name: LENOVO 20KH002JUS/20KH002JUS, BIOS N23ET66W (1.41 ) 09/02/2019
    RIP: 0010:perf_trace_buf_alloc+0x8c/0xa0
    Code: 80 3d 43 97 d0 01 00 74 07 31 c0 5b 5d 41 5c c3 ba 00 18 00 00 89 ee 48 c7 c7 00 82 7d 91 c6 05 25 97 d0 01 01 e8 22 ee bc 00 <0f> 0b 31 c0 eb db 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 55 89
    RSP: 0018:ffffb922026b7d58 EFLAGS: 00010282
    RAX: 0000000000000000 RBX: ffff9da5ee012000 RCX: 0000000000000027
    RDX: ffff9da881657828 RSI: 0000000000000001 RDI: ffff9da881657820
    RBP: 00000000000019f4 R08: 0000000000000000 R09: ffffb922026b7b80
    R10: ffffb922026b7b78 R11: ffffffff91dda688 R12: 000000000000000f
    R13: ffff9da5ee012108 R14: ffff9da8816570a0 R15: ffffb922026b7e30
    FS:  00007f420db1a080(0000) GS:ffff9da881640000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000000000060 CR3: 00000002504a8006 CR4: 00000000003706e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     kprobe_perf_func+0x11e/0x270
     ? do_execveat_common.isra.0+0x1/0x1c0
     ? do_execveat_common.isra.0+0x5/0x1c0
     kprobe_ftrace_handler+0x10e/0x1d0
     0xffffffffc03aa0c8
     ? do_execveat_common.isra.0+0x1/0x1c0
     do_execveat_common.isra.0+0x5/0x1c0
     __x64_sys_execve+0x33/0x40
     do_syscall_64+0x6b/0xc0
     ? do_syscall_64+0x11/0xc0
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    RIP: 0033:0x7f420dc1db37
    Code: ff ff 76 e7 f7 d8 64 41 89 00 eb df 0f 1f 80 00 00 00 00 f7 d8 64 41 89 00 eb dc 0f 1f 84 00 00 00 00 00 b8 3b 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 01 43 0f 00 f7 d8 64 89 01 48
    RSP: 002b:00007ffd4e8b4e38 EFLAGS: 00000246 ORIG_RAX: 000000000000003b
    RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f420dc1db37
    RDX: 0000564338d1e740 RSI: 0000564338d32d50 RDI: 0000564338d28f00
    RBP: 0000564338d28f00 R08: 0000564338d32d50 R09: 0000000000000020
    R10: 00000000000001b6 R11: 0000000000000246 R12: 0000564338d28f00
    R13: 0000564338d32d50 R14: 0000564338d1e740 R15: 0000564338d28c60
    ---[ end trace 83ab3e8e16275e49 ]---
    ```
    
    Link: https://lkml.kernel.org/r/20210831043723.13481-2-robbat2@gentoo.org
    
    Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    robbat2 authored and rostedt committed Oct 27, 2021
  2. tracing: Show size of requested perf buffer

    If the perf buffer isn't large enough, provide a hint about how large it
    needs to be for whatever is running.
    
    Link: https://lkml.kernel.org/r/20210831043723.13481-1-robbat2@gentoo.org
    
    Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    robbat2 authored and rostedt committed Oct 27, 2021
  3. bootconfig: Initialize ret in xbc_parse_tree()

    The do while loop continues while ret is zero, but ret is never
    initialized. The check for ret in the loop at the while should always be
    initialized, but if an empty string were to be passed in, q would be NULL
    and p would be '\0', and it would break out of the loop without ever
    setting ret.
    
    Set ret to zero, and then xbc_verify_tree() would be called and catch that
    it is an empty tree and report the proper error.
    
    Link: https://lkml.kernel.org/r/20211027105753.6ab9da5f@gandalf.local.home
    
    Fixes: bdac5c2 ("bootconfig: Allocate xbc_data inside xbc_init()")
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: Andrew Morton <akpm@linux-foundation.org>
    Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    rostedt committed Oct 27, 2021
  4. ftrace: do CPU checking after preemption disabled

    With CONFIG_DEBUG_PREEMPT we observed reports like:
    
      BUG: using smp_processor_id() in preemptible
      caller is perf_ftrace_function_call+0x6f/0x2e0
      CPU: 1 PID: 680 Comm: a.out Not tainted
      Call Trace:
       <TASK>
       dump_stack_lvl+0x8d/0xcf
       check_preemption_disabled+0x104/0x110
       ? optimize_nops.isra.7+0x230/0x230
       ? text_poke_bp_batch+0x9f/0x310
       perf_ftrace_function_call+0x6f/0x2e0
       ...
       __text_poke+0x5/0x620
       text_poke_bp_batch+0x9f/0x310
    
    This telling us the CPU could be changed after task is preempted, and
    the checking on CPU before preemption will be invalid.
    
    Since now ftrace_test_recursion_trylock() will help to disable the
    preemption, this patch just do the checking after trylock() to address
    the issue.
    
    Link: https://lkml.kernel.org/r/54880691-5fe2-33e7-d12f-1fa6136f5183@linux.alibaba.com
    
    CC: Steven Rostedt <rostedt@goodmis.org>
    Cc: Guo Ren <guoren@kernel.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
    Cc: Helge Deller <deller@gmx.de>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Paul Walmsley <paul.walmsley@sifive.com>
    Cc: Palmer Dabbelt <palmer@dabbelt.com>
    Cc: Albert Ou <aou@eecs.berkeley.edu>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: Miroslav Benes <mbenes@suse.cz>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Joe Lawrence <joe.lawrence@redhat.com>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Jisheng Zhang <jszhang@kernel.org>
    Reported-by: Abaci <abaci@linux.alibaba.com>
    Signed-off-by: Michael Wang <yun.wang@linux.alibaba.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    wangyun2137 authored and rostedt committed Oct 27, 2021
  5. ftrace: disable preemption when recursion locked

    As the documentation explained, ftrace_test_recursion_trylock()
    and ftrace_test_recursion_unlock() were supposed to disable and
    enable preemption properly, however currently this work is done
    outside of the function, which could be missing by mistake.
    
    And since the internal using of trace_test_and_set_recursion()
    and trace_clear_recursion() also require preemption disabled, we
    can just merge the logical.
    
    This patch will make sure the preemption has been disabled when
    trace_test_and_set_recursion() return bit >= 0, and
    trace_clear_recursion() will enable the preemption if previously
    enabled.
    
    Link: https://lkml.kernel.org/r/13bde807-779c-aa4c-0672-20515ae365ea@linux.alibaba.com
    
    CC: Petr Mladek <pmladek@suse.com>
    Cc: Guo Ren <guoren@kernel.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
    Cc: Helge Deller <deller@gmx.de>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Paul Walmsley <paul.walmsley@sifive.com>
    Cc: Palmer Dabbelt <palmer@dabbelt.com>
    Cc: Albert Ou <aou@eecs.berkeley.edu>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: Joe Lawrence <joe.lawrence@redhat.com>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Jisheng Zhang <jszhang@kernel.org>
    CC: Steven Rostedt <rostedt@goodmis.org>
    CC: Miroslav Benes <mbenes@suse.cz>
    Reported-by: Abaci <abaci@linux.alibaba.com>
    Suggested-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Michael Wang <yun.wang@linux.alibaba.com>
    [ Removed extra line in comment - SDR ]
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    wangyun2137 authored and rostedt committed Oct 27, 2021
  6. tracing/histogram: Document expression arithmetic and constants

    Histogram expressions now support division, and multiplication in
    addition to the already supported subtraction and addition operators.
    
    Numeric constants can also be used in a hist trigger expressions
    or assigned to a variable and used by refernce in an expression.
    
    Link: https://lkml.kernel.org/r/20211025200852.3002369-9-kaleshsingh@google.com
    
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Reviewed-by: Namhyung Kim <namhyung@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Oct 27, 2021
  7. tracing/histogram: Optimize division by a power of 2

    The division is a slow operation. If the divisor is a power of 2, use a
    shift instead.
    
    Results were obtained using Android's version of perf (simpleperf[1]) as
    described below:
    
    1. hist_field_div() is modified to call 2 test functions:
       test_hist_field_div_[not]_optimized(); passing them the
       same args. Use noinline and volatile to ensure these are
       not optimized out by the compiler.
    2. Create a hist event trigger that uses division:
          events/kmem/rss_stat$ echo 'hist:keys=common_pid:x=size/<divisor>'
             >> trigger
          events/kmem/rss_stat$ echo 'hist:keys=common_pid:vals=$x'
             >> trigger
    3. Run Android's lmkd_test[2] to generate rss_stat events, and
       record CPU samples with Android's simpleperf:
          simpleperf record -a --exclude-perf --post-unwind=yes -m 16384 -g
             -f 2000 -o perf.data
    
    == Results ==
    
    Divisor is a power of 2 (divisor == 32):
    
       test_hist_field_div_not_optimized  | 8,717,091 cpu-cycles
       test_hist_field_div_optimized      | 1,643,137 cpu-cycles
    
    If the divisor is a power of 2, the optimized version is ~5.3x faster.
    
    Divisor is not a power of 2 (divisor == 33):
    
       test_hist_field_div_not_optimized  | 4,444,324 cpu-cycles
       test_hist_field_div_optimized      | 5,497,958 cpu-cycles
    
    If the divisor is not a power of 2, as expected, the optimized version is
    slightly slower (~24% slower).
    
    [1] https://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/README.md
    [2] https://cs.android.com/android/platform/superproject/+/master:system/memory/lmkd/tests/lmkd_test.cpp
    
    Link: https://lkml.kernel.org/r/20211025200852.3002369-7-kaleshsingh@google.com
    
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Oct 27, 2021
  8. tracing/histogram: Covert expr to const if both operands are constants

    If both operands of a hist trigger expression are constants, convert the
    expression to a constant. This optimization avoids having to perform the
    same calculation multiple times and also saves on memory since the
    merged constants are represented by a single struct hist_field instead
    or multiple.
    
    Link: https://lkml.kernel.org/r/20211025200852.3002369-6-kaleshsingh@google.com
    
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Oct 27, 2021
  9. tracing/histogram: Simplify handling of .sym-offset in expressions

    The '-' in .sym-offset can confuse the hist trigger arithmetic
    expression parsing. Simplify the handling of this by replacing the
    'sym-offset' with 'symXoffset'. This allows us to correctly evaluate
    expressions where the user may have inadvertently added a .sym-offset
    modifier to one of the operands in an expression, instead of bailing
    out. In this case the .sym-offset has no effect on the evaluation of the
    expression. The only valid use of the .sym-offset is as a hist key
    modifier.
    
    Link: https://lkml.kernel.org/r/20211025200852.3002369-5-kaleshsingh@google.com
    
    Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Kalesh Singh authored and rostedt committed Oct 27, 2021
Older