01 Dec, 2020

1 commit

  • On powerpc, kprobe-direct.tc triggered FTRACE_WARN_ON() in
    ftrace_get_addr_new() followed by the below message:
    Bad trampoline accounting at: 000000004222522f (wake_up_process+0xc/0x20) (f0000001)

    The set of steps leading to this involved:
    - modprobe ftrace-direct-too
    - enable_probe
    - modprobe ftrace-direct
    - rmmod ftrace-direct
    Signed-off-by: Steven Rostedt (VMware)

    Naveen N. Rao
     

16 Oct, 2020

1 commit

  • Pull tracing updates from Steven Rostedt:
    "Updates for tracing and bootconfig:

    - Add support for "bool" type in synthetic events

    - Add per instance tracing for bootconfig

    - Support perf-style return probe ("SYMBOL%return") in kprobes and
    uprobes

    - Allow for kprobes to be enabled earlier in boot up

    - Added tracepoint helper function to allow testing if tracepoints
    are enabled in headers

    - Synthetic events can now have dynamic strings (variable length)

    - Various fixes and cleanups"

    * tag 'trace-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (58 commits)
    tracing: support "bool" type in synthetic trace events
    selftests/ftrace: Add test case for synthetic event syntax errors
    tracing: Handle synthetic event array field type checking correctly
    selftests/ftrace: Change synthetic event name for inter-event-combined test
    tracing: Add synthetic event error logging
    tracing: Check that the synthetic event and field names are legal
    tracing: Move is_good_name() from trace_probe.h to trace.h
    tracing: Don't show dynamic string internals in synthetic event description
    tracing: Fix some typos in comments
    tracing/boot: Add ftrace.instance.*.alloc_snapshot option
    tracing: Fix race in trace_open and buffer resize call
    tracing: Check return value of __create_val_fields() before using its result
    tracing: Fix synthetic print fmt check for use of __get_str()
    tracing: Remove a pointless assignment
    ftrace: ftrace_global_list is renamed to ftrace_ops_list
    ftrace: Format variable declarations of ftrace_allocate_records
    ftrace: Simplify the calculation of page number for ftrace_page->records
    ftrace: Simplify the dyn_ftrace->flags macro
    ftrace: Simplify the hash calculation
    ftrace: Use fls() to get the bits for dup_hash()
    ...

    Linus Torvalds
     

09 Oct, 2020

4 commits


03 Oct, 2020

1 commit

  • s/coorditate/coordinate/
    s/emty/empty/
    s/preeptive/preemptive/
    s/succes/success/
    s/carefule/careful/

    Link: https://lkml.kernel.org/r/20201002143126.2890-1-hqjagain@gmail.com

    Signed-off-by: Qiujun Huang
    Signed-off-by: Steven Rostedt (VMware)

    Qiujun Huang
     

30 Sep, 2020

1 commit

  • The first thing that the ftrace function callback helper functions should do
    is to check for recursion. Peter Zijlstra found that when
    "rcu_is_watching()" had its notrace removed, it caused perf function tracing
    to crash. This is because the call of rcu_is_watching() is tested before
    function recursion is checked and and if it is traced, it will cause an
    infinite recursion loop.

    rcu_is_watching() should still stay notrace, but to prevent this should
    never had crashed in the first place. The recursion prevention must be the
    first thing done in callback functions.

    Link: https://lore.kernel.org/r/20200929112541.GM2628@hirez.programming.kicks-ass.net

    Cc: stable@vger.kernel.org
    Cc: Paul McKenney
    Fixes: c68c0fa293417 ("ftrace: Have ftrace_ops_get_func() handle RCU and PER_CPU flags too")
    Acked-by: Peter Zijlstra (Intel)
    Reported-by: Peter Zijlstra (Intel)
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

22 Sep, 2020

1 commit


19 Sep, 2020

3 commits

  • Commit 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler")
    changed ctl_table.proc_handler to take a kernel pointer. Adjust the
    signature of ftrace_enable_sysctl to match ctl_table.proc_handler which
    fixes the following sparse warning:

    kernel/trace/ftrace.c:7544:43: warning: incorrect type in argument 3 (different address spaces)
    kernel/trace/ftrace.c:7544:43: expected void *
    kernel/trace/ftrace.c:7544:43: got void [noderef] __user *buffer

    Link: https://lkml.kernel.org/r/20200907093207.13540-1-tklauser@distanz.ch

    Fixes: 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler")
    Cc: Andrew Morton
    Cc: Ingo Molnar
    Cc: Christoph Hellwig
    Cc: Al Viro
    Signed-off-by: Tobias Klauser
    Signed-off-by: Steven Rostedt (VMware)

    Tobias Klauser
     
  • Add synchronize_rcu() after list_del_rcu() in
    ftrace_remove_trampoline_from_kallsyms() to protect readers of
    ftrace_ops_trampoline_list (in ftrace_get_trampoline_kallsym)
    which is used when kallsyms is read.

    Link: https://lkml.kernel.org/r/20200901091617.31837-1-adrian.hunter@intel.com

    Fixes: fc0ea795f53c8d ("ftrace: Add symbols for ftrace trampolines")
    Signed-off-by: Adrian Hunter
    Signed-off-by: Steven Rostedt (VMware)

    Adrian Hunter
     
  • Commit fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
    missed to remove ops from new ftrace_ops_trampoline_list in
    ftrace_startup() if ftrace_hash_ipmodify_enable() fails there. It may
    lead to BUG if such ops come from a module which may be removed.

    Moreover, the trampoline itself is not freed in this case.

    Fix it by calling ftrace_trampoline_free() during the rollback.

    Link: https://lkml.kernel.org/r/20200831122631.28057-1-mbenes@suse.cz

    Fixes: fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
    Fixes: f8b8be8a310a ("ftrace, kprobes: Support IPMODIFY flag to find IP modify conflict")
    Signed-off-by: Miroslav Benes
    Signed-off-by: Steven Rostedt (VMware)

    Miroslav Benes
     

08 Aug, 2020

1 commit

  • Pull tracing updates from Steven Rostedt:

    - The biggest news in that the tracing ring buffer can now time events
    that interrupted other ring buffer events.

    Before this change, if an interrupt came in while recording another
    event, and that interrupt also had an event, those events would all
    have the same time stamp as the event it interrupted.

    Now, with the new design, those events will have a unique time stamp
    and rightfully display the time for those events that were recorded
    while interrupting another event.

    - Bootconfig how has an "override" operator that lets the users have a
    default config, but then add options to override the default.

    - A fix was made to properly filter function graph tracing to the
    ftrace PIDs. This came in at the end of the -rc cycle, and needs to
    be backported.

    - Several clean ups, performance updates, and minor fixes as well.

    * tag 'trace-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (39 commits)
    tracing: Add trace_array_init_printk() to initialize instance trace_printk() buffers
    kprobes: Fix compiler warning for !CONFIG_KPROBES_ON_FTRACE
    tracing: Use trace_sched_process_free() instead of exit() for pid tracing
    bootconfig: Fix to find the initargs correctly
    Documentation: bootconfig: Add bootconfig override operator
    tools/bootconfig: Add testcases for value override operator
    lib/bootconfig: Add override operator support
    kprobes: Remove show_registers() function prototype
    tracing/uprobe: Remove dead code in trace_uprobe_register()
    kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler
    ftrace: Fix ftrace_trace_task return value
    tracepoint: Use __used attribute definitions from compiler_attributes.h
    tracepoint: Mark __tracepoint_string's __used
    trace : Have tracing buffer info use kvzalloc instead of kzalloc
    tracing: Remove outdated comment in stack handling
    ftrace: Do not let direct or IPMODIFY ftrace_ops be added to module and set trampolines
    ftrace: Setup correct FTRACE_FL_REGS flags for module
    tracing/hwlat: Honor the tracing_cpumask
    tracing/hwlat: Drop the duplicate assignment in start_kthread()
    tracing: Save one trace_event->type by using __TRACE_LAST_TYPE
    ...

    Linus Torvalds
     

05 Aug, 2020

1 commit

  • On exit, if a process is preempted after the trace_sched_process_exit()
    tracepoint but before the process is done exiting, then when it gets
    scheduled in, the function tracers will not filter it properly against the
    function tracing pid filters.

    That is because the function tracing pid filters hooks to the
    sched_process_exit() tracepoint to remove the exiting task's pid from the
    filter list. Because the filtering happens at the sched_switch tracepoint,
    when the exiting task schedules back in to finish up the exit, it will no
    longer be in the function pid filtering tables.

    This was noticeable in the notrace self tests on a preemptable kernel, as
    the tests would fail as it exits and preempted after being taken off the
    notrace filter table and on scheduling back in it would not be in the
    notrace list, and then the ending of the exit function would trace. The test
    detected this and would fail.

    Cc: stable@vger.kernel.org
    Cc: Namhyung Kim
    Fixes: 1e10486ffee0a ("ftrace: Add 'function-fork' trace option")
    Fixes: c37775d57830a ("tracing: Add infrastructure to allow set_event_pid to follow children"
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

04 Aug, 2020

1 commit

  • I was attempting to use pid filtering with function_graph, but it wasn't
    allowing anything to make it through. Turns out ftrace_trace_task
    returns false if ftrace_ignore_pid is not-empty, which isn't correct
    anymore. We're now setting it to FTRACE_PID_IGNORE if we need to ignore
    that pid, otherwise it's set to the pid (which is weird considering the
    name) or to FTRACE_PID_TRACE. Fix the check to check for !=
    FTRACE_PID_IGNORE. With this we can now use function_graph with pid
    filtering.

    Link: https://lkml.kernel.org/r/20200725005048.1790-1-josef@toxicpanda.com

    Fixes: 717e3f5ebc82 ("ftrace: Make function trace pid filtering a bit more exact")
    Signed-off-by: Josef Bacik
    Signed-off-by: Steven Rostedt (VMware)

    Josef Bacik
     

31 Jul, 2020

2 commits

  • When inserting a module, we find all ftrace_ops referencing it on the
    ftrace_ops_list. But FTRACE_OPS_FL_DIRECT and FTRACE_OPS_FL_IPMODIFY
    flags are special, and should not be set automatically. So warn and
    skip ftrace_ops that have these two flags set and adding new code.
    Also check if only one ftrace_ops references the module, in which case
    we can use a trampoline as an optimization.

    Link: https://lkml.kernel.org/r/20200728180554.65203-2-zhouchengming@bytedance.com

    Signed-off-by: Chengming Zhou
    Signed-off-by: Muchun Song
    Signed-off-by: Steven Rostedt (VMware)

    Chengming Zhou
     
  • When module loaded and enabled, we will use __ftrace_replace_code
    for module if any ftrace_ops referenced it found. But we will get
    wrong ftrace_addr for module rec in ftrace_get_addr_new, because
    rec->flags has not been setup correctly. It can cause the callback
    function of a ftrace_ops has FTRACE_OPS_FL_SAVE_REGS to be called
    with pt_regs set to NULL.
    So setup correct FTRACE_FL_REGS flags for rec when we call
    referenced_filters to find ftrace_ops references it.

    Link: https://lkml.kernel.org/r/20200728180554.65203-1-zhouchengming@bytedance.com

    Cc: stable@vger.kernel.org
    Fixes: 8c4f3c3fa9681 ("ftrace: Check module functions being traced on reload")
    Signed-off-by: Chengming Zhou
    Signed-off-by: Muchun Song
    Signed-off-by: Steven Rostedt (VMware)

    Chengming Zhou
     

02 Jul, 2020

1 commit


29 Jun, 2020

1 commit

  • If a direct hook is attached to a function that ftrace also has a function
    attached to it, then it is required that the ftrace_ops_list_func() is used
    to iterate over the registered ftrace callbacks. This will also include the
    direct ftrace_ops helper, that tells ftrace_regs_caller where to return to
    (the direct callback and not the function that called it).

    As this direct helper is only to handle the case of ftrace callbacks
    attached to the same function as the direct callback, the ftrace callback
    allocated trampolines (used to only call them), should never be used to
    return back to a direct callback.

    Only copy the portion of the ftrace_regs_caller that will return back to
    what called it, and not the portion that returns back to the direct caller.

    The direct ftrace_ops must then pick the ftrace_regs_caller builtin function
    as its own trampoline to ensure that it will never have one allocated for
    it (which would not include the handling of direct callbacks).

    Link: http://lkml.kernel.org/r/20200422162750.495903799@goodmis.org

    Cc: Peter Zijlstra
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

18 Jun, 2020

1 commit

  • During build compiler reports some 'false positive' warnings about
    variables {'seq_ops', 'filtered_pids', 'other_pids'} may be used
    uninitialized. This patch silences these warnings.
    Also delete some useless spaces

    Link: https://lkml.kernel.org/r/20200529141214.37648-1-pilgrimtao@gmail.com

    Signed-off-by: Kaitao Cheng
    Signed-off-by: Steven Rostedt (VMware)

    Kaitao Cheng
     

15 Jun, 2020

3 commits

  • Add perf text poke events for ftrace trampolines when created and when
    freed.

    There can be 3 text_poke events for ftrace trampolines:

    1. NULL -> trampoline
    By ftrace_update_trampoline() when !ops->trampoline
    Trampoline created

    2. [e.g. on x86] CALL rel32 -> CALL rel32
    By arch_ftrace_update_trampoline() when ops->trampoline and
    ops->flags & FTRACE_OPS_FL_ALLOC_TRAMP
    [e.g. on x86] via text_poke_bp() which generates text poke events
    Trampoline-called function target updated

    3. trampoline -> NULL
    By ftrace_trampoline_free() when ops->trampoline and
    ops->flags & FTRACE_OPS_FL_ALLOC_TRAMP
    Trampoline freed

    Signed-off-by: Adrian Hunter
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/20200512121922.8997-9-adrian.hunter@intel.com

    Adrian Hunter
     
  • Symbols are needed for tools to describe instruction addresses. Pages
    allocated for ftrace's purposes need symbols to be created for them.
    Add such symbols to be visible via perf ksymbol events.

    Signed-off-by: Adrian Hunter
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/20200512121922.8997-8-adrian.hunter@intel.com

    Adrian Hunter
     
  • Symbols are needed for tools to describe instruction addresses. Pages
    allocated for ftrace's purposes need symbols to be created for them.
    Add such symbols to be visible via /proc/kallsyms.

    Example on x86 with CONFIG_DYNAMIC_FTRACE=y

    # echo function > /sys/kernel/debug/tracing/current_tracer
    # cat /proc/kallsyms | grep '\[__builtin__ftrace\]'
    ffffffffc0238000 t ftrace_trampoline [__builtin__ftrace]

    Note: This patch adds "__builtin__ftrace" as a module name in /proc/kallsyms for
    symbols for pages allocated for ftrace's purposes, even though "__builtin__ftrace"
    is not a module.

    Signed-off-by: Adrian Hunter
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/20200512121922.8997-7-adrian.hunter@intel.com

    Adrian Hunter
     

10 Jun, 2020

2 commits

  • Pull tracing updates from Steven Rostedt:
    "No new features this release. Mostly clean ups, restructuring and
    documentation.

    - Have ftrace_bug() show ftrace errors before the WARN, as the WARN
    will reboot the box before the error messages are printed if
    panic_on_warn is set.

    - Have traceoff_on_warn disable tracing sooner (before prints)

    - Write a message to the trace buffer that its being disabled when
    disable_trace_on_warning() is set.

    - Separate out synthetic events from histogram code to let it be used
    by other parts of the kernel.

    - More documentation on histogram design.

    - Other small fixes and clean ups"

    * tag 'trace-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
    tracing: Remove obsolete PREEMPTIRQ_EVENTS kconfig option
    tracing/doc: Fix ascii-art in histogram-design.rst
    tracing: Add a trace print when traceoff_on_warning is triggered
    ftrace,bug: Improve traceoff_on_warn
    selftests/ftrace: Distinguish between hist and synthetic event checks
    tracing: Move synthetic events to a separate file
    tracing: Fix events.rst section numbering
    tracing/doc: Fix typos in histogram-design.rst
    tracing: Add hist_debug trace event files for histogram debugging
    tracing: Add histogram-design document
    tracing: Check state.disabled in synth event trace functions
    tracing/probe: reverse arguments to list_add
    tools/bootconfig: Add a summary of test cases and return error
    ftrace: show debugging information when panic_on_warn set

    Linus Torvalds
     
  • Patch series "Add log level to show_stack()", v3.

    Add log level argument to show_stack().

    Done in three stages:
    1. Introducing show_stack_loglvl() for every architecture
    2. Migrating old users with an explicit log level
    3. Renaming show_stack_loglvl() into show_stack()

    Justification:

    - It's a design mistake to move a business-logic decision into platform
    realization detail.

    - I have currently two patches sets that would benefit from this work:
    Removing console_loglevel jumps in sysrq driver [1] Hung task warning
    before panic [2] - suggested by Tetsuo (but he probably didn't realise
    what it would involve).

    - While doing (1), (2) the backtraces were adjusted to headers and other
    messages for each situation - so there won't be a situation when the
    backtrace is printed, but the headers are missing because they have
    lesser log level (or the reverse).

    - As the result in (2) plays with console_loglevel for kdb are removed.

    The least important for upstream, but maybe still worth to note that every
    company I've worked in so far had an off-list patch to print backtrace
    with the needed log level (but only for the architecture they cared
    about). If you have other ideas how you will benefit from show_stack()
    with a log level - please, reply to this cover letter.

    See also discussion on v1:
    https://lore.kernel.org/linux-riscv/20191106083538.z5nlpuf64cigxigh@pathway.suse.cz/

    This patch (of 50):

    print_ip_sym() needs to have a log level parameter to comply with other
    parts being printed. Otherwise, half of the expected backtrace would be
    printed and other may be missing with some logging level.

    The following callee(s) are using now the adjusted log level:
    - microblaze/unwind: the same level as headers & userspace unwind.
    Note that pr_debug()'s there are for debugging the unwinder itself.
    - nds32/traps: symbol addresses are printed with the same log level
    as backtrace headers.
    - lockdep: ip for locking issues is printed with the same log level
    as other part of the warning.
    - sched: ip where preemption was disabled is printed as error like
    the rest part of the message.
    - ftrace: bug reports are now consistent in the log level being used.

    Signed-off-by: Dmitry Safonov
    Signed-off-by: Andrew Morton
    Acked-by: Steven Rostedt (VMware)
    Cc: Albert Ou
    Cc: Ben Segall
    Cc: Dietmar Eggemann
    Cc: Greentime Hu
    Cc: Greg Kroah-Hartman
    Cc: Ingo Molnar
    Cc: James Hogan
    Cc: Juri Lelli
    Cc: Mel Gorman
    Cc: Michal Simek
    Cc: Palmer Dabbelt
    Cc: Paul Burton
    Cc: Paul Walmsley
    Cc: Peter Zijlstra
    Cc: Ralf Baechle
    Cc: Thomas Gleixner
    Cc: Vincent Chen
    Cc: Vincent Guittot
    Cc: Will Deacon
    Cc: Dmitry Safonov
    Cc: Dmitry Safonov
    Cc: Jiri Slaby
    Cc: Petr Mladek
    Cc: Sergey Senozhatsky
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Richard Henderson
    Cc: Vineet Gupta
    Cc: Russell King
    Cc: Catalin Marinas
    Cc: Aurelien Jacquiot
    Cc: Mark Salter
    Cc: Guo Ren
    Cc: Yoshinori Sato
    Cc: Brian Cain
    Cc: Fenghua Yu
    Cc: Tony Luck
    Cc: Geert Uytterhoeven
    Cc: Ley Foon Tan
    Cc: Jonas Bonn
    Cc: Stafford Horne
    Cc: Stefan Kristiansson
    Cc: Helge Deller
    Cc: "James E.J. Bottomley"
    Cc: Benjamin Herrenschmidt
    Cc: Michael Ellerman
    Cc: Paul Mackerras
    Cc: Christian Borntraeger
    Cc: Heiko Carstens
    Cc: Vasily Gorbik
    Cc: Rich Felker
    Cc: "David S. Miller"
    Cc: Anton Ivanov
    Cc: Jeff Dike
    Cc: Richard Weinberger
    Cc: Guan Xuetao
    Cc: Borislav Petkov
    Cc: "H. Peter Anvin"
    Cc: Chris Zankel
    Cc: Max Filippov
    Cc: Len Brown
    Cc: Pavel Machek
    Cc: "Rafael J. Wysocki"
    Cc: "Rafael J. Wysocki"
    Cc: Daniel Thompson
    Cc: Douglas Anderson
    Cc: Jason Wessel
    Link: http://lkml.kernel.org/r/20200418201944.482088-2-dima@arista.com
    Signed-off-by: Linus Torvalds

    Dmitry Safonov
     

20 May, 2020

1 commit

  • When an anomaly is detected in the function call modification
    code, ftrace_bug() is called to disable function tracing as well
    as give some warn and information that may help debug the problem.

    But currently, we call FTRACE_WARN_ON_ONCE() first in ftrace_bug(),
    so when panic_on_warn is set, we can't see the debugging information
    here. Call FTRACE_WARN_ON_ONCE() at the end of ftrace_bug() to ensure
    that the debugging information is displayed first.

    after this patch, the dmesg looks like:

    ------------[ ftrace bug ]------------
    ftrace failed to modify
    [] bcm2835_handle_irq+0x4/0x58
    actual: 1f:20:03:d5
    Setting ftrace call site to call ftrace function
    ftrace record flags: 80000001
    (1)
    expected tramp: ffff80001009d6f0
    ------------[ cut here ]------------
    WARNING: CPU: 2 PID: 1635 at kernel/trace/ftrace.c:2078 ftrace_bug+0x204/0x238
    Kernel panic - not syncing: panic_on_warn set ...
    CPU: 2 PID: 1635 Comm: sh Not tainted 5.7.0-rc5-00033-gb922183867f5 #14
    Hardware name: linux,dummy-virt (DT)
    Call trace:
    dump_backtrace+0x0/0x1b0
    show_stack+0x20/0x30
    dump_stack+0xc0/0x10c
    panic+0x16c/0x368
    __warn+0x120/0x160
    report_bug+0xc8/0x160
    bug_handler+0x28/0x98
    brk_handler+0x70/0xd0
    do_debug_exception+0xcc/0x1ac
    el1_sync_handler+0xe4/0x120
    el1_sync+0x7c/0x100
    ftrace_bug+0x204/0x238

    Link: https://lkml.kernel.org/r/20200515100828.7091-1-cj.chengjian@huawei.com

    Signed-off-by: Cheng Jian
    Signed-off-by: Steven Rostedt (VMware)

    Cheng Jian
     

19 May, 2020

1 commit


28 Apr, 2020

1 commit


23 Apr, 2020

1 commit

  • kmemleak reported the following:

    unreferenced object 0xffff90d47127a920 (size 32):
    comm "modprobe", pid 1766, jiffies 4294792031 (age 162.568s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 22 01 00 00 00 00 ad de ........".......
    00 78 12 a7 ff ff ff ff 00 00 b6 c0 ff ff ff ff .x..............
    backtrace:
    [] register_ftrace_direct+0xcb/0x3a0
    [] do_one_initcall+0x72/0x340
    [] do_init_module+0x5a/0x220
    [] load_module+0x2235/0x2550
    [] __do_sys_finit_module+0xc0/0x120
    [] do_syscall_64+0x60/0x230
    [] entry_SYSCALL_64_after_hwframe+0x49/0xb3

    The entry used to save the direct descriptor needs to be freed
    when unregistering.

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

06 Apr, 2020

1 commit

  • Pull tracing updates from Steven Rostedt:
    "New tracing features:

    - The ring buffer is no longer disabled when reading the trace file.

    The trace_pipe file was made to be used for live tracing and
    reading as it acted like the normal producer/consumer. As the trace
    file would not consume the data, the easy way of handling it was to
    just disable writes to the ring buffer.

    This came to a surprise to the BPF folks who complained about lost
    events due to reading. This is no longer an issue. If someone wants
    to keep the old disabling there's a new option "pause-on-trace"
    that can be set.

    - New set_ftrace_notrace_pid file. PIDs in this file will not be
    traced by the function tracer.

    Similar to set_ftrace_pid, which makes the function tracer only
    trace those tasks with PIDs in the file, the set_ftrace_notrace_pid
    does the reverse.

    - New set_event_notrace_pid file. PIDs in this file will cause events
    not to be traced if triggered by a task with a matching PID.

    Similar to the set_event_pid file but will not be traced. Note,
    sched_waking and sched_switch events may still be traced if one of
    the tasks referenced by those events contains a PID that is allowed
    to be traced.

    Tracing related features:

    - New bootconfig option, that is attached to the initrd file.

    If bootconfig is on the command line, then the initrd file is
    searched looking for a bootconfig appended at the end.

    - New GPU tracepoint infrastructure to help the gfx drivers to get
    off debugfs (acked by Greg Kroah-Hartman)

    And other minor updates and fixes"

    * tag 'trace-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (27 commits)
    tracing: Do not allocate buffer in trace_find_next_entry() in atomic
    tracing: Add documentation on set_ftrace_notrace_pid and set_event_notrace_pid
    selftests/ftrace: Add test to test new set_event_notrace_pid file
    selftests/ftrace: Add test to test new set_ftrace_notrace_pid file
    tracing: Create set_event_notrace_pid to not trace tasks
    ftrace: Create set_ftrace_notrace_pid to not trace tasks
    ftrace: Make function trace pid filtering a bit more exact
    ftrace/kprobe: Show the maxactive number on kprobe_events
    tracing: Have the document reflect that the trace file keeps tracing enabled
    ring-buffer/tracing: Have iterator acknowledge dropped events
    tracing: Do not disable tracing when reading the trace file
    ring-buffer: Do not disable recording when there is an iterator
    ring-buffer: Make resize disable per cpu buffer instead of total buffer
    ring-buffer: Optimize rb_iter_head_event()
    ring-buffer: Do not die if rb_iter_peek() fails more than thrice
    ring-buffer: Have rb_iter_head_event() handle concurrent writer
    ring-buffer: Add page_stamp to iterator for synchronization
    ring-buffer: Rename ring_buffer_read() to read_buffer_iter_advance()
    ring-buffer: Have ring_buffer_empty() not depend on tracing stopped
    tracing: Save off entry when peeking at next entry
    ...

    Linus Torvalds
     

28 Mar, 2020

3 commits

  • There's currently a way to select a task that should only have its events
    traced, but there's no way to select a task not to have itsevents traced.
    Add a set_event_notrace_pid file that acts the same as set_event_pid (and is
    also affected by event-fork), but the task pids in this file will not be
    traced even if they are listed in the set_event_pid file. This makes it easy
    for tools like trace-cmd to "hide" itself from beint traced by events when
    it is recording other tasks.

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • There's currently a way to select a task that should only be traced by
    functions, but there's no way to select a task not to be traced by the
    function tracer. Add a set_ftrace_notrace_pid file that acts the same as
    set_ftrace_pid (and is also affected by function-fork), but the task pids in
    this file will not be traced even if they are listed in the set_ftrace_pid
    file. This makes it easy for tools like trace-cmd to "hide" itself from the
    function tracer when it is recording other tasks.

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • The set_ftrace_pid file is used to filter function tracing to only trace
    tasks that are listed in that file. Instead of testing the pids listed in
    that file (it's a bitmask) at each function trace event, the logic is done
    via a sched_switch hook. A flag is set when the next task to run is in the
    list of pids in the set_ftrace_pid file. But the sched_switch hook is not at
    the exact location of when the task switches, and the flag gets set before
    the task to be traced actually runs. This leaves a residue of traced
    functions that do not belong to the pid that should be filtered on.

    By changing the logic slightly, where instead of having a boolean flag to
    test, record the pid that should be traced, with special values for not to
    trace and always trace. Then at each function call, a check will be made to
    see if the function should be ignored, or if the current pid matches the
    function that should be traced, and only trace if it matches (or if it has
    the special value to always trace).

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

11 Mar, 2020

1 commit

  • It appears that ip ranges can overlap so. In that case lookup_rec()
    returns whatever results it got last even if it found nothing in last
    searched page.

    This breaks an obscure livepatch late module patching usecase:
    - load livepatch
    - load the patched module
    - unload livepatch
    - try to load livepatch again

    To fix this return from lookup_rec() as soon as it found the record
    containing searched-for ip. This used to be this way prior lookup_rec()
    introduction.

    Link: http://lkml.kernel.org/r/20200306174317.21699-1-asavkov@redhat.com

    Cc: stable@vger.kernel.org
    Fixes: 7e16f581a817 ("ftrace: Separate out functionality from ftrace_location_range()")
    Signed-off-by: Artem Savkov
    Signed-off-by: Steven Rostedt (VMware)

    Artem Savkov
     

06 Feb, 2020

3 commits

  • As function_graph tracer can run when RCU is not "watching", it can not be
    protected by synchronize_rcu() it requires running a task on each CPU before
    it can be freed. Calling schedule_on_each_cpu(ftrace_sync) needs to be used.

    Link: https://lore.kernel.org/r/20200205131110.GT2935@paulmck-ThinkPad-P72

    Cc: stable@vger.kernel.org
    Fixes: b9b0c831bed26 ("ftrace: Convert graph filter to use hash tables")
    Reported-by: "Paul E. McKenney"
    Reviewed-by: Joel Fernandes (Google)
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • Fix following instances of sparse error
    kernel/trace/ftrace.c:5667:29: error: incompatible types in comparison
    kernel/trace/ftrace.c:5813:21: error: incompatible types in comparison
    kernel/trace/ftrace.c:5868:36: error: incompatible types in comparison
    kernel/trace/ftrace.c:5870:25: error: incompatible types in comparison

    Use rcu_dereference_protected to dereference the newly annotated pointer.

    Link: http://lkml.kernel.org/r/20200205055701.30195-1-frextrite@gmail.com

    Signed-off-by: Amol Grover
    Signed-off-by: Steven Rostedt (VMware)

    Amol Grover
     
  • Fix following instances of sparse error
    kernel/trace/ftrace.c:5664:29: error: incompatible types in comparison
    kernel/trace/ftrace.c:5785:21: error: incompatible types in comparison
    kernel/trace/ftrace.c:5864:36: error: incompatible types in comparison
    kernel/trace/ftrace.c:5866:25: error: incompatible types in comparison

    Use rcu_dereference_protected to access the __rcu annotated pointer.

    Link: http://lkml.kernel.org/r/20200201072703.17330-1-frextrite@gmail.com

    Reviewed-by: Joel Fernandes (Google)
    Signed-off-by: Amol Grover
    Signed-off-by: Steven Rostedt (VMware)

    Amol Grover
     

30 Jan, 2020

1 commit

  • if seq_file .next fuction does not change position index,
    read after some lseek can generate unexpected output.

    Without patch:
    # dd bs=4 skip=1 if=/sys/kernel/tracing/set_ftrace_pid
    dd: /sys/kernel/tracing/set_ftrace_pid: cannot skip to specified offset
    id
    no pid
    2+1 records in
    2+1 records out
    10 bytes copied, 0.000213285 s, 46.9 kB/s

    Notice the "id" followed by "no pid".

    With the patch:
    # dd bs=4 skip=1 if=/sys/kernel/tracing/set_ftrace_pid
    dd: /sys/kernel/tracing/set_ftrace_pid: cannot skip to specified offset
    id
    0+1 records in
    0+1 records out
    3 bytes copied, 0.000202112 s, 14.8 kB/s

    Notice that it only prints "id" and not the "no pid" afterward.

    Link: http://lkml.kernel.org/r/4f87c6ad-f114-30bb-8506-c32274ce2992@virtuozzo.com

    https://bugzilla.kernel.org/show_bug.cgi?id=206283
    Signed-off-by: Vasily Averin
    Signed-off-by: Steven Rostedt (VMware)

    Vasily Averin
     

25 Jan, 2020

1 commit

  • As warnings can trigger panics, especially when "panic_on_warn" is set,
    memory failure warnings can cause panics and fail fuzz testers that are
    stressing memory.

    Create a MEM_FAIL() macro to use instead of WARN() in the tracing code
    (perhaps this should be a kernel wide macro?), and use that for memory
    failure issues. This should stop failing fuzz tests due to warnings.

    Link: https://lore.kernel.org/r/CACT4Y+ZP-7np20GVRu3p+eZys9GPtbu+JpfV+HtsufAzvTgJrg@mail.gmail.com

    Suggested-by: Dmitry Vyukov
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

22 Jan, 2020

1 commit

  • This macro isn't used from commit cb7be3b2fc2c ("ftrace: remove
    daemon"). So no needs to keep it.

    Link: http://lkml.kernel.org/r/1579586063-44984-1-git-send-email-alex.shi@linux.alibaba.com

    Signed-off-by: Alex Shi
    Signed-off-by: Steven Rostedt (VMware)

    Alex Shi