09 Oct, 2020

2 commits

  • Fix the comment to comply with the code.

    Link: https://lkml.kernel.org/r/20200831031104.23322-7-richard.weiyang@linux.alibaba.com

    Signed-off-by: Wei Yang
    Signed-off-by: Steven Rostedt (VMware)

    Wei Yang
     
  • All the three macro are defined to be used for ftrace_rec_count(). This
    can be achieved by (flags & FTRACE_REF_MAX) directly.

    Since no other places would use those macros, remove them for clarity.

    Also it fixes a typo in the comment.

    Link: https://lkml.kernel.org/r/20200831031104.23322-4-richard.weiyang@linux.alibaba.com

    Signed-off-by: Wei Yang
    Signed-off-by: Steven Rostedt (VMware)

    Wei Yang
     

19 Sep, 2020

1 commit

  • 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
     

15 Jun, 2020

1 commit

  • 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
     

11 Jun, 2020

1 commit

  • Pull sysctl fixes from Al Viro:
    "Fixups to regressions in sysctl series"

    * 'work.sysctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    sysctl: reject gigantic reads/write to sysctl files
    cdrom: fix an incorrect __user annotation on cdrom_sysctl_info
    trace: fix an incorrect __user annotation on stack_trace_sysctl
    random: fix an incorrect __user annotation on proc_do_entropy
    net/sysctl: remove leftover __user annotations on neigh_proc_dointvec*
    net/sysctl: use cpumask_parse in flow_limit_cpu_sysctl

    Linus Torvalds
     

08 Jun, 2020

1 commit


16 May, 2020

1 commit


13 May, 2020

1 commit

  • Booting one of my machines, it triggered the following crash:

    Kernel/User page tables isolation: enabled
    ftrace: allocating 36577 entries in 143 pages
    Starting tracer 'function'
    BUG: unable to handle page fault for address: ffffffffa000005c
    #PF: supervisor write access in kernel mode
    #PF: error_code(0x0003) - permissions violation
    PGD 2014067 P4D 2014067 PUD 2015063 PMD 7b253067 PTE 7b252061
    Oops: 0003 [#1] PREEMPT SMP PTI
    CPU: 0 PID: 0 Comm: swapper Not tainted 5.4.0-test+ #24
    Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS SDBLI944.86P 05/08/2007
    RIP: 0010:text_poke_early+0x4a/0x58
    Code: 34 24 48 89 54 24 08 e8 bf 72 0b 00 48 8b 34 24 48 8b 4c 24 08 84 c0 74 0b 48 89 df f3 a4 48 83 c4 10 5b c3 9c 58 fa 48 89 df a4 50 9d 48 83 c4 10 5b e9 d6 f9 ff ff
    0 41 57 49
    RSP: 0000:ffffffff82003d38 EFLAGS: 00010046
    RAX: 0000000000000046 RBX: ffffffffa000005c RCX: 0000000000000005
    RDX: 0000000000000005 RSI: ffffffff825b9a90 RDI: ffffffffa000005c
    RBP: ffffffffa000005c R08: 0000000000000000 R09: ffffffff8206e6e0
    R10: ffff88807b01f4c0 R11: ffffffff8176c106 R12: ffffffff8206e6e0
    R13: ffffffff824f2440 R14: 0000000000000000 R15: ffffffff8206eac0
    FS: 0000000000000000(0000) GS:ffff88807d400000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffffffffa000005c CR3: 0000000002012000 CR4: 00000000000006b0
    Call Trace:
    text_poke_bp+0x27/0x64
    ? mutex_lock+0x36/0x5d
    arch_ftrace_update_trampoline+0x287/0x2d5
    ? ftrace_replace_code+0x14b/0x160
    ? ftrace_update_ftrace_func+0x65/0x6c
    __register_ftrace_function+0x6d/0x81
    ftrace_startup+0x23/0xc1
    register_ftrace_function+0x20/0x37
    func_set_flag+0x59/0x77
    __set_tracer_option.isra.19+0x20/0x3e
    trace_set_options+0xd6/0x13e
    apply_trace_boot_options+0x44/0x6d
    register_tracer+0x19e/0x1ac
    early_trace_init+0x21b/0x2c9
    start_kernel+0x241/0x518
    ? load_ucode_intel_bsp+0x21/0x52
    secondary_startup_64+0xa4/0xb0

    I was able to trigger it on other machines, when I added to the kernel
    command line of both "ftrace=function" and "trace_options=func_stack_trace".

    The cause is the "ftrace=function" would register the function tracer
    and create a trampoline, and it will set it as executable and
    read-only. Then the "trace_options=func_stack_trace" would then update
    the same trampoline to include the stack tracer version of the function
    tracer. But since the trampoline already exists, it updates it with
    text_poke_bp(). The problem is that text_poke_bp() called while
    system_state == SYSTEM_BOOTING, it will simply do a memcpy() and not
    the page mapping, as it would think that the text is still read-write.
    But in this case it is not, and we take a fault and crash.

    Instead, lets keep the ftrace trampolines read-write during boot up,
    and then when the kernel executable text is set to read-only, the
    ftrace trampolines get set to read-only as well.

    Link: https://lkml.kernel.org/r/20200430202147.4dc6e2de@oasis.local.home

    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Josh Poimboeuf
    Cc: "H. Peter Anvin"
    Cc: stable@vger.kernel.org
    Fixes: 768ae4406a5c ("x86/ftrace: Use text_poke()")
    Acked-by: Peter Zijlstra
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

27 Apr, 2020

1 commit

  • Instead of having all the sysctl handlers deal with user pointers, which
    is rather hairy in terms of the BPF interaction, copy the input to and
    from userspace in common code. This also means that the strings are
    always NUL-terminated by the common code, making the API a little bit
    safer.

    As most handler just pass through the data to one of the common handlers
    a lot of the changes are mechnical.

    Signed-off-by: Christoph Hellwig
    Acked-by: Andrey Ignatov
    Signed-off-by: Al Viro

    Christoph Hellwig
     

12 Dec, 2019

1 commit

  • Pull tracing fixes from Steven Rostedt:

    - Remove code I accidentally applied when doing a minor fix up to a
    patch, and then using "git commit -a --amend", which pulled in some
    other changes I was playing with.

    - Remove an used variable in trace_events_inject code

    - Fix function graph tracer when it traces a ftrace direct function.
    It will now ignore tracing a function that has a ftrace direct
    tramploine attached. This is needed for eBPF to use the ftrace direct
    code.

    * tag 'trace-v5.5-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
    ftrace: Fix function_graph tracer interaction with BPF trampoline
    tracing: remove set but not used variable 'buffer'
    module: Remove accidental change of module_enable_x()

    Linus Torvalds
     

11 Dec, 2019

1 commit

  • Depending on type of BPF programs served by BPF trampoline it can call original
    function. In such case the trampoline will skip one stack frame while
    returning. That will confuse function_graph tracer and will cause crashes with
    bad RIP. Teach graph tracer to skip functions that have BPF trampoline attached.

    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Steven Rostedt (VMware)

    Alexei Starovoitov
     

28 Nov, 2019

1 commit

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

    - New PERMANENT flag to ftrace_ops when attaching a callback to a
    function.

    As /proc/sys/kernel/ftrace_enabled when set to zero will disable
    all attached callbacks in ftrace, this has a detrimental impact on
    live kernel tracing, as it disables all that it patched. If a
    ftrace_ops is registered to ftrace with the PERMANENT flag set, it
    will prevent ftrace_enabled from being disabled, and if
    ftrace_enabled is already disabled, it will prevent a ftrace_ops
    with PREMANENT flag set from being registered.

    - New register_ftrace_direct().

    As eBPF would like to register its own trampolines to be called by
    the ftrace nop locations directly, without going through the ftrace
    trampoline, this function has been added. This allows for eBPF
    trampolines to live along side of ftrace, perf, kprobe and live
    patching. It also utilizes the ftrace enabled_functions file that
    keeps track of functions that have been modified in the kernel, to
    allow for security auditing.

    - Allow for kernel internal use of ftrace instances.

    Subsystems in the kernel can now create and destroy their own
    tracing instances which allows them to have their own tracing
    buffer, and be able to record events without worrying about other
    users from writing over their data.

    - New seq_buf_hex_dump() that lets users use the hex_dump() in their
    seq_buf usage.

    - Notifications now added to tracing_max_latency to allow user space
    to know when a new max latency is hit by one of the latency
    tracers.

    - Wider spread use of generic compare operations for use of bsearch
    and friends.

    - More synthetic event fields may be defined (32 up from 16)

    - Use of xarray for architectures with sparse system calls, for the
    system call trace events.

    This along with small clean ups and fixes"

    * tag 'trace-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (51 commits)
    tracing: Enable syscall optimization for MIPS
    tracing: Use xarray for syscall trace events
    tracing: Sample module to demonstrate kernel access to Ftrace instances.
    tracing: Adding new functions for kernel access to Ftrace instances
    tracing: Fix Kconfig indentation
    ring-buffer: Fix typos in function ring_buffer_producer
    ftrace: Use BIT() macro
    ftrace: Return ENOTSUPP when DYNAMIC_FTRACE_WITH_DIRECT_CALLS is not configured
    ftrace: Rename ftrace_graph_stub to ftrace_stub_graph
    ftrace: Add a helper function to modify_ftrace_direct() to allow arch optimization
    ftrace: Add helper find_direct_entry() to consolidate code
    ftrace: Add another check for match in register_ftrace_direct()
    ftrace: Fix accounting bug with direct->count in register_ftrace_direct()
    ftrace/selftests: Fix spelling mistake "wakeing" -> "waking"
    tracing: Increase SYNTH_FIELDS_MAX for synthetic_events
    ftrace/samples: Add a sample module that implements modify_ftrace_direct()
    ftrace: Add modify_ftrace_direct()
    tracing: Add missing "inline" in stub function of latency_fsnotify()
    tracing: Remove stray tab in TRACE_EVAL_MAP_FILE's help text
    tracing: Use seq_buf_hex_dump() to dump buffers
    ...

    Linus Torvalds
     

23 Nov, 2019

1 commit

  • It's cleaner to use the BIT() macro instead of raw shift operation.

    Link: http://lkml.kernel.org/r/20191121133815.15040-1-info@metux.net

    Signed-off-by: Enrico Weigelt, metux IT consult
    [ Added BIT() for bits 16 and 17 ]
    Signed-off-by: Steven Rostedt (VMware)

    Enrico Weigelt, metux IT consult
     

21 Nov, 2019

1 commit


19 Nov, 2019

1 commit

  • If a direct ftrace callback is at a location that does not have any other
    ftrace helpers attached to it, it is possible to simply just change the
    text to call the new caller (if the architecture supports it). But this
    requires special architecture code. Currently, modify_ftrace_direct() uses a
    trick to add a stub ftrace callback to the location forcing it to call the
    ftrace iterator. Then it can change the direct helper to call the new
    function in C, and then remove the stub. Removing the stub will have the
    location now call the new location that the direct helper is using.

    The new helper function does the registering the stub trick, but is a weak
    function, allowing an architecture to override it to do something a bit more
    direct.

    Link: https://lore.kernel.org/r/20191115215125.mbqv7taqnx376yed@ast-mbp.dhcp.thefacebook.com

    Suggested-by: Alexei Starovoitov
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

15 Nov, 2019

1 commit

  • Add a new function modify_ftrace_direct() that will allow a user to update
    an existing direct caller to a new trampoline, without missing hits due to
    unregistering one and then adding another.

    Link: https://lore.kernel.org/r/20191109022907.6zzo6orhxpt5n2sv@ast-mbp.dhcp.thefacebook.com

    Suggested-by: Alexei Starovoitov
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

13 Nov, 2019

4 commits

  • As testing for direct calls from the function graph tracer adds a little
    overhead (which is a lot when tracing every function), add a counter that
    can be used to test if function_graph tracer needs to test for a direct
    caller or not.

    It would have been nicer if we could use a static branch, but the static
    branch logic fails when used within the function graph tracer trampoline.

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • Enable x86 to allow for register_ftrace_direct(), where a custom trampoline
    may be called directly from an ftrace mcount/fentry location.

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • As function_graph tracer modifies the return address to insert a trampoline
    to trace the return of a function, it must be aware of a direct caller, as
    when it gets called, the function's return address may not be at on the
    stack where it expects. It may have to see if that return address points to
    the a direct caller and adjust if it is.

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • Add the start of the functionality to allow other trampolines to use the
    ftrace mcount/fentry/nop location. This adds two new functions:

    register_ftrace_direct() and unregister_ftrace_direct()

    Both take two parameters: the first is the instruction address of where the
    mcount/fentry/nop exists, and the second is the trampoline to have that
    location called.

    This will handle cases where ftrace is already used on that same location,
    and will make it still work, where the registered direct called trampoline
    will get called after all the registered ftrace callers are handled.

    Currently, it will not allow for IP_MODIFY functions to be called at the
    same locations, which include some kprobes and live kernel patching.

    At this point, no architecture supports this. This is only the start of
    implementing the framework.

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

06 Nov, 2019

2 commits

  • When using patchable-function-entry, the compiler will record the
    callsites into a section named "__patchable_function_entries" rather
    than "__mcount_loc". Let's abstract this difference behind a new
    FTRACE_CALLSITE_SECTION, so that architectures don't have to handle this
    explicitly (e.g. with custom module linker scripts).

    As parisc currently handles this explicitly, it is fixed up accordingly,
    with its custom linker script removed. Since FTRACE_CALLSITE_SECTION is
    only defined when DYNAMIC_FTRACE is selected, the parisc module loading
    code is updated to only use the definition in that case. When
    DYNAMIC_FTRACE is not selected, modules shouldn't have this section, so
    this removes some redundant work in that case.

    To make sure that this is keep up-to-date for modules and the main
    kernel, a comment is added to vmlinux.lds.h, with the existing ifdeffery
    simplified for legibility.

    I built parisc generic-{32,64}bit_defconfig with DYNAMIC_FTRACE enabled,
    and verified that the section made it into the .ko files for modules.

    Signed-off-by: Mark Rutland
    Acked-by: Helge Deller
    Acked-by: Steven Rostedt (VMware)
    Reviewed-by: Ard Biesheuvel
    Reviewed-by: Torsten Duwe
    Tested-by: Amit Daniel Kachhap
    Tested-by: Sven Schnelle
    Tested-by: Torsten Duwe
    Cc: Ingo Molnar
    Cc: James E.J. Bottomley
    Cc: Jessica Yu
    Cc: linux-parisc@vger.kernel.org

    Mark Rutland
     
  • Architectures may need to perform special initialization of ftrace
    callsites, and today they do so by special-casing ftrace_make_nop() when
    the expected branch address is MCOUNT_ADDR. In some cases (e.g. for
    patchable-function-entry), we don't have an mcount-like symbol and don't
    want a synthetic MCOUNT_ADDR, but we may need to perform some
    initialization of callsites.

    To make it possible to separate initialization from runtime
    modification, and to handle cases without an mcount-like symbol, this
    patch adds an optional ftrace_init_nop() function that architectures can
    implement, which does not pass a branch address.

    Where an architecture does not provide ftrace_init_nop(), we will fall
    back to the existing behaviour of calling ftrace_make_nop() with
    MCOUNT_ADDR.

    At the same time, ftrace_code_disable() is renamed to
    ftrace_nop_initialize() to make it clearer that it is intended to
    intialize a callsite into a disabled state, and is not for disabling a
    callsite that has been runtime enabled. The kerneldoc description of rec
    arguments is updated to cover non-mcount callsites.

    Signed-off-by: Mark Rutland
    Reviewed-by: Amit Daniel Kachhap
    Reviewed-by: Ard Biesheuvel
    Reviewed-by: Miroslav Benes
    Reviewed-by: Steven Rostedt (VMware)
    Reviewed-by: Torsten Duwe
    Tested-by: Amit Daniel Kachhap
    Tested-by: Sven Schnelle
    Tested-by: Torsten Duwe
    Cc: Ingo Molnar

    Mark Rutland
     

04 Nov, 2019

1 commit

  • Livepatch uses ftrace for redirection to new patched functions. It means
    that if ftrace is disabled, all live patched functions are disabled as
    well. Toggling global 'ftrace_enabled' sysctl thus affect it directly.
    It is not a problem per se, because only administrator can set sysctl
    values, but it still may be surprising.

    Introduce PERMANENT ftrace_ops flag to amend this. If the
    FTRACE_OPS_FL_PERMANENT is set on any ftrace ops, the tracing cannot be
    disabled by disabling ftrace_enabled. Equally, a callback with the flag
    set cannot be registered if ftrace_enabled is disabled.

    Link: http://lkml.kernel.org/r/20191016113316.13415-2-mbenes@suse.cz

    Reviewed-by: Petr Mladek
    Reviewed-by: Kamalesh Babulal
    Signed-off-by: Miroslav Benes
    Signed-off-by: Steven Rostedt (VMware)

    Miroslav Benes
     

26 May, 2019

1 commit

  • The code modification functions have "enable" and "update" variables that
    are sometimes "int" but used as "bool". Remove the ambiguity and make them
    "bool" when they are only used for true or false values.

    Link: http://lkml.kernel.org/r/e1429923d9eda92a3cf5ee9e33c7eacce539781d.1558115654.git.naveen.n.rao@linux.vnet.ibm.com

    Reported-by: "Naveen N. Rao"
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

16 May, 2019

1 commit

  • Pull tracing updates from Steven Rostedt:
    "The major changes in this tracing update includes:

    - Removal of non-DYNAMIC_FTRACE from 32bit x86

    - Removal of mcount support from x86

    - Emulating a call from int3 on x86_64, fixes live kernel patching

    - Consolidated Tracing Error logs file

    Minor updates:

    - Removal of klp_check_compiler_support()

    - kdb ftrace dumping output changes

    - Accessing and creating ftrace instances from inside the kernel

    - Clean up of #define if macro

    - Introduction of TRACE_EVENT_NOP() to disable trace events based on
    config options

    And other minor fixes and clean ups"

    * tag 'trace-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (44 commits)
    x86: Hide the int3_emulate_call/jmp functions from UML
    livepatch: Remove klp_check_compiler_support()
    ftrace/x86: Remove mcount support
    ftrace/x86_32: Remove support for non DYNAMIC_FTRACE
    tracing: Simplify "if" macro code
    tracing: Fix documentation about disabling options using trace_options
    tracing: Replace kzalloc with kcalloc
    tracing: Fix partial reading of trace event's id file
    tracing: Allow RCU to run between postponed startup tests
    tracing: Fix white space issues in parse_pred() function
    tracing: Eliminate const char[] auto variables
    ring-buffer: Fix mispelling of Calculate
    tracing: probeevent: Fix to make the type of $comm string
    tracing: probeevent: Do not accumulate on ret variable
    tracing: uprobes: Re-enable $comm support for uprobe events
    ftrace/x86_64: Emulate call function while updating in breakpoint handler
    x86_64: Allow breakpoints to emulate call instructions
    x86_64: Add gap to int3 to allow for call emulation
    tracing: kdb: Allow ftdump to skip all but the last few entries
    tracing: Add trace_total_entries() / trace_total_entries_cpu()
    ...

    Linus Torvalds
     

30 Apr, 2019

1 commit


29 Apr, 2019

1 commit

  • - Remove the extra array member of stack_dump_trace[] along with the
    ARRAY_SIZE - 1 initialization for struct stack_trace :: max_entries.

    Both are historical leftovers of no value. The stack tracer never exceeds
    the array and there is no extra storage requirement either.

    - Make variables which are only used in trace_stack.c static.

    - Simplify the enable/disable logic.

    - Rename stack_trace_print() as it's using the stack_trace_ namespace. Free
    the name up for stack trace related functions.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Steven Rostedt
    Reviewed-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Alexander Potapenko
    Cc: Alexey Dobriyan
    Cc: Andrew Morton
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: linux-mm@kvack.org
    Cc: David Rientjes
    Cc: Catalin Marinas
    Cc: Dmitry Vyukov
    Cc: Andrey Ryabinin
    Cc: kasan-dev@googlegroups.com
    Cc: Mike Rapoport
    Cc: Akinobu Mita
    Cc: Christoph Hellwig
    Cc: iommu@lists.linux-foundation.org
    Cc: Robin Murphy
    Cc: Marek Szyprowski
    Cc: Johannes Thumshirn
    Cc: David Sterba
    Cc: Chris Mason
    Cc: Josef Bacik
    Cc: linux-btrfs@vger.kernel.org
    Cc: dm-devel@redhat.com
    Cc: Mike Snitzer
    Cc: Alasdair Kergon
    Cc: Daniel Vetter
    Cc: intel-gfx@lists.freedesktop.org
    Cc: Joonas Lahtinen
    Cc: Maarten Lankhorst
    Cc: dri-devel@lists.freedesktop.org
    Cc: David Airlie
    Cc: Jani Nikula
    Cc: Rodrigo Vivi
    Cc: Tom Zanussi
    Cc: Miroslav Benes
    Cc: linux-arch@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190425094801.230654524@linutronix.de

    Thomas Gleixner
     

01 Jan, 2019

1 commit

  • Pull tracing updates from Steven Rostedt:

    - Rework of the kprobe/uprobe and synthetic events to consolidate all
    the dynamic event code. This will make changes in the future easier.

    - Partial rewrite of the function graph tracing infrastructure. This
    will allow for multiple users of hooking onto functions to get the
    callback (return) of the function. This is the ground work for having
    kprobes and function graph tracer using one code base.

    - Clean up of the histogram code that will facilitate adding more
    features to the histograms in the future.

    - Addition of str_has_prefix() and a few use cases. There currently is
    a similar function strstart() that is used in a few places, but only
    returns a bool and not a length. These instances will be removed in
    the future to use str_has_prefix() instead.

    - A few other various clean ups as well.

    * tag 'trace-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (57 commits)
    tracing: Use the return of str_has_prefix() to remove open coded numbers
    tracing: Have the historgram use the result of str_has_prefix() for len of prefix
    tracing: Use str_has_prefix() instead of using fixed sizes
    tracing: Use str_has_prefix() helper for histogram code
    string.h: Add str_has_prefix() helper function
    tracing: Make function ‘ftrace_exports’ static
    tracing: Simplify printf'ing in seq_print_sym
    tracing: Avoid -Wformat-nonliteral warning
    tracing: Merge seq_print_sym_short() and seq_print_sym_offset()
    tracing: Add hist trigger comments for variable-related fields
    tracing: Remove hist trigger synth_var_refs
    tracing: Use hist trigger's var_ref array to destroy var_refs
    tracing: Remove open-coding of hist trigger var_ref management
    tracing: Use var_refs[] for hist trigger reference checking
    tracing: Change strlen to sizeof for hist trigger static strings
    tracing: Remove unnecessary hist trigger struct field
    tracing: Fix ftrace_graph_get_ret_stack() to use task and not current
    seq_buf: Use size_t for len in seq_buf_puts()
    seq_buf: Make seq_buf_puts() null-terminate the buffer
    arm64: Use ftrace_graph_get_ret_stack() instead of curr_ret_stack
    ...

    Linus Torvalds
     

11 Dec, 2018

1 commit

  • The function ftrace_replace_code() is the ftrace engine that does the
    work to modify all the nops into the calls to the function callback in
    all the functions being traced.

    The generic version which is normally called from stop machine, but an
    architecture can implement a non stop machine version and still use the
    generic ftrace_replace_code(). When an architecture does this,
    ftrace_replace_code() may be called from a schedulable context, where
    it can allow the code to be preemptible, and schedule out.

    In order to allow an architecture to make ftrace_replace_code()
    schedulable, a new command flag is added called:

    FTRACE_MAY_SLEEP

    Which can be or'd to the command that is passed to
    ftrace_modify_all_code() that calls ftrace_replace_code() and will have
    it call cond_resched() in the loop that modifies the nops into the
    calls to the ftrace trampolines.

    Link: http://lkml.kernel.org/r/20181204192903.8193-1-anders.roxell@linaro.org
    Link: http://lkml.kernel.org/r/20181205183303.828422192@goodmis.org

    Reported-by: Anders Roxell
    Tested-by: Anders Roxell
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

09 Dec, 2018

3 commits

  • The ret_stack processing is going to change, and that is going
    to break anything that is accessing the ret_stack directly. One user is the
    function graph profiler. By using the ftrace_graph_get_ret_stack() helper
    function, the profiler can access the ret_stack entry without relying on the
    implementation details of the stack itself.

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

    Steven Rostedt (VMware)
     
  • Currently the registering of function graph is to pass in a entry and return
    function. We need to have a way to associate those functions together where
    the entry can determine to run the return hook. Having a structure that
    contains both functions will facilitate the process of converting the code
    to be able to do such.

    This is similar to the way function hooks are enabled (it passes in
    ftrace_ops). Instead of passing in the functions to use, a single structure
    is passed in to the registering function.

    The unregister function is now passed in the fgraph_ops handle. When we
    allow more than one callback to the function graph hooks, this will let the
    system know which one to remove.

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

    Steven Rostedt (VMware)
     
  • The curr_ret_stack is no longer set to a negative value when a function is
    not to be traced by the function graph tracer. Remove the usage of
    FTRACE_NOTRACE_DEPTH, as it is no longer needed.

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

    Steven Rostedt (VMware)
     

03 Dec, 2018

1 commit


30 Nov, 2018

1 commit


28 Nov, 2018

1 commit

  • As all architectures now call function_graph_enter() to do the entry work,
    no architecture should ever call ftrace_push_return_trace(). Make it static.

    This is needed to prepare for a fix of a design bug on how the curr_ret_stack
    is used.

    Cc: stable@kernel.org
    Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
    Reviewed-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

27 Nov, 2018

1 commit

  • Currently all the architectures do basically the same thing in preparing the
    function graph tracer on entry to a function. This code can be pulled into a
    generic location and then this will allow the function graph tracer to be
    fixed, as well as extended.

    Create a new function graph helper function_graph_enter() that will call the
    hook function (ftrace_graph_entry) and the shadow stack operation
    (ftrace_push_return_trace), and remove the need of the architecture code to
    manage the shadow stack.

    This is needed to prepare for a fix of a design bug on how the curr_ret_stack
    is used.

    Cc: stable@kernel.org
    Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
    Reviewed-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

23 Nov, 2018

1 commit

  • When building the kernel with W=1 we get a lot of -Wmissing-prototypes
    warnings, which are trivial in nature and easy to fix - and which may
    mask some real future bugs if the prototypes get out of sync with
    the function definition.

    This patch fixes most of -Wmissing-prototypes warnings which
    are in the root directory of arch/x86/kernel, not including
    the subdirectories.

    These are the warnings fixed in this patch:

    arch/x86/kernel/signal.c:865:17: warning: no previous prototype for ‘sys32_x32_rt_sigreturn’ [-Wmissing-prototypes]
    arch/x86/kernel/signal_compat.c:164:6: warning: no previous prototype for ‘sigaction_compat_abi’ [-Wmissing-prototypes]
    arch/x86/kernel/traps.c:625:46: warning: no previous prototype for ‘sync_regs’ [-Wmissing-prototypes]
    arch/x86/kernel/traps.c:640:24: warning: no previous prototype for ‘fixup_bad_iret’ [-Wmissing-prototypes]
    arch/x86/kernel/traps.c:929:13: warning: no previous prototype for ‘trap_init’ [-Wmissing-prototypes]
    arch/x86/kernel/irq.c:270:28: warning: no previous prototype for ‘smp_x86_platform_ipi’ [-Wmissing-prototypes]
    arch/x86/kernel/irq.c:301:16: warning: no previous prototype for ‘smp_kvm_posted_intr_ipi’ [-Wmissing-prototypes]
    arch/x86/kernel/irq.c:314:16: warning: no previous prototype for ‘smp_kvm_posted_intr_wakeup_ipi’ [-Wmissing-prototypes]
    arch/x86/kernel/irq.c:328:16: warning: no previous prototype for ‘smp_kvm_posted_intr_nested_ipi’ [-Wmissing-prototypes]
    arch/x86/kernel/irq_work.c:16:28: warning: no previous prototype for ‘smp_irq_work_interrupt’ [-Wmissing-prototypes]
    arch/x86/kernel/irqinit.c:79:13: warning: no previous prototype for ‘init_IRQ’ [-Wmissing-prototypes]
    arch/x86/kernel/quirks.c:672:13: warning: no previous prototype for ‘early_platform_quirks’ [-Wmissing-prototypes]
    arch/x86/kernel/tsc.c:1499:15: warning: no previous prototype for ‘calibrate_delay_is_known’ [-Wmissing-prototypes]
    arch/x86/kernel/process.c:653:13: warning: no previous prototype for ‘arch_post_acpi_subsys_init’ [-Wmissing-prototypes]
    arch/x86/kernel/process.c:717:15: warning: no previous prototype for ‘arch_randomize_brk’ [-Wmissing-prototypes]
    arch/x86/kernel/process.c:784:6: warning: no previous prototype for ‘do_arch_prctl_common’ [-Wmissing-prototypes]
    arch/x86/kernel/reboot.c:869:6: warning: no previous prototype for ‘nmi_panic_self_stop’ [-Wmissing-prototypes]
    arch/x86/kernel/smp.c:176:27: warning: no previous prototype for ‘smp_reboot_interrupt’ [-Wmissing-prototypes]
    arch/x86/kernel/smp.c:260:28: warning: no previous prototype for ‘smp_reschedule_interrupt’ [-Wmissing-prototypes]
    arch/x86/kernel/smp.c:281:28: warning: no previous prototype for ‘smp_call_function_interrupt’ [-Wmissing-prototypes]
    arch/x86/kernel/smp.c:291:28: warning: no previous prototype for ‘smp_call_function_single_interrupt’ [-Wmissing-prototypes]
    arch/x86/kernel/ftrace.c:840:6: warning: no previous prototype for ‘arch_ftrace_update_trampoline’ [-Wmissing-prototypes]
    arch/x86/kernel/ftrace.c:934:7: warning: no previous prototype for ‘arch_ftrace_trampoline_func’ [-Wmissing-prototypes]
    arch/x86/kernel/ftrace.c:946:6: warning: no previous prototype for ‘arch_ftrace_trampoline_free’ [-Wmissing-prototypes]
    arch/x86/kernel/crash.c:114:6: warning: no previous prototype for ‘crash_smp_send_stop’ [-Wmissing-prototypes]
    arch/x86/kernel/crash.c:351:5: warning: no previous prototype for ‘crash_setup_memmap_entries’ [-Wmissing-prototypes]
    arch/x86/kernel/crash.c:424:5: warning: no previous prototype for ‘crash_load_segments’ [-Wmissing-prototypes]
    arch/x86/kernel/machine_kexec_64.c:372:7: warning: no previous prototype for ‘arch_kexec_kernel_image_load’ [-Wmissing-prototypes]
    arch/x86/kernel/paravirt-spinlocks.c:12:16: warning: no previous prototype for ‘__native_queued_spin_unlock’ [-Wmissing-prototypes]
    arch/x86/kernel/paravirt-spinlocks.c:18:6: warning: no previous prototype for ‘pv_is_native_spin_unlock’ [-Wmissing-prototypes]
    arch/x86/kernel/paravirt-spinlocks.c:24:16: warning: no previous prototype for ‘__native_vcpu_is_preempted’ [-Wmissing-prototypes]
    arch/x86/kernel/paravirt-spinlocks.c:30:6: warning: no previous prototype for ‘pv_is_native_vcpu_is_preempted’ [-Wmissing-prototypes]
    arch/x86/kernel/kvm.c:258:1: warning: no previous prototype for ‘do_async_page_fault’ [-Wmissing-prototypes]
    arch/x86/kernel/jailhouse.c:200:6: warning: no previous prototype for ‘jailhouse_paravirt’ [-Wmissing-prototypes]
    arch/x86/kernel/check.c:91:13: warning: no previous prototype for ‘setup_bios_corruption_check’ [-Wmissing-prototypes]
    arch/x86/kernel/check.c:139:6: warning: no previous prototype for ‘check_for_bios_corruption’ [-Wmissing-prototypes]
    arch/x86/kernel/devicetree.c:32:13: warning: no previous prototype for ‘early_init_dt_scan_chosen_arch’ [-Wmissing-prototypes]
    arch/x86/kernel/devicetree.c:42:13: warning: no previous prototype for ‘add_dtb’ [-Wmissing-prototypes]
    arch/x86/kernel/devicetree.c:108:6: warning: no previous prototype for ‘x86_of_pci_init’ [-Wmissing-prototypes]
    arch/x86/kernel/devicetree.c:314:13: warning: no previous prototype for ‘x86_dtb_init’ [-Wmissing-prototypes]
    arch/x86/kernel/tracepoint.c:16:5: warning: no previous prototype for ‘trace_pagefault_reg’ [-Wmissing-prototypes]
    arch/x86/kernel/tracepoint.c:22:6: warning: no previous prototype for ‘trace_pagefault_unreg’ [-Wmissing-prototypes]
    arch/x86/kernel/head64.c:113:22: warning: no previous prototype for ‘__startup_64’ [-Wmissing-prototypes]
    arch/x86/kernel/head64.c:262:15: warning: no previous prototype for ‘__startup_secondary_64’ [-Wmissing-prototypes]
    arch/x86/kernel/head64.c:350:12: warning: no previous prototype for ‘early_make_pgtable’ [-Wmissing-prototypes]

    [ mingo: rewrote the changelog, fixed build errors. ]

    Signed-off-by: Yi Wang
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: akataria@vmware.com
    Cc: akpm@linux-foundation.org
    Cc: andy.shevchenko@gmail.com
    Cc: anton@enomsg.org
    Cc: ard.biesheuvel@linaro.org
    Cc: bhe@redhat.com
    Cc: bhelgaas@google.com
    Cc: bp@alien8.de
    Cc: ccross@android.com
    Cc: devicetree@vger.kernel.org
    Cc: douly.fnst@cn.fujitsu.com
    Cc: dwmw@amazon.co.uk
    Cc: dyoung@redhat.com
    Cc: ebiederm@xmission.com
    Cc: frank.rowand@sony.com
    Cc: frowand.list@gmail.com
    Cc: ivan.gorinov@intel.com
    Cc: jailhouse-dev@googlegroups.com
    Cc: jan.kiszka@siemens.com
    Cc: jgross@suse.com
    Cc: jroedel@suse.de
    Cc: keescook@chromium.org
    Cc: kexec@lists.infradead.org
    Cc: konrad.wilk@oracle.com
    Cc: kvm@vger.kernel.org
    Cc: linux-efi@vger.kernel.org
    Cc: linux-pci@vger.kernel.org
    Cc: luto@kernel.org
    Cc: m.mizuma@jp.fujitsu.com
    Cc: namit@vmware.com
    Cc: oleg@redhat.com
    Cc: pasha.tatashin@oracle.com
    Cc: pbonzini@redhat.com
    Cc: prarit@redhat.com
    Cc: pravin.shedge4linux@gmail.com
    Cc: rajvi.jingar@intel.com
    Cc: rkrcmar@redhat.com
    Cc: robh+dt@kernel.org
    Cc: robh@kernel.org
    Cc: rostedt@goodmis.org
    Cc: takahiro.akashi@linaro.org
    Cc: thomas.lendacky@amd.com
    Cc: tony.luck@intel.com
    Cc: up2wing@gmail.com
    Cc: virtualization@lists.linux-foundation.org
    Cc: zhe.he@windriver.com
    Cc: zhong.weidong@zte.com.cn
    Link: http://lkml.kernel.org/r/1542852249-19820-1-git-send-email-wang.yi59@zte.com.cn
    Signed-off-by: Ingo Molnar

    Yi Wang
     

31 Jul, 2018

1 commit

  • This patch detaches the preemptirq tracepoints from the tracers and
    keeps it separate.

    Advantages:
    * Lockdep and irqsoff event can now run in parallel since they no longer
    have their own calls.

    * This unifies the usecase of adding hooks to an irqsoff and irqson
    event, and a preemptoff and preempton event.
    3 users of the events exist:
    - Lockdep
    - irqsoff and preemptoff tracers
    - irqs and preempt trace events

    The unification cleans up several ifdefs and makes the code in preempt
    tracer and irqsoff tracers simpler. It gets rid of all the horrific
    ifdeferry around PROVE_LOCKING and makes configuration of the different
    users of the tracepoints more easy and understandable. It also gets rid
    of the time_* function calls from the lockdep hooks used to call into
    the preemptirq tracer which is not needed anymore. The negative delta in
    lines of code in this patch is quite large too.

    In the patch we introduce a new CONFIG option PREEMPTIRQ_TRACEPOINTS
    as a single point for registering probes onto the tracepoints. With
    this,
    the web of config options for preempt/irq toggle tracepoints and its
    users becomes:

    PREEMPT_TRACER PREEMPTIRQ_EVENTS IRQSOFF_TRACER PROVE_LOCKING
    | | \ | |
    \ (selects) / \ \ (selects) /
    TRACE_PREEMPT_TOGGLE ----> TRACE_IRQFLAGS
    \ /
    \ (depends on) /
    PREEMPTIRQ_TRACEPOINTS

    Other than the performance tests mentioned in the previous patch, I also
    ran the locking API test suite. I verified that all tests cases are
    passing.

    I also injected issues by not registering lockdep probes onto the
    tracepoints and I see failures to confirm that the probes are indeed
    working.

    This series + lockdep probes not registered (just to inject errors):
    [ 0.000000] hard-irqs-on + irq-safe-A/21: ok | ok | ok |
    [ 0.000000] soft-irqs-on + irq-safe-A/21: ok | ok | ok |
    [ 0.000000] sirq-safe-A => hirqs-on/12:FAILED|FAILED| ok |
    [ 0.000000] sirq-safe-A => hirqs-on/21:FAILED|FAILED| ok |
    [ 0.000000] hard-safe-A + irqs-on/12:FAILED|FAILED| ok |
    [ 0.000000] soft-safe-A + irqs-on/12:FAILED|FAILED| ok |
    [ 0.000000] hard-safe-A + irqs-on/21:FAILED|FAILED| ok |
    [ 0.000000] soft-safe-A + irqs-on/21:FAILED|FAILED| ok |
    [ 0.000000] hard-safe-A + unsafe-B #1/123: ok | ok | ok |
    [ 0.000000] soft-safe-A + unsafe-B #1/123: ok | ok | ok |

    With this series + lockdep probes registered, all locking tests pass:

    [ 0.000000] hard-irqs-on + irq-safe-A/21: ok | ok | ok |
    [ 0.000000] soft-irqs-on + irq-safe-A/21: ok | ok | ok |
    [ 0.000000] sirq-safe-A => hirqs-on/12: ok | ok | ok |
    [ 0.000000] sirq-safe-A => hirqs-on/21: ok | ok | ok |
    [ 0.000000] hard-safe-A + irqs-on/12: ok | ok | ok |
    [ 0.000000] soft-safe-A + irqs-on/12: ok | ok | ok |
    [ 0.000000] hard-safe-A + irqs-on/21: ok | ok | ok |
    [ 0.000000] soft-safe-A + irqs-on/21: ok | ok | ok |
    [ 0.000000] hard-safe-A + unsafe-B #1/123: ok | ok | ok |
    [ 0.000000] soft-safe-A + unsafe-B #1/123: ok | ok | ok |

    Link: http://lkml.kernel.org/r/20180730222423.196630-4-joel@joelfernandes.org

    Acked-by: Peter Zijlstra (Intel)
    Reviewed-by: Namhyung Kim
    Signed-off-by: Joel Fernandes (Google)
    Signed-off-by: Steven Rostedt (VMware)

    Joel Fernandes (Google)
     

26 Jul, 2018

1 commit

  • Remove ftrace_nr_registered_ops() because it is no longer used.

    ftrace_nr_registered_ops() has been introduced by commit ea701f11da44
    ("ftrace: Add selftest to test function trace recursion protection"), but
    its caller has been removed by commit 05cbbf643b8e ("tracing: Fix selftest
    function recursion accounting"). So it is not called anymore.

    Link: http://lkml.kernel.org/r/153260907227.12474.5234899025934963683.stgit@devbox

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

04 Jul, 2018

1 commit

  • clear_ftrace_function is not used outside of ftrace.c and is not help to
    use a function, so nuke it per Steve's suggestion.

    Link: http://lkml.kernel.org/r/1517537689-34947-1-git-send-email-xieyisheng1@huawei.com

    Suggested-by: Steven Rostedt
    Signed-off-by: Yisheng Xie
    Signed-off-by: Steven Rostedt (VMware)

    Yisheng Xie