30 Oct, 2020

1 commit

  • There is a regular need in the kernel to provide a way to declare having a
    dynamically sized set of trailing elements in a structure. Kernel code should
    always use “flexible array members”[1] for these cases. The older style of
    one-element or zero-length arrays should no longer be used[2].

    [1] https://en.wikipedia.org/wiki/Flexible_array_member
    [2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

03 Oct, 2020

1 commit

  • Naresh reported a bug that appears to be a side effect of the static
    calls. It happens when going from more than one tracepoint callback to
    a single one, and removing the first callback on the list. The list of
    tracepoint callbacks holds data and a function to call with the
    parameters of that tracepoint and a handler to the associated data.

    old_list:
    0: func = foo; data = NULL;
    1: func = bar; data = &bar_struct;

    new_list:
    0: func = bar; data = &bar_struct;

    CPU 0 CPU 1
    ----- -----
    tp_funcs = old_list;
    tp_static_caller = tp_interator

    __DO_TRACE()

    data = tp_funcs[0].data = NULL;

    tp_funcs = new_list;
    tracepoint_update_call()
    tp_static_caller = tp_funcs[0] = bar;
    tp_static_caller(data)
    bar(data)
    x = data->item = NULL->item

    BOOM!

    To solve this, add a tracepoint_synchronize_unregister() between
    changing tp_funcs and updating the static tracepoint, that does both a
    synchronize_rcu() and synchronize_srcu(). This will ensure that when
    the static call is updated to the single callback that it will be
    receiving the data that it registered with.

    Fixes: d25e37d89dd2f ("tracepoint: Optimize using static_call()")
    Reported-by: Naresh Kamboju
    Signed-off-by: Steven Rostedt (VMware)
    Signed-off-by: Peter Zijlstra (Intel)
    Link: https://lore.kernel.org/linux-next/CA+G9fYvPXVRO0NV7yL=FxCmFEMYkCwdz7R=9W+_votpT824YJA@mail.gmail.com

    Steven Rostedt (VMware)
     

01 Sep, 2020

2 commits

  • Currently the tracepoint site will iterate a vector and issue indirect
    calls to however many handlers are registered (ie. the vector is
    long).

    Using static_call() it is possible to optimize this for the common
    case of only having a single handler registered. In this case the
    static_call() can directly call this handler. Otherwise, if the vector
    is longer than 1, call a function that iterates the whole vector like
    the current code.

    [peterz: updated to new interface]

    Signed-off-by: Steven Rostedt (VMware)
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Ingo Molnar
    Cc: Linus Torvalds
    Link: https://lore.kernel.org/r/20200818135805.279421092@infradead.org

    Steven Rostedt (VMware)
     
  • While auditing all module notifiers I noticed a whole bunch of fail
    wrt the return value. Notifiers have a 'special' return semantics.

    As is; NOTIFY_DONE vs NOTIFY_OK is a bit vague; but
    notifier_from_errno(0) results in NOTIFY_OK and NOTIFY_DONE has a
    comment that says "Don't care".

    From this I've used NOTIFY_DONE when the function completely ignores
    the callback and notifier_to_error() isn't used.

    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Ingo Molnar
    Reviewed-by: Mathieu Desnoyers
    Reviewed-by: Joel Fernandes (Google)
    Reviewed-by: Robert Richter
    Acked-by: Steven Rostedt (VMware)
    Link: https://lore.kernel.org/r/20200818135804.385360407@infradead.org

    Peter Zijlstra
     

19 Jul, 2019

1 commit

  • Pull tracing updates from Steven Rostedt:
    "The main changes in this release include:

    - Add user space specific memory reading for kprobes

    - Allow kprobes to be executed earlier in boot

    The rest are mostly just various clean ups and small fixes"

    * tag 'trace-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (33 commits)
    tracing: Make trace_get_fields() global
    tracing: Let filter_assign_type() detect FILTER_PTR_STRING
    tracing: Pass type into tracing_generic_entry_update()
    ftrace/selftest: Test if set_event/ftrace_pid exists before writing
    ftrace/selftests: Return the skip code when tracing directory not configured in kernel
    tracing/kprobe: Check registered state using kprobe
    tracing/probe: Add trace_event_call accesses APIs
    tracing/probe: Add probe event name and group name accesses APIs
    tracing/probe: Add trace flag access APIs for trace_probe
    tracing/probe: Add trace_event_file access APIs for trace_probe
    tracing/probe: Add trace_event_call register API for trace_probe
    tracing/probe: Add trace_probe init and free functions
    tracing/uprobe: Set print format when parsing command
    tracing/kprobe: Set print format right after parsed command
    kprobes: Fix to init kprobes in subsys_initcall
    tracepoint: Use struct_size() in kmalloc()
    ring-buffer: Remove HAVE_64BIT_ALIGNED_ACCESS
    ftrace: Enable trampoline when rec count returns back to one
    tracing/kprobe: Do not run kprobe boot tests if kprobe_event is on cmdline
    tracing: Make a separate config for trace event self tests
    ...

    Linus Torvalds
     

18 Jun, 2019

1 commit

  • One of the more common cases of allocation size calculations is finding
    the size of a structure that has a zero-sized array at the end, along
    with memory for some number of elements for that array. For example:

    struct tp_probes {
    ...
    struct tracepoint_func probes[0];
    };

    instance = kmalloc(sizeof(sizeof(struct tp_probes) +
    sizeof(struct tracepoint_func) * count, GFP_KERNEL);

    Instead of leaving these open-coded and prone to type mistakes, we can
    now use the new struct_size() helper:

    instance = kmalloc(struct_size(instance, probes, count) GFP_KERNEL);

    This code was detected with the help of Coccinelle.

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Steven Rostedt (VMware)

    Gustavo A. R. Silva
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

28 Nov, 2018

1 commit

  • Now that synchronize_rcu() waits for preempt-disable regions of code
    as well as RCU read-side critical sections, synchronize_sched() can
    be replaced by synchronize_rcu(). Similarly, call_rcu_sched() can be
    replaced by call_rcu(). This commit therefore makes these changes.

    Signed-off-by: Paul E. McKenney
    Cc: Ingo Molnar
    Cc:
    Acked-by: Steven Rostedt (VMware)

    Paul E. McKenney
     

18 Oct, 2018

1 commit

  • commit 46e0c9be206f ("kernel: tracepoints: add support for relative
    references") changes the layout of the __tracepoint_ptrs section on
    architectures supporting relative references. However, it does so
    without turning struct tracepoint * const into const int elsewhere in
    the tracepoint code, which has the following side-effect:

    Setting mod->num_tracepoints is done in by module.c:

    mod->tracepoints_ptrs = section_objs(info, "__tracepoints_ptrs",
    sizeof(*mod->tracepoints_ptrs),
    &mod->num_tracepoints);

    Basically, since sizeof(*mod->tracepoints_ptrs) is a pointer size
    (rather than sizeof(int)), num_tracepoints is erroneously set to half the
    size it should be on 64-bit arch. So a module with an odd number of
    tracepoints misses the last tracepoint due to effect of integer
    division.

    So in the module going notifier:

    for_each_tracepoint_range(mod->tracepoints_ptrs,
    mod->tracepoints_ptrs + mod->num_tracepoints,
    tp_module_going_check_quiescent, NULL);

    the expression (mod->tracepoints_ptrs + mod->num_tracepoints) actually
    evaluates to something within the bounds of the array, but miss the
    last tracepoint if the number of tracepoints is odd on 64-bit arch.

    Fix this by introducing a new typedef: tracepoint_ptr_t, which
    is either "const int" on architectures that have PREL32 relocations,
    or "struct tracepoint * const" on architectures that does not have
    this feature.

    Also provide a new tracepoint_ptr_defer() static inline to
    encapsulate deferencing this type rather than duplicate code and
    ugly idefs within the for_each_tracepoint_range() implementation.

    This issue appears in 4.19-rc kernels, and should ideally be fixed
    before the end of the rc cycle.

    Acked-by: Ard Biesheuvel
    Acked-by: Jessica Yu
    Link: http://lkml.kernel.org/r/20181013191050.22389-1-mathieu.desnoyers@efficios.com
    Link: http://lkml.kernel.org/r/20180704083651.24360-7-ard.biesheuvel@linaro.org
    Cc: Michael Ellerman
    Cc: Ingo Molnar
    Cc: Ard Biesheuvel
    Cc: Arnd Bergmann
    Cc: Benjamin Herrenschmidt
    Cc: Bjorn Helgaas
    Cc: Catalin Marinas
    Cc: James Morris
    Cc: James Morris
    Cc: Josh Poimboeuf
    Cc: Kees Cook
    Cc: Nicolas Pitre
    Cc: Paul Mackerras
    Cc: Petr Mladek
    Cc: Russell King
    Cc: "Serge E. Hallyn"
    Cc: Sergey Senozhatsky
    Cc: Thomas Garnier
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Greg Kroah-Hartman
    Signed-off-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt (VMware)

    Mathieu Desnoyers
     

23 Aug, 2018

1 commit

  • To avoid the need for relocating absolute references to tracepoint
    structures at boot time when running relocatable kernels (which may
    take a disproportionate amount of space), add the option to emit
    these tables as relative references instead.

    Link: http://lkml.kernel.org/r/20180704083651.24360-7-ard.biesheuvel@linaro.org
    Acked-by: Michael Ellerman
    Acked-by: Ingo Molnar
    Acked-by: Steven Rostedt (VMware)
    Signed-off-by: Ard Biesheuvel
    Cc: Arnd Bergmann
    Cc: Benjamin Herrenschmidt
    Cc: Bjorn Helgaas
    Cc: Catalin Marinas
    Cc: James Morris
    Cc: James Morris
    Cc: Jessica Yu
    Cc: Josh Poimboeuf
    Cc: Kees Cook
    Cc: Nicolas Pitre
    Cc: Paul Mackerras
    Cc: Petr Mladek
    Cc: Russell King
    Cc: "Serge E. Hallyn"
    Cc: Sergey Senozhatsky
    Cc: Thomas Garnier
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ard Biesheuvel
     

11 Aug, 2018

1 commit

  • When enabling trace events via the kernel command line, I hit this warning:

    WARNING: CPU: 0 PID: 13 at kernel/rcu/srcutree.c:236 check_init_srcu_struct+0xe/0x61
    Modules linked in:
    CPU: 0 PID: 13 Comm: watchdog/0 Not tainted 4.18.0-rc6-test+ #6
    Hardware name: MSI MS-7823/CSM-H87M-G43 (MS-7823), BIOS V1.6 02/22/2014
    RIP: 0010:check_init_srcu_struct+0xe/0x61
    Code: 48 c7 c6 ec 8a 65 b4 e8 ff 79 fe ff 48 89 df 31 f6 e8 f2 fa ff ff 5a
    5b 41 5c 5d c3 0f 1f 44 00 00 83 3d 68 94 b8 01 01 75 02 0b 48 8b 87 f0
    0a 00 00 a8 03 74 45 55 48 89 e5 41 55 41 54 4c
    RSP: 0000:ffff96eb9ea03e68 EFLAGS: 00010246
    RAX: ffff96eb962b5b01 RBX: ffffffffb4a87420 RCX: 0000000000000001
    RDX: ffffffffb3107969 RSI: ffff96eb962b5b40 RDI: ffffffffb4a87420
    RBP: ffff96eb9ea03eb0 R08: ffffabbd00cd7f48 R09: 0000000000000000
    R10: ffff96eb9ea03e68 R11: ffffffffb4a6eec0 R12: ffff96eb962b5b40
    R13: ffff96eb9ea03ef8 R14: ffffffffb3107969 R15: ffffffffb3107948
    FS: 0000000000000000(0000) GS:ffff96eb9ea00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffff96eb13ab2000 CR3: 0000000192a1e001 CR4: 00000000001606f0
    Call Trace:

    ? __call_srcu+0x2d/0x290
    ? rcu_process_callbacks+0x26e/0x448
    ? allocate_probes+0x2b/0x2b
    call_srcu+0x13/0x15
    rcu_free_old_probes+0x1f/0x21
    rcu_process_callbacks+0x2ed/0x448
    __do_softirq+0x172/0x336
    irq_exit+0x62/0xb2
    smp_apic_timer_interrupt+0x161/0x19e
    apic_timer_interrupt+0xf/0x20

    The problem is that the enabling of trace events before RCU is set up will
    cause SRCU to give this warning. To avoid this, add a list to store probes
    that need to be freed till after RCU is initialized, and then free them
    then.

    Link: http://lkml.kernel.org/r/20180810113554.1df28050@gandalf.local.home
    Link: http://lkml.kernel.org/r/20180810123517.5e9714ad@gandalf.local.home

    Acked-by: Paul E. McKenney
    Reviewed-by: Joel Fernandes (Google)
    Fixes: e6753f23d961d ("tracepoint: Make rcuidle tracepoint callers use SRCU")
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

31 Jul, 2018

1 commit

  • In recent tests with IRQ on/off tracepoints, a large performance
    overhead ~10% is noticed when running hackbench. This is root caused to
    calls to rcu_irq_enter_irqson and rcu_irq_exit_irqson from the
    tracepoint code. Following a long discussion on the list [1] about this,
    we concluded that srcu is a better alternative for use during rcu idle.
    Although it does involve extra barriers, its lighter than the sched-rcu
    version which has to do additional RCU calls to notify RCU idle about
    entry into RCU sections.

    In this patch, we change the underlying implementation of the
    trace_*_rcuidle API to use SRCU. This has shown to improve performance
    alot for the high frequency irq enable/disable tracepoints.

    Test: Tested idle and preempt/irq tracepoints.

    Here are some performance numbers:

    With a run of the following 30 times on a single core x86 Qemu instance
    with 1GB memory:
    hackbench -g 4 -f 2 -l 3000

    Completion times in seconds. CONFIG_PROVE_LOCKING=y.

    No patches (without this series)
    Mean: 3.048
    Median: 3.025
    Std Dev: 0.064

    With Lockdep using irq tracepoints with RCU implementation:
    Mean: 3.451 (-11.66 %)
    Median: 3.447 (-12.22%)
    Std Dev: 0.049

    With Lockdep using irq tracepoints with SRCU implementation (this series):
    Mean: 3.020 (I would consider the improvement against the "without
    this series" case as just noise).
    Median: 3.013
    Std Dev: 0.033

    [1] https://patchwork.kernel.org/patch/10344297/

    [remove rcu_read_lock_sched_notrace as its the equivalent of
    preempt_disable_notrace and is unnecessary to call in tracepoint code]
    Link: http://lkml.kernel.org/r/20180730222423.196630-3-joel@joelfernandes.org

    Cleaned-up-by: Peter Zijlstra
    Acked-by: Peter Zijlstra
    Reviewed-by: Mathieu Desnoyers
    Signed-off-by: Joel Fernandes (Google)
    [ Simplified WARN_ON_ONCE() ]
    Signed-off-by: Steven Rostedt (VMware)

    Joel Fernandes (Google)
     

29 May, 2018

1 commit


01 May, 2018

1 commit

  • Tracepoint should only warn when a kernel API user does not respect the
    required preconditions (e.g. same tracepoint enabled twice, or called
    to remove a tracepoint that does not exist).

    Silence warning in out-of-memory conditions, given that the error is
    returned to the caller.

    This ensures that out-of-memory error-injection testing does not trigger
    warnings in tracepoint.c, which were seen by syzbot.

    Link: https://lkml.kernel.org/r/001a114465e241a8720567419a72@google.com
    Link: https://lkml.kernel.org/r/001a1140e0de15fc910567464190@google.com
    Link: http://lkml.kernel.org/r/20180315124424.32319-1-mathieu.desnoyers@efficios.com

    CC: Peter Zijlstra
    CC: Jiri Olsa
    CC: Arnaldo Carvalho de Melo
    CC: Alexander Shishkin
    CC: Namhyung Kim
    CC: stable@vger.kernel.org
    Fixes: de7b2973903c6 ("tracepoint: Use struct pointer instead of name hash for reg/unreg tracepoints")
    Reported-by: syzbot+9c0d616860575a73166a@syzkaller.appspotmail.com
    Reported-by: syzbot+4e9ae7fa46233396f64d@syzkaller.appspotmail.com
    Signed-off-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt (VMware)

    Mathieu Desnoyers
     

05 Dec, 2017

1 commit

  • The comment in tracepoint_add_func() mentions smp_read_barrier_depends(),
    whose use should be quite restricted. This commit updates the comment
    to instead mention the smp_store_release() and rcu_dereference_sched()
    that the current code actually uses.

    Signed-off-by: Paul E. McKenney
    Cc: Ingo Molnar
    Acked-by: Steven Rostedt (VMware)
    Acked-by: Mathieu Desnoyers

    Paul E. McKenney
     

02 Mar, 2017

2 commits


09 Dec, 2016

1 commit

  • Some tracepoints have a registration function that gets enabled when the
    tracepoint is enabled. There may be cases that the registraction function
    must fail (for example, can't allocate enough memory). In this case, the
    tracepoint should also fail to register, otherwise the user would not know
    why the tracepoint is not working.

    Cc: David Howells
    Cc: Seiji Aguchi
    Cc: Anton Blanchard
    Cc: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

23 Mar, 2016

1 commit

  • Use the more common logging method with the eventual goal of removing
    pr_warning altogether.

    Miscellanea:

    - Realign arguments
    - Coalesce formats
    - Add missing space between a few coalesced formats

    Signed-off-by: Joe Perches
    Acked-by: Rafael J. Wysocki [kernel/power/suspend.c]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

26 Oct, 2015

1 commit

  • In order to guarantee that a probe will be called before other probes that
    are attached to a tracepoint, there needs to be a mechanism to provide
    priority of one probe over the others.

    Adding a prio field to the struct tracepoint_func, which lets the probes be
    sorted by the priority set in the structure. If no priority is specified,
    then a priority of 10 is given (this is a macro, and perhaps may be changed
    in the future).

    Now probes may be added to affect other probes that are attached to a
    tracepoint with a guaranteed order.

    One use case would be to allow tracing of tracepoints be able to filter by
    pid. A special (higher priority probe) may be added to the sched_switch
    tracepoint and set the necessary flags of the other tracepoints to notify
    them if they should be traced or not. In case a tracepoint is enabled at the
    sched_switch tracepoint too, the order of the two are not random.

    Cc: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

21 Jun, 2014

2 commits

  • syscall_regfunc() ignores the kernel threads because "it has no effect",
    see cc3b13c1 "Don't trace kernel thread syscalls" which added this check.

    However, this means that a user-space task spawned by call_usermodehelper()
    will run without TIF_SYSCALL_TRACEPOINT if sys_tracepoint_refcount != 0.

    Remove this check. The unnecessary report from ret_from_fork path mentioned
    by cc3b13c1 is no longer possible, see See commit fb45550d76bb5 "make sure
    that kernel_thread() callbacks call do_exit() themselves".

    A kernel_thread() callback can only return and take the int_ret_from_sys_call
    path after do_execve() succeeds, otherwise the kernel will crash. But in this
    case it is no longer a kernel thread and thus is needs TIF_SYSCALL_TRACEPOINT.

    Link: http://lkml.kernel.org/p/20140413185938.GD20668@redhat.com

    Signed-off-by: Oleg Nesterov
    Signed-off-by: Steven Rostedt

    Oleg Nesterov
     
  • 1. Remove _irqsafe from syscall_regfunc/syscall_unregfunc,
    read_lock(tasklist) doesn't need to disable irqs.

    2. Change this code to avoid the deprecated do_each_thread()
    and use for_each_process_thread() (stolen from the patch
    from Frederic).

    3. Change syscall_regfunc() to check PF_KTHREAD to skip
    the kernel threads, ->mm != NULL is the common mistake.

    Note: probably this check should be simply removed, needs
    another patch.

    [fweisbec@gmail.com: s/do_each_thread/for_each_process_thread/]
    Link: http://lkml.kernel.org/p/20140413185918.GC20668@redhat.com

    Signed-off-by: Oleg Nesterov
    Signed-off-by: Steven Rostedt

    Oleg Nesterov
     

05 Jun, 2014

1 commit


08 May, 2014

1 commit

  • Commit de7b2973903c "tracepoint: Use struct pointer instead of name hash
    for reg/unreg tracepoints" introduces a use after free by calling
    release_probes on the old struct tracepoint array before the newly
    allocated array is published with rcu_assign_pointer. There is a race
    window where tracepoints (RCU readers) can perform a
    "use-after-grace-period-after-free", which shows up as a GPF in
    stress-tests.

    Link: http://lkml.kernel.org/r/53698021.5020108@oracle.com
    Link: http://lkml.kernel.org/p/1399549669-25465-1-git-send-email-mathieu.desnoyers@efficios.com

    Reported-by: Sasha Levin
    CC: Oleg Nesterov
    CC: Dave Jones
    Fixes: de7b2973903c "tracepoint: Use struct pointer instead of name hash for reg/unreg tracepoints"
    Signed-off-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Mathieu Desnoyers
     

13 Apr, 2014

1 commit

  • Pull more tracing updates from Steven Rostedt:
    "This includes the final patch to clean up and fix the issue with the
    design of tracepoints and how a user could register a tracepoint and
    have that tracepoint not be activated but no error was shown.

    The design was for an out of tree module but broke in tree users. The
    clean up was to remove the saving of the hash table of tracepoint
    names such that they can be enabled before they exist (enabling a
    module tracepoint before that module is loaded). This added more
    complexity than needed. The clean up was to remove that code and just
    enable tracepoints that exist or fail if they do not.

    This removed a lot of code as well as the complexity that it brought.
    As a side effect, instead of registering a tracepoint by its name, the
    tracepoint needs to be registered with the tracepoint descriptor.
    This removes having to duplicate the tracepoint names that are
    enabled.

    The second patch was added that simplified the way modules were
    searched for.

    This cleanup required changes that were in the 3.15 queue as well as
    some changes that were added late in the 3.14-rc cycle. This final
    change waited till the two were merged in upstream and then the change
    was added and full tests were run. Unfortunately, the test found some
    errors, but after it was already submitted to the for-next branch and
    not to be rebased. Sparse errors were detected by Fengguang Wu's bot
    tests, and my internal tests discovered that the anonymous union
    initialization triggered a bug in older gcc compilers. Luckily, there
    was a bugzilla for the gcc bug which gave a work around to the
    problem. The third and fourth patch handled the sparse error and the
    gcc bug respectively.

    A final patch was tagged along to fix a missing documentation for the
    README file"

    * tag 'trace-3.15-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
    tracing: Add missing function triggers dump and cpudump to README
    tracing: Fix anonymous unions in struct ftrace_event_call
    tracepoint: Fix sparse warnings in tracepoint.c
    tracepoint: Simplify tracepoint module search
    tracepoint: Use struct pointer instead of name hash for reg/unreg tracepoints

    Linus Torvalds
     

09 Apr, 2014

3 commits

  • Fix the following sparse warnings:

    CHECK kernel/tracepoint.c
    kernel/tracepoint.c:184:18: warning: incorrect type in assignment (different address spaces)
    kernel/tracepoint.c:184:18: expected struct tracepoint_func *tp_funcs
    kernel/tracepoint.c:184:18: got struct tracepoint_func [noderef] *funcs
    kernel/tracepoint.c:216:18: warning: incorrect type in assignment (different address spaces)
    kernel/tracepoint.c:216:18: expected struct tracepoint_func *tp_funcs
    kernel/tracepoint.c:216:18: got struct tracepoint_func [noderef] *funcs
    kernel/tracepoint.c:392:24: error: return expression in void function
    CC kernel/tracepoint.o
    kernel/tracepoint.c: In function tracepoint_module_going:
    kernel/tracepoint.c:491:6: warning: symbol 'syscall_regfunc' was not declared. Should it be static?
    kernel/tracepoint.c:508:6: warning: symbol 'syscall_unregfunc' was not declared. Should it be static?

    Link: http://lkml.kernel.org/r/1397049883-28692-1-git-send-email-mathieu.desnoyers@efficios.com

    Signed-off-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Mathieu Desnoyers
     
  • Instead of copying the num_tracepoints and tracepoints_ptrs from
    the module structure to the tp_mod structure, which only uses it to
    find the module associated to tracepoints of modules that are coming
    and going, simply copy the pointer to the module struct to the tracepoint
    tp_module structure.

    Also removed un-needed brackets around an if statement.

    Link: http://lkml.kernel.org/r/20140408201705.4dad2c4a@gandalf.local.home

    Acked-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     
  • Register/unregister tracepoint probes with struct tracepoint pointer
    rather than tracepoint name.

    This change, which vastly simplifies tracepoint.c, has been proposed by
    Steven Rostedt. It also removes 8.8kB (mostly of text) to the vmlinux
    size.

    From this point on, the tracers need to pass a struct tracepoint pointer
    to probe register/unregister. A probe can now only be connected to a
    tracepoint that exists. Moreover, tracers are responsible for
    unregistering the probe before the module containing its associated
    tracepoint is unloaded.

    text data bss dec hex filename
    10443444 4282528 10391552 25117524 17f4354 vmlinux.orig
    10434930 4282848 10391552 25109330 17f2352 vmlinux

    Link: http://lkml.kernel.org/r/1396992381-23785-2-git-send-email-mathieu.desnoyers@efficios.com

    CC: Ingo Molnar
    CC: Frederic Weisbecker
    CC: Andrew Morton
    CC: Frank Ch. Eigler
    CC: Johannes Berg
    Signed-off-by: Mathieu Desnoyers
    [ SDR - fixed return val in void func in tracepoint_module_going() ]
    Signed-off-by: Steven Rostedt

    Mathieu Desnoyers
     

07 Apr, 2014

1 commit

  • Pull module updates from Rusty Russell:
    "Nothing major: the stricter permissions checking for sysfs broke a
    staging driver; fix included. Greg KH said he'd take the patch but
    hadn't as the merge window opened, so it's included here to avoid
    breaking build"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    staging: fix up speakup kobject mode
    Use 'E' instead of 'X' for unsigned module taint flag.
    VERIFY_OCTAL_PERMISSIONS: stricter checking for sysfs perms.
    kallsyms: fix percpu vars on x86-64 with relocation.
    kallsyms: generalize address range checking
    module: LLVMLinux: Remove unused function warning from __param_check macro
    Fix: module signature vs tracepoints: add new TAINT_UNSIGNED_MODULE
    module: remove MODULE_GENERIC_TABLE
    module: allow multiple calls to MODULE_DEVICE_TABLE() per module
    module: use pr_cont

    Linus Torvalds
     

04 Apr, 2014

1 commit

  • Pull tracing updates from Steven Rostedt:
    "Most of the changes were largely clean ups, and some documentation.
    But there were a few features that were added:

    Uprobes now work with event triggers and multi buffers and have
    support under ftrace and perf.

    The big feature is that the function tracer can now be used within the
    multi buffer instances. That is, you can now trace some functions in
    one buffer, others in another buffer, all functions in a third buffer
    and so on. They are basically agnostic from each other. This only
    works for the function tracer and not for the function graph trace,
    although you can have the function graph tracer running in the top
    level buffer (or any tracer for that matter) and have different
    function tracing going on in the sub buffers"

    * tag 'trace-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (45 commits)
    tracing: Add BUG_ON when stack end location is over written
    tracepoint: Remove unused API functions
    Revert "tracing: Move event storage for array from macro to standalone function"
    ftrace: Constify ftrace_text_reserved
    tracepoints: API doc update to tracepoint_probe_register() return value
    tracepoints: API doc update to data argument
    ftrace: Fix compilation warning about control_ops_free
    ftrace/x86: BUG when ftrace recovery fails
    ftrace: Warn on error when modifying ftrace function
    ftrace: Remove freelist from struct dyn_ftrace
    ftrace: Do not pass data to ftrace_dyn_arch_init
    ftrace: Pass retval through return in ftrace_dyn_arch_init()
    ftrace: Inline the code from ftrace_dyn_table_alloc()
    ftrace: Cleanup of global variables ftrace_new_pgs and ftrace_update_cnt
    tracing: Evaluate len expression only once in __dynamic_array macro
    tracing: Correctly expand len expressions from __dynamic_array macro
    tracing/module: Replace include of tracepoint.h with jump_label.h in module.h
    tracing: Fix event header migrate.h to include tracepoint.h
    tracing: Fix event header writeback.h to include tracepoint.h
    tracing: Warn if a tracepoint is not set via debugfs
    ...

    Linus Torvalds
     

22 Mar, 2014

1 commit

  • After the following commit:

    commit b75ef8b44b1cb95f5a26484b0e2fe37a63b12b44
    Author: Mathieu Desnoyers
    Date: Wed Aug 10 15:18:39 2011 -0400

    Tracepoint: Dissociate from module mutex

    The following functions became unnecessary:

    - tracepoint_probe_register_noupdate,
    - tracepoint_probe_unregister_noupdate,
    - tracepoint_probe_update_all.

    In fact, none of the in-kernel tracers, nor LTTng, nor SystemTAP use
    them. Remove those.

    Moreover, the functions:

    - tracepoint_iter_start,
    - tracepoint_iter_next,
    - tracepoint_iter_stop,
    - tracepoint_iter_reset.

    are unused by in-kernel tracers, LTTng and SystemTAP. Remove those too.

    Link: http://lkml.kernel.org/r/1395379142-2118-2-git-send-email-mathieu.desnoyers@efficios.com

    Signed-off-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Mathieu Desnoyers
     

13 Mar, 2014

1 commit

  • Users have reported being unable to trace non-signed modules loaded
    within a kernel supporting module signature.

    This is caused by tracepoint.c:tracepoint_module_coming() refusing to
    take into account tracepoints sitting within force-loaded modules
    (TAINT_FORCED_MODULE). The reason for this check, in the first place, is
    that a force-loaded module may have a struct module incompatible with
    the layout expected by the kernel, and can thus cause a kernel crash
    upon forced load of that module on a kernel with CONFIG_TRACEPOINTS=y.

    Tracepoints, however, specifically accept TAINT_OOT_MODULE and
    TAINT_CRAP, since those modules do not lead to the "very likely system
    crash" issue cited above for force-loaded modules.

    With kernels having CONFIG_MODULE_SIG=y (signed modules), a non-signed
    module is tainted re-using the TAINT_FORCED_MODULE taint flag.
    Unfortunately, this means that Tracepoints treat that module as a
    force-loaded module, and thus silently refuse to consider any tracepoint
    within this module.

    Since an unsigned module does not fit within the "very likely system
    crash" category of tainting, add a new TAINT_UNSIGNED_MODULE taint flag
    to specifically address this taint behavior, and accept those modules
    within Tracepoints. We use the letter 'X' as a taint flag character for
    a module being loaded that doesn't know how to sign its name (proposed
    by Steven Rostedt).

    Also add the missing 'O' entry to trace event show_module_flags() list
    for the sake of completeness.

    Signed-off-by: Mathieu Desnoyers
    Acked-by: Steven Rostedt
    NAKed-by: Ingo Molnar
    CC: Thomas Gleixner
    CC: David Howells
    CC: Greg Kroah-Hartman
    Signed-off-by: Rusty Russell

    Mathieu Desnoyers
     

12 Mar, 2014

2 commits

  • Describe the return values of tracepoint_probe_register(), including
    -ENODEV added by commit:

    Author: Steven Rostedt

    tracing: Warn if a tracepoint is not set via debugfs

    Link: http://lkml.kernel.org/r/1394499898-1537-2-git-send-email-mathieu.desnoyers@efficios.com

    CC: Ingo Molnar
    CC: Frederic Weisbecker
    CC: Andrew Morton
    Signed-off-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Mathieu Desnoyers
     
  • Describe the @data argument (probe private data).

    Link: http://lkml.kernel.org/r/1394587948-27878-1-git-send-email-mathieu.desnoyers@efficios.com

    Fixes: 38516ab59fbc "tracing: Let tracepoints have data passed to tracepoint callbacks"
    CC: Ingo Molnar
    CC: Frederic Weisbecker
    CC: Andrew Morton
    Signed-off-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Mathieu Desnoyers
     

07 Mar, 2014

1 commit

  • Tracepoints were made to allow enabling a tracepoint in a module before that
    module was loaded. When a tracepoint is enabled and it does not exist, the
    name is stored and will be enabled when the tracepoint is created.

    The problem with this approach is that when a tracepoint is enabled when
    it expects to be there, it gives no warning that it does not exist.

    To add salt to the wound, if a module is added and sets the FORCED flag, which
    can happen if it isn't signed properly, the tracepoint code will not enabled
    the tracepoints, but they will be created in the debugfs system! When a user
    goes to enable the tracepoint, the tracepoint code will not see it existing
    and will think it is to be enabled later AND WILL NOT GIVE A WARNING.

    The tracing will look like it succeeded but will actually be doing nothing.
    This will cause lots of confusion and headaches for developers trying to
    figure out why they are not seeing their tracepoints.

    Link: http://lkml.kernel.org/r/20140213154507.4040fb06@gandalf.local.home

    Reported-by: Mathieu Desnoyers
    Reported-by: Johannes Berg
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

04 Mar, 2014

2 commits

  • No reason to allocate tp_module structures for modules that have no
    tracepoints. This just wastes memory.

    Fixes: b75ef8b44b1c "Tracepoint: Dissociate from module mutex"
    Acked-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     
  • If a module fails to add its tracepoints due to module tainting, do not
    create the module event infrastructure in the debugfs directory. As the events
    will not work and worse yet, they will silently fail, making the user wonder
    why the events they enable do not display anything.

    Having a warning on module load and the events not visible to the users
    will make the cause of the problem much clearer.

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

    Fixes: 6d723736e472 "tracing/events: add support for modules to TRACE_EVENT"
    Acked-by: Mathieu Desnoyers
    Cc: stable@vger.kernel.org # 2.6.31+
    Cc: Rusty Russell
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

30 Apr, 2013

1 commit

  • Pull tracing updates from Steven Rostedt:
    "Along with the usual minor fixes and clean ups there are a few major
    changes with this pull request.

    1) Multiple buffers for the ftrace facility

    This feature has been requested by many people over the last few
    years. I even heard that Google was about to implement it themselves.
    I finally had time and cleaned up the code such that you can now
    create multiple instances of the ftrace buffer and have different
    events go to different buffers. This way, a low frequency event will
    not be lost in the noise of a high frequency event.

    Note, currently only events can go to different buffers, the tracers
    (ie function, function_graph and the latency tracers) still can only
    be written to the main buffer.

    2) The function tracer triggers have now been extended.

    The function tracer had two triggers. One to enable tracing when a
    function is hit, and one to disable tracing. Now you can record a
    stack trace on a single (or many) function(s), take a snapshot of the
    buffer (copy it to the snapshot buffer), and you can enable or disable
    an event to be traced when a function is hit.

    3) A perf clock has been added.

    A "perf" clock can be chosen to be used when tracing. This will cause
    ftrace to use the same clock as perf uses, and hopefully this will
    make it easier to interleave the perf and ftrace data for analysis."

    * tag 'trace-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (82 commits)
    tracepoints: Prevent null probe from being added
    tracing: Compare to 1 instead of zero for is_signed_type()
    tracing: Remove obsolete macro guard _TRACE_PROFILE_INIT
    ftrace: Get rid of ftrace_profile_bits
    tracing: Check return value of tracing_init_dentry()
    tracing: Get rid of unneeded key calculation in ftrace_hash_move()
    tracing: Reset ftrace_graph_filter_enabled if count is zero
    tracing: Fix off-by-one on allocating stat->pages
    kernel: tracing: Use strlcpy instead of strncpy
    tracing: Update debugfs README file
    tracing: Fix ftrace_dump()
    tracing: Rename trace_event_mutex to trace_event_sem
    tracing: Fix comment about prefix in arch_syscall_match_sym_name()
    tracing: Convert trace_destroy_fields() to static
    tracing: Move find_event_field() into trace_events.c
    tracing: Use TRACE_MAX_PRINT instead of constant
    tracing: Use pr_warn_once instead of open coded implementation
    ring-buffer: Add ring buffer startup selftest
    tracing: Bring Documentation/trace/ftrace.txt up to date
    tracing: Add "perf" trace_clock
    ...

    Conflicts:
    kernel/trace/ftrace.c
    kernel/trace/trace.c

    Linus Torvalds
     

20 Apr, 2013

1 commit

  • Somehow tracepoint_entry_add_probe() function allows a null probe function.
    And, this may lead to unexpected results since the number of probe
    functions in an entry can be counted by checking whether a probe is null
    or not in the for-loop.
    This patch prevents a null probe from being added.
    In tracepoint_entry_remove_probe() function, checking probe parameter
    within the for-loop is moved out for code efficiency, leaving the null probe
    feature which removes all probe functions in the entry.

    Link: http://lkml.kernel.org/r/1365991995-19445-1-git-send-email-kpark3469@gmail.com

    Reviewed-by: Mathieu Desnoyers
    Acked-by: Mathieu Desnoyers
    Signed-off-by: Sahara
    Signed-off-by: Steven Rostedt

    Sahara
     

28 Feb, 2013

1 commit

  • I'm not sure why, but the hlist for each entry iterators were conceived

    list_for_each_entry(pos, head, member)

    The hlist ones were greedy and wanted an extra parameter:

    hlist_for_each_entry(tpos, pos, head, member)

    Why did they need an extra pos parameter? I'm not quite sure. Not only
    they don't really need it, it also prevents the iterator from looking
    exactly like the list iterator, which is unfortunate.

    Besides the semantic patch, there was some manual work required:

    - Fix up the actual hlist iterators in linux/list.h
    - Fix up the declaration of other iterators based on the hlist ones.
    - A very small amount of places were using the 'node' parameter, this
    was modified to use 'obj->member' instead.
    - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
    properly, so those had to be fixed up manually.

    The semantic patch which is mostly the work of Peter Senna Tschudin is here:

    @@
    iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

    type T;
    expression a,c,d,e;
    identifier b;
    statement S;
    @@

    -T b;

    [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
    [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
    [akpm@linux-foundation.org: checkpatch fixes]
    [akpm@linux-foundation.org: fix warnings]
    [akpm@linux-foudnation.org: redo intrusive kvm changes]
    Tested-by: Peter Senna Tschudin
    Acked-by: Paul E. McKenney
    Signed-off-by: Sasha Levin
    Cc: Wu Fengguang
    Cc: Marcelo Tosatti
    Cc: Gleb Natapov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sasha Levin