19 May, 2016

1 commit

  • Pull tracing updates from Steven Rostedt:
    "This includes two new updates for the ftrace infrastructure.

    - With the changing of the code for filtering events by pid, from a
    list of pids to a bitmask, we can now easily implement following
    forks. With a new tracing option "event-fork" which, when set,
    will have tasks with pids in set_event_pid, when they fork, to have
    their child pids added to set_event_pid and the child will be
    traced as well.

    Note, if "event-fork" is set and a task with its pid in
    set_event_pid exits, its pid will be removed from set_event_pid

    - The addition of Tom Zanussi's hist triggers. This includes a very
    thorough documentatino on how to use the hist triggers with events.
    This introduces a quick and easy way to get histogram data from
    events and their fields.

    Some other cleanups and updates were added as well. Like Masami
    Hiramatsu added test cases for the event trigger and hist triggers.
    Also I added a speed up of filtering by using a temp buffer when
    filters are set"

    * tag 'trace-v4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (45 commits)
    tracing: Use temp buffer when filtering events
    tracing: Remove TRACE_EVENT_FL_USE_CALL_FILTER logic
    tracing: Remove unused function trace_current_buffer_lock_reserve()
    tracing: Remove one use of trace_current_buffer_lock_reserve()
    tracing: Have trace_buffer_unlock_commit() call the _regs version with NULL
    tracing: Remove unused function trace_current_buffer_discard_commit()
    tracing: Move trace_buffer_unlock_commit{_regs}() to local header
    tracing: Fold filter_check_discard() into its only user
    tracing: Make filter_check_discard() local
    tracing: Move event_trigger_unlock_commit{_regs}() to local header
    tracing: Don't use the address of the buffer array name in copy_from_user
    tracing: Handle tracing_map_alloc_elts() error path correctly
    tracing: Add check for NULL event field when creating hist field
    tracing: checking for NULL instead of IS_ERR()
    tracing: Do not inherit event-fork option for instances
    tracing: Fix unsigned comparison to zero in hist trigger code
    kselftests/ftrace: Add a test for log2 modifier of hist trigger
    tracing: Add hist trigger 'log2' modifier
    kselftests/ftrace: Add hist trigger testcases
    kselftests/ftrace : Add event trigger testcases
    ...

    Linus Torvalds
     

03 May, 2016

1 commit


30 Apr, 2016

3 commits


27 Apr, 2016

2 commits


22 Apr, 2016

1 commit

  • move trace_call_bpf() into helper function to minimize the size
    of perf_trace_*() tracepoint handlers.
    text data bss dec hex filename
    10541679 5526646 2945024 19013349 1221ee5 vmlinux_before
    10509422 5526646 2945024 18981092 121a0e4 vmlinux_after

    It may seem that perf_fetch_caller_regs() can also be moved,
    but that is incorrect, since ip/sp will be wrong.

    bpf+tracepoint performance is not affected, since
    perf_swevent_put_recursion_context() is now inlined.
    export_symbol_gpl can also be dropped.

    No measurable change in normal perf tracepoints.

    Suggested-by: Steven Rostedt
    Signed-off-by: Alexei Starovoitov
    Acked-by: Peter Zijlstra (Intel)
    Acked-by: Steven Rostedt
    Signed-off-by: David S. Miller

    Alexei Starovoitov
     

20 Apr, 2016

2 commits

  • Similar to enable_event/disable_event triggers, these triggers enable
    and disable the aggregation of events into maps rather than enabling
    and disabling their writing into the trace buffer.

    They can be used to automatically start and stop hist triggers based
    on a matching filter condition.

    If there's a paused hist trigger on system:event, the following would
    start it when the filter condition was hit:

    # echo enable_hist:system:event [ if filter] > event/trigger

    And the following would disable a running system:event hist trigger:

    # echo disable_hist:system:event [ if filter] > event/trigger

    See Documentation/trace/events.txt for real examples.

    Link: http://lkml.kernel.org/r/f812f086e52c8b7c8ad5443487375e03c96a601f.1457029949.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     
  • 'hist' triggers allow users to continually aggregate trace events,
    which can then be viewed afterwards by simply reading a 'hist' file
    containing the aggregation in a human-readable format.

    The basic idea is very simple and boils down to a mechanism whereby
    trace events, rather than being exhaustively dumped in raw form and
    viewed directly, are automatically 'compressed' into meaningful tables
    completely defined by the user.

    This is done strictly via single-line command-line commands and
    without the aid of any kind of programming language or interpreter.

    A surprising number of typical use cases can be accomplished by users
    via this simple mechanism. In fact, a large number of the tasks that
    users typically do using the more complicated script-based tracing
    tools, at least during the initial stages of an investigation, can be
    accomplished by simply specifying a set of keys and values to be used
    in the creation of a hash table.

    The Linux kernel trace event subsystem happens to provide an extensive
    list of keys and values ready-made for such a purpose in the form of
    the event format files associated with each trace event. By simply
    consulting the format file for field names of interest and by plugging
    them into the hist trigger command, users can create an endless number
    of useful aggregations to help with investigating various properties
    of the system. See Documentation/trace/events.txt for examples.

    hist triggers are implemented on top of the existing event trigger
    infrastructure, and as such are consistent with the existing triggers
    from a user's perspective as well.

    The basic syntax follows the existing trigger syntax. Users start an
    aggregation by writing a 'hist' trigger to the event of interest's
    trigger file:

    # echo hist:keys=xxx [ if filter] > event/trigger

    Once a hist trigger has been set up, by default it continually
    aggregates every matching event into a hash table using the event key
    and a value field named 'hitcount'.

    To view the aggregation at any point in time, simply read the 'hist'
    file in the same directory as the 'trigger' file:

    # cat event/hist

    The detailed syntax provides additional options for user control, and
    is described exhaustively in Documentation/trace/events.txt and in the
    virtual tracing/README file in the tracing subsystem.

    Link: http://lkml.kernel.org/r/72d263b5e1853fe9c314953b65833c3aa75479f2.1457029949.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     

08 Apr, 2016

2 commits

  • during bpf program loading remember the last byte of ctx access
    and at the time of attaching the program to tracepoint check that
    the program doesn't access bytes beyond defined in tracepoint fields

    This also disallows access to __dynamic_array fields, but can be
    relaxed in the future.

    Signed-off-by: Alexei Starovoitov
    Signed-off-by: David S. Miller

    Alexei Starovoitov
     
  • split allows to move expensive update of 'struct trace_entry' to later phase.
    Repurpose unused 1st argument of perf_tp_event() to indicate event type.

    While splitting use temp variable 'rctx' instead of '*rctx' to avoid
    unnecessary loads done by the compiler due to -fno-strict-aliasing

    Signed-off-by: Alexei Starovoitov
    Acked-by: Peter Zijlstra (Intel)
    Signed-off-by: David S. Miller

    Alexei Starovoitov
     

25 Mar, 2016

1 commit

  • Pull tracing updates from Steven Rostedt:
    "Nothing major this round. Mostly small clean ups and fixes.

    Some visible changes:

    - A new flag was added to distinguish traces done in NMI context.

    - Preempt tracer now shows functions where preemption is disabled but
    interrupts are still enabled.

    Other notes:

    - Updates were done to function tracing to allow better performance
    with perf.

    - Infrastructure code has been added to allow for a new histogram
    feature for recording live trace event histograms that can be
    configured by simple user commands. The feature itself was just
    finished, but needs a round in linux-next before being pulled.

    This only includes some infrastructure changes that will be needed"

    * tag 'trace-v4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (22 commits)
    tracing: Record and show NMI state
    tracing: Fix trace_printk() to print when not using bprintk()
    tracing: Remove redundant reset per-CPU buff in irqsoff tracer
    x86: ftrace: Fix the misleading comment for arch/x86/kernel/ftrace.c
    tracing: Fix crash from reading trace_pipe with sendfile
    tracing: Have preempt(irqs)off trace preempt disabled functions
    tracing: Fix return while holding a lock in register_tracer()
    ftrace: Use kasprintf() in ftrace_profile_tracefs()
    ftrace: Update dynamic ftrace calls only if necessary
    ftrace: Make ftrace_hash_rec_enable return update bool
    tracing: Fix typoes in code comment and printk in trace_nop.c
    tracing, writeback: Replace cgroup path to cgroup ino
    tracing: Use flags instead of bool in trigger structure
    tracing: Add an unreg_all() callback to trigger commands
    tracing: Add needs_rec flag to event triggers
    tracing: Add a per-event-trigger 'paused' field
    tracing: Add get_syscall_name()
    tracing: Add event record param to trigger_ops.func()
    tracing: Make event trigger functions available
    tracing: Make ftrace_event_field checking functions available
    ...

    Linus Torvalds
     

16 Mar, 2016

1 commit

  • The following patch will need to declare array of struct
    trace_print_flags in a header. To prevent this header from pulling in
    all of RCU through trace_events.h, move the struct
    trace_print_flags{_64} definitions to the new lightweight
    tracepoint-defs.h header.

    Signed-off-by: Vlastimil Babka
    Acked-by: David Rientjes
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Ingo Molnar
    Cc: Rasmus Villemoes
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Sasha Levin
    Cc: "Kirill A. Shutemov"
    Cc: Mel Gorman
    Cc: Michal Hocko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vlastimil Babka
     

09 Mar, 2016

1 commit

  • Some triggers may need access to the trace event, so pass it in. Also
    fix up the existing trigger funcs and their callers.

    Link: http://lkml.kernel.org/r/543e31e9fc445ef61077421ab219033401c39846.1449767187.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     

04 Mar, 2016

1 commit

  • Commit 9f61668073a8d "tracing: Allow triggers to filter for CPU ids and
    process names" added a 'comm' filter that will filter events based on the
    current tasks struct 'comm'. But this now hides the ability to filter events
    that have a 'comm' field too. For example, sched_migrate_task trace event.
    That has a 'comm' field of the task to be migrated.

    echo 'comm == "bash"' > events/sched_migrate_task/filter

    will now filter all sched_migrate_task events for tasks named "bash" that
    migrates other tasks (in interrupt context), instead of seeing when "bash"
    itself gets migrated.

    This fix requires a couple of changes.

    1) Change the look up order for filter predicates to look at the events
    fields before looking at the generic filters.

    2) Instead of basing the filter function off of the "comm" name, have the
    generic "comm" filter have its own filter_type (FILTER_COMM). Test
    against the type instead of the name to assign the filter function.

    3) Add a new "COMM" filter that works just like "comm" but will filter based
    on the current task, even if the trace event contains a "comm" field.

    Do the same for "cpu" field, adding a FILTER_CPU and a filter "CPU".

    Cc: stable@vger.kernel.org # v4.3+
    Fixes: 9f61668073a8d "tracing: Allow triggers to filter for CPU ids and process names"
    Reported-by: Matt Fleming
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

26 Oct, 2015

1 commit

  • Add the necessary hooks to use the pids loaded in set_event_pid to filter
    all the events enabled in the tracing instance that match the pids listed.

    Two probes are added to both sched_switch and sched_wakeup tracepoints to be
    called before other probes are called and after the other probes are called.
    The first is used to set the necessary flags to let the probes know to test
    if they should be traced or not.

    The sched_switch pre probe will set the "ignore_pid" flag if neither the
    previous or next task has a matching pid.

    The sched_switch probe will set the "ignore_pid" flag if the next task
    does not match the matching pid.

    The pre probe allows for probes tracing sched_switch to be traced if
    necessary.

    The sched_wakeup pre probe will set the "ignore_pid" flag if neither the
    current task nor the wakee task has a matching pid.

    The sched_wakeup post probe will set the "ignore_pid" flag if the current
    task does not have a matching pid.

    Cc: "Paul E. McKenney"
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

26 Sep, 2015

2 commits


07 Aug, 2015

2 commits

  • By copying BPF related operation to uprobe processing path, this patch
    allow users attach BPF programs to uprobes like what they are already
    doing on kprobes.

    After this patch, users are allowed to use PERF_EVENT_IOC_SET_BPF on a
    uprobe perf event. Which make it possible to profile user space programs
    and kernel events together using BPF.

    Because of this patch, CONFIG_BPF_EVENTS should be selected by
    CONFIG_UPROBE_EVENT to ensure trace_call_bpf() is compiled even if
    KPROBE_EVENT is not set.

    Signed-off-by: Wang Nan
    Acked-by: Alexei Starovoitov
    Cc: Brendan Gregg
    Cc: Daniel Borkmann
    Cc: David Ahern
    Cc: He Kuang
    Cc: Jiri Olsa
    Cc: Kaixu Xia
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1435716878-189507-3-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     
  • Commit e1abf2cc8d5d80b41c4419368ec743ccadbb131e ("bpf: Fix the build on
    BPF_SYSCALL=y && !CONFIG_TRACING kernels, make it more configurable")
    updated the building condition of bpf_trace.o from CONFIG_BPF_SYSCALL
    to CONFIG_BPF_EVENTS, but the corresponding #ifdef controller in
    trace_events.h for trace_call_bpf() was not changed. Which, in theory,
    is incorrect.

    With current Kconfigs, we can create a .config with CONFIG_BPF_SYSCALL=y
    and CONFIG_BPF_EVENTS=n by unselecting CONFIG_KPROBE_EVENT and
    selecting CONFIG_BPF_SYSCALL. With these options, trace_call_bpf() will
    be defined as an extern function, but if anyone calls it a symbol missing
    error will be triggered since bpf_trace.o was not built.

    This patch changes the #ifdef controller for trace_call_bpf() from
    CONFIG_BPF_SYSCALL to CONFIG_BPF_EVENTS. I'll show its correctness:

    Before this patch:

    BPF_SYSCALL BPF_EVENTS trace_call_bpf bpf_trace.o
    y y normal compiled
    n n inline not compiled
    y n normal not compiled (incorrect)
    n y impossible (BPF_EVENTS depends on BPF_SYSCALL)

    After this patch:

    BPF_SYSCALL BPF_EVENTS trace_call_bpf bpf_trace.o
    y y normal compiled
    n n inline not compiled
    y n inline not compiled (fixed)
    n y impossible (BPF_EVENTS depends on BPF_SYSCALL)

    So this patch doesn't break anything. QED.

    Signed-off-by: Wang Nan
    Cc: Alexei Starovoitov
    Cc: Brendan Gregg
    Cc: Daniel Borkmann
    Cc: David Ahern
    Cc: He Kuang
    Cc: Jiri Olsa
    Cc: Kaixu Xia
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1435716878-189507-2-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     

14 May, 2015

12 commits