linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC]Sample module for Kernel access to Ftrace instances.
@ 2019-09-20 23:59 Divya Indi
  2019-09-20 23:59 ` [PATCH] tracing: Sample module to demonstrate kernel " Divya Indi
  0 siblings, 1 reply; 4+ messages in thread
From: Divya Indi @ 2019-09-20 23:59 UTC (permalink / raw)
  To: Steven Rostedt, linux-kernel
  Cc: Divya Indi, Joe Jin, Srinivas Eeda, Aruna Ramakrishna, Manjunath Patil

[PATCH] tracing: Sample module to demonstrate kernel access to Ftrace

Hi,

This patch is for a sample module to demonstrate the use of APIs that 
were introduced/exported in order to access Ftrace instances from within the kernel.

Please Note: This module is dependent on -
- commit: f45d122 tracing: Kernel access to Ftrace instances
- Patches pending review: https://lore.kernel.org/lkml/1565805327-579-1-git-send-email-divya.indi@oracle.com/

The sample module creates/lookup a trace array called sample-instance on module load time. 
We then start a kernel thread(simple-thread) to -
1) Enable tracing for event "sample_event" to buffer associated with the trace array - "sample-instance".
2) Start a timer that will disable tracing to this buffer after 5 sec. (Tracing disabled after 5 sec ie at count=4)
3) Write to the buffer using trace_array_printk()
4) Stop the kernel thread and destroy the buffer during module unload.

A sample output for the same -

# tracer: nop
#
# entries-in-buffer/entries-written: 16/16   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
 sample-instance-26797 [003] .... 955180.489833: simple_thread: trace_array_printk: count=0
 sample-instance-26797 [003] .... 955180.489836: sample_event: count value=0 at jiffies=5249940864
 sample-instance-26797 [003] .... 955181.513722: simple_thread: trace_array_printk: count=1
 sample-instance-26797 [003] .... 955181.513724: sample_event: count value=1 at jiffies=5249941888
 sample-instance-26797 [003] .... 955182.537629: simple_thread: trace_array_printk: count=2
 sample-instance-26797 [003] .... 955182.537631: sample_event: count value=2 at jiffies=5249942912
 sample-instance-26797 [003] .... 955183.561516: simple_thread: trace_array_printk: count=3
 sample-instance-26797 [003] .... 955183.561518: sample_event: count value=3 at jiffies=5249943936
 sample-instance-26797 [003] .... 955184.585423: simple_thread: trace_array_printk: count=4
 sample-instance-26797 [003] .... 955184.585427: sample_event: count value=4 at jiffies=5249944960
 sample-instance-26797 [003] .... 955185.609344: simple_thread: trace_array_printk: count=5
 sample-instance-26797 [003] .... 955186.633241: simple_thread: trace_array_printk: count=6
 sample-instance-26797 [003] .... 955187.657157: simple_thread: trace_array_printk: count=7
 sample-instance-26797 [003] .... 955188.681039: simple_thread: trace_array_printk: count=8
 sample-instance-26797 [003] .... 955189.704937: simple_thread: trace_array_printk: count=9
 sample-instance-26797 [003] .... 955190.728840: simple_thread: trace_array_printk: count=10

Let me know if you have any questions.

Thanks,
Divya

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-15 19:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20 23:59 [RFC]Sample module for Kernel access to Ftrace instances Divya Indi
2019-09-20 23:59 ` [PATCH] tracing: Sample module to demonstrate kernel " Divya Indi
2019-10-15 17:05   ` Steven Rostedt
2019-10-15 19:53     ` Divya Indi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).