1. 27 Sep, 2022 7 commits
    • Steven Rostedt (Google)'s avatar
      ring-buffer: Allow splice to read previous partially read pages · fa8f4a89
      Steven Rostedt (Google) authored
      If a page is partially read, and then the splice system call is run
      against the ring buffer, it will always fail to read, no matter how much
      is in the ring buffer. That's because the code path for a partial read of
      the page does will fail if the "full" flag is set.
      
      The splice system call wants full pages, so if the read of the ring buffer
      is not yet full, it should return zero, and the splice will block. But if
      a previous read was done, where the beginning has been consumed, it should
      still be given to the splice caller if the rest of the page has been
      written to.
      
      This caused the splice command to never consume data in this scenario, and
      let the ring buffer just fill up and lose events.
      
      Link: https://lkml.kernel.org/r/20220927144317.46be6b80@gandalf.local.home
      
      Cc: stable@vger.kernel.org
      Fixes: 8789a9e7 ("ring-buffer: read page interface")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      fa8f4a89
    • Song Liu's avatar
      ftrace: Fix recursive locking direct_mutex in ftrace_modify_direct_caller · 9d2ce78d
      Song Liu authored
      Naveen reported recursive locking of direct_mutex with sample
      ftrace-direct-modify.ko:
      
      [   74.762406] WARNING: possible recursive locking detected
      [   74.762887] 6.0.0-rc6+ #33 Not tainted
      [   74.763216] --------------------------------------------
      [   74.763672] event-sample-fn/1084 is trying to acquire lock:
      [   74.764152] ffffffff86c9d6b0 (direct_mutex){+.+.}-{3:3}, at: \
          register_ftrace_function+0x1f/0x180
      [   74.764922]
      [   74.764922] but task is already holding lock:
      [   74.765421] ffffffff86c9d6b0 (direct_mutex){+.+.}-{3:3}, at: \
          modify_ftrace_direct+0x34/0x1f0
      [   74.766142]
      [   74.766142] other info that might help us debug this:
      [   74.766701]  Possible unsafe locking scenario:
      [   74.766701]
      [   74.767216]        CPU0
      [   74.767437]        ----
      [   74.767656]   lock(direct_mutex);
      [   74.767952]   lock(direct_mutex);
      [   74.768245]
      [   74.768245]  *** DEADLOCK ***
      [   74.768245]
      [   74.768750]  May be due to missing lock nesting notation
      [   74.768750]
      [   74.769332] 1 lock held by event-sample-fn/1084:
      [   74.769731]  #0: ffffffff86c9d6b0 (direct_mutex){+.+.}-{3:3}, at: \
          modify_ftrace_direct+0x34/0x1f0
      [   74.770496]
      [   74.770496] stack backtrace:
      [   74.770884] CPU: 4 PID: 1084 Comm: event-sample-fn Not tainted ...
      [   74.771498] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), ...
      [   74.772474] Call Trace:
      [   74.772696]  <TASK>
      [   74.772896]  dump_stack_lvl+0x44/0x5b
      [   74.773223]  __lock_acquire.cold.74+0xac/0x2b7
      [   74.773616]  lock_acquire+0xd2/0x310
      [   74.773936]  ? register_ftrace_function+0x1f/0x180
      [   74.774357]  ? lock_is_held_type+0xd8/0x130
      [   74.774744]  ? my_tramp2+0x11/0x11 [ftrace_direct_modify]
      [   74.775213]  __mutex_lock+0x99/0x1010
      [   74.775536]  ? register_ftrace_function+0x1f/0x180
      [   74.775954]  ? slab_free_freelist_hook.isra.43+0x115/0x160
      [   74.776424]  ? ftrace_set_hash+0x195/0x220
      [   74.776779]  ? register_ftrace_function+0x1f/0x180
      [   74.777194]  ? kfree+0x3e1/0x440
      [   74.777482]  ? my_tramp2+0x11/0x11 [ftrace_direct_modify]
      [   74.777941]  ? __schedule+0xb40/0xb40
      [   74.778258]  ? register_ftrace_function+0x1f/0x180
      [   74.778672]  ? my_tramp1+0xf/0xf [ftrace_direct_modify]
      [   74.779128]  register_ftrace_function+0x1f/0x180
      [   74.779527]  ? ftrace_set_filter_ip+0x33/0x70
      [   74.779910]  ? __schedule+0xb40/0xb40
      [   74.780231]  ? my_tramp1+0xf/0xf [ftrace_direct_modify]
      [   74.780678]  ? my_tramp2+0x11/0x11 [ftrace_direct_modify]
      [   74.781147]  ftrace_modify_direct_caller+0x5b/0x90
      [   74.781563]  ? 0xffffffffa0201000
      [   74.781859]  ? my_tramp1+0xf/0xf [ftrace_direct_modify]
      [   74.782309]  modify_ftrace_direct+0x1b2/0x1f0
      [   74.782690]  ? __schedule+0xb40/0xb40
      [   74.783014]  ? simple_thread+0x2a/0xb0 [ftrace_direct_modify]
      [   74.783508]  ? __schedule+0xb40/0xb40
      [   74.783832]  ? my_tramp2+0x11/0x11 [ftrace_direct_modify]
      [   74.784294]  simple_thread+0x76/0xb0 [ftrace_direct_modify]
      [   74.784766]  kthread+0xf5/0x120
      [   74.785052]  ? kthread_complete_and_exit+0x20/0x20
      [   74.785464]  ret_from_fork+0x22/0x30
      [   74.785781]  </TASK>
      
      Fix this by using register_ftrace_function_nolock in
      ftrace_modify_direct_caller.
      
      Link: https://lkml.kernel.org/r/20220927004146.1215303-1-song@kernel.org
      
      Fixes: 53cd885b ("ftrace: Allow IPMODIFY and DIRECT ops on the same function")
      Reported-and-tested-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      9d2ce78d
    • Zheng Yejian's avatar
      ftrace: Properly unset FTRACE_HASH_FL_MOD · 0ce0638e
      Zheng Yejian authored
      When executing following commands like what document said, but the log
      "#### all functions enabled ####" was not shown as expect:
        1. Set a 'mod' filter:
          $ echo 'write*:mod:ext3' > /sys/kernel/tracing/set_ftrace_filter
        2. Invert above filter:
          $ echo '!write*:mod:ext3' >> /sys/kernel/tracing/set_ftrace_filter
        3. Read the file:
          $ cat /sys/kernel/tracing/set_ftrace_filter
      
      By some debugging, I found that flag FTRACE_HASH_FL_MOD was not unset
      after inversion like above step 2 and then result of ftrace_hash_empty()
      is incorrect.
      
      Link: https://lkml.kernel.org/r/20220926152008.2239274-1-zhengyejian1@huawei.com
      
      Cc: <mingo@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: 8c08f0d5 ("ftrace: Have cached module filters be an active filter")
      Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      0ce0638e
    • Tao Chen's avatar
      tracing/eprobe: Fix alloc event dir failed when event name no set · dc399ade
      Tao Chen authored
      The event dir will alloc failed when event name no set, using the
      command:
      "echo "e:esys/ syscalls/sys_enter_openat file=\$filename:string"
      >> dynamic_events"
      It seems that dir name="syscalls/sys_enter_openat" is not allowed
      in debugfs. So just use the "sys_enter_openat" as the event name.
      
      Link: https://lkml.kernel.org/r/1664028814-45923-1-git-send-email-chentao.kernel@linux.alibaba.com
      
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Tom Zanussi <zanussi@kernel.org>
      Cc: Linyu Yuan <quic_linyyuan@quicinc.com>
      Cc: Tao Chen <chentao.kernel@linux.alibaba.com
      Cc: stable@vger.kernel.org
      Fixes: 95c104c3 ("tracing: Auto generate event name when creating a group of events")
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarTao Chen <chentao.kernel@linux.alibaba.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      dc399ade
    • Chen Zhongjin's avatar
      x86: kprobes: Remove unused macro stack_addr · ae398ad8
      Chen Zhongjin authored
      An unused macro reported by [-Wunused-macros].
      
      This macro is used to access the sp in pt_regs because at that time
      x86_32 can only get sp by kernel_stack_pointer(regs).
      
      '3c88c692 ("x86/stackframe/32: Provide consistent pt_regs")'
      This commit have unified the pt_regs and from them we can get sp from
      pt_regs with regs->sp easily. Nowhere is using this macro anymore.
      
      Refrencing pt_regs directly is more clear. Remove this macro for
      code cleaning.
      
      Link: https://lkml.kernel.org/r/20220924072629.104759-1-chenzhongjin@huawei.comSigned-off-by: default avatarChen Zhongjin <chenzhongjin@huawei.com>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      ae398ad8
    • Gaosheng Cui's avatar
      ftrace: Remove obsoleted code from ftrace and task_struct · 3008119a
      Gaosheng Cui authored
      The trace of "struct task_struct" was no longer used since
      commit 345ddcc8 ("ftrace: Have set_ftrace_pid use the
      bitmap like events do"), and the functions about flags for
      current->trace is useless, so remove them.
      
      Link: https://lkml.kernel.org/r/20220923090012.505990-1-cuigaosheng1@huawei.comSigned-off-by: default avatarGaosheng Cui <cuigaosheng1@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      3008119a
    • Waiman Long's avatar
      tracing: Disable interrupt or preemption before acquiring arch_spinlock_t · c0a581d7
      Waiman Long authored
      It was found that some tracing functions in kernel/trace/trace.c acquire
      an arch_spinlock_t with preemption and irqs enabled. An example is the
      tracing_saved_cmdlines_size_read() function which intermittently causes
      a "BUG: using smp_processor_id() in preemptible" warning when the LTP
      read_all_proc test is run.
      
      That can be problematic in case preemption happens after acquiring the
      lock. Add the necessary preemption or interrupt disabling code in the
      appropriate places before acquiring an arch_spinlock_t.
      
      The convention here is to disable preemption for trace_cmdline_lock and
      interupt for max_lock.
      
      Link: https://lkml.kernel.org/r/20220922145622.1744826-1-longman@redhat.com
      
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: stable@vger.kernel.org
      Fixes: a35873a0 ("tracing: Add conditional snapshot")
      Fixes: 939c7a4f ("tracing: Introduce saved_cmdlines_size file")
      Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      c0a581d7
  2. 26 Sep, 2022 15 commits
  3. 25 Sep, 2022 8 commits
  4. 24 Sep, 2022 10 commits