linux/samples
Kefeng Wang e9b7b1c0c1 sample-trace-array: Fix sleeping function called from invalid context
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:935
 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/5
 1 lock held by swapper/5/0:
  #0: ffff80001002bd90 (samples/ftrace/sample-trace-array.c:38){+.-.}-{0:0}, at: call_timer_fn+0x8/0x3e0
 CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.7.0+ #8
 Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
 Call trace:
  dump_backtrace+0x0/0x1a0
  show_stack+0x20/0x30
  dump_stack+0xe4/0x150
  ___might_sleep+0x160/0x200
  __might_sleep+0x58/0x90
  __mutex_lock+0x64/0x948
  mutex_lock_nested+0x3c/0x58
  __ftrace_set_clr_event+0x44/0x88
  trace_array_set_clr_event+0x24/0x38
  mytimer_handler+0x34/0x40 [sample_trace_array]

mutex_lock() will be called in interrupt context, using workqueue to fix it.

Link: https://lkml.kernel.org/r/20200610011244.2209486-1-wangkefeng.wang@huawei.com

Cc: stable@vger.kernel.org
Fixes: 89ed42495e ("tracing: Sample module to demonstrate kernel access to Ftrace instances.")
Reviewed-by: Divya Indi <divya.indi@oracle.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2020-06-16 21:21:02 -04:00
..
auxdisplay samples: auxdisplay: use 'userprogs' syntax 2020-05-17 18:52:02 +09:00
binderfs binderfs: add gitignore for generated sample program 2020-06-13 13:41:24 -07:00
bpf samples, bpf: Refactor kprobe, tail call kern progs map definition 2020-05-19 17:13:03 +02:00
configfs
connector samples: connector: build sample program for target architecture 2020-05-17 18:52:01 +09:00
ftrace sample-trace-array: Fix sleeping function called from invalid context 2020-06-16 21:21:02 -04:00
hidraw samples: hidraw: build sample program for target architecture 2020-05-17 18:52:01 +09:00
hw_breakpoint
kdb
kfifo
kobject
kprobes samples/kprobes: Add __kprobes and NOKPROBE_SYMBOL() for handlers. 2020-05-12 17:15:33 +02:00
livepatch
mei samples: mei: build sample program for target architecture 2020-05-17 18:52:02 +09:00
mic/mpssd
pidfd samples: pidfd: build sample program for target architecture 2020-05-17 18:52:02 +09:00
pktgen
qmi
rpmsg
seccomp samples: seccomp: build sample programs for target architecture 2020-05-17 18:52:01 +09:00
timers samples: timers: use 'userprogs' syntax 2020-05-17 18:52:02 +09:00
trace_events
trace_printk
uhid samples: uhid: build sample program for target architecture 2020-05-17 18:52:01 +09:00
v4l
vfio-mdev
vfs Kbuild updates for v5.8 2020-06-06 12:00:25 -07:00
watch_queue watch_queue: add gitignore for generated sample program 2020-06-13 13:00:54 -07:00
watchdog samples: watchdog: use 'userprogs' syntax 2020-05-17 18:52:02 +09:00
Kconfig Kbuild updates for v5.8 (2nd) 2020-06-13 13:29:16 -07:00
Makefile Kbuild updates for v5.8 (2nd) 2020-06-13 13:29:16 -07:00